From e4737e85f0da6d3f90fd08f6be1c2825195fe16f Mon Sep 17 00:00:00 2001 From: admin Date: Wed, 1 Dec 2004 10:48:31 +0000 Subject: [PATCH] Merge with version on tag OCC-V2_1_0d --- INSTALL | 9 +- Makefile.in | 28 +- adm_local/unix/config_files/check_Geom.m4 | 11 +- adm_local/unix/config_files/check_Med.m4 | 11 +- adm_local/unix/config_files/check_Netgen.m4 | 126 - adm_local/unix/make_commence.in | 5 +- adm_local/unix/make_conclude.in | 346 + bin/VERSION | 2 +- build_configure | 2 +- configure.in.base | 2 +- doc/salome/gui/SMESH/SMESH.log | 183 +- doc/salome/gui/SMESH/extrusion.htm | 184 + .../gui/SMESH/files/1d_meshing_algorithm.htm | 13 +- .../2d_(quadrangle)_meshing_algorithm.htm | 13 +- .../gui/SMESH/files/2d_meshing_algorithm.htm | 13 +- .../gui/SMESH/files/3d_meshing_algorithm.htm | 14 +- .../gui/SMESH/files/about_hypotheses.htm | 93 +- doc/salome/gui/SMESH/files/about_meshes.htm | 4 +- .../SMESH/files/about_meshing_algorithms.htm | 37 +- .../files/about_modification_of_meshes.htm | 13 +- .../SMESH/files/about_quality_controls.htm | 2 +- .../SMESH/files/adding_nodes_and_elements.htm | 179 +- .../gui/SMESH/files/area_of_elements.htm | 2 +- doc/salome/gui/SMESH/files/arithmetic_1d.htm | 164 + doc/salome/gui/SMESH/files/aspect_ratio.htm | 2 +- .../changing_orientation_of_elements.htm | 75 +- .../gui/SMESH/files/computing_meshes.htm | 2 +- doc/salome/gui/SMESH/files/connectivity.htm | 2 +- ...nstructing_groups_of_specific_elements.htm | 126 + .../gui/SMESH/files/constructing_meshes.htm | 34 +- .../SMESH/files/constructing_submeshes.htm | 42 +- .../gui/SMESH/files/creating_groups.htm | 230 + .../gui/SMESH/files/cutting_quadrangles.htm | 215 + doc/salome/gui/SMESH/files/deflection_1d.htm | 171 + .../files/diagonal_iversion_of_elements.htm | 66 +- .../gui/SMESH/files/displacing_nodes.htm | 93 +- .../files/displaying_elements_numbers.htm | 11 +- .../SMESH/files/displaying_nodes_numbers.htm | 12 +- doc/salome/gui/SMESH/files/editing_groups.htm | 139 + .../gui/SMESH/files/editing_hypotheses.htm | 56 +- .../files/importing_and_exporting_meshes.htm | 2 +- .../gui/SMESH/files/introduction_to_smesh.htm | 2 +- .../gui/SMESH/files/length_from_edges.htm | 135 + .../gui/SMESH/files/length_of_edges.htm | 2 +- .../SMESH/files/local_length_hypothesis.htm | 50 +- .../files/max._element_area_hypothesis.htm | 67 +- .../files/max._element_volume_hypothsis.htm | 68 +- doc/salome/gui/SMESH/files/merging_nodes.htm | 136 + doc/salome/gui/SMESH/files/minimum_angle.htm | 2 +- .../non_conform_mesh_allowed_hypothesis.htm | 129 + .../files/number_of_segments_hypothesis.htm | 38 +- ...ion_of_1d_hypothesis_on_opposite_edges.htm | 127 + .../reassigning_hypotheses_and_algorithms.htm | 117 +- .../files/removing_nodes_and_elements.htm | 147 +- .../files/renumbering_nodes_and_elements.htm | 184 + doc/salome/gui/SMESH/files/rotation.htm | 151 + .../gui/SMESH/files/running_smesh_module.htm | 2 +- .../gui/SMESH/files/scalar_bar_properties.htm | 5 +- doc/salome/gui/SMESH/files/sewing_meshes.htm | 328 + doc/salome/gui/SMESH/files/shading.htm | 2 +- doc/salome/gui/SMESH/files/shrink.htm | 2 +- doc/salome/gui/SMESH/files/skew.htm | 2 +- doc/salome/gui/SMESH/files/smoothing.htm | 217 + .../files/start_and_end_length_hypothesis.htm | 165 + doc/salome/gui/SMESH/files/symmetry.htm | 164 + doc/salome/gui/SMESH/files/taper.htm | 2 +- .../tetrahedron_(ghs3d)_meshing_algorithm.htm | 130 + ...tetrahedron_(netgen)_meshing_algorithm.htm | 36 +- doc/salome/gui/SMESH/files/translation.htm | 148 + .../files/uniting_a_set_of_triangles.htm | 191 + .../gui/SMESH/files/uniting_two_triangles.htm | 166 + .../files/using_operations_on_groups.htm | 243 + .../gui/SMESH/files/using_smesh_module.htm | 2 +- doc/salome/gui/SMESH/files/view_update.htm | 5 +- .../gui/SMESH/files/viewing_mesh_info.htm | 10 +- .../gui/SMESH/files/visualization_modes.htm | 21 +- .../SMESH/files/visualization_properties.htm | 5 +- doc/salome/gui/SMESH/files/warp.htm | 2 +- doc/salome/gui/SMESH/files/wireframe.htm | 2 +- doc/salome/gui/SMESH/image12.gif | Bin 0 -> 983 bytes doc/salome/gui/SMESH/image13.gif | Bin 0 -> 950 bytes doc/salome/gui/SMESH/image14.gif | Bin 0 -> 978 bytes doc/salome/gui/SMESH/image15.gif | Bin 0 -> 998 bytes doc/salome/gui/SMESH/image16.gif | Bin 0 -> 1026 bytes doc/salome/gui/SMESH/image16.jpg | Bin 0 -> 20555 bytes doc/salome/gui/SMESH/image17.jpg | Bin 0 -> 18256 bytes doc/salome/gui/SMESH/image18.jpg | Bin 0 -> 21345 bytes doc/salome/gui/SMESH/image20.jpg | Bin 0 -> 32034 bytes doc/salome/gui/SMESH/image21.jpg | Bin 0 -> 38677 bytes doc/salome/gui/SMESH/image22.jpg | Bin 0 -> 34642 bytes doc/salome/gui/SMESH/image23.jpg | Bin 0 -> 36428 bytes doc/salome/gui/SMESH/image30.jpg | Bin 0 -> 30000 bytes doc/salome/gui/SMESH/image31.jpg | Bin 0 -> 29277 bytes doc/salome/gui/SMESH/image32.jpg | Bin 0 -> 14908 bytes doc/salome/gui/SMESH/image34.jpg | Bin 0 -> 22197 bytes doc/salome/gui/SMESH/image35.jpg | Bin 0 -> 21749 bytes doc/salome/gui/SMESH/image36.jpg | Bin 0 -> 13508 bytes doc/salome/gui/SMESH/image38.jpg | Bin 0 -> 14183 bytes doc/salome/gui/SMESH/image39.jpg | Bin 0 -> 17825 bytes doc/salome/gui/SMESH/image40.jpg | Bin 0 -> 13980 bytes doc/salome/gui/SMESH/image41.jpg | Bin 0 -> 34209 bytes doc/salome/gui/SMESH/image42.jpg | Bin 0 -> 13176 bytes doc/salome/gui/SMESH/image43.jpg | Bin 0 -> 9197 bytes doc/salome/gui/SMESH/image44.jpg | Bin 0 -> 14292 bytes doc/salome/gui/SMESH/image45.jpg | Bin 0 -> 19039 bytes doc/salome/gui/SMESH/image46.jpg | Bin 0 -> 16104 bytes doc/salome/gui/SMESH/image47.jpg | Bin 0 -> 18787 bytes doc/salome/gui/SMESH/image48.jpg | Bin 0 -> 14192 bytes doc/salome/gui/SMESH/image49.jpg | Bin 0 -> 25380 bytes doc/salome/gui/SMESH/image50.jpg | Bin 0 -> 27180 bytes doc/salome/gui/SMESH/image51.jpg | Bin 0 -> 22124 bytes doc/salome/gui/SMESH/image52.jpg | Bin 0 -> 22197 bytes doc/salome/gui/SMESH/image53.jpg | Bin 0 -> 21043 bytes doc/salome/gui/SMESH/image54.jpg | Bin 0 -> 32186 bytes doc/salome/gui/SMESH/image55.jpg | Bin 0 -> 18872 bytes doc/salome/gui/SMESH/image57.gif | Bin 0 -> 11122 bytes doc/salome/gui/SMESH/image57.jpg | Bin 0 -> 17172 bytes doc/salome/gui/SMESH/image58.jpg | Bin 0 -> 20235 bytes doc/salome/gui/SMESH/image59.jpg | Bin 0 -> 19842 bytes doc/salome/gui/SMESH/image60.jpg | Bin 0 -> 8061 bytes doc/salome/gui/SMESH/image61.gif | Bin 0 -> 2241 bytes doc/salome/gui/SMESH/image61.jpg | Bin 0 -> 10055 bytes doc/salome/gui/SMESH/image62.jpg | Bin 0 -> 10571 bytes doc/salome/gui/SMESH/image63.gif | Bin 0 -> 929 bytes doc/salome/gui/SMESH/image63.jpg | Bin 0 -> 12348 bytes doc/salome/gui/SMESH/image64.gif | Bin 0 -> 954 bytes doc/salome/gui/SMESH/image64.jpg | Bin 0 -> 11306 bytes doc/salome/gui/SMESH/image65.gif | Bin 0 -> 5679 bytes doc/salome/gui/SMESH/image65.jpg | Bin 0 -> 9630 bytes doc/salome/gui/SMESH/image66.gif | Bin 0 -> 5260 bytes doc/salome/gui/SMESH/image66.jpg | Bin 0 -> 11280 bytes doc/salome/gui/SMESH/image67.gif | Bin 0 -> 945 bytes doc/salome/gui/SMESH/image67.jpg | Bin 0 -> 12193 bytes doc/salome/gui/SMESH/image68.gif | Bin 0 -> 6133 bytes doc/salome/gui/SMESH/image68.jpg | Bin 0 -> 11843 bytes doc/salome/gui/SMESH/image69.gif | Bin 0 -> 4706 bytes doc/salome/gui/SMESH/image69.jpg | Bin 0 -> 12705 bytes doc/salome/gui/SMESH/image7.gif | Bin 0 -> 1047 bytes doc/salome/gui/SMESH/image70.gif | Bin 0 -> 979 bytes doc/salome/gui/SMESH/image70.jpg | Bin 0 -> 12029 bytes doc/salome/gui/SMESH/image71.gif | Bin 0 -> 988 bytes doc/salome/gui/SMESH/image71.jpg | Bin 0 -> 11550 bytes doc/salome/gui/SMESH/image72.gif | Bin 0 -> 4721 bytes doc/salome/gui/SMESH/image72.jpg | Bin 0 -> 24132 bytes doc/salome/gui/SMESH/image73.gif | Bin 0 -> 2977 bytes doc/salome/gui/SMESH/image73.jpg | Bin 0 -> 20374 bytes doc/salome/gui/SMESH/image74.gif | Bin 0 -> 987 bytes doc/salome/gui/SMESH/image74.jpg | Bin 0 -> 25111 bytes doc/salome/gui/SMESH/image75.gif | Bin 0 -> 5735 bytes doc/salome/gui/SMESH/image75.jpg | Bin 0 -> 24687 bytes doc/salome/gui/SMESH/image76.gif | Bin 0 -> 5694 bytes doc/salome/gui/SMESH/image76.jpg | Bin 0 -> 22981 bytes doc/salome/gui/SMESH/image77.gif | Bin 0 -> 5632 bytes doc/salome/gui/SMESH/image77.jpg | Bin 0 -> 26424 bytes doc/salome/gui/SMESH/image78.gif | Bin 0 -> 8236 bytes doc/salome/gui/SMESH/image78.jpg | Bin 0 -> 25224 bytes doc/salome/gui/SMESH/image79.gif | Bin 0 -> 956 bytes doc/salome/gui/SMESH/image8.gif | Bin 0 -> 998 bytes doc/salome/gui/SMESH/image80.gif | Bin 0 -> 977 bytes doc/salome/gui/SMESH/image80.jpg | Bin 0 -> 20488 bytes doc/salome/gui/SMESH/image81.gif | Bin 0 -> 8606 bytes doc/salome/gui/SMESH/image81.jpg | Bin 0 -> 15777 bytes doc/salome/gui/SMESH/image82.gif | Bin 0 -> 984 bytes doc/salome/gui/SMESH/image82.jpg | Bin 0 -> 13186 bytes doc/salome/gui/SMESH/image83.gif | Bin 0 -> 4552 bytes doc/salome/gui/SMESH/image84.gif | Bin 0 -> 956 bytes doc/salome/gui/SMESH/image85.gif | Bin 0 -> 10574 bytes doc/salome/gui/SMESH/image87.gif | Bin 0 -> 4901 bytes doc/salome/gui/SMESH/image88.gif | Bin 0 -> 942 bytes doc/salome/gui/SMESH/image89.gif | Bin 0 -> 5212 bytes doc/salome/gui/SMESH/image9.gif | Bin 0 -> 30034 bytes doc/salome/gui/SMESH/image90.gif | Bin 0 -> 9562 bytes doc/salome/gui/SMESH/image91.gif | Bin 0 -> 975 bytes doc/salome/gui/SMESH/image92.gif | Bin 0 -> 984 bytes doc/salome/gui/SMESH/image93.gif | Bin 0 -> 14366 bytes doc/salome/gui/SMESH/image94.gif | Bin 0 -> 5678 bytes doc/salome/gui/SMESH/image95.gif | Bin 0 -> 3941 bytes doc/salome/gui/SMESH/image96.gif | Bin 0 -> 4286 bytes doc/salome/gui/SMESH/image97.gif | Bin 0 -> 6203 bytes doc/salome/gui/SMESH/image98.gif | Bin 0 -> 965 bytes doc/salome/gui/SMESH/pattern_mapping.htm | 307 + doc/salome/gui/SMESH/revolution.htm | 171 + doc/salome/gui/SMESH/smesh.htm | 150 + doc/salome/gui/SMESH/smesh_csh.htm | 100 + doc/salome/gui/SMESH/smesh_rhc.htm | 100 + .../tetrahedron_(ghs3d)_meshing_algorithm.htm | 132 + doc/salome/gui/SMESH/whdata/whftdata0.htm | 28 +- doc/salome/gui/SMESH/whdata/whftdata0.xml | 28 +- doc/salome/gui/SMESH/whdata/whfts.htm | 4 +- doc/salome/gui/SMESH/whdata/whfts.xml | 4 +- doc/salome/gui/SMESH/whdata/whfwdata0.htm | 934 ++- doc/salome/gui/SMESH/whdata/whfwdata0.xml | 934 ++- doc/salome/gui/SMESH/whdata/whtdata0.htm | 54 +- doc/salome/gui/SMESH/whdata/whtdata0.xml | 45 +- doc/salome/gui/SMESH/whgdata/whlstf0.htm | 10 +- doc/salome/gui/SMESH/whgdata/whlstf1.htm | 20 +- doc/salome/gui/SMESH/whgdata/whlstf2.htm | 16 +- doc/salome/gui/SMESH/whgdata/whlstf3.htm | 15 +- doc/salome/gui/SMESH/whgdata/whlstf4.htm | 51 + doc/salome/gui/SMESH/whgdata/whlstf5.htm | 49 + doc/salome/gui/SMESH/whgdata/whlstf6.htm | 45 + doc/salome/gui/SMESH/whgdata/whlstf7.htm | 52 + doc/salome/gui/SMESH/whgdata/whlstfl0.htm | 2 +- doc/salome/gui/SMESH/whgdata/whlstfl1.htm | 2 +- doc/salome/gui/SMESH/whgdata/whlstfl10.htm | 2 +- doc/salome/gui/SMESH/whgdata/whlstfl11.htm | 2 +- doc/salome/gui/SMESH/whgdata/whlstfl12.htm | 2 +- doc/salome/gui/SMESH/whgdata/whlstfl13.htm | 2 +- doc/salome/gui/SMESH/whgdata/whlstfl14.htm | 2 +- doc/salome/gui/SMESH/whgdata/whlstfl15.htm | 2 +- doc/salome/gui/SMESH/whgdata/whlstfl16.htm | 2 +- doc/salome/gui/SMESH/whgdata/whlstfl17.htm | 2 +- doc/salome/gui/SMESH/whgdata/whlstfl18.htm | 2 +- doc/salome/gui/SMESH/whgdata/whlstfl19.htm | 2 +- doc/salome/gui/SMESH/whgdata/whlstfl2.htm | 2 +- doc/salome/gui/SMESH/whgdata/whlstfl20.htm | 2 +- doc/salome/gui/SMESH/whgdata/whlstfl21.htm | 2 +- doc/salome/gui/SMESH/whgdata/whlstfl22.htm | 2 +- doc/salome/gui/SMESH/whgdata/whlstfl23.htm | 45 + doc/salome/gui/SMESH/whgdata/whlstfl3.htm | 2 +- doc/salome/gui/SMESH/whgdata/whlstfl4.htm | 2 +- doc/salome/gui/SMESH/whgdata/whlstfl5.htm | 2 +- doc/salome/gui/SMESH/whgdata/whlstfl6.htm | 2 +- doc/salome/gui/SMESH/whgdata/whlstfl7.htm | 2 +- doc/salome/gui/SMESH/whgdata/whlstfl8.htm | 2 +- doc/salome/gui/SMESH/whgdata/whlstfl9.htm | 2 +- doc/salome/gui/SMESH/whgdata/whlstt1.htm | 6 +- doc/salome/gui/SMESH/whgdata/whlstt10.htm | 16 +- doc/salome/gui/SMESH/whgdata/whlstt11.htm | 23 +- doc/salome/gui/SMESH/whgdata/whlstt12.htm | 29 +- doc/salome/gui/SMESH/whgdata/whlstt13.htm | 61 + doc/salome/gui/SMESH/whgdata/whlstt2.htm | 6 +- doc/salome/gui/SMESH/whgdata/whlstt3.htm | 16 +- doc/salome/gui/SMESH/whgdata/whlstt4.htm | 6 +- doc/salome/gui/SMESH/whgdata/whlstt5.htm | 6 +- doc/salome/gui/SMESH/whgdata/whlstt6.htm | 6 +- doc/salome/gui/SMESH/whgdata/whlstt7.htm | 7 +- doc/salome/gui/SMESH/whgdata/whlstt8.htm | 8 +- doc/salome/gui/SMESH/whgdata/whlstt9.htm | 6 +- doc/salome/gui/SMESH/whgdata/whnvl32.htm | 6 +- doc/salome/gui/SMESH/whskin_info.htm | 4 +- .../tui/SMESH/HTML/SMESH_BasicHypothesis.html | 104 +- doc/salome/tui/SMESH/HTML/SMESH_Gen.html | 48 +- .../tui/SMESH/HTML/SMESH_Hypothesis.html | 4 + doc/salome/tui/SMESH/HTML/SMESH_Mesh.html | 164 +- doc/salome/tui/SMESH/doxyfile | 2 +- .../tui/SMESH/sources/static/page2.html | 4 + doc/salome/tui/SMESH/sources/static/tree.js | 2 +- idl/Makefile.in | 3 +- idl/SMESH_BasicHypothesis.idl | 63 + idl/SMESH_Filter.idl | 375 +- idl/SMESH_Gen.idl | 31 +- idl/SMESH_Group.idl | 50 +- idl/SMESH_Mesh.idl | 277 +- idl/SMESH_Pattern.idl | 160 + resources/SMESHCatalog.xml | 2 +- resources/SMESH_Meshers.xml | 78 - resources/SMESH_MeshersWithNETGEN.xml | 89 - resources/SMESH_en.xml | 102 +- resources/SMESH_fr.xml | 34 +- resources/StdMeshers.xml | 24 +- resources/mesh_algo_tetra.png | Bin 371 -> 616 bytes resources/mesh_cutGroups.png | Bin 0 -> 340 bytes resources/mesh_cutquad.png | Bin 0 -> 417 bytes resources/mesh_deleteGroups.png | Bin 0 -> 212 bytes resources/mesh_extrusion.png | Bin 0 -> 427 bytes resources/mesh_intersectGroups.png | Bin 0 -> 324 bytes resources/mesh_merge_nodes.png | Bin 0 -> 560 bytes resources/mesh_pattern.png | Bin 0 -> 292 bytes resources/mesh_renumbering_elements.png | Bin 0 -> 346 bytes resources/mesh_renumbering_nodes.png | Bin 0 -> 388 bytes resources/mesh_revolution.png | Bin 0 -> 450 bytes resources/mesh_rotation.png | Bin 0 -> 646 bytes resources/mesh_sew_bordertoside.png | Bin 0 -> 359 bytes resources/mesh_sew_conform_freeborders.png | Bin 0 -> 419 bytes resources/mesh_sew_freeborders.png | Bin 0 -> 412 bytes resources/mesh_sew_sideelements.png | Bin 0 -> 295 bytes resources/mesh_smoothing.png | Bin 0 -> 416 bytes resources/mesh_symmetry_axis.png | Bin 0 -> 430 bytes resources/mesh_symmetry_plane.png | Bin 0 -> 426 bytes resources/mesh_symmetry_point.png | Bin 0 -> 430 bytes resources/mesh_translation_points.png | Bin 0 -> 469 bytes resources/mesh_translation_vector.png | Bin 0 -> 458 bytes resources/mesh_tree_algo_tetra.png | Bin 148 -> 281 bytes resources/mesh_union2tri.png | Bin 0 -> 504 bytes resources/mesh_unionGroups.png | Bin 0 -> 425 bytes resources/mesh_uniontri.png | Bin 0 -> 417 bytes resources/pattern_sample_2d.png | Bin 0 -> 1180 bytes resources/pattern_sample_3D.png | Bin 0 -> 2160 bytes src/Controls/Makefile.in | 52 + .../SMESHControls.cxx} | 41 +- src/Controls/SMESH_Controls.cxx | 1762 +++++ src/Controls/SMESH_Controls.hxx | 527 ++ src/Driver/Document_Reader.h | 44 - src/Driver/Driver_Document.cxx | 36 + .../{Mesh_Reader.h => Driver_Document.h} | 33 +- .../{Document_Reader.cxx => Driver_Mesh.cxx} | 22 +- .../{Document_Writer.h => Driver_Mesh.h} | 33 +- .../{Mesh_Reader.cxx => Driver_SMDS_Mesh.cxx} | 18 +- src/Driver/Driver_SMDS_Mesh.h | 38 + ...ent_Writer.cxx => Driver_SMESHDS_Mesh.cxx} | 21 +- src/Driver/Driver_SMESHDS_Mesh.h | 38 + src/Driver/Driver_dl.cxx | 209 - src/Driver/Makefile.in | 14 +- src/Driver/SMESHDriver.cxx | 139 - src/DriverDAT/DAT_Test.cxx | 28 + src/DriverDAT/DriverDAT_R_SMDS_Mesh.cxx | 333 +- src/DriverDAT/DriverDAT_R_SMDS_Mesh.h | 34 +- .../DriverDAT_R_SMESHDS_Document.cxx | 97 - src/DriverDAT/DriverDAT_R_SMESHDS_Document.h | 28 +- src/DriverDAT/DriverDAT_R_SMESHDS_Mesh.cxx | 66 - src/DriverDAT/DriverDAT_R_SMESHDS_Mesh.h | 33 +- src/DriverDAT/DriverDAT_W_SMDS_Mesh.cxx | 288 +- src/DriverDAT/DriverDAT_W_SMDS_Mesh.h | 28 +- .../DriverDAT_W_SMESHDS_Document.cxx | 89 - src/DriverDAT/DriverDAT_W_SMESHDS_Document.h | 29 +- src/DriverDAT/DriverDAT_W_SMESHDS_Mesh.cxx | 203 - src/DriverDAT/DriverDAT_W_SMESHDS_Mesh.h | 27 +- src/DriverDAT/Makefile.in | 12 +- src/DriverMED/DriverMED_Family.cxx | 22 +- src/DriverMED/DriverMED_Family.h | 32 +- src/DriverMED/DriverMED_R_SMDS_Mesh.cxx | 600 -- src/DriverMED/DriverMED_R_SMDS_Mesh.h | 36 +- .../DriverMED_R_SMESHDS_Document.cxx | 103 - src/DriverMED/DriverMED_R_SMESHDS_Document.h | 30 +- src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx | 148 +- src/DriverMED/DriverMED_R_SMESHDS_Mesh.h | 50 +- src/DriverMED/DriverMED_W_SMDS_Mesh.cxx | 395 -- src/DriverMED/DriverMED_W_SMDS_Mesh.h | 38 +- .../DriverMED_W_SMESHDS_Document.cxx | 76 - src/DriverMED/DriverMED_W_SMESHDS_Document.h | 33 +- src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx | 101 +- src/DriverMED/DriverMED_W_SMESHDS_Mesh.h | 42 +- src/DriverMED/MED_Test.cxx | 28 + src/DriverMED/Makefile.in | 11 +- src/DriverSTL/DriverSTL_R_SMDS_Mesh.cxx | 344 + .../DriverSTL/DriverSTL_R_SMDS_Mesh.h | 40 +- src/DriverSTL/DriverSTL_W_SMDS_Mesh.cxx | 261 + .../DriverSTL_W_SMDS_Mesh.h} | 34 +- src/DriverSTL/Makefile.in | 61 + src/DriverSTL/STL_Test.cxx | 28 + src/DriverUNV/DriverUNV_R_SMDS_Mesh.cxx | 320 +- src/DriverUNV/DriverUNV_R_SMDS_Mesh.h | 46 +- .../DriverUNV_R_SMESHDS_Document.cxx | 108 +- src/DriverUNV/DriverUNV_R_SMESHDS_Document.h | 40 +- src/DriverUNV/DriverUNV_R_SMESHDS_Mesh.cxx | 74 +- src/DriverUNV/DriverUNV_R_SMESHDS_Mesh.h | 45 +- src/DriverUNV/DriverUNV_W_SMDS_Mesh.cxx | 351 +- src/DriverUNV/DriverUNV_W_SMDS_Mesh.h | 46 +- .../DriverUNV_W_SMESHDS_Document.cxx | 101 +- src/DriverUNV/DriverUNV_W_SMESHDS_Document.h | 41 +- src/DriverUNV/DriverUNV_W_SMESHDS_Mesh.cxx | 250 +- src/DriverUNV/DriverUNV_W_SMESHDS_Mesh.h | 46 +- src/DriverUNV/Makefile.in | 23 +- src/DriverUNV/UNV2411_Structure.cxx | 124 + .../UNV2411_Structure.hxx} | 39 +- src/DriverUNV/UNV2412_Structure.cxx | 203 + src/DriverUNV/UNV2412_Structure.hxx | 61 + src/DriverUNV/UNV_Test.cxx | 69 + src/DriverUNV/UNV_Utilities.cxx | 37 + src/DriverUNV/UNV_Utilities.hxx | 104 + src/MEFISTO2/Rn.h | 21 +- src/MEFISTO2/aptrte.cxx | 39 +- src/Makefile.in | 2 +- src/OBJECT/Makefile.in | 8 +- src/OBJECT/SMESH_Actor.cxx | 563 +- src/OBJECT/SMESH_Actor.h | 61 +- src/OBJECT/SMESH_ActorUtils.cxx | 39 + .../SMESH_ActorUtils.h} | 21 +- src/OBJECT/SMESH_DeviceActor.cxx | 244 +- src/OBJECT/SMESH_DeviceActor.h | 41 +- src/OBJECT/SMESH_ExtractGeometry.cxx | 254 + .../SMESH_ExtractGeometry.h} | 73 +- src/OBJECT/SMESH_Object.cxx | 118 +- src/OBJECT/SMESH_Object.h | 27 +- src/SMDS/Makefile.in | 10 +- src/SMDS/SMDSAbs_ElementType.hxx | 2 +- src/SMDS/SMDSControl.cxx | 234 - src/SMDS/SMDSControl.hxx | 115 - src/SMDS/SMDSControl_BoundaryEdges.cxx | 79 - src/SMDS/SMDSControl_BoundaryEdges.hxx | 114 - src/SMDS/SMDSControl_BoundaryFaces.cxx | 102 - src/SMDS/SMDSControl_BoundaryFaces.hxx | 114 - src/SMDS/SMDSControl_MeshBoundary.cxx | 60 - src/SMDS/SMDSControl_MeshBoundary.hxx | 114 - src/SMDS/SMDSEdit_Transform.cxx | 120 - src/SMDS/SMDSEdit_Transform.hxx | 115 - src/SMDS/SMDS_EdgePosition.cxx | 3 + src/SMDS/SMDS_FaceOfEdges.cxx | 2 + src/SMDS/SMDS_FaceOfEdges.hxx | 8 +- src/SMDS/SMDS_FaceOfNodes.cxx | 24 + src/SMDS/SMDS_FaceOfNodes.hxx | 10 +- src/SMDS/SMDS_FacePosition.cxx | 3 + src/SMDS/SMDS_HexahedronOfNodes.cxx | 95 - src/SMDS/SMDS_IteratorOfElements.hxx | 5 +- src/SMDS/SMDS_Mesh.cxx | 220 +- src/SMDS/SMDS_Mesh.hxx | 71 +- src/SMDS/SMDS_MeshEdge.cxx | 17 +- src/SMDS/SMDS_MeshEdge.hxx | 4 +- src/SMDS/SMDS_MeshElement.cxx | 3 + src/SMDS/SMDS_MeshElement.hxx | 5 +- src/SMDS/SMDS_MeshElementIDFactory.cxx | 31 + src/SMDS/SMDS_MeshElementIDFactory.hxx | 8 +- src/SMDS/SMDS_MeshGroup.cxx | 4 +- src/SMDS/SMDS_MeshGroup.hxx | 14 +- src/SMDS/SMDS_MeshHexahedron.cxx | 217 - src/SMDS/SMDS_MeshHexahedron.hxx | 125 - src/SMDS/SMDS_MeshIDFactory.cxx | 2 + src/SMDS/SMDS_MeshIDFactory.hxx | 4 +- src/SMDS/SMDS_MeshNode.cxx | 2 + src/SMDS/SMDS_MeshNode.hxx | 6 +- src/SMDS/SMDS_MeshNodeIDFactory.hxx | 112 - src/SMDS/SMDS_MeshPrism.cxx | 182 - src/SMDS/SMDS_MeshPrism.hxx | 125 - src/SMDS/SMDS_MeshPyramid.cxx | 168 - src/SMDS/SMDS_MeshPyramid.hxx | 125 - src/SMDS/SMDS_MeshQuadrangle.cxx | 83 - src/SMDS/SMDS_MeshQuadrangle.hxx | 119 - src/SMDS/SMDS_MeshTetrahedron.cxx | 149 - src/SMDS/SMDS_MeshTetrahedron.hxx | 125 - src/SMDS/SMDS_MeshTriangle.cxx | 71 - src/SMDS/SMDS_MeshTriangle.hxx | 119 - src/SMDS/SMDS_Position.cxx | 19 + src/SMDS/SMDS_Position.hxx | 6 +- src/SMDS/SMDS_Tria3OfNodes.cxx | 107 - src/SMDS/SMDS_Tria3OfNodes.hxx | 50 - src/SMDS/SMDS_TypeOfPosition.hxx | 12 +- src/SMDS/SMDS_VertexPosition.cxx | 3 + src/SMDS/SMDS_VolumeOfFaces.cxx | 3 + src/SMDS/SMDS_VolumeOfFaces.hxx | 6 +- src/SMDS/SMDS_VolumeOfNodes.cxx | 18 +- src/SMDS/SMDS_VolumeOfNodes.hxx | 8 +- src/SMDS/SMDS_VolumeTool.cxx | 771 ++ src/SMDS/SMDS_VolumeTool.hxx | 230 + src/SMESH/Makefile.in | 15 +- src/SMESH/SMESH_Algo.hxx | 11 +- src/SMESH/SMESH_Gen.cxx | 175 +- src/SMESH/SMESH_Gen.hxx | 16 +- src/SMESH/SMESH_Group.cxx | 23 +- src/SMESH/SMESH_Group.hxx | 17 +- src/SMESH/SMESH_Hypothesis.hxx | 2 +- src/SMESH/SMESH_Mesh.cxx | 545 +- src/SMESH/SMESH_Mesh.hxx | 241 +- src/SMESH/SMESH_MeshEditor.cxx | 3556 ++++++++++ src/SMESH/SMESH_MeshEditor.hxx | 241 + src/SMESH/SMESH_Pattern.cxx | 4310 ++++++++++++ src/SMESH/SMESH_Pattern.hxx | 258 + src/SMESH/SMESH_subMesh.cxx | 815 ++- src/SMESH/SMESH_subMesh.hxx | 20 +- src/SMESHDS/Makefile.in | 10 +- src/SMESHDS/SMESHDS_Command.cxx | 42 +- src/SMESHDS/SMESHDS_Command.hxx | 10 +- src/SMESHDS/SMESHDS_CommandType.hxx | 28 +- src/SMESHDS/SMESHDS_Document.cxx | 2 + src/SMESHDS/SMESHDS_Document.hxx | 12 +- src/SMESHDS/SMESHDS_Group.cxx | 124 +- src/SMESHDS/SMESHDS_Group.hxx | 42 +- src/SMESHDS/SMESHDS_GroupBase.cxx | 138 + src/SMESHDS/SMESHDS_GroupBase.hxx | 89 + src/SMESHDS/SMESHDS_GroupOnGeom.cxx | 112 + src/SMESHDS/SMESHDS_GroupOnGeom.hxx | 56 + src/SMESHDS/SMESHDS_Hypothesis.cxx | 3 +- src/SMESHDS/SMESHDS_Hypothesis.hxx | 16 +- src/SMESHDS/SMESHDS_Mesh.cxx | 163 +- src/SMESHDS/SMESHDS_Mesh.hxx | 48 +- src/SMESHDS/SMESHDS_Script.cxx | 267 +- src/SMESHDS/SMESHDS_Script.hxx | 11 +- src/SMESHDS/SMESHDS_SubMesh.cxx | 190 +- src/SMESHDS/SMESHDS_SubMesh.hxx | 43 +- src/SMESHFiltersSelection/Makefile.in | 30 +- .../SMESH_LogicalFilter.cxx | 148 + .../SMESH_LogicalFilter.hxx | 102 + .../SMESH_NumberFilter.cxx | 225 + .../SMESH_NumberFilter.hxx | 124 + .../SMESH_TypeFilter.cxx | 51 +- src/SMESHGUI/Makefile.in | 91 +- src/SMESHGUI/SMESHBin.cxx | 4 + src/SMESHGUI/SMESHGUI.cxx | 6266 +++++------------ src/SMESHGUI/SMESHGUI.h | 236 +- src/SMESHGUI/SMESHGUI_AddAlgorithmDlg.cxx | 466 -- src/SMESHGUI/SMESHGUI_AddAlgorithmDlg.h | 130 - src/SMESHGUI/SMESHGUI_AddEdgeDlg.cxx | 388 - src/SMESHGUI/SMESHGUI_AddHypothesisDlg.cxx | 467 -- src/SMESHGUI/SMESHGUI_AddHypothesisDlg.h | 132 - src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx | 696 ++ ...entsDlg.h => SMESHGUI_AddMeshElementDlg.h} | 78 +- src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx | 132 +- src/SMESHGUI/SMESHGUI_AddSubMeshDlg.h | 3 +- src/SMESHGUI/SMESHGUI_AddVolumeDlg.cxx | 406 -- src/SMESHGUI/SMESHGUI_ClippingDlg.cxx | 756 ++ src/SMESHGUI/SMESHGUI_ClippingDlg.h | 126 + src/SMESHGUI/SMESHGUI_ComputeScalarValue.cxx | 425 -- src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.cxx | 36 +- src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.h | 3 - src/SMESHGUI/SMESHGUI_CreatePatternDlg.cxx | 797 +++ src/SMESHGUI/SMESHGUI_CreatePatternDlg.h | 158 + src/SMESHGUI/SMESHGUI_DeleteGroupDlg.cxx | 295 + src/SMESHGUI/SMESHGUI_DeleteGroupDlg.h | 96 + .../SMESHGUI_DiagonalInversionDlg.cxx | 369 - src/SMESHGUI/SMESHGUI_EditHypothesesDlg.cxx | 270 +- src/SMESHGUI/SMESHGUI_EditHypothesesDlg.h | 6 +- src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx | 748 ++ ...I_AddFaceDlg.h => SMESHGUI_ExtrusionDlg.h} | 86 +- src/SMESHGUI/SMESHGUI_Filter.cxx | 304 +- src/SMESHGUI/SMESHGUI_Filter.h | 106 +- src/SMESHGUI/SMESHGUI_FilterDlg.cxx | 2680 +++++-- src/SMESHGUI/SMESHGUI_FilterDlg.h | 514 +- src/SMESHGUI/SMESHGUI_FilterLibraryDlg.cxx | 1159 +++ src/SMESHGUI/SMESHGUI_FilterLibraryDlg.h | 154 + src/SMESHGUI/SMESHGUI_FilterUtils.cxx | 37 + src/SMESHGUI/SMESHGUI_FilterUtils.h | 34 + src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx | 60 + src/SMESHGUI/SMESHGUI_GEOMGenUtils.h | 38 + src/SMESHGUI/SMESHGUI_GroupDlg.cxx | 706 +- src/SMESHGUI/SMESHGUI_GroupDlg.h | 24 + src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx | 401 ++ src/SMESHGUI/SMESHGUI_GroupOpDlg.h | 109 + src/SMESHGUI/SMESHGUI_GroupUtils.cxx | 46 + src/SMESHGUI/SMESHGUI_GroupUtils.h | 36 + src/SMESHGUI/SMESHGUI_Hypotheses.cxx | 490 ++ src/SMESHGUI/SMESHGUI_Hypotheses.h | 1 + src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx | 554 ++ src/SMESHGUI/SMESHGUI_HypothesesUtils.h | 71 + src/SMESHGUI/SMESHGUI_IdValidator.h | 68 + src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx | 96 +- src/SMESHGUI/SMESHGUI_InitMeshDlg.h | 6 +- src/SMESHGUI/SMESHGUI_MergeNodesDlg.cxx | 707 ++ src/SMESHGUI/SMESHGUI_MergeNodesDlg.h | 134 + src/SMESHGUI/SMESHGUI_MeshInfosDlg.cxx | 32 +- src/SMESHGUI/SMESHGUI_MeshInfosDlg.h | 5 - src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx | 1151 +++ src/SMESHGUI/SMESHGUI_MeshPatternDlg.h | 169 + src/SMESHGUI/SMESHGUI_MeshUtils.cxx | 47 + src/SMESHGUI/SMESHGUI_MeshUtils.h | 36 + src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx | 792 ++- src/SMESHGUI/SMESHGUI_MoveNodesDlg.h | 124 +- src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx | 1123 +++ src/SMESHGUI/SMESHGUI_MultiEditDlg.h | 209 + src/SMESHGUI/SMESHGUI_NodesDlg.cxx | 383 +- src/SMESHGUI/SMESHGUI_NodesDlg.h | 8 +- .../SMESHGUI_OrientationElementsDlg.cxx | 372 - src/SMESHGUI/SMESHGUI_PatternUtils.cxx | 32 + src/SMESHGUI/SMESHGUI_PatternUtils.h | 34 + src/SMESHGUI/SMESHGUI_PatternWidget.cxx | 171 + src/SMESHGUI/SMESHGUI_PatternWidget.h | 74 + src/SMESHGUI/SMESHGUI_PrecisionDlg.cxx | 221 + src/SMESHGUI/SMESHGUI_PrecisionDlg.h | 96 + .../SMESHGUI_Preferences_ScalarBarDlg.cxx | 13 +- .../SMESHGUI_Preferences_SelectionDlg.cxx | 6 +- src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx | 177 +- src/SMESHGUI/SMESHGUI_RemoveElementsDlg.h | 11 +- src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx | 187 +- src/SMESHGUI/SMESHGUI_RemoveNodesDlg.h | 10 +- ...aceDlg.cxx => SMESHGUI_RenumberingDlg.cxx} | 369 +- ...AddEdgeDlg.h => SMESHGUI_RenumberingDlg.h} | 53 +- src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx | 917 +++ src/SMESHGUI/SMESHGUI_RevolutionDlg.h | 147 + src/SMESHGUI/SMESHGUI_RotationDlg.cxx | 831 +++ src/SMESHGUI/SMESHGUI_RotationDlg.h | 143 + .../SMESHGUI_SMESHGenUtils.cxx} | 38 +- src/SMESHGUI/SMESHGUI_SMESHGenUtils.h | 35 + src/SMESHGUI/SMESHGUI_SewingDlg.cxx | 886 +++ ...nalInversionDlg.h => SMESHGUI_SewingDlg.h} | 90 +- src/SMESHGUI/SMESHGUI_SingleEditDlg.cxx | 544 ++ src/SMESHGUI/SMESHGUI_SingleEditDlg.h | 129 + src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx | 729 ++ ...AddVolumeDlg.h => SMESHGUI_SmoothingDlg.h} | 76 +- src/SMESHGUI/SMESHGUI_SpinBox.cxx | 4 +- src/SMESHGUI/SMESHGUI_StudyAPI.cxx | 457 -- src/SMESHGUI/SMESHGUI_StudyAPI.h | 98 - src/SMESHGUI/SMESHGUI_Swig.cxx | 9 +- src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx | 901 +++ src/SMESHGUI/SMESHGUI_SymmetryDlg.h | 144 + src/SMESHGUI/SMESHGUI_TranslationDlg.cxx | 834 +++ src/SMESHGUI/SMESHGUI_TranslationDlg.h | 137 + src/SMESHGUI/SMESHGUI_TransparencyDlg.cxx | 34 +- src/SMESHGUI/SMESHGUI_Utils.cxx | 196 + src/SMESHGUI/SMESHGUI_Utils.h | 99 + src/SMESHGUI/SMESHGUI_VTKUtils.cxx | 653 ++ src/SMESHGUI/SMESHGUI_VTKUtils.h | 189 + src/SMESHGUI/SMESHGUI_XmlHandler.cxx | 14 +- src/SMESHGUI/SMESHGUI_XmlHandler.h | 12 +- src/SMESHGUI/SMESHGUI_aParameter.cxx | 119 + src/SMESHGUI/SMESHGUI_aParameter.h | 117 + src/SMESHGUI/SMESHGUI_aParameterDlg.cxx | 202 +- src/SMESHGUI/SMESHGUI_aParameterDlg.h | 41 +- src/SMESHGUI/SMESH_icons.po | 98 +- src/SMESHGUI/SMESH_msg_en.po | 876 ++- src/SMESH_I/Makefile.in | 24 +- src/SMESH_I/SMESHEngine.cxx | 23 + src/SMESH_I/SMESH_Algo_i.cxx | 2 +- src/SMESH_I/SMESH_Filter_i.cxx | 2212 ++++-- src/SMESH_I/SMESH_Filter_i.hxx | 1039 +-- src/SMESH_I/SMESH_Gen_i.cxx | 1199 ++-- src/SMESH_I/SMESH_Gen_i.hxx | 84 +- src/SMESH_I/SMESH_Gen_i_1.cxx | 850 +++ src/SMESH_I/SMESH_Group_i.cxx | 283 +- src/SMESH_I/SMESH_Group_i.hxx | 82 +- src/SMESH_I/SMESH_MEDFamily_i.cxx | 8 +- src/SMESH_I/SMESH_MEDFamily_i.hxx | 8 +- src/SMESH_I/SMESH_MEDMesh_i.cxx | 3 +- src/SMESH_I/SMESH_MEDMesh_i.hxx | 5 + src/SMESH_I/SMESH_MeshEditor_i.cxx | 840 ++- src/SMESH_I/SMESH_MeshEditor_i.hxx | 140 +- src/SMESH_I/SMESH_Mesh_i.cxx | 1072 ++- src/SMESH_I/SMESH_Mesh_i.hxx | 86 +- src/SMESH_I/SMESH_Pattern_i.cxx | 359 + src/SMESH_I/SMESH_Pattern_i.hxx | 93 + src/SMESH_I/SMESH_subMesh_i.cxx | 84 +- src/SMESH_I/SMESH_subMesh_i.hxx | 8 +- src/SMESH_I/SMESH_test.py | 169 +- src/SMESH_SWIG/Makefile.in | 29 +- src/SMESH_SWIG/SMESH_BelongToGeom.py | 28 + src/SMESH_SWIG/SMESH_GroupFromGeom.py | 49 + src/SMESH_SWIG/SMESH_Partition1_tetra.py | 133 +- src/SMESH_SWIG/SMESH_blocks.py | 43 + src/SMESH_SWIG/SMESH_box2_tetra.py | 69 +- src/SMESH_SWIG/SMESH_box3_tetra.py | 82 +- src/SMESH_SWIG/SMESH_box_tetra.py | 36 +- src/SMESH_SWIG/SMESH_controls.py | 20 +- src/SMESH_SWIG/SMESH_fixation.py | 398 +- src/SMESH_SWIG/SMESH_fixation_hexa.py | 38 +- src/SMESH_SWIG/SMESH_fixation_tetra.py | 43 +- src/SMESH_SWIG/SMESH_flight_skin.py | 48 +- src/SMESH_SWIG/SMESH_freebord.py | 20 +- src/SMESH_SWIG/SMESH_mechanic.py | 327 +- src/SMESH_SWIG/SMESH_mechanic_editor.py | 308 + src/SMESH_SWIG/SMESH_mechanic_tetra.py | 162 +- src/SMESH_SWIG/SMESH_test0.py | 46 +- src/SMESH_SWIG/SMESH_test1.py | 60 +- src/SMESH_SWIG/SMESH_test2.py | 5 +- src/SMESH_SWIG/SMESH_test3.py | 86 +- src/SMESH_SWIG/SMESH_test4.py | 21 +- src/SMESH_SWIG/SMESH_test5.py | 79 + src/SMESH_SWIG/batchmode_mefisto.py | 60 +- src/SMESH_SWIG/batchmode_smesh.py | 247 +- src/SMESH_SWIG/cube2geometry.py | 92 + src/SMESH_SWIG/cube2partition.py | 83 + src/SMESH_SWIG/cube2pyGibi.py | 295 + src/SMESH_SWIG/cyl2complementary.py | 100 + src/SMESH_SWIG/cyl2geometry.py | 170 + src/SMESH_SWIG/grid17partition.py | 108 + src/SMESH_SWIG/grid3partition.py | 94 + src/SMESH_SWIG/grid4partition.py | 72 + src/SMESH_SWIG/grid4pyGibi.py | 114 + src/SMESH_SWIG/hole1geometry.py | 109 + src/SMESH_SWIG/hole1partition.py | 75 + src/SMESH_SWIG/hole1pyGibi.py | 116 + src/SMESH_SWIG/hole2pyGibi.py | 113 + src/SMESH_SWIG/meshpy.py | 101 + src/StdMeshers/Makefile.in | 14 +- src/StdMeshers/StdMeshers_Arithmetic1D.cxx | 139 + src/StdMeshers/StdMeshers_Arithmetic1D.hxx | 55 + src/StdMeshers/StdMeshers_Deflection1D.cxx | 136 + .../StdMeshers_Deflection1D.hxx} | 36 +- src/StdMeshers/StdMeshers_Hexa_3D.cxx | 159 +- src/StdMeshers/StdMeshers_MEFISTO_2D.cxx | 768 +- src/StdMeshers/StdMeshers_MEFISTO_2D.hxx | 32 +- src/StdMeshers/StdMeshers_Propagation.cxx | 102 + src/StdMeshers/StdMeshers_Propagation.hxx | 47 + src/StdMeshers/StdMeshers_Quadrangle_2D.cxx | 1391 ++-- src/StdMeshers/StdMeshers_Quadrangle_2D.hxx | 16 +- src/StdMeshers/StdMeshers_Regular_1D.cxx | 729 +- src/StdMeshers/StdMeshers_Regular_1D.hxx | 39 +- src/StdMeshers/StdMeshers_StartEndLength.cxx | 143 + src/StdMeshers/StdMeshers_StartEndLength.hxx | 53 + src/StdMeshersGUI/Makefile.in | 28 +- src/StdMeshersGUI/StdMeshersGUI.cxx | 146 +- .../StdMeshersGUI_CreateHypothesisDlg.cxx | 343 + ....h => StdMeshersGUI_CreateHypothesisDlg.h} | 45 +- .../StdMeshersGUI_CreateStdHypothesisDlg.cxx | 109 + .../StdMeshersGUI_CreateStdHypothesisDlg.h} | 58 +- .../StdMeshersGUI_LocalLengthDlg.cxx | 296 - .../StdMeshersGUI_MaxElementAreaDlg.cxx | 299 - .../StdMeshersGUI_MaxElementAreaDlg.h | 89 - .../StdMeshersGUI_MaxElementVolumeDlg.cxx | 298 - .../StdMeshersGUI_MaxElementVolumeDlg.h | 89 - .../StdMeshersGUI_NbSegmentsDlg.cxx | 297 - .../StdMeshersGUI_NbSegmentsDlg.h | 89 - .../StdMeshersGUI_Parameters.cxx | 306 + src/StdMeshersGUI/StdMeshersGUI_Parameters.h | 54 + src/StdMeshersGUI/StdMeshers_icons.po | 32 + src/StdMeshersGUI/StdMeshers_msg_en.po | 49 +- src/StdMeshers_I/Makefile.in | 11 +- .../StdMeshers_Arithmetic1D_i.cxx | 120 + .../StdMeshers_Arithmetic1D_i.hxx | 63 + .../StdMeshers_Deflection1D_i.cxx | 119 + .../StdMeshers_Deflection1D_i.hxx} | 69 +- src/StdMeshers_I/StdMeshers_Propagation_i.cxx | 76 + src/StdMeshers_I/StdMeshers_Propagation_i.hxx | 57 + .../StdMeshers_StartEndLength_i.cxx | 120 + .../StdMeshers_StartEndLength_i.hxx | 67 + src/StdMeshers_I/StdMeshers_i.cxx | 16 +- 693 files changed, 68510 insertions(+), 27930 deletions(-) delete mode 100644 adm_local/unix/config_files/check_Netgen.m4 create mode 100644 adm_local/unix/make_conclude.in create mode 100755 doc/salome/gui/SMESH/extrusion.htm create mode 100755 doc/salome/gui/SMESH/files/arithmetic_1d.htm create mode 100755 doc/salome/gui/SMESH/files/constructing_groups_of_specific_elements.htm create mode 100755 doc/salome/gui/SMESH/files/creating_groups.htm create mode 100755 doc/salome/gui/SMESH/files/cutting_quadrangles.htm create mode 100755 doc/salome/gui/SMESH/files/deflection_1d.htm create mode 100755 doc/salome/gui/SMESH/files/editing_groups.htm create mode 100755 doc/salome/gui/SMESH/files/length_from_edges.htm create mode 100755 doc/salome/gui/SMESH/files/merging_nodes.htm create mode 100755 doc/salome/gui/SMESH/files/non_conform_mesh_allowed_hypothesis.htm create mode 100755 doc/salome/gui/SMESH/files/propagation_of_1d_hypothesis_on_opposite_edges.htm create mode 100755 doc/salome/gui/SMESH/files/renumbering_nodes_and_elements.htm create mode 100755 doc/salome/gui/SMESH/files/rotation.htm create mode 100755 doc/salome/gui/SMESH/files/sewing_meshes.htm create mode 100755 doc/salome/gui/SMESH/files/smoothing.htm create mode 100755 doc/salome/gui/SMESH/files/start_and_end_length_hypothesis.htm create mode 100755 doc/salome/gui/SMESH/files/symmetry.htm create mode 100755 doc/salome/gui/SMESH/files/tetrahedron_(ghs3d)_meshing_algorithm.htm create mode 100755 doc/salome/gui/SMESH/files/translation.htm create mode 100755 doc/salome/gui/SMESH/files/uniting_a_set_of_triangles.htm create mode 100755 doc/salome/gui/SMESH/files/uniting_two_triangles.htm create mode 100755 doc/salome/gui/SMESH/files/using_operations_on_groups.htm create mode 100755 doc/salome/gui/SMESH/image12.gif create mode 100755 doc/salome/gui/SMESH/image13.gif create mode 100755 doc/salome/gui/SMESH/image14.gif create mode 100755 doc/salome/gui/SMESH/image15.gif create mode 100755 doc/salome/gui/SMESH/image16.gif create mode 100755 doc/salome/gui/SMESH/image16.jpg create mode 100755 doc/salome/gui/SMESH/image17.jpg create mode 100755 doc/salome/gui/SMESH/image18.jpg create mode 100755 doc/salome/gui/SMESH/image20.jpg create mode 100755 doc/salome/gui/SMESH/image21.jpg create mode 100755 doc/salome/gui/SMESH/image22.jpg create mode 100755 doc/salome/gui/SMESH/image23.jpg create mode 100755 doc/salome/gui/SMESH/image30.jpg create mode 100755 doc/salome/gui/SMESH/image31.jpg create mode 100755 doc/salome/gui/SMESH/image32.jpg create mode 100755 doc/salome/gui/SMESH/image34.jpg create mode 100755 doc/salome/gui/SMESH/image35.jpg create mode 100755 doc/salome/gui/SMESH/image36.jpg create mode 100755 doc/salome/gui/SMESH/image38.jpg create mode 100755 doc/salome/gui/SMESH/image39.jpg create mode 100755 doc/salome/gui/SMESH/image40.jpg create mode 100755 doc/salome/gui/SMESH/image41.jpg create mode 100755 doc/salome/gui/SMESH/image42.jpg create mode 100755 doc/salome/gui/SMESH/image43.jpg create mode 100755 doc/salome/gui/SMESH/image44.jpg create mode 100755 doc/salome/gui/SMESH/image45.jpg create mode 100755 doc/salome/gui/SMESH/image46.jpg create mode 100755 doc/salome/gui/SMESH/image47.jpg create mode 100755 doc/salome/gui/SMESH/image48.jpg create mode 100755 doc/salome/gui/SMESH/image49.jpg create mode 100755 doc/salome/gui/SMESH/image50.jpg create mode 100755 doc/salome/gui/SMESH/image51.jpg create mode 100755 doc/salome/gui/SMESH/image52.jpg create mode 100755 doc/salome/gui/SMESH/image53.jpg create mode 100755 doc/salome/gui/SMESH/image54.jpg create mode 100755 doc/salome/gui/SMESH/image55.jpg create mode 100755 doc/salome/gui/SMESH/image57.gif create mode 100755 doc/salome/gui/SMESH/image57.jpg create mode 100755 doc/salome/gui/SMESH/image58.jpg create mode 100755 doc/salome/gui/SMESH/image59.jpg create mode 100755 doc/salome/gui/SMESH/image60.jpg create mode 100755 doc/salome/gui/SMESH/image61.gif create mode 100755 doc/salome/gui/SMESH/image61.jpg create mode 100755 doc/salome/gui/SMESH/image62.jpg create mode 100755 doc/salome/gui/SMESH/image63.gif create mode 100755 doc/salome/gui/SMESH/image63.jpg create mode 100755 doc/salome/gui/SMESH/image64.gif create mode 100755 doc/salome/gui/SMESH/image64.jpg create mode 100755 doc/salome/gui/SMESH/image65.gif create mode 100755 doc/salome/gui/SMESH/image65.jpg create mode 100755 doc/salome/gui/SMESH/image66.gif create mode 100755 doc/salome/gui/SMESH/image66.jpg create mode 100755 doc/salome/gui/SMESH/image67.gif create mode 100755 doc/salome/gui/SMESH/image67.jpg create mode 100755 doc/salome/gui/SMESH/image68.gif create mode 100755 doc/salome/gui/SMESH/image68.jpg create mode 100755 doc/salome/gui/SMESH/image69.gif create mode 100755 doc/salome/gui/SMESH/image69.jpg create mode 100755 doc/salome/gui/SMESH/image7.gif create mode 100755 doc/salome/gui/SMESH/image70.gif create mode 100755 doc/salome/gui/SMESH/image70.jpg create mode 100755 doc/salome/gui/SMESH/image71.gif create mode 100755 doc/salome/gui/SMESH/image71.jpg create mode 100755 doc/salome/gui/SMESH/image72.gif create mode 100755 doc/salome/gui/SMESH/image72.jpg create mode 100755 doc/salome/gui/SMESH/image73.gif create mode 100755 doc/salome/gui/SMESH/image73.jpg create mode 100755 doc/salome/gui/SMESH/image74.gif create mode 100755 doc/salome/gui/SMESH/image74.jpg create mode 100755 doc/salome/gui/SMESH/image75.gif create mode 100755 doc/salome/gui/SMESH/image75.jpg create mode 100755 doc/salome/gui/SMESH/image76.gif create mode 100755 doc/salome/gui/SMESH/image76.jpg create mode 100755 doc/salome/gui/SMESH/image77.gif create mode 100755 doc/salome/gui/SMESH/image77.jpg create mode 100755 doc/salome/gui/SMESH/image78.gif create mode 100755 doc/salome/gui/SMESH/image78.jpg create mode 100755 doc/salome/gui/SMESH/image79.gif create mode 100755 doc/salome/gui/SMESH/image8.gif create mode 100755 doc/salome/gui/SMESH/image80.gif create mode 100755 doc/salome/gui/SMESH/image80.jpg create mode 100755 doc/salome/gui/SMESH/image81.gif create mode 100755 doc/salome/gui/SMESH/image81.jpg create mode 100755 doc/salome/gui/SMESH/image82.gif create mode 100755 doc/salome/gui/SMESH/image82.jpg create mode 100755 doc/salome/gui/SMESH/image83.gif create mode 100755 doc/salome/gui/SMESH/image84.gif create mode 100755 doc/salome/gui/SMESH/image85.gif create mode 100755 doc/salome/gui/SMESH/image87.gif create mode 100755 doc/salome/gui/SMESH/image88.gif create mode 100755 doc/salome/gui/SMESH/image89.gif create mode 100755 doc/salome/gui/SMESH/image9.gif create mode 100755 doc/salome/gui/SMESH/image90.gif create mode 100755 doc/salome/gui/SMESH/image91.gif create mode 100755 doc/salome/gui/SMESH/image92.gif create mode 100755 doc/salome/gui/SMESH/image93.gif create mode 100755 doc/salome/gui/SMESH/image94.gif create mode 100755 doc/salome/gui/SMESH/image95.gif create mode 100755 doc/salome/gui/SMESH/image96.gif create mode 100755 doc/salome/gui/SMESH/image97.gif create mode 100755 doc/salome/gui/SMESH/image98.gif create mode 100755 doc/salome/gui/SMESH/pattern_mapping.htm create mode 100755 doc/salome/gui/SMESH/revolution.htm create mode 100755 doc/salome/gui/SMESH/smesh.htm create mode 100755 doc/salome/gui/SMESH/smesh_csh.htm create mode 100755 doc/salome/gui/SMESH/smesh_rhc.htm create mode 100755 doc/salome/gui/SMESH/tetrahedron_(ghs3d)_meshing_algorithm.htm create mode 100755 doc/salome/gui/SMESH/whgdata/whlstf4.htm create mode 100755 doc/salome/gui/SMESH/whgdata/whlstf5.htm create mode 100755 doc/salome/gui/SMESH/whgdata/whlstf6.htm create mode 100755 doc/salome/gui/SMESH/whgdata/whlstf7.htm create mode 100755 doc/salome/gui/SMESH/whgdata/whlstfl23.htm create mode 100755 doc/salome/gui/SMESH/whgdata/whlstt13.htm create mode 100644 idl/SMESH_Pattern.idl delete mode 100644 resources/SMESH_Meshers.xml delete mode 100644 resources/SMESH_MeshersWithNETGEN.xml create mode 100644 resources/mesh_cutGroups.png create mode 100644 resources/mesh_cutquad.png create mode 100644 resources/mesh_deleteGroups.png create mode 100644 resources/mesh_extrusion.png create mode 100644 resources/mesh_intersectGroups.png create mode 100644 resources/mesh_merge_nodes.png create mode 100755 resources/mesh_pattern.png create mode 100644 resources/mesh_renumbering_elements.png create mode 100644 resources/mesh_renumbering_nodes.png create mode 100644 resources/mesh_revolution.png create mode 100644 resources/mesh_rotation.png create mode 100644 resources/mesh_sew_bordertoside.png create mode 100644 resources/mesh_sew_conform_freeborders.png create mode 100644 resources/mesh_sew_freeborders.png create mode 100644 resources/mesh_sew_sideelements.png create mode 100644 resources/mesh_smoothing.png create mode 100644 resources/mesh_symmetry_axis.png create mode 100644 resources/mesh_symmetry_plane.png create mode 100644 resources/mesh_symmetry_point.png create mode 100644 resources/mesh_translation_points.png create mode 100644 resources/mesh_translation_vector.png create mode 100644 resources/mesh_union2tri.png create mode 100644 resources/mesh_unionGroups.png create mode 100644 resources/mesh_uniontri.png create mode 100755 resources/pattern_sample_2d.png create mode 100755 resources/pattern_sample_3D.png create mode 100644 src/Controls/Makefile.in rename src/{SMDS/SMDS_IteratorOfArray.hxx => Controls/SMESHControls.cxx} (69%) create mode 100644 src/Controls/SMESH_Controls.cxx create mode 100644 src/Controls/SMESH_Controls.hxx delete mode 100644 src/Driver/Document_Reader.h create mode 100644 src/Driver/Driver_Document.cxx rename src/Driver/{Mesh_Reader.h => Driver_Document.h} (71%) rename src/Driver/{Document_Reader.cxx => Driver_Mesh.cxx} (79%) rename src/Driver/{Document_Writer.h => Driver_Mesh.h} (60%) rename src/Driver/{Mesh_Reader.cxx => Driver_SMDS_Mesh.cxx} (85%) create mode 100644 src/Driver/Driver_SMDS_Mesh.h rename src/Driver/{Document_Writer.cxx => Driver_SMESHDS_Mesh.cxx} (75%) create mode 100644 src/Driver/Driver_SMESHDS_Mesh.h delete mode 100644 src/Driver/Driver_dl.cxx delete mode 100644 src/Driver/SMESHDriver.cxx create mode 100644 src/DriverDAT/DAT_Test.cxx create mode 100644 src/DriverMED/MED_Test.cxx create mode 100644 src/DriverSTL/DriverSTL_R_SMDS_Mesh.cxx rename idl/SMESH_NetgenAlgorithm.idl => src/DriverSTL/DriverSTL_R_SMDS_Mesh.h (65%) create mode 100644 src/DriverSTL/DriverSTL_W_SMDS_Mesh.cxx rename src/{Driver/Mesh_Writer.h => DriverSTL/DriverSTL_W_SMDS_Mesh.h} (59%) create mode 100644 src/DriverSTL/Makefile.in create mode 100644 src/DriverSTL/STL_Test.cxx create mode 100644 src/DriverUNV/UNV2411_Structure.cxx rename src/{Driver/SMESHDriver.h => DriverUNV/UNV2411_Structure.hxx} (59%) create mode 100644 src/DriverUNV/UNV2412_Structure.cxx create mode 100644 src/DriverUNV/UNV2412_Structure.hxx create mode 100644 src/DriverUNV/UNV_Test.cxx create mode 100644 src/DriverUNV/UNV_Utilities.cxx create mode 100644 src/DriverUNV/UNV_Utilities.hxx create mode 100644 src/OBJECT/SMESH_ActorUtils.cxx rename src/{Driver/Mesh_Writer.cxx => OBJECT/SMESH_ActorUtils.h} (84%) create mode 100644 src/OBJECT/SMESH_ExtractGeometry.cxx rename src/{SMDS/SMDS_HexahedronOfNodes.hxx => OBJECT/SMESH_ExtractGeometry.h} (51%) delete mode 100644 src/SMDS/SMDSControl.cxx delete mode 100644 src/SMDS/SMDSControl.hxx delete mode 100644 src/SMDS/SMDSControl_BoundaryEdges.cxx delete mode 100644 src/SMDS/SMDSControl_BoundaryEdges.hxx delete mode 100644 src/SMDS/SMDSControl_BoundaryFaces.cxx delete mode 100644 src/SMDS/SMDSControl_BoundaryFaces.hxx delete mode 100644 src/SMDS/SMDSControl_MeshBoundary.cxx delete mode 100644 src/SMDS/SMDSControl_MeshBoundary.hxx delete mode 100644 src/SMDS/SMDSEdit_Transform.cxx delete mode 100644 src/SMDS/SMDSEdit_Transform.hxx delete mode 100644 src/SMDS/SMDS_HexahedronOfNodes.cxx delete mode 100644 src/SMDS/SMDS_MeshHexahedron.cxx delete mode 100644 src/SMDS/SMDS_MeshHexahedron.hxx delete mode 100644 src/SMDS/SMDS_MeshNodeIDFactory.hxx delete mode 100644 src/SMDS/SMDS_MeshPrism.cxx delete mode 100644 src/SMDS/SMDS_MeshPrism.hxx delete mode 100644 src/SMDS/SMDS_MeshPyramid.cxx delete mode 100644 src/SMDS/SMDS_MeshPyramid.hxx delete mode 100644 src/SMDS/SMDS_MeshQuadrangle.cxx delete mode 100644 src/SMDS/SMDS_MeshQuadrangle.hxx delete mode 100644 src/SMDS/SMDS_MeshTetrahedron.cxx delete mode 100644 src/SMDS/SMDS_MeshTetrahedron.hxx delete mode 100644 src/SMDS/SMDS_MeshTriangle.cxx delete mode 100644 src/SMDS/SMDS_MeshTriangle.hxx delete mode 100644 src/SMDS/SMDS_Tria3OfNodes.cxx delete mode 100644 src/SMDS/SMDS_Tria3OfNodes.hxx create mode 100644 src/SMDS/SMDS_VolumeTool.cxx create mode 100644 src/SMDS/SMDS_VolumeTool.hxx create mode 100644 src/SMESH/SMESH_MeshEditor.cxx create mode 100644 src/SMESH/SMESH_MeshEditor.hxx create mode 100644 src/SMESH/SMESH_Pattern.cxx create mode 100644 src/SMESH/SMESH_Pattern.hxx create mode 100644 src/SMESHDS/SMESHDS_GroupBase.cxx create mode 100644 src/SMESHDS/SMESHDS_GroupBase.hxx create mode 100644 src/SMESHDS/SMESHDS_GroupOnGeom.cxx create mode 100644 src/SMESHDS/SMESHDS_GroupOnGeom.hxx create mode 100644 src/SMESHFiltersSelection/SMESH_LogicalFilter.cxx create mode 100644 src/SMESHFiltersSelection/SMESH_LogicalFilter.hxx create mode 100644 src/SMESHFiltersSelection/SMESH_NumberFilter.cxx create mode 100644 src/SMESHFiltersSelection/SMESH_NumberFilter.hxx create mode 100644 src/SMESHGUI/SMESHBin.cxx delete mode 100644 src/SMESHGUI/SMESHGUI_AddAlgorithmDlg.cxx delete mode 100644 src/SMESHGUI/SMESHGUI_AddAlgorithmDlg.h delete mode 100644 src/SMESHGUI/SMESHGUI_AddEdgeDlg.cxx delete mode 100644 src/SMESHGUI/SMESHGUI_AddHypothesisDlg.cxx delete mode 100644 src/SMESHGUI/SMESHGUI_AddHypothesisDlg.h create mode 100644 src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx rename src/SMESHGUI/{SMESHGUI_OrientationElementsDlg.h => SMESHGUI_AddMeshElementDlg.h} (53%) delete mode 100644 src/SMESHGUI/SMESHGUI_AddVolumeDlg.cxx create mode 100644 src/SMESHGUI/SMESHGUI_ClippingDlg.cxx create mode 100644 src/SMESHGUI/SMESHGUI_ClippingDlg.h delete mode 100644 src/SMESHGUI/SMESHGUI_ComputeScalarValue.cxx create mode 100755 src/SMESHGUI/SMESHGUI_CreatePatternDlg.cxx create mode 100755 src/SMESHGUI/SMESHGUI_CreatePatternDlg.h create mode 100644 src/SMESHGUI/SMESHGUI_DeleteGroupDlg.cxx create mode 100644 src/SMESHGUI/SMESHGUI_DeleteGroupDlg.h delete mode 100644 src/SMESHGUI/SMESHGUI_DiagonalInversionDlg.cxx create mode 100644 src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx rename src/SMESHGUI/{SMESHGUI_AddFaceDlg.h => SMESHGUI_ExtrusionDlg.h} (60%) create mode 100644 src/SMESHGUI/SMESHGUI_FilterLibraryDlg.cxx create mode 100644 src/SMESHGUI/SMESHGUI_FilterLibraryDlg.h create mode 100644 src/SMESHGUI/SMESHGUI_FilterUtils.cxx create mode 100644 src/SMESHGUI/SMESHGUI_FilterUtils.h create mode 100644 src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx create mode 100644 src/SMESHGUI/SMESHGUI_GEOMGenUtils.h create mode 100644 src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx create mode 100644 src/SMESHGUI/SMESHGUI_GroupOpDlg.h create mode 100644 src/SMESHGUI/SMESHGUI_GroupUtils.cxx create mode 100644 src/SMESHGUI/SMESHGUI_GroupUtils.h create mode 100644 src/SMESHGUI/SMESHGUI_Hypotheses.cxx create mode 100644 src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx create mode 100644 src/SMESHGUI/SMESHGUI_HypothesesUtils.h create mode 100644 src/SMESHGUI/SMESHGUI_IdValidator.h create mode 100644 src/SMESHGUI/SMESHGUI_MergeNodesDlg.cxx create mode 100644 src/SMESHGUI/SMESHGUI_MergeNodesDlg.h create mode 100755 src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx create mode 100755 src/SMESHGUI/SMESHGUI_MeshPatternDlg.h create mode 100644 src/SMESHGUI/SMESHGUI_MeshUtils.cxx create mode 100644 src/SMESHGUI/SMESHGUI_MeshUtils.h create mode 100755 src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx create mode 100755 src/SMESHGUI/SMESHGUI_MultiEditDlg.h delete mode 100644 src/SMESHGUI/SMESHGUI_OrientationElementsDlg.cxx create mode 100644 src/SMESHGUI/SMESHGUI_PatternUtils.cxx create mode 100644 src/SMESHGUI/SMESHGUI_PatternUtils.h create mode 100644 src/SMESHGUI/SMESHGUI_PatternWidget.cxx create mode 100644 src/SMESHGUI/SMESHGUI_PatternWidget.h create mode 100755 src/SMESHGUI/SMESHGUI_PrecisionDlg.cxx create mode 100755 src/SMESHGUI/SMESHGUI_PrecisionDlg.h rename src/SMESHGUI/{SMESHGUI_AddFaceDlg.cxx => SMESHGUI_RenumberingDlg.cxx} (59%) rename src/SMESHGUI/{SMESHGUI_AddEdgeDlg.h => SMESHGUI_RenumberingDlg.h} (74%) create mode 100644 src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx create mode 100644 src/SMESHGUI/SMESHGUI_RevolutionDlg.h create mode 100644 src/SMESHGUI/SMESHGUI_RotationDlg.cxx create mode 100644 src/SMESHGUI/SMESHGUI_RotationDlg.h rename src/{SMDS/SMDS_MeshNodeIDFactory.cxx => SMESHGUI/SMESHGUI_SMESHGenUtils.cxx} (63%) create mode 100644 src/SMESHGUI/SMESHGUI_SMESHGenUtils.h create mode 100644 src/SMESHGUI/SMESHGUI_SewingDlg.cxx rename src/SMESHGUI/{SMESHGUI_DiagonalInversionDlg.h => SMESHGUI_SewingDlg.h} (58%) create mode 100755 src/SMESHGUI/SMESHGUI_SingleEditDlg.cxx create mode 100755 src/SMESHGUI/SMESHGUI_SingleEditDlg.h create mode 100644 src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx rename src/SMESHGUI/{SMESHGUI_AddVolumeDlg.h => SMESHGUI_SmoothingDlg.h} (61%) delete mode 100644 src/SMESHGUI/SMESHGUI_StudyAPI.cxx delete mode 100644 src/SMESHGUI/SMESHGUI_StudyAPI.h create mode 100644 src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx create mode 100644 src/SMESHGUI/SMESHGUI_SymmetryDlg.h create mode 100644 src/SMESHGUI/SMESHGUI_TranslationDlg.cxx create mode 100644 src/SMESHGUI/SMESHGUI_TranslationDlg.h create mode 100644 src/SMESHGUI/SMESHGUI_Utils.cxx create mode 100644 src/SMESHGUI/SMESHGUI_Utils.h create mode 100644 src/SMESHGUI/SMESHGUI_VTKUtils.cxx create mode 100644 src/SMESHGUI/SMESHGUI_VTKUtils.h create mode 100644 src/SMESHGUI/SMESHGUI_aParameter.cxx create mode 100644 src/SMESHGUI/SMESHGUI_aParameter.h create mode 100644 src/SMESH_I/SMESHEngine.cxx create mode 100644 src/SMESH_I/SMESH_Gen_i_1.cxx create mode 100644 src/SMESH_I/SMESH_Pattern_i.cxx create mode 100644 src/SMESH_I/SMESH_Pattern_i.hxx create mode 100644 src/SMESH_SWIG/SMESH_BelongToGeom.py create mode 100644 src/SMESH_SWIG/SMESH_GroupFromGeom.py create mode 100644 src/SMESH_SWIG/SMESH_blocks.py create mode 100644 src/SMESH_SWIG/SMESH_mechanic_editor.py create mode 100644 src/SMESH_SWIG/SMESH_test5.py create mode 100644 src/SMESH_SWIG/cube2geometry.py create mode 100644 src/SMESH_SWIG/cube2partition.py create mode 100644 src/SMESH_SWIG/cube2pyGibi.py create mode 100644 src/SMESH_SWIG/cyl2complementary.py create mode 100644 src/SMESH_SWIG/cyl2geometry.py create mode 100644 src/SMESH_SWIG/grid17partition.py create mode 100644 src/SMESH_SWIG/grid3partition.py create mode 100644 src/SMESH_SWIG/grid4partition.py create mode 100644 src/SMESH_SWIG/grid4pyGibi.py create mode 100644 src/SMESH_SWIG/hole1geometry.py create mode 100644 src/SMESH_SWIG/hole1partition.py create mode 100644 src/SMESH_SWIG/hole1pyGibi.py create mode 100644 src/SMESH_SWIG/hole2pyGibi.py create mode 100644 src/SMESH_SWIG/meshpy.py create mode 100644 src/StdMeshers/StdMeshers_Arithmetic1D.cxx create mode 100644 src/StdMeshers/StdMeshers_Arithmetic1D.hxx create mode 100644 src/StdMeshers/StdMeshers_Deflection1D.cxx rename src/{SMESHGUI/SMESHGUI_ComputeScalarValue.h => StdMeshers/StdMeshers_Deflection1D.hxx} (56%) create mode 100644 src/StdMeshers/StdMeshers_Propagation.cxx create mode 100644 src/StdMeshers/StdMeshers_Propagation.hxx create mode 100644 src/StdMeshers/StdMeshers_StartEndLength.cxx create mode 100644 src/StdMeshers/StdMeshers_StartEndLength.hxx create mode 100644 src/StdMeshersGUI/StdMeshersGUI_CreateHypothesisDlg.cxx rename src/StdMeshersGUI/{StdMeshersGUI_LocalLengthDlg.h => StdMeshersGUI_CreateHypothesisDlg.h} (65%) create mode 100644 src/StdMeshersGUI/StdMeshersGUI_CreateStdHypothesisDlg.cxx rename src/{SMESH_I/SMESH_topo.cxx => StdMeshersGUI/StdMeshersGUI_CreateStdHypothesisDlg.h} (51%) delete mode 100644 src/StdMeshersGUI/StdMeshersGUI_LocalLengthDlg.cxx delete mode 100644 src/StdMeshersGUI/StdMeshersGUI_MaxElementAreaDlg.cxx delete mode 100644 src/StdMeshersGUI/StdMeshersGUI_MaxElementAreaDlg.h delete mode 100644 src/StdMeshersGUI/StdMeshersGUI_MaxElementVolumeDlg.cxx delete mode 100644 src/StdMeshersGUI/StdMeshersGUI_MaxElementVolumeDlg.h delete mode 100644 src/StdMeshersGUI/StdMeshersGUI_NbSegmentsDlg.cxx delete mode 100644 src/StdMeshersGUI/StdMeshersGUI_NbSegmentsDlg.h create mode 100644 src/StdMeshersGUI/StdMeshersGUI_Parameters.cxx create mode 100644 src/StdMeshersGUI/StdMeshersGUI_Parameters.h create mode 100644 src/StdMeshers_I/StdMeshers_Arithmetic1D_i.cxx create mode 100644 src/StdMeshers_I/StdMeshers_Arithmetic1D_i.hxx create mode 100644 src/StdMeshers_I/StdMeshers_Deflection1D_i.cxx rename src/{SMESH_I/SMESH_topo.hxx => StdMeshers_I/StdMeshers_Deflection1D_i.hxx} (51%) create mode 100644 src/StdMeshers_I/StdMeshers_Propagation_i.cxx create mode 100644 src/StdMeshers_I/StdMeshers_Propagation_i.hxx create mode 100644 src/StdMeshers_I/StdMeshers_StartEndLength_i.cxx create mode 100644 src/StdMeshers_I/StdMeshers_StartEndLength_i.hxx diff --git a/INSTALL b/INSTALL index 694c906d4..d17758ff4 100644 --- a/INSTALL +++ b/INSTALL @@ -1,6 +1,5 @@ -This is SMESH V2.0.0 - +This is the version 2.1.0 of SMESH Compatible with : - GEOM V2_0_0 - KERNEL V2_0_0 - MED V2_0_0 + - KERNEL 2.1.0 + - GEOM 2.1.0 + - MED 2.1.0 diff --git a/Makefile.in b/Makefile.in index a79be56d3..cae80c162 100644 --- a/Makefile.in +++ b/Makefile.in @@ -86,13 +86,39 @@ mesh_wrap.png \ mesh_tree_group.png \ mesh_edit_group.png \ mesh_make_group.png \ +mesh_union2tri.png \ +mesh_uniontri.png \ +mesh_cutquad.png \ +mesh_smoothing.png \ +mesh_renumbering_nodes.png \ +mesh_renumbering_elements.png \ +mesh_extrusion.png \ +mesh_revolution.png \ ModuleMesh.png \ +mesh_unionGroups.png \ +mesh_intersectGroups.png \ +mesh_cutGroups.png \ +mesh_deleteGroups.png \ +mesh_translation_vector.png \ +mesh_translation_points.png \ +mesh_rotation.png \ +mesh_symmetry_point.png \ +mesh_symmetry_axis.png \ +mesh_symmetry_plane.png \ +mesh_sew_freeborders.png \ +mesh_sew_conform_freeborders.png \ +mesh_sew_bordertoside.png \ +mesh_sew_sideelements.png \ +mesh_merge_nodes.png \ select1.png \ SMESH_en.xml \ SMESH.config \ StdMeshers.xml \ SMESHCatalog.xml \ -flight_solid.brep +flight_solid.brep \ +mesh_pattern.png \ +pattern_sample_2d.png \ +pattern_sample_3D.png BIN_SCRIPT= \ VERSION diff --git a/adm_local/unix/config_files/check_Geom.m4 b/adm_local/unix/config_files/check_Geom.m4 index 803ca754b..13f3be40c 100644 --- a/adm_local/unix/config_files/check_Geom.m4 +++ b/adm_local/unix/config_files/check_Geom.m4 @@ -22,20 +22,11 @@ if test "x$GEOM_DIR" == "x" ; then # GEOM_ROOT_DIR environment variable defined GEOM_DIR=$GEOM_ROOT_DIR - else - - # search Geom binaries in PATH variable - AC_PATH_PROG(TEMP, libGEOM_Swig.py) - if test "x$TEMP" != "x" ; then - GEOM_BIN_DIR=`dirname $TEMP` - GEOM_DIR=`dirname $GEOM_BIN_DIR` - fi - fi # fi -if test -f ${GEOM_DIR}/bin/salome/libGEOM_Swig.py ; then +if test -f ${GEOM_DIR}/lib/salome/libGEOMClient.so ; then Geom_ok=yes AC_MSG_RESULT(Using Geom module distribution in ${GEOM_DIR}) diff --git a/adm_local/unix/config_files/check_Med.m4 b/adm_local/unix/config_files/check_Med.m4 index 492727053..727bf4381 100644 --- a/adm_local/unix/config_files/check_Med.m4 +++ b/adm_local/unix/config_files/check_Med.m4 @@ -22,20 +22,11 @@ if test "x$MED_DIR" == "x" ; then # MED_ROOT_DIR environment variable defined MED_DIR=$MED_ROOT_DIR - else - - # search Med binaries in PATH variable - AC_PATH_PROG(TEMP, libMEDMEM_Swig.py) - if test "x$TEMP" != "x" ; then - MED_BIN_DIR=`dirname $TEMP` - MED_DIR=`dirname $MED_BIN_DIR` - fi - fi # fi -if test -f ${MED_DIR}/bin/salome/libMEDMEM_Swig.py ; then +if test -f ${MED_DIR}/idl/salome/MED.idl ; then Med_ok=yes AC_MSG_RESULT(Using Med module distribution in ${MED_DIR}) diff --git a/adm_local/unix/config_files/check_Netgen.m4 b/adm_local/unix/config_files/check_Netgen.m4 deleted file mode 100644 index 971477c3d..000000000 --- a/adm_local/unix/config_files/check_Netgen.m4 +++ /dev/null @@ -1,126 +0,0 @@ -AC_DEFUN([CHECK_NETGEN],[ - -AC_REQUIRE([AC_PROG_CXX])dnl -AC_REQUIRE([AC_PROG_CXXCPP])dnl - -AC_CHECKING(for Netgen Libraries) - -AC_LANG_SAVE -AC_LANG_CPLUSPLUS - -AC_ARG_WITH(netgen, - [ --with-netgen=DIR root directory path of NETGEN installation], - WITHNETGEN="yes",WITHNETGEN="no") - -NETGEN_INCLUDES="" -NETGEN_LIBS="" - -Netgen_ok=no - -if test "$WITHNETGEN" = yes; then - - echo - echo - echo ------------------------------------------------- - echo You are about to choose to use somehow the - echo Netgen Library to generate Tetrahedric mesh. - echo - echo WARNING - echo ---------------------------------------------------------- - echo ---------------------------------------------------------- - echo You are strongly advised to consult the file - echo SMESH_SRC/src/NETGEN/ReadMeForNgUsers, particularly about - echo assumptions made on the installation of the Netgen - echo application and libraries. - echo Ask your system administrator for those details. - echo ---------------------------------------------------------- - echo ---------------------------------------------------------- - echo - echo - - NETGEN_HOME=$withval - - if test "$NETGEN_HOME"; then - NETGEN_INCLUDES="-I$NETGEN_HOME/include" - NETGEN_LIBS_DIR="$NETGEN_HOME/lib/LINUX" - NETGEN_LIBS="-L$NETGEN_LIBS_DIR" - fi - - CPPFLAGS_old="$CPPFLAGS" - CPPFLAGS="$NETGEN_INCLUDES $CPPFLAGS" - CXXFLAGS_old="$CXXFLAGS" - CXXFLAGS="$NETGEN_INCLUDES $CXXFLAGS" - - AC_MSG_CHECKING(for Netgen header file) - - AC_CHECK_HEADER(nglib.h,Netgen_ok=yes,Netgen_ok=no) - CPPFLAGS="$CPPFLAGS_old" - CXXFLAGS="$CXXFLAGS_old" - - if test "$WITHNETGEN" = "yes";then - NETGEN_LIBS="-L. -lNETGEN" - - AC_MSG_CHECKING(for Netgen libraries) - - CPPFLAGS_old="$CPPFLAGS" - CPPFLAGS="$NETGEN_INCLUDES $CPPFLAGS" - CXXFLAGS_old="$CXXFLAGS" - CXXFLAGS="$NETGEN_INCLUDES $CXXFLAGS" - - LDFLAGS_old="$LDFLAGS" - LDFLAGS="$NETGEN_LIBS $LDFLAGS" - - AC_TRY_COMPILE(#include -#include -#include "nglib.h" -,Ng_Init(); - Ng_Exit();,Netgen_ok=yes;ar x "$NETGEN_LIBS_DIR/libnginterface.a"; - ar x "$NETGEN_LIBS_DIR/libcsg.a"; - ar x "$NETGEN_LIBS_DIR/libgprim.a"; - ar x "$NETGEN_LIBS_DIR/libmesh.a"; - ar x "$NETGEN_LIBS_DIR/libopti.a"; - ar x "$NETGEN_LIBS_DIR/libgen.a"; - ar x "$NETGEN_LIBS_DIR/libla.a"; - ar x "$NETGEN_LIBS_DIR/libstlgeom.a"; - ar x "$NETGEN_LIBS_DIR/libgeom2d.a"; - $CXX -shared linopt.o bfgs.o linsearch.o global.o bisect.o meshtool.o refine.o ruler3.o improve3.o adfront3.o tetrarls.o prism2rls.o pyramidrls.o pyramid2rls.o netrule3.o ruler2.o meshclass.o improve2.o adfront2.o netrule2.o triarls.o geomsearch.o secondorder.o meshtype.o parser3.o quadrls.o specials.o parser2.o meshing2.o meshing3.o meshfunc.o localh.o improve2gen.o delaunay.o boundarylayer.o msghandler.o meshfunc2d.o smoothing2.o smoothing3.o topology.o curvedelems.o clusters.o zrefine.o ngexception.o geomtest3d.o geom2d.o geom3d.o adtree.o transform3d.o geomfuncs.o polynomial.o densemat.o vector.o basemat.o sparsmat.o algprim.o brick.o manifold.o bspline2d.o meshsurf.o csgeom.o polyhedra.o curve2d.o singularref.o edgeflw.o solid.o explicitcurve2d.o specpoin.o gencyl.o revolution.o genmesh.o spline3d.o surface.o identify.o triapprox.o meshstlsurface.o stlline.o stltopology.o stltool.o stlgeom.o stlgeomchart.o stlgeommesh.o table.o optmem.o spbita2d.o hashtabl.o sort.o flags.o seti.o bitarray.o array.o symbolta.o mystring.o moveablemem.o spline2d.o splinegeometry2.o ngnewdelete.o nglib.o -o libNETGEN.so; - rm -rf adfront2.o adfront3.o adtree.o algprim.o array.o basemat.o bfgs.o bisect.o bitarray.o boundarylayer.o brick.o bspline2d.o clusters.o csgeom.o csgparser.o curve2d.o curvedelems.o delaunay.o densemat.o dynamicmem.o edgeflw.o explicitcurve2d.o extrusion.o flags.o gencyl.o genmesh.o geom2dmesh.o geom2d.o geom3d.o geomfuncs.o geomsearch.o geomtest3d.o global.o hashtabl.o hprefinement.o identify.o importsolution.o improve2gen.o improve2.o improve3.o linopt.o linsearch.o localh.o manifold.o meshclass.o meshfunc2d.o meshfunc.o meshing2.o meshing3.o meshstlsurface.o meshsurf.o meshtool.o meshtype.o moveablemem.o msghandler.o mystring.o netrule2.o netrule3.o ngexception.o nglib.o ngnewdelete.o optmem.o parser2.o parser3.o parthreads.o polyhedra.o polynomial.o prism2rls.o pyramid2rls.o pyramidrls.o quadrls.o readuser.o refine.o revolution.o ruler2.o ruler3.o secondorder.o seti.o singularref.o smoothing2.o smoothing3.o solid.o sort.o sparsmat.o spbita2d.o specials.o specpoin.o spline2d.o spline3d.o splinegeometry2.o stlgeomchart.o stlgeommesh.o stlgeom.o stlline.o stltool.o stltopology.o surface.o symbolta.o table.o tetrarls.o topology.o transform3d.o triapprox.o triarls.o vector.o writeabaqus.o writediffpack.o writefeap.o writefluent.o writepermas.o writetecplot.o writetochnog.o writeuser.o wuchemnitz.o zrefine.o, - Netgen_ok=no) - - AC_CACHE_VAL(salome_netgen_lib,[ - AC_TRY_LINK( -#include -#include -#include "nglib.h" -,Ng_Init(); - Ng_Exit();, - eval "salome_netgen_lib=yes";rm -rf libNETGEN.so,eval "salome_netgen_lib=no";rm -rf libNETGEN.so) - ]) - Netgen_ok="$salome_netgen_lib" - - - LDFLAGS="$LDFLAGS_old" - CPPFLAGS="$CPPFLAGS_old" - CXXFLAGS="$CXXFLAGS_old" - fi - - -if test "x$Netgen_ok" = xno ; then - AC_MSG_RESULT(no) - AC_MSG_WARN(Netgen libraries not found or not properly installed) -else - AC_MSG_RESULT(yes) - NETGEN_LIBS="-lNETGEN" - CPPFLAGS="${CPPFLAGS} -DHAVE_NETGEN" - IDLCXXFLAGS="${IDLCXXFLAGS} -DHAVE_NETGEN" - OMNIORB_IDLPYFLAGS="${OMNIORB_IDLPYFLAGS} -DHAVE_NETGEN" -fi -fi -AC_SUBST(NETGEN_INCLUDES) -AC_SUBST(NETGEN_LIBS) -AC_SUBST(NETGEN_LIBS_DIR) -AC_SUBST(WITHNETGEN) - -AC_LANG_RESTORE - -])dnl diff --git a/adm_local/unix/make_commence.in b/adm_local/unix/make_commence.in index ad1a9a52f..43b015ee6 100644 --- a/adm_local/unix/make_commence.in +++ b/adm_local/unix/make_commence.in @@ -10,9 +10,12 @@ HAVE_SSTREAM=@HAVE_SSTREAM@ LIBS=@LIBS@ +LIBSFORBIN=@LIBS@ LDFLAGS=@LDFLAGS@ -L$(top_builddir)/lib/salome -Xlinker -rpath-link -Xlinker -L$(top_builddir)/lib/salome +LDFLAGSFORBIN=@LDFLAGS@ -L$(top_builddir)/lib/salome -Xlinker -rpath-link -Xlinker -L$(top_builddir)/lib/salome # add libstdc++ to link c++ library with libtool ! LDFLAGS+= -lstdc++ +LDFLAGSFORBIN+= -lstdc++ CP=@CP@ @@ -31,7 +34,7 @@ C_DEPEND_FLAG = @C_DEPEND_FLAG@ # C++ CXX = @CXX@ -CXXFLAGS = @CXXFLAGS@ +CXXFLAGS = @CXXFLAGS@ CXX_DEPEND_FLAG = @CXX_DEPEND_FLAG@ # BOOST Library diff --git a/adm_local/unix/make_conclude.in b/adm_local/unix/make_conclude.in new file mode 100644 index 000000000..9eac1df82 --- /dev/null +++ b/adm_local/unix/make_conclude.in @@ -0,0 +1,346 @@ +#======================================================================= +# This section of this makefile comes from the file +# 'adm/unix/make_conclude' which was generated with config.status +# from file adm/unix/make_conclude.in +#======================================================================= +# -* Makefile *- +# +# Authors : Patrick GOLDBRONN (CEA) - Marc Tajchman (CEA) +# Date : 6/07/2001 +# $Header$ +# + +# ORB Specifics rules +@CORBA@ + +# transform idl reference in appropriate obj file +LIB_CLIENT_SRC = $(LIB_CLIENT_IDL:%.idl=%$(IDL_CLN_CXX)) +LIB_SERVER_SRC = $(LIB_SERVER_IDL:%.idl=%$(IDL_SRV_CXX)) +LIB_MOC_SRC = $(LIB_MOC:%.h=%_moc.cxx) +LIB_SRC+=$(LIB_MOC_SRC) +LIB_SWIG_SRC = $(SWIG_DEF:%.i=%_wrap.cxx) +LIB_DEP= $(LIB_SRC) $(LIB_CLIENT_SRC) $(LIB_SERVER_SRC) $(LIB_SWIG_SRC) + +LIB_CLIENT_OBJ = $(LIB_CLIENT_IDL:%.idl=%$(IDL_CLN_OBJ)) +LIB_SERVER_OBJ = $(LIB_SERVER_IDL:%.idl=%$(IDL_SRV_OBJ)) + + +# transform c file in appropriate libtool obj file (.c, .cc and .cxx) +LIB_OBJ_C = $(patsubst %.c, %.lo, $(filter %.c, $(LIB_SRC))) +LIB_OBJ_CC = $(patsubst %.cc, %.lo, $(filter %.cc, $(LIB_SRC))) +LIB_OBJ_CXX = $(patsubst %.cxx, %.lo, $(filter %.cxx, $(LIB_SRC))) +LIB_SWIG_OBJ = $(LIB_SWIG_SRC:%.cxx=%.lo) +LIB_OBJ_F = $(patsubst %.f, %.lo, $(filter %.f, $(LIB_SRC))) + +# all libtool obj file in library +LIB_OBJ = $(LIB_OBJ_CXX) $(LIB_OBJ_CC) $(LIB_OBJ_C) $(LIB_CLIENT_OBJ:%.o=%.lo) $(LIB_SERVER_OBJ:%.o=%.lo) $(LIB_SWIG_OBJ) $(LIB_OBJ_F) + +# LIB_BUILD = $(LIB:%.la=$(top_builddir)/lib/salome/%.la) +LIB_BUILD = $(patsubst %.la, $(top_builddir)/lib/salome/%.la, $(filter %.la, $(LIB))) +LIB_BUILD_A = $(patsubst %.a, $(top_builddir)/lib/salome/%.a, $(filter %.a, $(LIB))) + +ifneq ($(findstring cmodule.la,$(filter %.la, $(LIB))),) +LIB_SWIG = $(patsubst %cmodule.la,%.so, $(filter %.la, $(LIB))) +else +LIB_SWIG = +endif + +lib: $(LIB_BUILD) $(LIB_CLIENT_PY) +# we don't build static library ! + +$(LIB_BUILD): $(top_builddir)/lib/salome/%.la: %.la + -$(RM) $@ + -$(RM) $(patsubst %.la, %.so, $@) + -$(RM) $(patsubst %.la, %.a, $@) + ln -sf $(CURDIR)/$< $@ || true + ln -sf $(patsubst %.la, %.so, $(CURDIR)/.libs/$<) \ + $(patsubst %.la, %.so, $@) || true + ln -sf $(patsubst %.la, %.so, $(CURDIR)/.libs/$<).0 \ + $(patsubst %.la, %.so, $@).0 || true + + if ! test -z $(LIB_SWIG) ; then \ + ln -sf $(patsubst %.la,%.so, $(CURDIR)/.libs/$<) $(top_builddir)/lib/salome/_$(LIB_SWIG) || true;\ + fi; + +$(LIB_BUILD_A): $(top_builddir)/lib/salome/%.a: %.a + -$(RM) $@ + ln -sf $(CURDIR)/$< $@ || true + +$(LIB): $(LIB_OBJ) + @$(LT) --mode=link $(CXX) -rpath $(libdir) -o $@ $(CXXFLAGS) $(LIB_OBJ) $(LDFLAGS) $(LIBS) + +# transform idl reference in appropriate obj file +BIN_CLIENT_SRC = $(BIN_CLIENT_IDL:%.idl=%$(IDL_CLN_CXX)) +BIN_SERVER_SRC = $(BIN_SERVER_IDL:%.idl=%$(IDL_SRV_CXX)) +BIN_MOC_SRC = $(BIN_MOC:%.h=%_moc.cxx) +BIN_SRC+=$(BIN_MOC_SRC) +BIN_DEP=$(BIN:%=%.cxx) $(BIN_SRC) $(BIN_CLIENT_SRC) $(BIN_SERVER_SRC) + +BIN_CLIENT_OBJ = $(BIN_CLIENT_IDL:%.idl=%$(IDL_CLN_OBJ)) +BIN_SERVER_OBJ = $(BIN_SERVER_IDL:%.idl=%$(IDL_SRV_OBJ)) +# transform c file in appropriate libtool obj file (.c) +BIN_OBJ_C = $(patsubst %.c, %.o, $(filter %.c, $(BIN_SRC))) +# transform c++ file in appropriate libtool obj file (.cc and .cxx) +BIN_OBJ_CC = $(patsubst %.cc, %.o, $(filter %.cc, $(BIN_SRC))) +BIN_OBJ_CXX = $(patsubst %.cxx, %.o, $(filter %.cxx, $(BIN_SRC))) +# all obj file in bin target +BIN_OBJ = $(BIN_OBJ_CC) $(BIN_OBJ_CXX) $(BIN_OBJ_C) $(BIN_CLIENT_OBJ) $(BIN_SERVER_OBJ) + +bin: $(BIN:%=$(top_builddir)/bin/salome/%) $(BIN) $(LIB) pyscripts sharedpyscripts + +BIN_LIB=$(LIB:lib%.la=-l%) + +$(BIN:%=$(top_builddir)/bin/salome/%) $(TEST_PROGS:%=$(top_builddir)/bin/salome/%): $(top_builddir)/bin/salome/%: % + -$(RM) $@ + ln -sf $(CURDIR)/$< $@ + +$(BIN) $(TEST_PROGS): %: %.lo $(BIN_OBJ) + $(CXX) $(CXXFLAGS) -o $@ $^ $(BIN_LIB) $(LDFLAGSFORBIN) $(LIBSFORBIN) + +# copy python scripts in $(top_builddir)/bin/salome +# +DEST_PYSCRIPTS = $(EXPORT_PYSCRIPTS:%=$(top_builddir)/bin/salome/%) +pyscripts: $(DEST_PYSCRIPTS) +$(DEST_PYSCRIPTS): $(top_builddir)/bin/salome/%: % + cp -f $< $@ + +# copy pyqt files in $(PYTHON_SHARED_SITE) +# +PYTHON_SHARED_SITE=$(top_builddir)/lib/python$(PYTHON_VERSION)/site-packages/salome/shared_modules + +$(PYTHON_SHARED_SITE): + $(INSTALL) -d $@ + +DEST_SHAREDPYSCRIPTS = $(EXPORT_SHAREDPYSCRIPTS:%=$(PYTHON_SHARED_SITE)/%) +sharedpyscripts: $(PYTHON_SHARED_SITE) $(DEST_SHAREDPYSCRIPTS) +$(DEST_SHAREDPYSCRIPTS): $(PYTHON_SHARED_SITE)/%: % + cp -f $< $@ + +check: test + +tests: test + +test: $(LIB) $(TEST_PROGS:%=$(top_builddir)/bin/salome/%) + + +# copy header file in $(inc_builddir) +# +DEST_HEADERS = $(EXPORT_HEADERS:%=$(inc_builddir)/%) +inc: $(DEST_HEADERS) +$(DEST_HEADERS): $(inc_builddir)/%: % + cp -f $< $@ + +# build resources file (icons and messages) : .qm file from .po file +resources: $(PO_FILES:%.po=$(top_builddir)/share/salome/resources/%.qm) + +# Make installation directories if they don't exist. +$(libdir) $(includedir) $(bindir) $(datadir) $(idldir) $(sharedpydir): + $(INSTALL) -d $@ && chmod 755 $@ + +# Install the library, the public header files, and programs. +install: $(LIB) $(BIN) $(TEST_PROGS) $(libdir) $(includedir) $(bindir) $(datadir) $(idldir) install-python install-sharedpyqt install-qm + @for f in X $(LIB); do \ + if test $$f != X; then \ + ($(LT_INSTALL_LIB) $$f $(libdir)/. || exit 1); \ + fi; \ + done + @if ! test -z $(LIB_SWIG) ; then \ + (cd $(libdir); ln -sf $(patsubst %.so, %cmodule.so, $(LIB_SWIG)) _$(LIB_SWIG) || true); \ + fi; + @for f in X $(BIN); do \ + if test $$f != X; then \ + ($(LT_INSTALL_PROG) $$f $(bindir)/. || exit 1); \ + fi; \ + done +# Install tests programmes in bindir + @for f in X $(TEST_PROGS); do \ + if test $$f != X; then \ + ($(LT_INSTALL_PROG) $$f $(bindir)/. || exit 1); \ + fi; \ + done +# Install exported includes in includedir + @for f in X $(EXPORT_HEADERS:%=$(srcdir)/%); do \ + if test $$f != X; then \ + (cp -p -f $$f $(includedir) || exit 1); \ + fi; \ + done + +# Install python script in $(bindir) +install-python: $(bindir) $(EXPORT_PYSCRIPTS:%=install-%) + +$(EXPORT_PYSCRIPTS:%=install-%): install-%: % + $(INSTALL_PROGRAM) $< $(bindir)/. + +#install-python: $(bindir) $(EXPORT_PYSCRIPTS) +# @for f in X $(EXPORT_PYSCRIPTS); do \ +# if test $$f != X; then \ +# ($(INSTALL_PROGRAM) $$f $(bindir)/. || exit 1); \ +# fi; \ +# done + +# Install pyqt script in $(install-sharedpyqt) +install-sharedpyqt: $(sharedpydir) $(EXPORT_SHAREDPYSCRIPTS:%=install-%) + +$(EXPORT_SHAREDPYSCRIPTS:%=install-%): install-%: % + $(INSTALL_PROGRAM) $< $(sharedpydir)/. + + +# generic rule to install .qm files : +install-qm: resources + $(INSTALL) -d $(datadir)/resources + @for f in X $(PO_FILES:%.po=$(top_builddir)/share/salome/resources/%.qm); do \ + if test $$f != X; then \ + ($(INSTALL_DATA) $$f $(datadir)/resources/. || exit 1); \ + fi; \ + done + +# Removes those things that `make install' (would have) installed. +uninstall: + @if test "X$(LIB)" != X; then \ + for f in $(LIB); do \ + $(LT_UNINSTALL) $(libdir)/$$f; \ + done; \ + fi + @if test "X$(BIN)" != X; then \ + for f in $(BIN); do \ + $(LT_UNINSTALL) $(bindir)/$$f; \ + done; \ + fi + @for f in X $(TEST_PROGS); do \ + if test $$f != X; then \ + $(LT_UNINSTALL) $(bindir)/$$f; \ + fi; \ + done +# Uninstall exported includes in includedir + @for f in X $(EXPORT_HEADERS); do \ + if test $$f != X; then \ + $(LT_UNINSTALL) $(includedir)/$$f; \ + fi; \ + done +# Uninstall python script in $(bindir) + @for f in X $(EXPORT_PYSCRIPTS); do \ + if test $$f != X; then \ + $(LT_UNINSTALL) $(bindir)/$$f ; \ + fi; \ + done + +# Uninstall pyqt script in $(sharedpydir) + @for f in X $(EXPORT_SHAREDPYSCRIPTS); do \ + if test $$f != X; then \ + $(LT_UNINSTALL) $(sharedpydir)/$$f ; \ + fi; \ + done + +# Uninstall qm files + @for f in X $(PO_FILES:%.po=%.qm); do \ + if test $$f != X; then \ + $(LT_UNINSTALL) $(datadir)/resources/$$f ; \ + fi; \ + done + +# remove all dependencies files +# +cleandep: + -$(RM) .dep* + +# Removes temporary files without removing the final target files. That is, +# remove things like object files but not libraries or executables. +# +mostlyclean: cleandep + -$(RM) $(LIB_OBJ) $(LIB_OBJ:.lo=.o) + -$(RM) $(BIN_OBJ) $(BIN:%=%.o) + -$(RM) $(TEST_OBJ) $(TEST_OBJ:.lo=.o) + -$(RM) $(PROG_OBJ) $(PROG_OBJ:.lo=.o) $(MOSTLYCLEAN) + +# Like `mostlyclean' except it also removes the final targets: things like +# libraries and executables. This target doesn't remove any file that +# is part of the SALOME distribution. +# +clean: mostlyclean + -$(RM) $(LIB) $(TEST_PROGS) $(BIN) $(CLEAN) + -$(RM) TAGS *~ *# core *.core + -$(RM) -r .libs + -$(RM) $(top_builddir)/lib/salome/$(LIB) + -$(RM) $(patsubst %,$(top_builddir)/bin/salome/%, $(BIN)) + -$(RM) $(patsubst %.la, %.so, $(top_builddir)/lib/salome/$(LIB)) + -$(RM) $(patsubst %.la, %.a, $(top_builddir)/lib/salome/$(LIB)) +# remove idl generated files (sources) + -$(RM) $(LIB_CLIENT_SRC) $(LIB_SERVER_SRC) $(BIN_CLIENT_SRC) $(BIN_SERVER_SRC) +# remove idl generated files (headers) + -$(RM) $(LIB_CLIENT_IDL:%.idl=%$(IDL_CLN_H)) $(LIB_SERVER_IDL:%.idl=%$(IDL_SRV_H)) + -$(RM) $(BIN_CLIENT_IDL:%.idl=%$(IDL_CLN_H)) $(BIN_SERVER_IDL:%.idl=%$(IDL_SRV_H)) + -$(RM) $(LIB_MOC_SRC) $(BIN_MOC_SRC) + -$(RM) $(LIB_SWIG_SRC) + +# Like `clean' except it also removes files that were created by running +# configure. If you've unpacked the source and built without creating +# any other files, then `make distclean' will leave only the files that were +# in the distribution. +# +distclean: clean + #remove qm file ! + -$(RM) $(PO_FILES:%.po=%.qm) $(PO_FILES:%.po=$(top_builddir)/share/salome/resources/%.qm) + #remove include files + -$(RM) $(DEST_HEADERS) + -$(RM) $(DISTCLEAN) *.bak *.old *.new .dep* + @if test -f $(srcdir)/Makefile.in; then \ + (@SETX@; $(RM) Makefile); \ + fi + + +#implicits rules +.cc.o: + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< + +.cc.lo: + $(LT) --mode=compile $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< + +.cxx.o: + $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< + +.cxx.lo: + $(LT) --mode=compile $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< + +.c.o: + $(CC) $(CFLAGS) $(CPPFLAGS) -c $< + +.c.lo: + $(LT_COMPILE) $(CFLAGS) $(CPPFLAGS) -c $< + +.f.o: + $(FC) $(FFLAGS) -c $< -o $@ + +.f.lo: + $(LT) --mode=compile $(FC) $(FFLAGS) -c $< + +.ui.h: + $(UIC) -o $@ $< + +.ui.cxx: + $(UIC) -o $@ -i $*.h $< + +#pattern rules +%_moc.cxx : %.h + $(MOC) $< -o $@ + +%_wrap.cxx : %.i + $(SWIG) $(SWIG_FLAGS) -o $@ $< + +$(top_builddir)/share/salome/resources/%.qm: %.po + if test -e ${KERNEL_ROOT_DIR}/bin/salome/msg2qm ; then \ + ${KERNEL_ROOT_DIR}/bin/salome/msg2qm $< $@ ; \ + else \ + $(top_builddir)/bin/salome/msg2qm $< $@ ; \ + fi + +#------------------------------------------------------------------------------ +# The following section of this makefile contains dependencies between the +# source files and the header files. If GNU make and GCC are being used then +# the dependencies are in the form of rules that cause the information to +# be kept updated automatically. Otherwise the dependencies are listed +# explicitly and come from the `.distdep' files in the various directories. +# These files are part of the distribution and are generated automatically on +# GNU/GCC systems. +#------------------------------------------------------------------------------ + +@DEPEND@ diff --git a/bin/VERSION b/bin/VERSION index fe67dd416..662ebbd99 100755 --- a/bin/VERSION +++ b/bin/VERSION @@ -1,2 +1,2 @@ -THIS IS SALOME - SMESH VERSION: 2.0.0 +THIS IS SALOME - SMESH VERSION: 2.1.0 diff --git a/build_configure b/build_configure index 163b46353..a0dda39dc 100755 --- a/build_configure +++ b/build_configure @@ -128,7 +128,7 @@ echo " ./salome_adm/unix/depend \\" >> configure.in_tmp1 echo " ./adm_local/unix/make_omniorb \\" >> configure.in_tmp1 echo " ./salome_adm/unix/envScript \\" >> configure.in_tmp1 echo " ./adm_local/unix/make_commence \\" >> configure.in_tmp1 -echo " ./salome_adm/unix/make_conclude \\" >> configure.in_tmp1 +echo " ./adm_local/unix/make_conclude \\" >> configure.in_tmp1 echo " ./salome_adm/unix/make_module \\" >> configure.in_tmp1 \rm -f configure.in_tmp2 configure.in_tmp3 diff --git a/configure.in.base b/configure.in.base index 5573498ca..16b6b77fa 100644 --- a/configure.in.base +++ b/configure.in.base @@ -303,7 +303,7 @@ echo dnl generals files which could be included in every makefile AC_SUBST_FILE(COMMENCE) COMMENCE=adm_local/unix/make_commence -AC_SUBST_FILE(CONCLUDE) CONCLUDE=salome_adm/unix/make_conclude +AC_SUBST_FILE(CONCLUDE) CONCLUDE=adm_local/unix/make_conclude AC_SUBST_FILE(MODULE) MODULE=salome_adm/unix/make_module dnl les dependences diff --git a/doc/salome/gui/SMESH/SMESH.log b/doc/salome/gui/SMESH/SMESH.log index 4552b0906..fb02a90f8 100755 --- a/doc/salome/gui/SMESH/SMESH.log +++ b/doc/salome/gui/SMESH/SMESH.log @@ -1,5 +1,5 @@ |SourceProjectName:SMESH.hpr -|DestinationProjectName:smesh.html +|DestinationProjectName:smesh.htm whhost.js whmsg.js whmozemu.js @@ -127,6 +127,7 @@ whskin_frmset01.htm smesh_hha.hhk smesh.hhc smesh.hhk +extrusion.htm files\1d_meshing_algorithm.htm files\2d_(quadrangle)_meshing_algorithm.htm files\2d_meshing_algorithm.htm @@ -138,34 +139,55 @@ files\about_modification_of_meshes.htm files\about_quality_controls.htm files\adding_nodes_and_elements.htm files\area_of_elements.htm +files\arithmetic_1d.htm files\aspect_ratio.htm files\changing_orientation_of_elements.htm files\computing_meshes.htm files\connectivity.htm +files\constructing_groups_of_specific_elements.htm files\constructing_meshes.htm files\constructing_submeshes.htm +files\creating_groups.htm +files\cutting_quadrangles.htm +files\deflection_1d.htm files\diagonal_iversion_of_elements.htm files\displacing_nodes.htm files\displaying_elements_numbers.htm files\displaying_nodes_numbers.htm +files\editing_groups.htm files\editing_hypotheses.htm files\importing_and_exporting_meshes.htm files\introduction_to_smesh.htm +files\length_from_edges.htm files\length_of_edges.htm files\local_length_hypothesis.htm files\max._element_area_hypothesis.htm files\max._element_volume_hypothsis.htm +files\merging_nodes.htm files\minimum_angle.htm +files\non_conform_mesh_allowed_hypothesis.htm files\number_of_segments_hypothesis.htm +files\propagation_of_1d_hypothesis_on_opposite_edges.htm files\reassigning_hypotheses_and_algorithms.htm files\removing_nodes_and_elements.htm +files\renumbering_nodes_and_elements.htm +files\rotation.htm files\running_smesh_module.htm files\scalar_bar_properties.htm +files\sewing_meshes.htm files\shading.htm files\shrink.htm files\skew.htm +files\smoothing.htm +files\start_and_end_length_hypothesis.htm +files\symmetry.htm files\taper.htm +files\tetrahedron_(ghs3d)_meshing_algorithm.htm files\tetrahedron_(netgen)_meshing_algorithm.htm +files\translation.htm +files\uniting_a_set_of_triangles.htm +files\uniting_two_triangles.htm +files\using_operations_on_groups.htm files\using_smesh_module.htm files\view_update.htm files\viewing_mesh_info.htm @@ -173,64 +195,149 @@ files\visualization_modes.htm files\visualization_properties.htm files\warp.htm files\wireframe.htm -texture_horiz_ltbluebubbles.jpg +pattern_mapping.htm +revolution.htm ehlpdhtm.js +texture_horiz_ltbluebubbles.jpg smesh.glo default.css -image3.jpg -image55.gif +image96.gif +image77.jpg +image66.jpg +image55.jpg +image85.gif +image74.gif +image44.jpg +image63.gif +image22.jpg +image11.jpg +image41.gif +image97.gif +image78.jpg +image67.jpg +image75.gif +image45.jpg +image34.jpg +image64.gif +image23.jpg +image12.jpg +image31.gif +image98.gif +image87.gif +image68.jpg +image57.jpg +image76.gif +image46.jpg +image35.jpg +image65.gif +image43.gif +image32.gif +image24.jpg +image88.gif +image69.jpg +image58.jpg +image77.gif +image47.jpg +image36.jpg +image66.gif image44.gif image33.gif image22.gif image25.jpg -image4.jpg -image56.gif -image45.gif +image89.gif +image59.jpg +image78.gif +image48.jpg +image67.gif image34.gif image26.jpg -image2.gif +image79.gif +image49.jpg +image38.jpg +image68.gif +image57.gif +image16.jpg image46.gif image35.gif image27.jpg image24.gif -image6.jpg -image47.gif +image39.jpg +image69.gif +image3.jpg +pics\exemple.gif image36.gif image28.jpg image25.gif -image4.gif -image7.jpg -image48.gif +image18.jpg +image4.jpg image37.gif image29.jpg image26.gif -image8.jpg -image49.gif +note1.gif +image2.gif image38.gif image27.gif -note1.gif -image6.gif -image9.jpg +image80.jpg +image6.jpg image39.gif image28.gif +image81.jpg +image70.jpg +image4.gif +image7.jpg image29.gif -i_blue.jpg -image50.gif pics\new.jpg +image90.gif +image71.jpg +image60.jpg +image8.jpg +image91.gif +image72.jpg +image61.jpg +image50.jpg +image80.gif +image6.gif +image9.jpg +image92.gif +image73.jpg +image62.jpg +image51.jpg +image81.gif +image40.jpg +image70.gif +image7.gif +i_blue.jpg +image93.gif +image74.jpg +image63.jpg +image52.jpg +image82.gif +image41.jpg +image71.gif +image30.jpg +image8.gif +image94.gif +image75.jpg +image64.jpg +image53.jpg +image83.gif +image42.jpg +image72.gif +image61.gif +image31.jpg +image9.gif +image20.jpg +image95.gif +image76.jpg +image65.jpg +image54.jpg +image84.gif +image43.jpg +image73.gif +image32.jpg +image21.jpg image10.jpg -image51.gif image40.gif -image11.jpg -image52.gif -image41.gif -image12.jpg -pics\exemple.gif -image53.gif -image42.gif -image31.gif -image43.gif -image32.gif -image24.jpg smesh.ppf default_ns.css whdata\whtdata0.xml @@ -254,6 +361,7 @@ whgdata\whlstt9.htm whgdata\whlstt10.htm whgdata\whlstt11.htm whgdata\whlstt12.htm +whgdata\whlstt13.htm whgdata\whlsti0.htm whgdata\whlstfl0.htm whgdata\whlstfl1.htm @@ -278,11 +386,16 @@ whgdata\whlstfl19.htm whgdata\whlstfl20.htm whgdata\whlstfl21.htm whgdata\whlstfl22.htm +whgdata\whlstfl23.htm whgdata\whlstf0.htm whgdata\whlstf1.htm whgdata\whlstf2.htm whgdata\whlstf3.htm +whgdata\whlstf4.htm +whgdata\whlstf5.htm +whgdata\whlstf6.htm +whgdata\whlstf7.htm whgdata\whlstg0.htm -smesh.html -smesh_csh.html -smesh_rhc.html +smesh.htm +smesh_csh.htm +smesh_rhc.htm diff --git a/doc/salome/gui/SMESH/extrusion.htm b/doc/salome/gui/SMESH/extrusion.htm new file mode 100755 index 000000000..45a64ee07 --- /dev/null +++ b/doc/salome/gui/SMESH/extrusion.htm @@ -0,0 +1,184 @@ + + + + + + + + + + +Extrusion + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Extrusion

+ +

Extrusion is a type of surface meshing by generation from discretized + lines. It is used to build mesh elements of plus one dimension than the + swept ones. Each swept 1D element produces one or more quadrangles (or + triangles if one node of a rotated element lays on the revolution axis).

+ +

 

+ +

To use extrusion:

+ +

 

+ +

1. From the Modification + menu choose the Extrusion item + or click button in the toolbar. The following dialog box + shall appear:

+ +

 

+ +

+ +

 

+ +

2. In this dialog box you should select

+ +
    + +
  • the type of elements + which will be extruded (1D or 2D),

  • + +
  • specify the IDs of + the elements which will be extruded by selecting them in the 3D viewer + or select the whole mesh or submesh,

  • + +
  • specify the vector + along which the elements will be extruded,

  • + +
  • number of steps

  • +
+ +

 

+ +

3. Click the Apply + or OK button.

+ +

 

+ +

 

+ + + +++ + + + +
+

+

+ +

 

+ +

 

+ + + + + diff --git a/doc/salome/gui/SMESH/files/1d_meshing_algorithm.htm b/doc/salome/gui/SMESH/files/1d_meshing_algorithm.htm index d34ee9f28..51d954a9f 100755 --- a/doc/salome/gui/SMESH/files/1d_meshing_algorithm.htm +++ b/doc/salome/gui/SMESH/files/1d_meshing_algorithm.htm @@ -19,8 +19,8 @@ - - + + @@ -36,7 +36,6 @@ if (navigator.appName !="Netscape")

About modification of meshes

-

Type topic text here.

+

 

+

Adding nodes and elements

-

Type topic text here.

+

In SMESH you can add to your mesh different elements such as:

+ +

 

+ +
    + +
  • Nodes

  • + +
  • Edges

  • + +
  • Triangles

  • + +
  • Quadrangles

  • + +
  • Tetrahedrons

  • + +
  • Hexahedrons

  • +
+ +

 

+ +

To add a node or an element to your mesh:

+ +

 

+ +

1. Select your mesh in the Object Browser + or in the 3D viewer.

+ +

 

+ +

2. From the Modification + menu choose the Add item, + the following associated submenu will appear:

+ +

 

+ +

+ +

 

+ +

 

+ +

From this submenu select the type of element + which you would like to add to your mesh. The corresponding dialog box + shall appear.

+ +

Adding nodes

+ +

+ +

 

+ +

In this dialog box set coordinates for your + node in the Coordinates set of + fields and click the Apply or + OK button. Your node will be created:

+ +

 

+ +

+ +

 

+ +

Adding edges

+ +

 

+ +

+ +

 

+ +

In this dialog box specify the nodes which + will form your edge by selecting them in the 3D viewer with pressed Shift + button and click the Apply or + OK button. Your edge will be created:

+ +

 

+ +

+ +

 

+ +

Adding triangles

+ +

 

+ +

+ +

 

+ +

In this dialog box specify the nodes which + will form your triangle by selecting them in the 3D viewer with pressed + Shift button and click the Apply or + OK button. Your triangle will + be created:

+ +

 

+ +

+ +

 

+ +

Adding quadrangles

+ +

+ +

In this dialog box specify the nodes which + will form your quadrangle by selecting them in the 3D viewer with pressed + Shift button and click the Apply or + OK button. Your quadrangle will + be created:

+ +

 

+ +

+ +

 

+ +

Adding tetrahedrons

+ +

+ +

 

+ +

In this dialog box specify the nodes which + will form your tetrahedron by selecting them in the 3D viewer with pressed + Shift button and click the Apply or + OK button. Your tetrahedron will + be created:

+ +

 

+ +

+ +

Adding hexahedrons

+ +

+ +

 

+ +

In this dialog box specify the nodes which + will form your hexahedron by selecting them in the 3D viewer with pressed + Shift button and click the Apply or + OK button. Your hexahedron will + be created:

+ +

 

+ +

 

+ +

+ + + + + + + + + + + + + + + + + +

Arithmetic 1D hypothesis

+ +

Arithmetic 1D + - hypothesis for the Regular 1D algorithm. It allows to split edges into + segments with a length that changes in arithmetic progression (Lk = Lk-1 + + d) beginning from a given starting length and up to a given end length.

+ +

 

+ +

Similar to Start and End Length.

+ +

 

+ +

To define the Arithmetic 1D hypothesis:

+ +

 

+ +

Select this hypothesis in the + Create Hypotheses dialog box + click Create. The following dialog + box will appear:

+ +

 

+ +

+ +

 

+ +

In this dialog box you can set:

+ +

 

+ +
    + +
  • Name + of your Arithmetic 1D hypothesis;

  • + +
  • Start + and End length values

  • +
+ + + + + diff --git a/doc/salome/gui/SMESH/files/aspect_ratio.htm b/doc/salome/gui/SMESH/files/aspect_ratio.htm index b7e6cdb1d..1e1117fd0 100755 --- a/doc/salome/gui/SMESH/files/aspect_ratio.htm +++ b/doc/salome/gui/SMESH/files/aspect_ratio.htm @@ -105,7 +105,7 @@ addButton("show",BTN_TEXT,"Show","","","","",0,0,"","",""); if (window.setRelStartPage) { - setRelStartPage("../smesh.html"); + setRelStartPage("../smesh.htm"); autoSync(0); sendSyncInfo(); diff --git a/doc/salome/gui/SMESH/files/changing_orientation_of_elements.htm b/doc/salome/gui/SMESH/files/changing_orientation_of_elements.htm index 0df9544cc..f51e87294 100755 --- a/doc/salome/gui/SMESH/files/changing_orientation_of_elements.htm +++ b/doc/salome/gui/SMESH/files/changing_orientation_of_elements.htm @@ -18,9 +18,9 @@ - - - + + + @@ -32,6 +32,15 @@ if (navigator.appName !="Netscape") { document.write("");} //--> +

Changing orientation of elements

-

Type topic text here.

+

Orientation of an element is changed by reverting the order of nodes + of the selected elements.

+ +

 

+ +

To change orientation of elements:

+ +

 

+ +

1. Display a mesh or a submesh in the 3D + viewer.

+ +

 

+ +

2. In the Modification + menu select the Orientation item + or click button in the toolbar. The following dialog box + will appear:

+ +

 

+ +

+ +

 

+ +
    + +
  • The main list shall contain the + elements which will be reoriented. You can click on an element + in the 3D viewer and it will be highlighted. After that click the Add button and the ID of this element + will be added to the list. To remove a selected element or elements from + the list click the Remove button. + The Sort button allows to sort + the list of elements IDs. The Set filter + button allows to apply a definite filter to selection of elements + of your group.

  • + +
  • Apply to all radio button allows + to modify the orientation of all elements of the currently displayed mesh + or submesh.

  • + +
  • Select from set of fields allows to + choose a submesh or an existing group whose elements will be automatically + added to the list.

  • +
+ +

 

+ +

3. Click the Apply + or OK button to confirm + the operation.

+ +

 

+ + + + + + + + + + + + + + + + +

Constructing groups of specific elements

+ +

In SMESH you can easily construct groups of specific elements (nodes, + edges or faces) which will be taken from a definite submesh.

+ +

 

+ +

To construct a group of specific elements:

+ +

 

+ +

Right-click on a submesh in the Object Browser + and choose the Construct Group item + or select your submesh in the Object Browser and in the Mesh + menu chose the Construct Group + item. SMESH will construct several groups consisting of elements + of the definite type: nodes, edges or faces

+ + + + + diff --git a/doc/salome/gui/SMESH/files/constructing_meshes.htm b/doc/salome/gui/SMESH/files/constructing_meshes.htm index 5c46cb7e5..e4a680d66 100755 --- a/doc/salome/gui/SMESH/files/constructing_meshes.htm +++ b/doc/salome/gui/SMESH/files/constructing_meshes.htm @@ -19,8 +19,8 @@ - - + + @@ -40,6 +40,7 @@ p.whs3 {margin-left: 40px;} img_whs4 {border-style: none; border: none; width: 22px; height: 24px;} p.whs5 {margin-left: 80px;} img_whs6 {border-style: none; border: none; width: 304px; height: 305px;} +img_whs7 {border-style: none; border: none; width: 268px; height: 161px;} --> + + + + + + + + + + + + + + + + +

Creating groups

+ +

In + SMESH you can create groups of elements of different types and having + definite properties.

+ +

 

+ +

To create a group of elements:

+ +

 

+ +

1. In the Mesh + menu select Create + Group. The following dialog box will appear:

+ +

 

+ +

 

+ +

 

+ +

This dialog box contains + the following fields which should be filled:

+ +

 

+ +
    + +
  • Mesh: the name of the mesh whose elements + will form your group. You can enter the name manually or select your mesh + in the Objet Browser or in the 3D viewer.

  • + +
  • Elements Type set of radio buttons allows + to select the type of elements which will form your group:

  • + +
      + +
    • Nodes

    • + +
    • Edges +

    • + +
    • Faces

    • + +
    • Volumes

    • +
    + +
  • Name field allows to enter the + name of your new group.

  • + +
  • Group type set of radio buttons allows + to select the type of your group:

  • + +
      + +
    • Standalone group  consisting + of mesh elements.

    • + +
    • Group on geometry consisting of + geometrical elements. If you choose this type of group your dialog + box will change and it will look like as follows:

    • +
    +
+ +

 

+ +

+ +

 

+ +

In this dialog box you should enter the name + of the geometrical object (you can enter the name manually or select your + geometrical object in the Objet Browser or in the 3D viewer) from which + the elements will be taken. And after confirmation of the operation SMESH + will create a new group consisting of geometrical elements of the previously + defined type.

+ +

 

+ +
    + +
  • Content field + allows to manually define the mesh elements which will form your + group. You can click on an element in the 3D viewer and it will be highlighted. + After that click the Add button + and the ID of this element will be added to the list. To remove a selected + element or elements from the list click the Remove + button. The Sort button + allows to sort the list of elements IDs. The Set + filter button allows to apply a definite filter to selection + of the elements of your group.

  • + +
  • Select from set of fields allows to + choose a submesh or an existing group whose elements of the previously + defined type will be added to the list of elements which will form your + group.

  • +
+ +

 

+ +

2. Click the OK + button to confirm creation of your group or Cancel to quit this dialog box.

+ + + + + diff --git a/doc/salome/gui/SMESH/files/cutting_quadrangles.htm b/doc/salome/gui/SMESH/files/cutting_quadrangles.htm new file mode 100755 index 000000000..8e2220693 --- /dev/null +++ b/doc/salome/gui/SMESH/files/cutting_quadrangles.htm @@ -0,0 +1,215 @@ + + + + + + + + + + +Cutting quadrangles + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Cutting quadrangles

+ +

This operation allows to cut one or several quadrangle + elements by addition of a supplementary edge which will connect two opposite + corners.

+ +

 

+ +

To cut quadrangles:

+ +

 

+ +

1. Display a mesh or a submesh in the 3D + viewer.

+ +

 

+ +

2. In the Modification + menu select the Cutting of quadrangles + item or click button in the toolbar. The following + dialog box will appear:

+ +

 

+ +

+ +

 

+ +
    + +
  • The main list shall contain the quadrangles + which will be cutted. You can click on an quadrangle in the 3D viewer + and it will be highlighted. After that click the Add + button and the ID of this quadrangle will be added to the list. + To remove a selected element or elements from the list click the Remove button. The Sort + button allows to sort the list of IDs. The Set + filter button allows to apply a definite filter to selection of + quadrangles.

  • + +
  • Apply to all radio button allows to + modify the orientation of all quadrangles of the currently displayed mesh + or submesh.

  • + +
  • Use diagonal 2-4 radio button allows + to specify the opposite corners which will be connected by the cutting + edge.

  • + +
  • Preview

  • + +
  • Select from set of fields allows to + choose a submesh or an existing group whose quadrangle elements will be + automatically added to the list.

  • +
+ +

 

+ +

3. Click the Apply + or OK button to confirm + the operation.

+ +

 

+ +

 

+ + + +++ + + + +
+

+

+ +

 

+ + + + + diff --git a/doc/salome/gui/SMESH/files/deflection_1d.htm b/doc/salome/gui/SMESH/files/deflection_1d.htm new file mode 100755 index 000000000..50612ac08 --- /dev/null +++ b/doc/salome/gui/SMESH/files/deflection_1d.htm @@ -0,0 +1,171 @@ + + + + + + + + + + +Local Length hypothesis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Average Length hypothesis

+ +

Average Length hypothesis + can be applied for meshing of edges composing your geometrical object. + Definition of this hypothesis consists of setting the length + of segments, which will split these edges. The points on the edges generated + by these segments will represent nodes of your mesh. Later these nodes + will be used for meshing of the faces abutting to these edges.

+ +

 

+ +

+ +

 

+ +

To define the Average Length hypothesis:

+ +

 

+ +

Select this hypothesis in the + Create Hypotheses dialog box + click Create. The following dialog + box will appear:

+ +

 

+ +

+ +

 

+ +

In this dialog box you can set:

+ +

 

+ +
    + +
  • Name + of your Average Length hypothesis

  • + +
  • Length + of segments which will split the edges of your geometrical object

  • +
+ +

 

+ + + + + diff --git a/doc/salome/gui/SMESH/files/diagonal_iversion_of_elements.htm b/doc/salome/gui/SMESH/files/diagonal_iversion_of_elements.htm index da44a8912..e736e199e 100755 --- a/doc/salome/gui/SMESH/files/diagonal_iversion_of_elements.htm +++ b/doc/salome/gui/SMESH/files/diagonal_iversion_of_elements.htm @@ -19,8 +19,8 @@ - - + + @@ -32,6 +32,19 @@ if (navigator.appName !="Netscape") { document.write("");} //--> +

Diagonal inversion of elements

-

Type topic text here.

+

 In SMESH + you can inverse the diagonal (edge) of a pseudo-quadrangle formed by two + neighboring triangles with one common edge.

+ +

 

+ +

To inverse the diagonal:

+ +

 

+ +

1. From the Modification + menu choose the Diagonal inversion + item or click button in the toolbar. The following + dialog box shall appear:

+ +

 

+ +

+ +

 

+ +

2. Enter the ID of the required edge in the + Edge  field + or select this edge in the 3D viewer.

+ +

 

+ +

3. Click the Apply + or OK button.

+ +

 

+ +

 

+ + + +++ + + + +
+

+

+ + -

Displacing nodes

+

Moving nodes

+ +

In SMESH you can change the location of any node of your mesh. In this + case all adjacent elements (edges) will be also transformed right after + the displaced node.

+ +

 

+ +

To displace a node:

+ +

 

+ +

1. From the Modification + menu choose the Move node item + or click button in the toolbar. The following dialog box + shall appear:

+ +

 

+ +

+ +

 

+ +

2. Enter the ID of the required node in the + Node ID  field + or select this node in the 3D viewer. The coordinates of your node will + be automatically displayed in the Coordinates + set of fields.

+ +

 

+ +

3. Set new coordinates for your node in the + Coordinates set of fields.

+ +

 

+ +

4. Click the Apply + or OK button.

+ +

 

+ + + +++ + + + +
+

+

+ +

 

+ +

 

-

Type topic text here.

+

 

+ + + + + + + + + + + + + + + + +

Editing groups

+ +

To edit an existing group of elements:

+ +

 

+ +

1. Select your group in the Object Browser + and in the Mesh menu click the + Edit Group item or icon in the toolbar. The following dialog box will appear:

+ +

 

+ +

+ +

 

+ +

In this dialog box you can modify the name of your group and add or remove the + elements forming it. For more information see + here.

+ +

 

+ +

2. Click the OK + or  Apply + button to confirm modification of the group.

+ + + + + diff --git a/doc/salome/gui/SMESH/files/editing_hypotheses.htm b/doc/salome/gui/SMESH/files/editing_hypotheses.htm index e36d19b96..a0d30a3f6 100755 --- a/doc/salome/gui/SMESH/files/editing_hypotheses.htm +++ b/doc/salome/gui/SMESH/files/editing_hypotheses.htm @@ -19,8 +19,8 @@ - - + + @@ -32,6 +32,12 @@ if (navigator.appName !="Netscape") { document.write("");} //--> + -

Editing hypotheses

+

Editing hypotheses and algorithms

+ +

In SMESH you can rename created + and already applied hypotheses and algorithms and edit + the input data of the created and already applied hypotheses.

 

+

To rename a hypothesis or algorithm:

+ +

 

+ +

1. Select the required hypothesis or algorithm + in the Object Browser and right-click on it. From the associated popup + menu select the Rename item, the + following dialog box will appear:

+ +

 

+ +

+ +

 

+ +

2. In this dialog box enter a new name for + your hypothesis or algorithm and click the OK + button.

+ +

 

+ +

To edit the input data of a hypothesis:

+ +

 

+ +

1. Select the required hypothesis  in + the Object Browser and right-click on it. From the associated popup menu + select the Edit item and in the + appeared dialog box (it will differ depending on the type of the edited + hypothesis) enter a new input value for your hypothesis.

+ +

 

+ +

2. Click the OK + button to confirm your changes.

+ + + + + + + + + + + + + + + + + +

Length from edges (2D hypothesis for Triangulator) hypothesis

+ +

Length from edges + hypothesis builds 1D mesh segments having a length calculated as an average + edge length for a given wire.

+ +

 

+ +

This hypothesis has no parameters.

+ +

 

+ +

 

+ +

To apply the Length from edges hypothesis:

+ +

 

+ +

Select this hypotheses in the + Create Hypotheses dialog box + click Create.

+ +

 

+ +

 

+ + + + + diff --git a/doc/salome/gui/SMESH/files/length_of_edges.htm b/doc/salome/gui/SMESH/files/length_of_edges.htm index e49ef746c..70acb620a 100755 --- a/doc/salome/gui/SMESH/files/length_of_edges.htm +++ b/doc/salome/gui/SMESH/files/length_of_edges.htm @@ -89,7 +89,7 @@ addButton("show",BTN_TEXT,"Show","","","","",0,0,"","",""); if (window.setRelStartPage) { - setRelStartPage("../smesh.html"); + setRelStartPage("../smesh.htm"); autoSync(0); sendSyncInfo(); diff --git a/doc/salome/gui/SMESH/files/local_length_hypothesis.htm b/doc/salome/gui/SMESH/files/local_length_hypothesis.htm index 10316eaf2..a53261d03 100755 --- a/doc/salome/gui/SMESH/files/local_length_hypothesis.htm +++ b/doc/salome/gui/SMESH/files/local_length_hypothesis.htm @@ -19,8 +19,8 @@ - - + + @@ -38,11 +38,10 @@ img_whs1 {border-style: none; border: none; width: 30px; height: 30px; float: no p.whs2 {font-weight: bold; margin-left: 40px;} img_whs3 {border-style: none; border: none; width: 367px; height: 224px;} p.whs4 {margin-left: 40px;} -img_whs5 {border-style: none; border: none; width: 26px; height: 24px;} -p.whs6 {margin-left: 80px;} -img_whs7 {border-style: none; border: none; width: 304px; height: 233px;} -p.whs8 {margin-left: 0px;} -ul.whs9 {list-style: disc;} +p.whs5 {margin-left: 80px;} +img_whs6 {border-style: none; border: none; width: 304px; height: 233px;} +p.whs7 {margin-left: 0px;} +ul.whs8 {list-style: disc;} --> -

Local Length hypothesis

+

Average Length hypothesis

-

Local Length hypothesis +

Average Length hypothesis can be applied for meshing of edges composing your geometrical object. Definition of this hypothesis consists of setting the length of segments, which will split these edges. The points on the edges generated @@ -131,34 +130,35 @@ else

 

-

To define the Local Length hypothesis:

+

To define the Average Length hypothesis:

 

-

From the Hypotheses - menu select Average Length or - click button. The following dialog box will appear:

+

Select this hypotheses in the + Create Hypotheses dialog box + click Create. The following dialog + box will appear:

 

-

+

-

 

+

 

-

In this dialog box you can set:

+

In this dialog box you can set:

-

 

+

 

-
    +
      -
    • Name - of your Local Length hypothesis

    • +
    • Name + of your Average Length hypothesis

    • -
    • Length +

    • Length of segments which will split the edges of your geometrical object

    -

     

    +

     

    -

    Max Element Area hypothesis

    +

    Length from edges (2D hypothesis for Triangulator) hypothesis

    -

    Max Element Area hypothesis - can be applied for meshing of 2D faces composing your geometrical object. - Definition of this hypothesis consists of setting the maximum - area of meshing elements (depending on the chosen meshing algorithm - it can be triangles or quadrangles), - which will compose the mesh of these 2D faces.

    +

    Length from edges + hypothesis builds 1D mesh segments having a length calculated as an average + edge length for a given wire.

     

    -

    To define the Max Element Area hypothesis:

    - -

     

    - -

    From the Hypotheses - menu select Max Element Area or - click button. The following dialog box will appear:

    +

    This hypothesis has no parameters.

    -

     

    +

     

    -

    +

     

    -

     

    +

    To apply the Length from edges hypothesis:

    -

    In this dialog box you can set:

    +

     

    -

     

    +

    Select this hypothesis in the + Create Hypotheses dialog box + click Create.

    -
      - -
    • Name - of your Max Element Area hypothesis

    • - -
    • Max. - Area: the maximum area of meshing elements

    • -
    +

     

    -

     

    +

     

    -

    Max Element Volume hypothesis

    +

    Non conform mesh allowed hypothesis

    -

    Max Element Area hypothesis - can be applied for meshing of 3D objects composing your geometrical object. - Definition of this hypothesis consists of setting the maximum - volume of 3D meshing elements (depending on the chosen meshing - algorithm it can be hexahedrons or - tetrahedrons), which will compose - the mesh of these 3D objects.

    +

    Non Conform mesh allowed + hypothesis allows to generate non-conform meshes (that is, meshes having + some edges ending on an edge or face of adjacent elements).

     

    -

    To define the Max Element Volume hypothesis:

    - -

     

    +

    This hypothesis has no parameters.

    -

    From the Hypotheses - menu select Max Element Volume - or click button. The following dialog box will appear:

    - -

     

    - -

    - -

     

    - -

    In this dialog box you can set:

    +

     

    -

     

    +

    To apply this hypothesis:

    -
      - -
    • Name - of your Max Element Volume hypothesis

    • - -
    • Max. - Volume: the maximum volume - of 3D meshing elements

    • -
    +

     

    -

     

    +

    Select this hypothesis s in the + Create Hypotheses dialog box + click Create.

    + + + + + + + + + + + + + + + + +

    Merging nodes

    + +

    This functionality allows user to detect groups of coincident + nodes with desirable tolerance, edit these groups and merge.

    + +

     

    + +

    To merge nodes of your mesh:

    + +

     

    + +

    1. From the Modification + choose Transformation and +  from its + sub-menu select the Merge nodes item. + The following dialog box shall appear:

    + +

     

    + +

    + +

     

    + +

    This dialog box allows to create groups of + coincident nodes and to merge them.

    + + + + + diff --git a/doc/salome/gui/SMESH/files/minimum_angle.htm b/doc/salome/gui/SMESH/files/minimum_angle.htm index 7cfc2299e..7a88843cf 100755 --- a/doc/salome/gui/SMESH/files/minimum_angle.htm +++ b/doc/salome/gui/SMESH/files/minimum_angle.htm @@ -89,7 +89,7 @@ addButton("show",BTN_TEXT,"Show","","","","",0,0,"","",""); if (window.setRelStartPage) { - setRelStartPage("../smesh.html"); + setRelStartPage("../smesh.htm"); autoSync(0); sendSyncInfo(); diff --git a/doc/salome/gui/SMESH/files/non_conform_mesh_allowed_hypothesis.htm b/doc/salome/gui/SMESH/files/non_conform_mesh_allowed_hypothesis.htm new file mode 100755 index 000000000..baecc1235 --- /dev/null +++ b/doc/salome/gui/SMESH/files/non_conform_mesh_allowed_hypothesis.htm @@ -0,0 +1,129 @@ + + + + + + + + + + +Non conform mesh allowed hypothesis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Non conform mesh allowed hypothesis

    + +

    Non Conform mesh allowed + hypothesis allows to generate non-conform meshes (that is, meshes having + some edges ending on an edge or face of adjacent elements).

    + +

     

    + +

    This hypothesis has no parameters.

    + +

     

    + +

    To apply this hypothesis:

    + +

     

    + +

    Select this hypothesis s in the + Create Hypotheses dialog box + click Create.

    + + + + + diff --git a/doc/salome/gui/SMESH/files/number_of_segments_hypothesis.htm b/doc/salome/gui/SMESH/files/number_of_segments_hypothesis.htm index ec3ce9c4e..aeceb759d 100755 --- a/doc/salome/gui/SMESH/files/number_of_segments_hypothesis.htm +++ b/doc/salome/gui/SMESH/files/number_of_segments_hypothesis.htm @@ -19,8 +19,8 @@ - - + + @@ -37,11 +37,10 @@ if (navigator.appName !="Netscape") img_whs1 {border-style: none; border: none; width: 30px; height: 30px; float: none;} p.whs2 {margin-left: 40px;} img_whs3 {border-style: none; border: none; width: 431px; height: 233px;} -img_whs4 {border-style: none; border: none; width: 25px; height: 24px;} -p.whs5 {margin-left: 80px;} -img_whs6 {border-style: none; border: none; width: 304px; height: 233px;} -p.whs7 {margin-left: 0px;} -ul.whs8 {list-style: disc;} +p.whs4 {margin-left: 80px;} +img_whs5 {border-style: none; border: none; width: 304px; height: 233px;} +p.whs6 {margin-left: 0px;} +ul.whs7 {list-style: disc;} --> + + + + + + + + + + + + + + + + +

    Propagation of 1D Hypothesis on opposite edges

    + +

    Propagation of 1D Hypothesis + on opposite edges allows to propagate a set hypothesis onto an + opposite edge. If a local hypothesis and propagation are set on one of + edges of a quadrangular face, the opposite edge will have the same hypothesis, + unless another hypothesis has been locally set on such opposite edge.

    + +

     

    + +

    To apply this hypothesis:

    + +

     

    + +

    Select this hypothesis s in the + Create Hypotheses dialog box + click Create.

    + + + + + diff --git a/doc/salome/gui/SMESH/files/reassigning_hypotheses_and_algorithms.htm b/doc/salome/gui/SMESH/files/reassigning_hypotheses_and_algorithms.htm index 245bf84e0..51938ab6a 100755 --- a/doc/salome/gui/SMESH/files/reassigning_hypotheses_and_algorithms.htm +++ b/doc/salome/gui/SMESH/files/reassigning_hypotheses_and_algorithms.htm @@ -19,8 +19,8 @@ - - + + @@ -32,6 +32,27 @@ if (navigator.appName !="Netscape") { document.write("");} //--> + +

    Reassigning hypotheses and algorithms

    +

    After you have created a mesh or submesh with definite applied hypotheses + and algorithms you can edit your mesh by assigning + new hypotheses and algorithms or unassigning + the applied hypotheses and algorithms.

    + +

     

    + +

    To assign or unassign algorithms and hypotheses:

    + +

     

    + +

    1. In the Mesh + menu select the Edit + Hypothesis, the following dialog box will appear:

    +

     

    +

    + +

     

    + +

    This dialog box contains the following fields: +

    + +
      + +
    • Mesh + or SubMesh field: here you should enter the name of the mesh or + submesh for which you would like to assign or unassign hypotheses and + algorithms. It can be also done by choosing the required mesh or submesh + in the Object Browser or in the 3D viewer;

    • + +
    • Hypotheses + set of fields containing two columns: +

    • + +
        + +
      • Available: + the hypotheses which have been created + in the current study;

      • + +
      • Used: the + hypotheses which have been applied to previously selected mesh or submesh.

      • +
      + +
    • Algorithms + set of fields containing two columns:

    • + +
        + +
      • Available: + the algorithms which have been created + in the current study.

      • + +
      • Used: + the algorithms which have been applied + to previously selected mesh or submesh.

      • +
      +
    + +

     

    + +

    2. Double-click on the definite algorithm + or hypothesis to move it from the Available + column into the Used column + and vice versa.  Thus + you will be able to apply new hypotheses and algorithms to your mesh or + unassign the applied hypotheses + and algorithms.

    + +

     

    + +

    3. Confirm your changes by clicking the OK button.

    + +

     

    + +

    After modification of applied algorithms you + should recompute your mesh once again.

    + +

     

    + +

    You can also unassign an + applied algorithm or hypothesis by right-clicking on it in the Object + Browser and choosing from the associated popup menu the Unassign + Algorithm or Unassign Hypothesis + item.

    + + +

    Removing nodes and elements

    -

    Type topic text here.

    +

    In SMESH you can remove nodes and all types of cells of your mesh.

    + +

     

    + +

    To remove a node:

    + +

     

    + +

    1. Select your mesh in the Object Browser + or in the 3D viewer.

    + +

     

    + +

    2. From the Modification + menu choose Remove and + from the associated submenu select the Remove + nodes, or just click icon in the toolbar. The + following dialog box will appear:

    + +

     

    + +

    + +

     

    + +

    In this dialog box you can specify one or + several nodes (with pressed Shift button) by choosing them in the 3D viewer.

    + +

     

    + +

    3. Click OK + or Apply  to + confirm deletion of the specified nodes.

    + +

     

    + +

    Be careful while removing + nodes because if you remove a definite node of your mesh all adjacent + elements will be also deleted.

    + +

     

    + + + +++ + + + +
    +

    +

    + +

     

    + +

     

    + +

    To remove an element:

    + +

     

    + +

    1. Select your mesh in the Object Browser + or in the 3D viewer.

    + +

     

    + +

    2. From the Modification + menu choose Remove and + from the associated submenu select the Remove + elements, or just click icon in the toolbar. The + following dialog box will appear:

    + +

     

    + +

    + +

     

    + +

    In this dialog box you can specify one or + several elements of your mesh (with pressed Shift button) by choosing + them in the 3D viewer.

    + +

     

    + +

    3. Click OK + or Apply  to + confirm deletion of the specified elements.

    + +

     

    + + + +++ + + + +
    +

    +

    + +

     

    + +

     

    + +

     

    + + + + + + + + + + + + + + + + +

    Renumbering nodes and elements

    + +

    In SMESH you can renumber the nodes and elements of your mesh.

    + +

     

    + +

    To renumber the nodes of your mesh:

    + +

     

    + +

    1. In the Modification + menu select Renumbering submenu + and choose the Nodes item or click + button in the toolbar. The following dialog box will + appear:

    + +

     

    + +

     

    + +

    + +

     

    + +

    2. Fill the Mesh + field by selecting your mesh in the Object Browser or in the 3D + viewer.

    + +

     

    + +

    3. Click the Apply + or OK button + to perform the operation.

    + +

     

    + +

     

    + +

    To renumber the elements of your mesh:

    + +

     

    + +

    1. In the Modification + menu select Renumbering submenu + and choose the Elements item or + click button in the toolbar. The following dialog box will + appear:

    + +

     

    + +

     

    + +

    + +

     

    + +

    2. Fill the Mesh + field by selecting your mesh in the Object Browser or in the 3D + viewer.

    + +

     

    + +

    3. Click the Apply + or OK button + to perform the operation.

    + +

     

    + +

     

    + +

     

    + + + + + diff --git a/doc/salome/gui/SMESH/files/rotation.htm b/doc/salome/gui/SMESH/files/rotation.htm new file mode 100755 index 000000000..7ec631e22 --- /dev/null +++ b/doc/salome/gui/SMESH/files/rotation.htm @@ -0,0 +1,151 @@ + + + + + + + + + + +Rotation + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Rotation

    + +

    This geometrical operation allows to rotate in space your mesh or some + of its elements.

    + +

     

    + +

     To + rotate your mesh:

    + +

     

    + +

    From the Modification + choose Transformation and +  from its + sub-menu select the Rotation item. + The following dialog box shall appear:

    + +

     

    + +

    + +

     

    + +

    In this dialog box you can specify the elements + which should be rotated and the rotation parameters:

    + +
      + +
    • Axis: + point and vector

    • + +
    • Angle + of rotation

    • +
    + +

     

    + +

    Create a + copy radio button allows to copy the rotated object.

    + + + + + diff --git a/doc/salome/gui/SMESH/files/running_smesh_module.htm b/doc/salome/gui/SMESH/files/running_smesh_module.htm index d42bc5018..430218edd 100755 --- a/doc/salome/gui/SMESH/files/running_smesh_module.htm +++ b/doc/salome/gui/SMESH/files/running_smesh_module.htm @@ -95,7 +95,7 @@ addButton("show",BTN_TEXT,"Show","","","","",0,0,"","",""); if (window.setRelStartPage) { - setRelStartPage("../smesh.html"); + setRelStartPage("../smesh.htm"); autoSync(0); sendSyncInfo(); diff --git a/doc/salome/gui/SMESH/files/scalar_bar_properties.htm b/doc/salome/gui/SMESH/files/scalar_bar_properties.htm index 793178598..2e301a78f 100755 --- a/doc/salome/gui/SMESH/files/scalar_bar_properties.htm +++ b/doc/salome/gui/SMESH/files/scalar_bar_properties.htm @@ -69,8 +69,7 @@ if (window.gbWhTopic) { if (window.addTocInfo) { - addTocInfo("SMESH module\nSetting SMESH preferences\nScalar Bar properties"); -addButton("show",BTN_TEXT,"Show","","","","",0,0,"","",""); + addButton("show",BTN_TEXT,"Show","","","","",0,0,"","",""); } if (window.writeBtnStyle) @@ -81,7 +80,7 @@ addButton("show",BTN_TEXT,"Show","","","","",0,0,"","",""); if (window.setRelStartPage) { - setRelStartPage("../smesh.html"); + setRelStartPage("../smesh.htm"); autoSync(0); sendSyncInfo(); diff --git a/doc/salome/gui/SMESH/files/sewing_meshes.htm b/doc/salome/gui/SMESH/files/sewing_meshes.htm new file mode 100755 index 000000000..e27d967c7 --- /dev/null +++ b/doc/salome/gui/SMESH/files/sewing_meshes.htm @@ -0,0 +1,328 @@ + + + + + + + + + + +Sewing meshes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Sewing meshes

    + +

    In SMESH you can sew elements of  different + meshes. The current functionality allows you to sew:

    + +

     

    + + + +

     

    + +

    To sew elements of different meshes:

    + +

     

    + +

    1. From the Modification + menu choose the Transformation + item and  from + its sub-menu select the Sewing item. + The following dialog box shall appear:

    + +

     

    + +

    + +

     

    + +

    2. In the upper part of this dialog box check + one of the radio buttons corresponding to the type of sewing operation + you would like to perform:

    + +

     

    + +

    + +

     

    + +

    3. Fill the other fields available in the + dialog box

    + +

    4. Click the OK + or Apply button + to perform the operation of sewing.

    + +

     

    + +

    Sew free borders

    + +

    This functionality allows you to unite two free borders of a 2D mesh.

    + +

     

    + +

    For sewing free borders you should define three points on each border: + first, second and the last node:

    + +

     

    + +
      + +
    •  the + first node specifies beginning of the border ;

    • + +
    •  the + second node specifies the part of the border which should be considered + (as far as the free border usually forms a closed contour);

    • + +
    •  the + last node specifies the end of the border.

    • +
    + +

     

    + +

    You can select these nodes in the 3D viewer or define by its id.

    + +

     

    + +

    The first and the second nodes should belong to the same link of a face. + The second and the last nodes of a border can be the same. The first and + the last nodes of two borders can be the same. The corresponding end nodes + of two borders will be merged. Intermediate nodes of two borders will + be either merged or inserted into faces of the opposite border.

    + +

     

    + +

    The sewing algorithm is as follows:

    + +

     

    + +

    1. The parameter (U) of each node within + a border is computed. So that the first node has U=0.0, the last node + has U=1.0, for the rest nodes 0.0 < U < 1.0;

    + +

    2. Compare node parameters of the two borders. + If two nodes of the opposite borders have close parameters, they are merged, + i.e. a node of the first border is replaced in all elements by a node + of the second border. If a node has no node with a close parameter in + the opposite border, it is inserted into an edge of element of the opposite + border, an element is split. Two nodes are considered close enough to + merge, if difference of their parameters is less than one fifth of minimum + length of adjacent face edges on the borders.

    + +

     

    + +

    + +

     

    + +

    Sew conform free borders

    + +

    This functionality can be used to unite two free borders of a 2D mesh.

    + +

     

    + +

    The borders of meshes for sewing are defined as for "Sew free borders" + except that the second free border is not limited and can be defined by + the first and the second nodes only. The first nodes of two borders can + be the same.

    + +

     

    + +

    + +

    The algorithm is following: counting nodes starting at the first ones, + the n-th node of the first border is merged with the n-th node of the + other border, until the end of either of borders. Nodes of the first border + are replaced in all elements with corresponding nodes of the second border.

    + +

    For sewing conform free borders you should define three points on the + first border and two points on the second one. User can select these nodes + in 3D viewer or define node by its id.

    + +

     

    + +

     

    + +

    Sew border to side

    + +

    "Sew border to side" is intended to sew a free border to a + mesh surface.

    + +

    The free border is defined as for "Sewing of free borders". + The place where to sew the border is defined by two nodes, between which + the border faces are placed, so that the first border node is merged with + the first node on the side and the last node of the border is merged with + the second specified node on the side.

    + +

     

    + +

    + +

    The algorithm is following.

    + +

    1. Find a sequence of linked nodes on the side such that the found links + to be most co-directed with the links of the free border.

    + +

    2. Sew two sequences of nodes using algorithm of "Sewing of free + berders".

    + +

    For sewing border to side you should define three points on the border + and two points on the side. User can select these nodes in 3D viewer or + define node by its id.

    + +

     

    + +

    Sew side elements

    + +

     

    + +

     

    + +

    + +

    This operation is intended to unite two mesh surfaces.

    + +

    Surfaces may be defined by either 2d or 3d elements. The number of given + elements of the sides must be the same. The sets of given elements must + be topologically equal, i.e. each node of one element set must have a + corresponding node in the other element set and corresponding nodes must + be equally linked. If there are 3d elements in a set, only their free + faces must obey to that rule.

    + +

    Two corresponding nodes on each side must be specified. They must belong + to one element and must be located on an element set boundary.

    + +

    Sewing algorithm finds and merges the corresponding nodes starting from + the specified ones.

    + +

     

    + +

    + +

    For sewing side elements you should define elements for sewing and two + nodes for merging on the each side. User can select these elements and + nodes in 3D viewer or define them by its id.

    + +

     

    + + + + + diff --git a/doc/salome/gui/SMESH/files/shading.htm b/doc/salome/gui/SMESH/files/shading.htm index 28db384ad..2d937e4de 100755 --- a/doc/salome/gui/SMESH/files/shading.htm +++ b/doc/salome/gui/SMESH/files/shading.htm @@ -85,7 +85,7 @@ if (window.gbWhTopic) if (window.setRelStartPage) { - setRelStartPage("../smesh.html"); + setRelStartPage("../smesh.htm"); autoSync(0); sendSyncInfo(); diff --git a/doc/salome/gui/SMESH/files/shrink.htm b/doc/salome/gui/SMESH/files/shrink.htm index e7bc1038e..53386bb7e 100755 --- a/doc/salome/gui/SMESH/files/shrink.htm +++ b/doc/salome/gui/SMESH/files/shrink.htm @@ -85,7 +85,7 @@ if (window.gbWhTopic) if (window.setRelStartPage) { - setRelStartPage("../smesh.html"); + setRelStartPage("../smesh.htm"); autoSync(0); sendSyncInfo(); diff --git a/doc/salome/gui/SMESH/files/skew.htm b/doc/salome/gui/SMESH/files/skew.htm index 39f2f82db..24198ba15 100755 --- a/doc/salome/gui/SMESH/files/skew.htm +++ b/doc/salome/gui/SMESH/files/skew.htm @@ -102,7 +102,7 @@ addButton("show",BTN_TEXT,"Show","","","","",0,0,"","",""); if (window.setRelStartPage) { - setRelStartPage("../smesh.html"); + setRelStartPage("../smesh.htm"); autoSync(0); sendSyncInfo(); diff --git a/doc/salome/gui/SMESH/files/smoothing.htm b/doc/salome/gui/SMESH/files/smoothing.htm new file mode 100755 index 000000000..8d87e630d --- /dev/null +++ b/doc/salome/gui/SMESH/files/smoothing.htm @@ -0,0 +1,217 @@ + + + + + + + + + + +Smoothing + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Smoothing

    + +

    Smoothing is used to adjust the locations of element + corners (nodes) to reduce distortions in these elements.

    + +

     

    + +

    To apply smoothing to the elements of your mesh:

    + +

     

    + +

    1. Display a mesh or a submesh in the 3D + viewer.

    + +

     

    + +

    2. In the Modification + menu select the Smoothing item + or click button in the toolbar. The following dialog box + will appear:

    + +

     

    + +

    + +

     

    + +

    This dialog box contains the following fields + which should be specified:

    + +

     

    + +
      + +
    • Id Elements field allows to specify + the elements which should be smoothed by selecting them in the 3D viewer. + Note: to select several elements press Shift + button.

    • + +
        + +
      • Smoothing is applied + to the whole mesh or its part

      • + +
      • Fixed nodes + ids: some nodes keep their location during smoothing. If a mesh + is built on a geometry shape, the nodes built on geometrical edges are + always fixed. If smoothing is applied to a part of a mesh then the boundary + nodes of an elements set are also fixed. Any other nodes may be additionally + fixed.

      • + +
      •  

      • + +
      • Smoothing + method:

      • + +
          + +
        • Laplacian + smoothing pulls a node toward the center of surrounding nodes directly + connected to that node along an element edge. Centroidal smoothing pulls + a node toward the element-area-weighted centroid of the surrounding elements. + Typically, the Laplacian method will produce the mesh with the least element + distortion. It is also the faster method.

        • + +
        • Centroidal + smoothing usually produces a mesh that has more uniform element sizes. + Both methods produce good results with "free" meshes.

        • +
        +
      +
    + +

    + +
      + +
    • Iteration limit: both of the smoothing + methods use an iterative procedure to converge toward a smoothed mesh. + All nodes are smoothed according to one of the techniques shown above. + Then the smoothing is reevaluated with the updated nodal locations. This + process continues until the maximum number of iterations has been exceeded, + or all elements has aspect ratio less or equal than the specified one.

    • + +
    • Max. aspect ratio.

    • +
    + +

     

    + +

    3. Click the Apply + or OK button to confirm + the operation.

    + +

     

    + +

     

    + +

     

    + + + + + diff --git a/doc/salome/gui/SMESH/files/start_and_end_length_hypothesis.htm b/doc/salome/gui/SMESH/files/start_and_end_length_hypothesis.htm new file mode 100755 index 000000000..3a8059d29 --- /dev/null +++ b/doc/salome/gui/SMESH/files/start_and_end_length_hypothesis.htm @@ -0,0 +1,165 @@ + + + + + + + + + + +Start and End Length hypothesis + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Start and End Length hypothesis

    + +

    Start and End Length + hypothesis is used to build 1D mesh on geometrical edges.

    + +

    A geometrical edge is divided into segments so that the first and the + last segments have a specified length. Length of each but the first segment + differs from length of the previous one by a constant factor. Then mesh + nodes are constructed at segment ends location and 1D mesh elements are + constructed on them.

    + +

     

    + +

    To define the Average Length hypothesis:

    + +

     

    + +

    Select this hypothesis s in the + Create Hypotheses dialog box + click Create. The following dialog + box will appear:

    + +

     

    + +

    + +

     

    + +

    In this dialog box you can set:

    + +

     

    + +
      + +
    • Name + of your Start and End Length hypothesis

    • + +
    • Start + and End Length of segments

    • +
    + + + + + diff --git a/doc/salome/gui/SMESH/files/symmetry.htm b/doc/salome/gui/SMESH/files/symmetry.htm new file mode 100755 index 000000000..446029ce2 --- /dev/null +++ b/doc/salome/gui/SMESH/files/symmetry.htm @@ -0,0 +1,164 @@ + + + + + + + + + + +Symmetry + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Symmetry

    + +

    This geometrical operation allows to perform a symmetrical copy of your + mesh or some of its elements.

    + +

     

    + +

     To + apply symmetry to your mesh:

    + +

     

    + +

    From the Modification + choose Transformation and +  from its + sub-menu select the Symmetry item. + The following dialog box shall appear:

    + +

     

    + +

    + +

     

    + +

    + +

     

    + +

    + +

     

    + +

    This operation has three options, you can + symmetrically copy your mesh or some of its elements specifying:

    + +
      + +
    • one point

    • + +
    • one axis (point and + vector)

    • + +
    • one plane (point and + normal)

    • +
    + +

     

    + +

    Create a + copy radio button allows to keep the initial elements or + mesh.

    + + + + + diff --git a/doc/salome/gui/SMESH/files/taper.htm b/doc/salome/gui/SMESH/files/taper.htm index 958fd05f9..38e4f8951 100755 --- a/doc/salome/gui/SMESH/files/taper.htm +++ b/doc/salome/gui/SMESH/files/taper.htm @@ -90,7 +90,7 @@ addButton("show",BTN_TEXT,"Show","","","","",0,0,"","",""); if (window.setRelStartPage) { - setRelStartPage("../smesh.html"); + setRelStartPage("../smesh.htm"); autoSync(0); sendSyncInfo(); diff --git a/doc/salome/gui/SMESH/files/tetrahedron_(ghs3d)_meshing_algorithm.htm b/doc/salome/gui/SMESH/files/tetrahedron_(ghs3d)_meshing_algorithm.htm new file mode 100755 index 000000000..f2364d118 --- /dev/null +++ b/doc/salome/gui/SMESH/files/tetrahedron_(ghs3d)_meshing_algorithm.htm @@ -0,0 +1,130 @@ + + + + + + + + + + +Tetrahedron (GHS3D) meshing algorithm + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Tetrahedron (GHS3D) meshing algorithm

    + +

    This algorithm is used for meshing of 3D entities of + geometrical objects - volume objects. + While NETGEN + generates 3D elements having a volume less than the one specified by hypothesis, + GHS3D does not need any hypotheses, all it needs is a surface mesh built + in advance

    + +

     

    + +

     

    + +

    To apply the Tetrahedron GHS3D meshing algorithm:

    + +

     

    + +

    In + the Create Algorithms dialog box + select this algorithm and click Create.

    + + + + + diff --git a/doc/salome/gui/SMESH/files/tetrahedron_(netgen)_meshing_algorithm.htm b/doc/salome/gui/SMESH/files/tetrahedron_(netgen)_meshing_algorithm.htm index c9f35898c..c788450f2 100755 --- a/doc/salome/gui/SMESH/files/tetrahedron_(netgen)_meshing_algorithm.htm +++ b/doc/salome/gui/SMESH/files/tetrahedron_(netgen)_meshing_algorithm.htm @@ -19,8 +19,8 @@ - - + + @@ -36,9 +36,23 @@ if (navigator.appName !="Netscape") + + + + + + + + + + + + + + + + + +

    Translation

    + +

    This geometrical operation allows to translate in space your mesh or + some of its elements.

    + +

     

    + +

     To + translate your mesh:

    + +

     

    + +

    From the Modification + choose Transformation and +  from its + sub-menu select the Translation item. + The following dialog box shall appear:

    + +

     

    + +

    + +

     

    + +

    This operation has two options, you can translate + in space your mesh or some of its elements specifying:

    + +
      + +
    • two points (starting + and ending)

    • + +
    • one vector

    • +
    + +

    Create a + copy radio button allows to copy the translated object.

    + + + + + diff --git a/doc/salome/gui/SMESH/files/uniting_a_set_of_triangles.htm b/doc/salome/gui/SMESH/files/uniting_a_set_of_triangles.htm new file mode 100755 index 000000000..460599634 --- /dev/null +++ b/doc/salome/gui/SMESH/files/uniting_a_set_of_triangles.htm @@ -0,0 +1,191 @@ + + + + + + + + + + +Uniting a set of triangles + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Uniting a set of triangles

    + +

    In contrast to the + previous operation this one allows to unite at once many triangles + if they have adjacent edges.

    + +

     

    + +

    To union several triangles:

    + +

     

    + +

    1. Display a mesh or a submesh in the 3D + viewer.

    + +

     

    + +

    2. In the Modification + menu select the Union of triangles + item or click button in the toolbar. The following + dialog box will appear:

    + +

     

    + +

    + +

     

    + +
      + +
    • The main list shall contain the triangles + which will be united. You can click on an triangle in the 3D viewer and + it will be highlighted. After that click the Add + button and the ID of this triangle will be added to the list. To + remove a selected element or elements from the list click the Remove + button. The Sort button + allows to sort the list of IDs. The Set + filter button allows to apply a definite filter to selection of + triangles.

    • + +
    • Apply to all radio button allows + to modify the orientation of all triangles of the currently displayed + mesh or submesh.

    • + +
    • Select from set of fields allows to + choose a submesh or an existing group whose triangle elements will be + automatically added to the list.

    • +
    + +

     

    + +

    3. Click the Apply + or OK button to confirm + the operation.

    + +

     

    + +

    If some selected triangle + elements have no adjacent edges with one of the others, the operation + on these elements shall take no effect.

    + +

     

    + + + + + diff --git a/doc/salome/gui/SMESH/files/uniting_two_triangles.htm b/doc/salome/gui/SMESH/files/uniting_two_triangles.htm new file mode 100755 index 000000000..7d1d9999a --- /dev/null +++ b/doc/salome/gui/SMESH/files/uniting_two_triangles.htm @@ -0,0 +1,166 @@ + + + + + + + + + + +Uniting two triangles + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Uniting two triangles

    + +

     In SMESH + you can union two neighboring triangles (cells) by deletion of the common + edge.

    + +

     

    + +

    To unite two triangles:

    + +

     

    + +

    1. From the Modification + menu choose the Union of two triangles + item or click button in the toolbar. The following + dialog box shall appear:

    + +

     

    + +

    + +

     

    + +

    2. Enter the ID of the required edge in the + Edge  field + or select this edge in the 3D viewer.

    + +

     

    + +

    3. Click the Apply + or OK button.

    + +

     

    + +

     

    + + + +++ + + + +
    +

    +

    + + + + + diff --git a/doc/salome/gui/SMESH/files/using_operations_on_groups.htm b/doc/salome/gui/SMESH/files/using_operations_on_groups.htm new file mode 100755 index 000000000..3320787f2 --- /dev/null +++ b/doc/salome/gui/SMESH/files/using_operations_on_groups.htm @@ -0,0 +1,243 @@ + + + + + + + + + + +Using operations on groups + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Using operations on groups

    + +

    In SMESH you can + perform  Boolean + operations on groups such as:

    + +

     

    + + + +

     

    + +

    Union of two groups

    + +

    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.

    + +

     

    + +

    To union two groups:

    + +

     

    + +

    1. In the Mesh + menu select the Union Groups item. + The following dialog box will appear:

    + +

     

    + +

    + +

     

    + +

    In this dialog box you should specify the + name of the resulting group and + two groups which will be united.

    + +

     

    + +

    2. Click the OK + or  Apply + button to confirm creation of the group.

    + +

     

    + +

     

    + +

    Intersection of two groups

    + +

    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 new + one.

    + +

     

    + +

    To intersect two groups:

    + +

     

    + +

    1. In the Mesh + menu select the Intersect Groups + item. The following dialog box will appear:

    + +

     

    + +

    + +

     

    + +

    In this dialog box you should specify the + name of the resulting group and + two groups which will be intersected.

    + +

     

    + +

    2. Click the OK + or  Apply + button to confirm creation of the group.

    + +

     

    + +

     

    + +

    Cut of two groups

    + +

    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.

    + +

     

    + +

    To cut two groups:

    + +

     

    + +

    1. In the Mesh + menu select the Cut Groups item. + The following dialog box will appear:

    + +

     

    + +

    + +

     

    + +

    In this dialog box you should specify the + name of the resulting group and + two groups which will be cut.

    + +

     

    + +

    2. Click the OK + or  Apply + button to confirm creation of the group.  

    + +

     

    + +

     

    + +

     

    + + + + + diff --git a/doc/salome/gui/SMESH/files/using_smesh_module.htm b/doc/salome/gui/SMESH/files/using_smesh_module.htm index 6a3250b03..92fc07c05 100755 --- a/doc/salome/gui/SMESH/files/using_smesh_module.htm +++ b/doc/salome/gui/SMESH/files/using_smesh_module.htm @@ -80,7 +80,7 @@ if (window.gbWhTopic) if (window.setRelStartPage) { - setRelStartPage("../smesh.html"); + setRelStartPage("../smesh.htm"); autoSync(0); sendSyncInfo(); diff --git a/doc/salome/gui/SMESH/files/view_update.htm b/doc/salome/gui/SMESH/files/view_update.htm index d9a84057f..add17849a 100755 --- a/doc/salome/gui/SMESH/files/view_update.htm +++ b/doc/salome/gui/SMESH/files/view_update.htm @@ -74,8 +74,7 @@ if (window.gbWhTopic) { if (window.addTocInfo) { - addTocInfo("SMESH module\nSetting SMESH preferences\nView update"); -addButton("show",BTN_TEXT,"Show","","","","",0,0,"","",""); + addButton("show",BTN_TEXT,"Show","","","","",0,0,"","",""); } if (window.writeBtnStyle) @@ -86,7 +85,7 @@ addButton("show",BTN_TEXT,"Show","","","","",0,0,"","",""); if (window.setRelStartPage) { - setRelStartPage("../smesh.html"); + setRelStartPage("../smesh.htm"); autoSync(0); sendSyncInfo(); diff --git a/doc/salome/gui/SMESH/files/viewing_mesh_info.htm b/doc/salome/gui/SMESH/files/viewing_mesh_info.htm index 956791a89..012d1bca3 100755 --- a/doc/salome/gui/SMESH/files/viewing_mesh_info.htm +++ b/doc/salome/gui/SMESH/files/viewing_mesh_info.htm @@ -19,8 +19,8 @@ - - + + @@ -38,7 +38,7 @@ p.whs1 {margin-left: 40px;} img_whs2 {border-style: none; border: none; width: 21px; height: 20px;} p.whs3 {margin-left: 0px;} p.whs4 {margin-left: 80px;} -img_whs5 {border-style: none; border: none; width: 258px; height: 282px;} +img_whs5 {border: none; width: 190px; height: 350px;} -->

+

 

+ +

To set the visualization mode for displaying of your mesh:

+ +

 

+ +

1. Select your mesh in the Object + Browser.

+ +

 

+ +

2. Right-click on the mesh in the viewer + and from the pop-up menu select Properties + > Display mode

+ + + + + + + + + + + + + + + + + + +

Pattern mapping

+ +

About patterns

+ +

The pattern describes a mesh to generate: positions of + nodes within a geometrical domain and nodal connectivity of elements. + As well, a pattern specifies the so-called key-points, i.e. nodes that + will be located at geometrical vertices. Pattern description is stored + in <pattern_name>.smp file.

+ +

 

+ +

The smp file contains 4 sections:

+ +

 

+ +

1. The first line holds the number of nodes + (N).

+ +

 

+ +

2. The next N lines describe nodes coordinates. + Each line holds 2 coordinates of a node.

+ +

 

+ +

3. A key-points line: indices of nodes to + be mapped on geometrical vertices. An index n refers to a node described + on an n-th line of section 2. The first node index is zero.

+ +

 

+ +

4. The rest lines describe nodal connectivity + of elements, one line for an element. A line holds indices of nodes forming + an element. An index n refers to a node described on an n-th line of the + section 2. The first node index is zero. There must be 3 or 4 indices + on a line: only 2d elements are allowed.

+ +

 

+ +

The 2D pattern must contain at least one element and at least one key-point. + All key-points must lay on boundaries.

+ +

 

+ +

An example of a simple smp file and a preview of a pattern described + in this file:

+ +

 

+ +

+ +

 

+ +

Creating patterns

+ +

The pattern description can be created manually or automatically. Manual + pattern creation implies creation of pattern file by hands. For an automatic + generation the user just specifies a geometrical face having a mesh built + on it. Mesh nodes lying on face vertices become key-points. Additionally, + the user may choose the way of getting nodes coordinates by projecting + nodes on the face instead of using "positions on face" generated + by mesher (if there are any). Faces having a seam edge canÂ’t be used for + automatic pattern creation.

+ +

 

+ +

When creating a pattern from an existing mesh, there are two possible + cases:

+ +

 

+ +

1. A sub-mesh on face is selected. A pattern is created from the 2d + elements bound to a face by mesher. Node coordinates are either "positions + on face" computed by mesher, or coordinates got by node projection + on a geometrical surface, according to your choice.

+ +

 

+ +

2. A mesh where the main shape is a face, is selected. A pattern is + created from all the 2d elements in a mesh. If all mesh elements are build + by mesher, the user can select the way of getting nodes coordinates, else + all nodes are projected on a face surface.

+ +

 

+ +

Application of pattern mapping

+ +

To apply pattern mapping to a geometrical object:

+ +

 

+ +

1. From the Modification + menu choose the Pattern Mapping + item or click button in the toolbar. The following + dialog box shall appear:

+ +

 

+ + + +++ + + + +
+

+

+ +

 

+ +

To apply a pattern to a geometrical object, you should specify:

+ +

 

+ +

- a face having the number of vertices equal + to the number of key-points in the pattern; the number of key-points on + internal boundaries of a pattern must also be equal to the number of vertices + on internal boundaries of a face;

+ +

- a vertex to which the first key-point should + be mapped,

+ +

- reverse or not the order of key-points. + (The order of vertices of a face is counterclockwise looking from outside).

+ +

 

+ +

 

+ +

Mapping algorithm:

+ +

The mapping algorithm is as follows:

+ +

 

+ +

1. Key-points are set in the order that they + are encountered when walking along a pattern boundary so that elements + are on the left. The first key-point is preserved.

+ +

2. Find geometrical vertices corresponding + to key-points by vertices order in a face boundary; here, "Reverse + order of key-points" flag is taken into account.

+ +

 

+ +

+ +

 

+ +

3. Boundary nodes of a pattern are mapped + onto edges of a face: a node located between certain key-points on a pattern + boundary is mapped on a geometrical edge limited by corresponding geometrical + vertices. Node position on an edge reflects its distance from two key-points.

+ +

 

+ +

+ +

 

+ +

4. Coordinates of a non-boundary node in + a parametric space of a face are defined as following. In a parametric + space of a pattern, a node lays at the intersection of two iso-lines, + each of which intersects a pattern boundary at least at two points. Knowing + mapped positions of boundary nodes, we find where isoline-boundary intersection + points are mapped to, and hence we can find mapped isolines direction + and then, two node positions on two mapped isolines. The eventual mapped + position of a node is found as an average of positions on mapped isolines.

+ +

 

+ +

+ + + + + diff --git a/doc/salome/gui/SMESH/revolution.htm b/doc/salome/gui/SMESH/revolution.htm new file mode 100755 index 000000000..515b1a45d --- /dev/null +++ b/doc/salome/gui/SMESH/revolution.htm @@ -0,0 +1,171 @@ + + + + + + + + + + +Revolution + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Revolution

+ +

Revolution is a type of surface meshing by generation from discretized + lines. It is used to build mesh elements of plus one dimension than the + swept ones. Each swept 1D element produces one or more quadrangles (or + triangles if one node of a rotated element lays on the revolution axis).

+ +

 

+ +

To apply revolution:

+ +

 

+ +

1. From the Modification + menu choose the Revolution item + or click button in the toolbar. The following dialog box + shall appear:

+ +

 

+ +

+ +

 

+ +

2. In this dialog box you should specify:

+ +
    + +
  • the type of elements + which will be extruded (1D or 2D),

  • + +
  • specify the IDs of + the elements which will be revolved by selecting them in the 3D viewer + or select the whole mesh or submesh,

  • + +
  • specify the axis (point + and vector) around which the elements will be revolved,

  • + +
  • angle of rotation,

  • + +
  • number of steps,

  • + +
  • tolerance of rotation

  • +
+ +

 

+ +

3. Click the Apply + or OK button.

+ +

 

+ +

+ +

 

+ +

 

+ + + + + diff --git a/doc/salome/gui/SMESH/smesh.htm b/doc/salome/gui/SMESH/smesh.htm new file mode 100755 index 000000000..c5c12b4e7 --- /dev/null +++ b/doc/salome/gui/SMESH/smesh.htm @@ -0,0 +1,150 @@ + + + + SMESH reference manual + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/doc/salome/gui/SMESH/smesh_csh.htm b/doc/salome/gui/SMESH/smesh_csh.htm new file mode 100755 index 000000000..187fb111f --- /dev/null +++ b/doc/salome/gui/SMESH/smesh_csh.htm @@ -0,0 +1,100 @@ + + +SMESH reference manual + + + + + + + + + + + + + \ No newline at end of file diff --git a/doc/salome/gui/SMESH/smesh_rhc.htm b/doc/salome/gui/SMESH/smesh_rhc.htm new file mode 100755 index 000000000..9acb37e4c --- /dev/null +++ b/doc/salome/gui/SMESH/smesh_rhc.htm @@ -0,0 +1,100 @@ + + +SMESH reference manual + + + + + + + + + + + + + \ No newline at end of file diff --git a/doc/salome/gui/SMESH/tetrahedron_(ghs3d)_meshing_algorithm.htm b/doc/salome/gui/SMESH/tetrahedron_(ghs3d)_meshing_algorithm.htm new file mode 100755 index 000000000..e6c912b52 --- /dev/null +++ b/doc/salome/gui/SMESH/tetrahedron_(ghs3d)_meshing_algorithm.htm @@ -0,0 +1,132 @@ + + + + + + + + + + +Tetrahedron (GHS3D) meshing algorithm + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Tetrahedron (GHS3D) meshing algorithm

+ +

This algorithm is used for meshing of 3D entities of + geometrical objects - volume objects. + While NETGEN + generates 3D elements having a volume less than the one specified by hypothesis, + GHS3D does not need any hypotheses, all it needs is a surface mesh built + in advance

+ +

 

+ +

 

+ +

To apply the Tetrahedron GHS3D meshing algorithm:

+ +

 

+ +

From the Hypotheses + menu select Create Algorithms + >  Tetrahedron (GHS3D) and + click Create.

+ + + + + diff --git a/doc/salome/gui/SMESH/whdata/whftdata0.htm b/doc/salome/gui/SMESH/whdata/whftdata0.htm index fe18c10da..22a15d7e5 100755 --- a/doc/salome/gui/SMESH/whdata/whftdata0.htm +++ b/doc/salome/gui/SMESH/whdata/whftdata0.htm @@ -10,6 +10,7 @@ diff --git a/doc/salome/gui/SMESH/whdata/whftdata0.xml b/doc/salome/gui/SMESH/whdata/whftdata0.xml index 3a6d528f3..e76c52606 100755 --- a/doc/salome/gui/SMESH/whdata/whftdata0.xml +++ b/doc/salome/gui/SMESH/whdata/whftdata0.xml @@ -1,5 +1,6 @@ + @@ -11,37 +12,60 @@ + + + + + + + - - + + + + + + + + + + + + + + + + + + diff --git a/doc/salome/gui/SMESH/whdata/whfts.htm b/doc/salome/gui/SMESH/whdata/whfts.htm index 977cbfa97..c66f6baf4 100755 --- a/doc/salome/gui/SMESH/whdata/whfts.htm +++ b/doc/salome/gui/SMESH/whdata/whfts.htm @@ -6,9 +6,9 @@ diff --git a/doc/salome/gui/SMESH/whdata/whfts.xml b/doc/salome/gui/SMESH/whdata/whfts.xml index 8322231b5..f8bc49348 100755 --- a/doc/salome/gui/SMESH/whdata/whfts.xml +++ b/doc/salome/gui/SMESH/whdata/whfts.xml @@ -1,7 +1,7 @@ - + - + diff --git a/doc/salome/gui/SMESH/whdata/whfwdata0.htm b/doc/salome/gui/SMESH/whdata/whfwdata0.htm index 8b0a6b8e3..36480d595 100755 --- a/doc/salome/gui/SMESH/whdata/whfwdata0.htm +++ b/doc/salome/gui/SMESH/whdata/whfwdata0.htm @@ -10,346 +10,600 @@ diff --git a/doc/salome/gui/SMESH/whdata/whfwdata0.xml b/doc/salome/gui/SMESH/whdata/whfwdata0.xml index 66eddc02d..608b52b45 100755 --- a/doc/salome/gui/SMESH/whdata/whfwdata0.xml +++ b/doc/salome/gui/SMESH/whdata/whfwdata0.xml @@ -1,344 +1,598 @@ - 5, - 5, - 10,11,13,19,20,22,24,28,34,35,39,42, - 0,5,6,23, - 10,11,13,19,20,22,24,28,34,35,39,42, - 1,2,5,6,10,11,23,26,28,42, - 5,10,11,22,32,34,42, - 3,5,6,23,27,36, - 5, - 5,10,11,34,35,42, - 5, - 25,29, - 8,10,11,24,28,34,35,42, - 4, - 9, - 23, - 5,32, - 28, - 0,1,2,3,4,5,6,8,10,15,16,23,26,27,30,36, - 4,22,23, - 8,23,28,34,42, - 5, - 0,1,2,3,10,11,23,24,28,34,35,36,42, - 15,16,25,26,27,29,32, - 10,11,24,25,26,27,28,29,34,35,42, - 8, - 4,15,16, - 29, - 42, - 4,8,10,23,26,27,35, - 8,11,23, - 42, - 25,42, - 42, - 8,33, - 4,10,23,42, - 5, - 4, - 32, - 42, - 42, - 23, - 32, - 5, - 4, - 15,16,22,25,26,27,29,32, - 13,39, - 0,1,2,3,10,11,13,15,16,22,24,25,26,27,28,29,34,35,36,39,42, - 5, - 8,11,35, - 4,10,24,28, - 12, - 8, - 5, - 4, - 10,11,22,24,28,32,34,35,42, - 26,27, - 0,1,2,3,10,11,13,15,16,22,24,25,26,27,28,29,32,34,35,36,39,42, - 5, - 8,10,11,24,28,34,35,42, - 24, - 23,32, - 4,5,6,8,19,25,26,27,29,34, - 13, - 13,15,16, - 4, - 5,23, - 14, - 5, - 8,10,11,15,16,24,25,26,27,28,29,35, - 15,16, - 15,16, - 5,6,22, - 5, - 8,10,11,23,24,28,34,35,42, - 5, - 42, - 42, - 5,8,22, - 5, - 5,23,32,42, - 5,32, - 23, - 10,11,24,28,34,35,42, - 42, - 5, - 5, - 32, - 5,11,25,26,27,29, - 5,8,23,29, - 25,26,27,29, - 23, - 4,5,26,27, - 5, - 32, - 5,8,23, - 4, - 17,35, - 15,16,22,25,26,27,29, - 4, - 5, - 5, - 42, - 0,5,6, - 18, - 8,10,11,19,20,24,28,34,35,39,40,42, - 8, - 42, - 5, - 0,4,5,6,8,11,23,24,25,29,42, - 21, - 4,5,8,9,10,11,12,17,19,23,24,26,27,28,31,34,35,42, - 16, - 22, - 0,1,2,3,5,6,36, - 5, - 11, - 11, - 8, - 42, - 5, - 22,23, - 22, - 42, - 1,2,4,5,6,23,25,26,29,42, - 22, - 13, - 22, - 5, - 4,5,6,8,11,15,16,19,20,25,26,27,29,32,39, - 22,23, - 5,42, - 5,23, - 5, - 5,22, - 4,5,8,23,25,29,32, - 13, - 5,23, - 5,8, - 0,1,2,3,4,5,6,15,16,23,25,26,27,29,36, - 15, - 23, - 42, - 11, - 11, - 42, - 11,42, - 8, - 5,7,9,12,14,17,18,31,33,41, - 3,5,6,27, - 5, - 15,16, - 0,1,2,3,4,15,16,21,23,25,26,27,29,30,36, - 4,25,26,27,29, - 3, - 32, - 19,20, - 5, - 5, - 22,23, - 22, - 5, - 42, - 39, - 5,39, - 32, - 5, - 23, - 5, - 17, - 22, - 3, - 34, - 3, - 6, - 42, - 11, - 32, - 4,8,11,23,24,25,29,42, - 4, - 19,20,32, - 5,34, - 4,16,23,25,29, - 22, - 11, - 19,20,32, - 5, - 32, - 4, - 1, - 4,23,26,27, - 26,27,34, - 5, - 5, - 42, - 2, - 0,1,2,3,13,15,16,19,20,22,25,26,27,29,32,36,39, - 0,1,2,3,4,5,6,7,8,10,11,13,15,16,19,20,22,23,24,25,26,27,28,29,32,34,35,36,39,40,42, - 8,23,28, - 40, - 5,23, - 5,7,23, - 5,6,23,32, - 23, - 23, - 11, - 22,25,26,27,29, - 29, - 36, - 32, - 5,9,10,11,18,20,23,25,29,31,34,35,42, - 42, - 5, - 4,5,23,29, - 19,20, - 0,1,2,3,4,6,13,15,16,25,26,27,29,36,39, - 22, - 5,15,16, - 23, - 34, - 5, - 5, - 12, - 42, - 5, - 5, - 4, - 5, - 5, - 11, - 23, - 42, - 42, - 32, - 5,25,29,42, - 5, - 4, - 5, - 8, - 4, - 15,16,23, - 11, - 5, - 42, - 42, - 33,41, - 42, - 1,5,6,10,11,24,26,28,34, - 8,10,11,23,24,28,34,35,42, - 4, - 8,11,23,35,42, - 30, - 5,8, - 4, - 34, - 32, - 5, - 5, - 11, - 31, - 11, - 4,5,25,29,35, - 5, - 5, - 4, - 11, - 5, - 4, - 32, - 11, - 23,32, - 5,29, - 8,33, - 5, - 22, - 4,23,25,29, - 0,1,2,3,4,13,15,16,19,20,22,25,26,27,29,32,36,39, - 5, - 35, - 5,6,23,25,26,27,29,32, - 40, - 4,5,11, - 11,42, - 32, - 8, - 40, - 11,28,34, - 5, - 8,23,34, - 4,5,6,8,19,20,22,23,32,37,40, - 4,11,35, - 5, - 25,29, - 22,32, - 32, - 13, - 32, - 22, - 4,16, - 5, - 5, - 5, - 4, - 8,23,35, - 5,6,27,36, - 7,9,12,14,17,18,31,33,41, - 5,40, - 0,1,2,3,11,13,15,16,24,32,34,35,36,39,42, - 7,9,12,14,17,18,31,33,41, - 5, - 5, - 2,5,6,10,11,24,26,28,34,35, - 5,11,28,35, - 5,7,9,12,14,17,18,31,33,41, - 5, - 22, - 32,38, - 0,1,2,3,5,6,15,16,25,29,36,37, - 8, - 5, - 8,11,28,34, - 42, - 5, - 10,11,19,20,24,28,32,34,35,38,39,40,42, - 8, - 40,41, - 3,4,5,6,23,27,36, - 32, - 8,23,42, - 5, - 4,5,10,11,15,16,19,20,22,24,25,26,27,28,29,32,34,35,39,42, - 32, - 0,6, - 40, - 29, - 32, - 5,42, - 5, - 4,5,8,10,11,13,16,19,20,22,24,25,26,27,28,29,34,35,39,42, - 5, + 6,47, + 6, + 10,11,12,13,14,15,20,21,23,24,25,26,27,28,0,29,32,36,37,65,41,42,43,66,47,48,49,52,56,57,58,61,62,64, + 1,5,6,7,12,0,30,34,31,40,66,50, + 10,11,13,14,15,20,21,23,24,25,26,27,28,0,29,32,37,65,41,42,43,66,47,48,49,52,56,57,58,61,62,64, + 2,3,6,7,11,13,0,30,34,31,37,65,66,47,64, + 6,11,13,14,21,23,24,0,29,65,41,42,43,66,45,47,48,49,56,57,64, + 4,6,7,10,14,20,21,23,24,25,26,0,30,41,42,43,66,47,49,53,54,56,57, + 6, + 6,11,13,21,24,65,47,48,52,64, + 6, + 41, + 49, + 58, + 33,22,39, + 9,11,13,32,37,65,48,49,52,64, + 5,65, + 10,14,20,21,56,58, + 10,14,20,21,27,56, + 21,30, + 6,65,45,49, + 24,37,35,38,42,47,56, + 49, + 53, + 41, + 1,2,3,4,5,6,7,9,11,12,18,19,28,30,65,41,47,53,54, + 5,12,14,20,21,29,30,36,35,38,65,40,44,47,49,51,55,56,58, + 0,65,49, + 28, + 49, + 9,30,37,66,44,48,64, + 40, + 6,24,65,49,53, + 1,2,3,4,7,10,11,13,14,20,21,23,24,27,0,30,34,31,32,37,35,38,65,40,41,42,43,66,47,48,49,51,52,53,54,56,57,58,64, + 5,7,10,12,14,18,19,20,21,23,24,27,28,0,33,22,36,39,65,41,42,43,66,44,45,47,49,50,51,55,56,57,58, + 11,13,18,19,28,32,33,22,37,39,41,48,49,52,64, + 9,65, + 5,18,19, + 39, + 64, + 5,9,11,30,49,52, + 5,12, + 66, + 9,13,30,49, + 41,64, + 10,25,26,28,41,42, + 65, + 14,21,24,65,56, + 41,47, + 5,34,31,33,22,65,50,64, + 0,66,44,51,64, + 9,46, + 5,11,30,64, + 6,18,19, + 5, + 65, + 45, + 12,47, + 47, + 47, + 64, + 64, + 58, + 47, + 30,47, + 49,58, + 45, + 6,65, + 65, + 5,65,47,49, + 1,2,3,4,5,10,12,14,18,19,20,21,23,24,27,28,0,29,34,31,33,22,36,35,38,39,65,40,41,42,43,66,44,45,47,49,50,51,53,54,55,56,57,58, + 5,7,10,15,17,18,19,20,27,28,41,42,43,61,62, + 0,34,31,65,66,50, + 65,49,53, + 10,11,13,14,15,18,19,20,21,23,24,27,28,0,29,32,37,65,41,42,43,66,44,47,48,49,51,52,55,56,57,58,61,64, + 6, + 65, + 9,13,34,31,52, + 5,11,32,37, + 20, + 42, + 24,65, + 42,57, + 49, + 49, + 49, + 65, + 12,14,20,24,28,41, + 9, + 6, + 47, + 5,65, + 10,11,13,14,17,20,21,23,24,25,26,0,29,32,36,37,65,41,42,43,66,44,45,47,48,51,52,55,56,57,64, + 17, + 5, + 1,2,3,4,5,7,10,11,12,13,14,15,17,18,19,20,21,23,24,25,26,27,28,0,29,34,31,32,33,22,37,35,38,39,65,40,41,42,43,66,45,47,48,49,50,52,53,54,56,57,58,61,62,64, + 6,47, + 47, + 36, + 9,11,13,32,37,48,52,64, + 41, + 32, + 23,57, + 47, + 30,45, + 5,6,7,9,25,33,22,39,48, + 15,65,47, + 15,18,19, + 5, + 14,20,21,27,28,41,42,49,56,58, + 20, + 5,35,38,47, + 21,49, + 6,30, + 16,65, + 6,47, + 9,11,13,17,18,19,20,32,33,22,37,39,52, + 50, + 17,18,19,50, + 18,19, + 6,7,14,18,19,20,21,29,65,41,49,56, + 20, + 49, + 6,47, + 56, + 9,11,13,30,32,37,48,52,64, + 49, + 6,10,24,65, + 44,51,55, + 64, + 21,49,64, + 5,6,9,10,29,65,47, + 6, + 47, + 65, + 1,2,3,4,5,6,7,10,12,20,28,30,34,31,33,22,36,35,38,39,65,40,41,44,45,50,51,53,54,55,58,64, + 6,20,65,45,58, + 30, + 11,13,32,37,48,52,64, + 64, + 14,21,41,47,56, + 6, + 21,58, + 12, + 5,28, + 6, + 45, + 6,12,13,20,33,22,39,65,47,50, + 6,9,14,17,20,21,30,39,41,42,56, + 33,22,39, + 5, + 42, + 30,42,57, + 5,6,28, + 6,65, + 65, + 36, + 45, + 6,9,30, + 5, + 36, + 21,23,52, + 1,2,3,4,5,10,12,14,18,19,20,21,23,24,27,28,0,29,34,31,33,22,36,35,38,39,65,40,41,42,43,66,44,47,49,50,51,53,54,55,56,57,58, + 28, + 50, + 47, + 5,10,20,47, + 6,0,66, + 6,47,49, + 65,64, + 0,66, + 1,6,7, + 24, + 9,11,13,14,18,19,21,24,25,26,32,37,48,49,52,56,61,62,64, + 9, + 65,64, + 49, + 50, + 53, + 65, + 6,41, + 41, + 65,47, + 17, + 1,5,6,7,9,10,12,13,17,20,21,23,24,30,34,31,32,33,22,35,38,39,65,40,47,49,50,56,57,64, + 27,28,36,41, + 56, + 65,47, + 5,6,9,10,11,13,14,17,20,21,23,24,25,27,0,30,32,37,35,38,65,42,43,66,44,47,48,49,50,51,52,53,55,56,58,64, + 65, + 19, + 65, + 5,12,35,38,47,50,55, + 47, + 20,23,24,28,29,41,57, + 1,2,3,4,6,7,53,54, + 6, + 13,65,47,49, + 13, + 9, + 65, + 64, + 6,65,54, + 49, + 47, + 14,20,21,27,65,56, + 29,30, + 29, + 64, + 0,66, + 0, + 2,3,5,6,7,17,20,30,33,22,35,38,39,65,40,47,64, + 50, + 47, + 49, + 10,14,20,21,23,24,41,43,47,49,56,57, + 47, + 20,29,65, + 43,47, + 14,20,21,56, + 15, + 29,65,47, + 65,47,50, + 6,49, + 65, + 5,7,18,19, + 5,6,7,9,10,12,13,14,18,19,20,21,23,24,25,26,27,28,0,33,22,36,39,65,41,42,43,66,44,45,47,49,50,51,55,56,57,58,61, + 23,27,65,47, + 29,30, + 6,64, + 6,30,47,49, + 6, + 6,29,36,47, + 5,6,9,30,33,22,35,38,39,65,45,53, + 15,0,65,66, + 6,30, + 6,9, + 1,2,3,4,5,6,7,18,19,20,30,33,22,39,65,44,49,50,51,53,54,55, + 20,49, + 65, + 53, + 12,34,31,47, + 18, + 49, + 65, + 14,17,20,21,27,30,36,56,58, + 64, + 13, + 13, + 64, + 65, + 20,34,31,35,38,65,53, + 13,64, + 9, + 65, + 6,16,27,65,41,46,63, + 4,6,7,10, + 6, + 14,20,21,56, + 65, + 18,19, + 5,7,12,18,19,28,30,34,31,33,22,35,38,39,40,41,50,53, + 5,12,28,34,31,33,22,35,38,39,40,41,50,53, + 65,47, + 27,42,45, + 14,20,21,23,24,25,26,0,66,47,49,56,57, + 6,20,0,65,40,42,66,47,49,56, + 6, + 65, + 29,30, + 29, + 6, + 65, + 65, + 64, + 61, + 6,27,61, + 45,51,58, + 5,28, + 47, + 65, + 47, + 6, + 47, + 65, + 65,58, + 65,58, + 30, + 6,23, + 23, + 65, + 65, + 5,7,10,14,17,21,23,24,27,28,0,29,36,65,41,43,66,44,47,49,51,55,56,57,58, + 49, + 49, + 48, + 65,42, + 49,51, + 65, + 7, + 65, + 64, + 49, + 13, + 47,50, + 45, + 0,65,66, + 65,49, + 65, + 5,9,12,13,30,34,31,32,33,22,39,47,50,64, + 47,49,53, + 5, + 10,20,25,26,41,45,47, + 65,47,49, + 6,0,65,66,48, + 47, + 14,20,21,56, + 12, + 19,30,39,40, + 65,47, + 24,29,49,50, + 13, + 20,25,26,65,45, + 6, + 65, + 5,7,14,21,65,45,56,58, + 5, + 20,65, + 65, + 5,30,49, + 48,49, + 6, + 6, + 64, + 3, + 5,7,10,14,15,17,18,19,20,21,23,24,25,26,27,28,0,29,36,39,65,41,42,43,66,44,45,47,49,51,55,56,57,58,61,62, + 36,47, + 1,2,3,4,5,6,7,8,9,10,11,13,14,15,17,18,19,20,21,24,25,26,27,0,29,30,34,31,32,33,22,36,37,35,38,39,65,41,42,43,66,44,45,47,48,49,50,51,52,53,54,55,56,58,61,62,64, + 49, + 9,30,37,47, + 62, + 6,30, + 6,8,10,14,21,23,24,27,0,30,36,65,41,42,43,66,44,47,49,51,55,56,57, + 14,21,27,56, + 6,7,30,45, + 24,30,41, + 30, + 13, + 65,47, + 65,47, + 12,20,27,28,29,33,22,39,41,50,58, + 39, + 53, + 53, + 23,57, + 53,54, + 18,19,20,24,28,41,45,58, + 65, + 6,10,11,13,14,17,20,24,26,0,30,33,22,36,39,65,42,43,66,47,48,49,50,52,64, + 65,49, + 51,64, + 49, + 6, + 5,6,0,30,39,65,66,47,49, + 25,26, + 47, + 1,2,3,4,5,7,10,15,17,18,19,20,27,28,33,22,39,65,41,42,43,44,53,54,55,61,62, + 20, + 10,14,20,21,23,24,27,28,0,29,41,42,43,66,47,49,56,57,58, + 5,6,7,18,19,21,23,0,65,40,42,66,47,49,50,51,53,55,56,58, + 41,56, + 65,40, + 14,20,21,30,43,44,47,49,51,55,56,58, + 5,21,40,47,48, + 6,51,55, + 6,14,65, + 14,21,56, + 64, + 56, + 65, + 6, + 6,47, + 5,34,31,35,38,44,47, + 6,65, + 47,49, + 6, + 65, + 65, + 13, + 30,43,47,51,58, + 47, + 51,64, + 64, + 45, + 0,66, + 6,33,22,39,65,66,44,47,51,55,64, + 25,26,62, + 28,41, + 6,65, + 5,65, + 10,42,49, + 6,58, + 9, + 65, + 5, + 21,65, + 50,56, + 18,19,20,30,41, + 13,49, + 49, + 6,0,66,49, + 64, + 12, + 65, + 65,64, + 40, + 5,40, + 20,46,62,63, + 23, + 49, + 64, + 2,6,7,10,11,13,21,23,0,32,37,66,48, + 40, + 9,11,13,30,32,37,48,52,64, + 5, + 20, + 14,20,21,44,47,51,55,56, + 9,13,30,49,52,64, + 41, + 41, + 49, + 49, + 65, + 6,9,18,19, + 5, + 65,48, + 12, + 45, + 6, + 6, + 13, + 14,20,21,27,42,56, + 28, + 43, + 43, + 14, + 13, + 47, + 5,6,33,22,39,52, + 6, + 23,24,28,41,57, + 65,47, + 6, + 5,49,58, + 13, + 6, + 65, + 14, + 0,66, + 66, + 17,24,25,26,28,41,62, + 0,66,44, + 66,44, + 5, + 47, + 45, + 13,35,38,40,50, + 30,45, + 6,39,40,47, + 9,46, + 6,27, + 65, + 29, + 47, + 65, + 5,12,30,34,31,33,22,39,50, + 1,2,3,4,5,7,10,12,14,15,17,18,19,20,21,23,24,27,28,0,29,34,31,33,22,36,35,38,39,65,40,41,42,43,66,44,45,47,49,50,51,53,54,55,56,57,58,61,62, + 14,20,21,56, + 6, + 52, + 47, + 6,7,10,12,14,20,21,24,30,33,22,39,65,40,41,45,47,49,50,56,62, + 47, + 62, + 5,7,10,14,21,23,24,0,36,65,66,44,47,51,55,56,57, + 5,6,13,65,49, + 10,42,49, + 13,64, + 20,0,65,41,66,44,45,47,49,58, + 9,49, + 62, + 13,37,47,48, + 12, + 6,65, + 49, + 9,30,48, + 5,6,7,9,10,17,20,23,24,25,26,28,29,30,42,43,45,47,57,58,59,62, + 49, + 65, + 5,13,65,47,50,52, + 14,20,21,56, + 6,65,44,55, + 65,42,47,49,50,53, + 17, + 10,21,0,65,42,66,44,49,51,55,58, + 12,33,22,39,47, + 20, + 29,45, + 5,12,45,47,50,55, + 15,0,66, + 65, + 18,19, + 41,45, + 29,36,65,44,47,51,55, + 10,42,43, + 5,14,17,19,20,21,0,41,66,49,56, + 21, + 6,0,65,66,47,53, + 6,49, + 0,66, + 51, + 51, + 6,65, + 56, + 5,17,20,65, + 9,30,52, + 49, + 6,7,10,53,54, + 16,46,63, + 65,47, + 10,0,36,42,66,47,49,50, + 6,47,51,62, + 41, + 36,66, + 58, + 13,14,15,18,19,21,23,24,27,0,32,65,42,43,66,45,48,49,52,56,57,61,64, + 16,46,63, + 6,47, + 6, + 49, + 24, + 36,44,47,51,55, + 55, + 55, + 3,6,7,10,11,13,23,0,32,37,66,48,52,56,57, + 34,31, + 6,13,21,23,37,65,41,47,52,55,57,58, + 5,6,10,16,17,20,28,0,42,66,46,47,63, + 49, + 6,47, + 41, + 49, + 56,57,58, + 47,56,57,58, + 40, + 29, + 12,25,26,47,62, + 45,49,60, + 1,2,3,4,6,7,18,19,0,33,22,36,39,65,41,66,47,49,50,53,54,58,59, + 9, + 47,49, + 6, + 9,12,13,28,37,48, + 0,66,44,51,55,64, + 41, + 6,65, + 65, + 41, + 10,11,13,14,20,21,23,24,25,26,0,32,37,41,42,43,66,45,47,48,49,52,56,57,60,61,62,64, + 9, + 62,63, + 4,5,6,7,20,30,53,54, + 45, + 65, + 9,30,64, + 6,65,58, + 49, + 65, + 42,53, + 0,66,49, + 14,20,21,56, + 5,6,7,10,11,12,13,14,17,18,19,20,21,24,25,26,27,28,0,29,32,33,22,37,39,65,40,41,42,43,66,45,47,48,49,50,52,56,58,61,64, + 45, + 1,7,34,31, + 62, + 65,47, + 39, + 45, + 10,41,47, + 6,64, + 6, + 5,6,9,10,11,12,13,14,15,17,19,20,24,25,26,27,28,29,32,33,22,36,37,39,65,41,42,43,44,48,49,50,51,52,55,61,62,64, + 6, + 65, diff --git a/doc/salome/gui/SMESH/whdata/whtdata0.htm b/doc/salome/gui/SMESH/whdata/whtdata0.htm index 429476ba8..827bf7b7c 100755 --- a/doc/salome/gui/SMESH/whdata/whtdata0.htm +++ b/doc/salome/gui/SMESH/whdata/whtdata0.htm @@ -6,34 +6,41 @@ diff --git a/doc/salome/gui/SMESH/whdata/whtdata0.xml b/doc/salome/gui/SMESH/whdata/whtdata0.xml index 175e7627d..27bb8721b 100755 --- a/doc/salome/gui/SMESH/whdata/whtdata0.xml +++ b/doc/salome/gui/SMESH/whdata/whtdata0.xml @@ -8,10 +8,16 @@ - - + + + + + + + + @@ -25,6 +31,7 @@ + @@ -33,7 +40,7 @@ - + @@ -45,25 +52,39 @@ + + + + + + - - - + + + + + + + + + + + + + + + + + - - - - - - diff --git a/doc/salome/gui/SMESH/whgdata/whlstf0.htm b/doc/salome/gui/SMESH/whgdata/whlstf0.htm index 0e2fad95b..a3aefffef 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstf0.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstf0.htm @@ -34,15 +34,11 @@ A:hover {color:Navy; } A:hover {font-family:Tahoma; } A:hover {font-size:8pt; }

-0d
1d 1 2 3 4
2d 1 2 3 4 5 6 7 8 9 10
3d 1 2 3 4 5 6
3rd
5th
+0d
1d 1 2 3 4 5 6 7 8 9 10 11 12
2d 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
3d 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
3rd
5th


-abutting 1 2
according 1 2 3 4 5 6 7 8
account
adding
addition
additional 1 2
adjacent
algorithm 1 2 3 4 5 6 7 8 9 10 11
algorithms 1 2 3 4 5 6
allow
allowing
allows
angle 1 2 3 4 5
angles
any
appear 1 2 3 4 5 6 7
application
applied 1 2 3 4 5 6 7 8 9 10 11
apply 1 2 3 4 5 6 7 8 9 10 11 12 13
applying 1 2 3
approximately
arcsine
area 1 2 3 4 5 6
areas
aspect 1 2 3
assigned
average 1 2
axis
+able
above
absent
abutting 1 2 3
according 1 2 3 4 5 6 7 8 9 10
account 1 2
add 1 2 3 4 5 6
added 1 2 3 4 5
adding
addition 1 2
additional 1 2
additionally 1 2
adjacent 1 2 3 4 5 6 7
adjust
advance
again
algorithm 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
algorithms 1 2 3 4 5 6 7 8 9 10 11 12 13
allow
allowed 1 2 3 4
allowing
allows 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
along 1 2 3
already
always
angle 1 2 3 4 5 6 7
angles
another
any 1 2 3 4 5
appear 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
appeared
application 1 2
applied 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
apply 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
applying 1 2 3
approximately
arcsine
area 1 2 3 4 5
areas
arithmetic 1 2
around
aspect 1 2 3 4
assign
assigned
assigning
associated 1 2 3 4 5 6
automatic
automatically 1 2 3 4 5
available 1 2
average 1 2 3 4 5 6 7 8
axis 1 2 3 4 5


-bar 1 2
based 1 2
basic
basing 1 2
basis
before
bisecting
bisector
borders
bottom
boundary
bounded
bounding
bounds
box 1 2 3 4 5 6 7 8
browser 1 2
button 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
-

-cad
calculated 1 2 3
calculates
calculation 1 2 3
calculations
changing
characteristic
characterizes
choice
choose 1 2 3 4 5 6 7 8 9
chosen 1 2
click 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
clicking
closed
colored 1 2 3 4 5 6 7 8
coloring
combining
component 1 2
compose 1 2 3
composed 1 2
composing 1 2 3 4 5 6 7
computation 1 2 3
compute
computing
conditions
connections 1 2
connectivity
considered
consisting 1 2 3
consists 1 2 3 4 5 6 7 8 9
construct 1 2
constructing 1 2
construction 1 2
contain 1 2
containing
contains
contour
control 1 2 3 4 5 6 7 8 9
controls 1 2 3 4 5 6 7 8
coordinates
corner
corners
corresponding 1 2 3
could
create 1 2
created 1 2
creating
creation 1 2
criteria
criterion 1 2 3 4 5 6 7
cross
curve
-

-dealing
default
define 1 2 3 4
defined 1 2
definite 1 2 3 4
definition 1 2 3 4
deletion
depending 1 2 3
depends 1 2
described
desktop
destined 1 2 3
detail


>> +bar 1 2
based 1 2
basic
basing 1 2
basis 1 2 3
become
before
beginning 1 2
belong
berders
bisecting
bisector
boolean
border
borders 1 2
both 1 2
bottom
bound
boundaries
boundary 1 2 3 4
bounded
bounding
bounds
box 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44


>> diff --git a/doc/salome/gui/SMESH/whgdata/whlstf1.htm b/doc/salome/gui/SMESH/whgdata/whlstf1.htm index 78d071975..7a42fac21 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstf1.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstf1.htm @@ -33,25 +33,9 @@ A:hover {color:Navy; } A:hover {font-family:Tahoma; } A:hover {font-size:8pt; }

<<

-diagonal 1 2
dialog 1 2 3 4 5 6 7
different
dimension
direct
direction
discretization 1 2 3
displacing
display 1 2 3 4 5 6 7 8 9
displayed 1 2 3 4 5 6 7 8 9
displaying 1 2 3
disposal
distance
don
+browser 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
build 1 2 3 4
builds 1 2
built 1 2 3
button 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
buttons 1 2


-edge 1 2 3
edges 1 2 3 4 5 6 7 8 9 10 11
editing
element 1 2 3 4 5 6 7 8 9
elements 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
encapsulate
enter
entities 1 2 3 4 5 6 7
entity
equal
equilateral
etc
every
example
export 1 2
exportation
exported
exporting
extends
-

-face 1 2
faces 1 2 3 4 5 6 7 8 9
file
files
final
find
fixed
following 1 2 3 4 5 6 7 8 9 10 11
follows 1 2 3 4 5
format 1 2
four 1 2
free 1 2
functionality 1 2
functions
-

-generate 1 2 3
generated 1 2 3 4 5
generation
geom 1 2
geometric 1 2
geometrical 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
global
grouping
groups
-

-h
h1
h2
half
height 1 2
help
here 1 2 3 4 5 6 7 8 9 10
hexahedron 1 2 3
hexahedrons
higher
hyp 1 2
hypotheses 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
hypothesis 1 2 3 4 5
-

-i
icon
id 1 2
if
imply
import 1 2
importation
imported
importing
including
indicates
info
information 1 2
infos
initial
interested
introduction
inverse
inversion
item
-

-j
join
-

-k
kinds
-

-l
largest
launching
length 1 2 3 4 5 6 7 8
level
like 1 2 3
line
lines
local 1 2 3 4 5
locally
location
longest
look 1 2 3
lower
-

-main
manage
mapping
max 1 2 3 4
maximum 1 2 3
meaning
meaningful
measured
mefisto
menu 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
menus
mesh 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
meshed 1 2
meshes 1 2 3 4 5 6 7 8 9 10 11
meshing 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19


>> +cad
calculated 1 2 3 4 5
calculates
calculation 1 2 3
calculations
called
cancel
careful
case
cases
cells 1 2
center
centroid
centroidal
certain
change 1 2 3
changed
changes 1 2 3
changing
characteristic
characterizes
check
choice 1 2
choose 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
choosing 1 2
chose
chosen
click 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
clicking 1 2
close
closed 1 2
co
coincident
colored 1 2 3 4 5 6 7 8
coloring
column
columns
combining
common 1 2
compare
component 1 2
compose
composed 1 2
composing 1 2 3 4 5 6
computation 1 2 3
compute
computed 1 2
computing
conditions
confirm 1 2 3 4 5 6 7 8 9 10
confirmation
conform 1 2 3 4
connect
connected 1 2
connections 1 2
connectivity 1 2
considered 1 2
consisting 1 2 3 4 5
consists 1 2 3 4 5 6 7 8
constant
construct 1 2 3
constructed 1 2 3
constructing 1 2 3
construction 1 2
contain 1 2 3 4 5 6
containing 1 2 3 4
contains 1 2 3 4 5 6 7
content
continues
contour 1 2
contrast
control 1 2 3 4 5 6 7 8 9
controls 1 2 3 4 5 6 7 8
converge
coordinates 1 2 3 4
copy 1 2 3
corner
corners 1 2 3
corresponding 1 2 3 4 5 6 7
could
counterclockwise
counting


>> diff --git a/doc/salome/gui/SMESH/whgdata/whlstf2.htm b/doc/salome/gui/SMESH/whgdata/whlstf2.htm index 91add7633..9f0c11199 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstf2.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstf2.htm @@ -33,21 +33,11 @@ A:hover {color:Navy; } A:hover {font-family:Tahoma; } A:hover {font-size:8pt; }

<<

-minimum 1 2 3
model
models
modes
modification 1 2 3
module 1 2 3 4
moving
multi
multiplied
+create 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
created 1 2 3 4 5 6 7 8
creating 1 2 3
creation 1 2 3 4 5
criteria
criterion 1 2 3 4 5 6 7
cross
current 1 2
currently 1 2 3
curve
cut 1 2
cutted
cutting


-name 1 2 3 4 5
nb
netgen
new
node
nodes 1 2 3 4 5 6 7 8 9 10 11 12 13
normal
notice
number 1 2 3 4
numbering 1 2
numbers 1 2
+d
data 1 2
dealing
default
define 1 2 3 4 5 6 7
defined 1 2 3 4 5
definite 1 2 3 4 5 6 7 8 9 10 11
definition 1 2 3
deflection
deleted
deletion 1 2 3
depending 1 2
depends 1 2
describe
described 1 2
describes
description
desirable
desktop
destined 1 2 3
detail
detect
diagonal 1 2 3
dialog 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
differ
difference
different 1 2 3 4
differs
dimension 1 2 3
direct
directed
direction 1 2
directly
discretization 1 2 3
discretized 1 2
displace
displaced
display 1 2 3 4 5 6 7 8 9 10 11 12 13 14
displayed 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
displaying 1 2 3
disposal
distance 1 2
distortion
distortions
divided
does
domain
don
done
double


-object 1 2 3 4 5 6 7 8 9
objects 1 2 3 4 5 6 7 8
ok
one 1 2 3
operations
opposite
options
order
orientation
origin
own
-

-parameter
parameters
parametric
particularity
perfect
performing
planar
plane
platform
point 1 2
points 1 2 3
position
possible
presentation
presented
preset
previously 1 2 3
procedure
produced
product
projection
properties 1 2
-

-quad
quadrangle 1 2 3 4
quadrangles 1 2 3 4 5
quality 1 2 3 4 5 6 7 8 9
quantity
-

-ratio 1 2 3 4 5
reassigning
reference 1 2
refined
reflects
related
relations
relationship
relationships
remaining
removing
repeated
represent 1 2 3
representation
representations
represents 1 2
restricted
resulting
retained
retrieve
rough
run
running
-

-s
salome 1 2
same 1 2
scalar 1 2
search
see
segments 1 2 3 4
select 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
selected
selecting 1 2
sense
separated
set 1 2 3 4 5 6 7 8
setting 1 2 3 4
shading
shape 1 2
shapes
shortest 1 2
should
shown
shrink
side
sides 1 2
simple
skew 1 2 3
smesh 1 2 3 4 5 6 7 8 9 10 11
so 1 2 3
space
split 1 2
standard 1 2
start
step
study
sub
submesh 1 2
submeshes 1 2
surface
surrounding
-

-t
taken
taper 1 2 3
tetrahedron 1 2 3
tetrahedrons
text 1 2 3 4 5 6 7 8 9
three 1 2
toolbar 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
toolbars
topic 1 2 3 4 5 6 7 8 9
topological
topology


>> +e 1 2
easily
edge 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
edges 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
edit 1 2 3 4
edited
editing 1 2
effect
either 1 2
element 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
elements 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
else
encapsulate
encountered
end 1 2 3 4
ending 1 2 3
ends
enough
enter 1 2 3 4 5 6 7
entities 1 2 3 4 5 6 7 8
entity


>> diff --git a/doc/salome/gui/SMESH/whgdata/whlstf3.htm b/doc/salome/gui/SMESH/whgdata/whlstf3.htm index a3444891f..589a09631 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstf3.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstf3.htm @@ -33,19 +33,16 @@ A:hover {color:Navy; } A:hover {font-family:Tahoma; } A:hover {font-size:8pt; }

<<

-triangle 1 2 3 4
triangles 1 2 3 4 5 6
two 1 2 3 4
type 1 2 3 4 5 6 7 8 9 10
types
+equal 1 2 3 4
equally
equilateral
etc
eventual
every
example 1 2 3
exceeded
except
existing 1 2 3 4 5 6
export 1 2
exportation
exported
exporting
extends
extruded 1 2
extrusion


-u
unv
update
updated
usage
used 1 2 3 4 5 6 7 8 9 10
using 1 2
+face 1 2 3 4 5 6 7
faces 1 2 3 4 5 6 7 8 9 10 11 12 13
factor
far
faster
field 1 2 3 4 5 6 7
fields 1 2 3 4 5 6 7 8 9
fifth
file 1 2
files
fill 1 2
filled
filter 1 2 3 4
final
find 1 2 3
finds
first 1 2 3
fixed 1 2
flag
folder 1 2 3 4
following 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
follows 1 2 3 4 5 6 7 8 9 10
format 1 2
formed
forming 1 2
forms
four 1 2
free 1 2 3 4
functionality 1 2 3 4
functions


-v
value 1 2 3 4
values
vector
vertex
view 1 2
viewer 1 2 3 4 5 6 7 8 9 10 11
viewing
visual
visualization 1 2
volume 1 2 3 4 5 6 7
volumes 1 2
vtk
+generate 1 2 3 4 5 6
generated 1 2 3 4 5 6 7
generates
generation 1 2 3 4
geom 1 2
geometric 1 2
geometrical 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
geometry 1 2
getting
ghs3d
given 1 2 3 4
global
good
got
group 1 2 3 4 5 6 7
grouping
groups 1 2 3 4 5 6


-warp
warping 1 2 3
way
will 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
window
wire 1 2
wireframe
words
work
+h
h1
h2
half
hands
having 1 2 3 4 5 6 7
height 1 2
help
hence
here 1 2 3 4 5 6 7
hexahedron 1 2 3 4
hexahedrons
higher
highlighted 1 2 3 4
holds
hyp 1 2
hypotheses 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
hypothesis 1 2 3 4 5 6 7 8 9 10 11 12 13 14


-x 1 2
-

-y
your 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
-

-z


+i 1 2
icon 1 2 3
id 1 2 3 4 5 6 7 8 9 10 11
ids 1 2 3 4 5 6 7
if 1 2 3 4 5 6 7 8 9 10
implies
imply
import 1 2
importation
imported
importing
including
index
indicates
indices
info
information 1 2 3
infos
initial 1 2 3
input 1 2
inserted
instead
intended
interested
intermediate
internal
intersect
intersected
intersection 1 2
intersects
introduction
inverse 1 2
inversion


>> + diff --git a/doc/salome/gui/SMESH/whgdata/whlstf4.htm b/doc/salome/gui/SMESH/whgdata/whlstf4.htm new file mode 100755 index 000000000..d5432dcd9 --- /dev/null +++ b/doc/salome/gui/SMESH/whgdata/whlstf4.htm @@ -0,0 +1,51 @@ + + +Search Words List + + + + + + + +

<<

+

+iso
isoline
isolines
item 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
items 1 2
iteration
iterations
iterative
+

+join
just 1 2
+

+keep 1 2
key
kinds
knowing
+

+l
laplacian
largest
last 1 2
launching
lay
lays 1 2 3
least 1 2
left
length 1 2 3 4 5 6 7 8 9 10 11 12 13 14
less 1 2 3
level
like 1 2 3 4 5 6 7
limit
limited 1 2
line 1 2
lines 1 2 3 4
link
linked
links
list 1 2 3 4
lk
local 1 2 3 4
locally 1 2
located 1 2
location 1 2 3 4
locations
longest
look 1 2 3 4
looking
lower
lying
+

+main 1 2 3 4 5 6 7 8
manage
manual
manually 1 2
mapped
mapping
max 1 2 3
maximum 1 2
meaning
meaningful
measured
mefisto
menu 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
menus
merge 1 2
merged
merges
merging 1 2
mesh 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
meshed 1 2
mesher
meshes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
meshing 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
method
methods
minimum 1 2 3 4
mode
model
models
modes
modification 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
modify 1 2 3 4
module 1 2 3 4
move 1 2
moving 1 2
multi
multiplied
must 1 2
+

+n 1 2
name 1 2 3 4 5 6 7 8 9 10 11
nb
need
needs
neighboring 1 2
netgen 1 2
new 1 2 3 4 5 6 7 8
next


>> + + + + + diff --git a/doc/salome/gui/SMESH/whgdata/whlstf5.htm b/doc/salome/gui/SMESH/whgdata/whlstf5.htm new file mode 100755 index 000000000..d35002e19 --- /dev/null +++ b/doc/salome/gui/SMESH/whgdata/whlstf5.htm @@ -0,0 +1,49 @@ + + +Search Words List + + + + + + + +

<<

+

+nodal 1 2
node 1 2 3 4 5 6 7 8 9
nodes 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
normal 1 2
note
notice
number 1 2 3 4 5 6 7 8 9
numbering 1 2
numbers 1 2
+

+obey
object 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
objects 1 2 3 4 5 6 7 8
objet
ok 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
once 1 2
one 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
ones 1 2 3
onto 1 2
operation 1 2 3 4 5 6 7 8 9 10 11
operations 1 2
opposite 1 2 3 4 5
options 1 2 3
order 1 2 3
orientation 1 2 3
origin
others
outside
own
+

+parameter 1 2
parameters 1 2 3 4 5 6 7
parametric 1 2
part 1 2
particularity
pattern
pattern_name
patterns
perfect
perform 1 2 3 4
performing
place
placed
planar
plane 1 2
platform
plus 1 2
point 1 2 3 4 5 6
points 1 2 3 4 5 6 7
pop 1 2 3
popup 1 2
position 1 2
positions
possible 1 2
present
presentation
presented
preserved
preset
press
pressed 1 2
preview 1 2
previous 1 2
previously 1 2 3 4 5
procedure 1 2
process
produce
produced
produces 1 2 3
product
progression
projected
projecting
projection 1 2
propagate
propagation 1 2
properties 1 2 3 4
pseudo
pulls
+

+quad
quadrangle 1 2 3 4 5 6 7
quadrangles 1 2 3 4 5 6 7 8
quadrangular
quality 1 2 3 4 5 6 7 8 9
quantity
quit
+

+radio 1 2 3 4 5 6 7 8
ratio 1 2 3 4 5 6
reassigning
recompute
reduce
reevaluated
reference 1 2 3 4
references 1 2
refers
refined
reflects 1 2
regular
related
relations
relationship
relationships
remaining
remove 1 2 3 4 5 6
removing
rename
renumber
renumbering
reoriented
repeated
replaced
represent 1 2 3 4
representation
representations
represents 1 2
required 1 2 3 4 5
rest 1 2
restricted
resulting 1 2
results
retained
retrieve
reverse
reverting
revolution 1 2
revolved


>> + + + + + diff --git a/doc/salome/gui/SMESH/whgdata/whlstf6.htm b/doc/salome/gui/SMESH/whgdata/whlstf6.htm new file mode 100755 index 000000000..2158cef4f --- /dev/null +++ b/doc/salome/gui/SMESH/whgdata/whlstf6.htm @@ -0,0 +1,45 @@ + + +Search Words List + + + + + + + +

<<

+

+right 1 2 3 4 5 6 7
rotate
rotated 1 2 3
rotation 1 2
rough
rule
run
running
+

+s 1 2 3 4 5
salome 1 2
same 1 2 3 4
scalar 1 2
seam
search
second
section
sections
see 1 2
segment
segments 1 2 3 4 5 6 7 8 9
select 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
selected 1 2 3 4 5 6 7
selecting 1 2 3 4 5 6 7
selection 1 2 3 4
sense
separated
sequence
sequences
set 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
sets
setting 1 2 3
sew
sewing
shading
shall 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
shape 1 2 3 4
shapes
shift 1 2 3
shortest 1 2
should 1 2 3 4 5 6 7 8 9 10
shown 1 2
shrink
side 1 2
sides 1 2 3
similar
simple 1 2
sizes
skew 1 2 3
smesh 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
smoothed
smoothing
smp
so 1 2 3 4 5 6
sort 1 2 3 4
space 1 2 3 4
specific
specified 1 2 3 4 5
specifies 1 2
specify 1 2 3 4 5 6 7 8 9
specifying 1 2
split 1 2 3 4 5
standalone
standard 1 2
start 1 2 3 4
starting 1 2 3
step
steps 1 2
stored
structure 1 2
study 1 2
sub 1 2 3 4 5 6 7
submenu 1 2 3
submesh 1 2 3 4 5 6 7 8 9 10 11
submeshes 1 2
supplementary
surface 1 2 3 4 5 6
surfaces
surrounding 1 2
swept 1 2
symmetrical
symmetrically
symmetry
+

+t 1 2
take
taken 1 2 3 4
taper 1 2 3
techniques
tetrahedron 1 2 3 4 5
tetrahedrons
text 1 2 3
th 1 2
them 1 2 3 4 5 6 7 8
three 1 2 3 4
thus


>> + + + + + diff --git a/doc/salome/gui/SMESH/whgdata/whlstf7.htm b/doc/salome/gui/SMESH/whgdata/whlstf7.htm new file mode 100755 index 000000000..36d6d9353 --- /dev/null +++ b/doc/salome/gui/SMESH/whgdata/whlstf7.htm @@ -0,0 +1,52 @@ + + +Search Words List + + + + + + + +

<<

+

+tolerance 1 2
tool
toolbar 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
toolbars
topic 1 2 3
topological
topologically
topology
toward
transformation 1 2 3 4 5
transformed
translate
translated
translation
triangle 1 2 3 4 5 6
triangles 1 2 3 4 5 6 7 8 9 10 11
triangulator 1 2
two 1 2 3 4 5 6 7 8 9 10 11 12
type 1 2 3 4 5 6 7 8 9 10 11 12
types 1 2 3
typically
+

+u 1 2
unassign
unassigning
uniform
union 1 2 3
unite 1 2 3
united 1 2
uniting 1 2
unless
unv
up 1 2 3 4
update
updated 1 2
upper
usage
used 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
user 1 2 3
using 1 2 3 4 5
usually 1 2
+

+v
value 1 2 3 4 5
values 1 2
vector 1 2 3 4 5 6
versa
vertex 1 2
vertices
vice
view 1 2
viewer 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
viewing
visual
visualization 1 2
volume 1 2 3 4 5 6 7
volumes 1 2 3
vtk
+

+walking
warp
warping 1 2 3
way 1 2 3
weighted
well
while 1 2
whole 1 2 3
whose 1 2 3 4
will 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
window
wire 1 2 3 4
wireframe
within 1 2
words
work
would 1 2 3
+

+x 1 2
+

+y
your 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
+

+z
zero


+ + + + diff --git a/doc/salome/gui/SMESH/whgdata/whlstfl0.htm b/doc/salome/gui/SMESH/whgdata/whlstfl0.htm index c3d21e37a..6e96a51fe 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstfl0.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstfl0.htm @@ -37,7 +37,7 @@ body {background-color:White; } -

^ AB AC AD AL AN AP AR AS AV AX ^

+

^ AB AC AD AG AL AN AP AR AS AU AV AX ^

diff --git a/doc/salome/gui/SMESH/whgdata/whlstfl1.htm b/doc/salome/gui/SMESH/whgdata/whlstfl1.htm index 9e477497a..6cc407bdf 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstfl1.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstfl1.htm @@ -37,7 +37,7 @@ body {background-color:White; } -

^ BA BE BI BO BR BU ^

+

^ BA BE BI BO BR BU ^

diff --git a/doc/salome/gui/SMESH/whgdata/whlstfl10.htm b/doc/salome/gui/SMESH/whgdata/whlstfl10.htm index 99b45b65e..279e88dfb 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstfl10.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstfl10.htm @@ -37,7 +37,7 @@ body {background-color:White; } -

^ K KI ^

+

^ KE KI KN ^

diff --git a/doc/salome/gui/SMESH/whgdata/whlstfl11.htm b/doc/salome/gui/SMESH/whgdata/whlstfl11.htm index 792262322..a1f912d0e 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstfl11.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstfl11.htm @@ -37,7 +37,7 @@ body {background-color:White; } -

^ L LA LE LI LO ^

+

^ L LA LE LI LK LO LY ^

diff --git a/doc/salome/gui/SMESH/whgdata/whlstfl12.htm b/doc/salome/gui/SMESH/whgdata/whlstfl12.htm index 3e186c11b..9733f350c 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstfl12.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstfl12.htm @@ -37,7 +37,7 @@ body {background-color:White; } -

^ MA ME MI MO MU ^

+

^ MA ME MI MO MU ^

diff --git a/doc/salome/gui/SMESH/whgdata/whlstfl13.htm b/doc/salome/gui/SMESH/whgdata/whlstfl13.htm index d0d0eeac6..359bc6d19 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstfl13.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstfl13.htm @@ -37,7 +37,7 @@ body {background-color:White; } -

^ NA NB NE NO NU ^

+

^ N NA NB NE NO NU ^

diff --git a/doc/salome/gui/SMESH/whgdata/whlstfl14.htm b/doc/salome/gui/SMESH/whgdata/whlstfl14.htm index 6ba06ed43..d2d32a28a 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstfl14.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstfl14.htm @@ -37,7 +37,7 @@ body {background-color:White; } -

^ OB OK ON OP OR OW ^

+

^ OB OK ON OP OR OT OU OW ^

diff --git a/doc/salome/gui/SMESH/whgdata/whlstfl15.htm b/doc/salome/gui/SMESH/whgdata/whlstfl15.htm index c38ad9afc..41d264168 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstfl15.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstfl15.htm @@ -37,7 +37,7 @@ body {background-color:White; } -

^ PA PE PL PO PR ^

+

^ PA PE PL PO PR PS PU ^

diff --git a/doc/salome/gui/SMESH/whgdata/whlstfl16.htm b/doc/salome/gui/SMESH/whgdata/whlstfl16.htm index 62b79cc3c..da1c3fb8e 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstfl16.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstfl16.htm @@ -37,7 +37,7 @@ body {background-color:White; } -

^ RA RE RO RU ^

+

^ RA RE RI RO RU ^

diff --git a/doc/salome/gui/SMESH/whgdata/whlstfl17.htm b/doc/salome/gui/SMESH/whgdata/whlstfl17.htm index 17165a88b..018a26944 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstfl17.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstfl17.htm @@ -37,7 +37,7 @@ body {background-color:White; } -

^ S SA SC SE SH SI SK SM SO SP ST SU ^

+

^ S SA SC SE SH SI SK SM SO SP ST SU SW SY ^

diff --git a/doc/salome/gui/SMESH/whgdata/whlstfl18.htm b/doc/salome/gui/SMESH/whgdata/whlstfl18.htm index 3475b7700..28b4bc669 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstfl18.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstfl18.htm @@ -37,7 +37,7 @@ body {background-color:White; } -

^ T TA TE TH TO TR TW TY ^

+

^ T TA TE TH TO TR TW TY ^

diff --git a/doc/salome/gui/SMESH/whgdata/whlstfl19.htm b/doc/salome/gui/SMESH/whgdata/whlstfl19.htm index 354e37fba..0c980e5dd 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstfl19.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstfl19.htm @@ -37,7 +37,7 @@ body {background-color:White; } -

^ U UN UP US ^

+

^ U UN UP US ^

diff --git a/doc/salome/gui/SMESH/whgdata/whlstfl2.htm b/doc/salome/gui/SMESH/whgdata/whlstfl2.htm index 7434a0d75..10d30f51a 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstfl2.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstfl2.htm @@ -37,7 +37,7 @@ body {background-color:White; } -

^ CA CH CL CO CR CU ^

+

^ CA CE CH CL CO CR CU ^

diff --git a/doc/salome/gui/SMESH/whgdata/whlstfl20.htm b/doc/salome/gui/SMESH/whgdata/whlstfl20.htm index 92ab563e4..779c1e94d 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstfl20.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstfl20.htm @@ -37,7 +37,7 @@ body {background-color:White; } -

^ V VA VE VI VO VT ^

+

^ V VA VE VI VO VT ^

diff --git a/doc/salome/gui/SMESH/whgdata/whlstfl21.htm b/doc/salome/gui/SMESH/whgdata/whlstfl21.htm index dc58ab384..7aedae790 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstfl21.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstfl21.htm @@ -37,7 +37,7 @@ body {background-color:White; } -

^ WA WI WO ^

+

^ WA WE WH WI WO ^

diff --git a/doc/salome/gui/SMESH/whgdata/whlstfl22.htm b/doc/salome/gui/SMESH/whgdata/whlstfl22.htm index c15cca9fb..26a585fb4 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstfl22.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstfl22.htm @@ -37,7 +37,7 @@ body {background-color:White; } -

^ Y YO ^

+

^ Y YO ^

diff --git a/doc/salome/gui/SMESH/whgdata/whlstfl23.htm b/doc/salome/gui/SMESH/whgdata/whlstfl23.htm new file mode 100755 index 000000000..afed4bf66 --- /dev/null +++ b/doc/salome/gui/SMESH/whgdata/whlstfl23.htm @@ -0,0 +1,45 @@ + + +Search Words letter + + + + + + + + + +

^ Z ZE ^

+ + + + + diff --git a/doc/salome/gui/SMESH/whgdata/whlstfl3.htm b/doc/salome/gui/SMESH/whgdata/whlstfl3.htm index 6ec052cbf..1f8c82d94 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstfl3.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstfl3.htm @@ -37,7 +37,7 @@ body {background-color:White; } -

^ DE DI DO ^

+

^ D DA DE DI DO ^

diff --git a/doc/salome/gui/SMESH/whgdata/whlstfl4.htm b/doc/salome/gui/SMESH/whgdata/whlstfl4.htm index 39d6e98e2..2c9f64dbb 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstfl4.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstfl4.htm @@ -37,7 +37,7 @@ body {background-color:White; } -

^ ED EL EN EQ ET EV EX ^

+

^ E EA ED EF EI EL EN EQ ET EV EX ^

diff --git a/doc/salome/gui/SMESH/whgdata/whlstfl5.htm b/doc/salome/gui/SMESH/whgdata/whlstfl5.htm index 1b78c5664..a4c02a330 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstfl5.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstfl5.htm @@ -37,7 +37,7 @@ body {background-color:White; } -

^ FA FI FO FR FU ^

+

^ FA FI FL FO FR FU ^

diff --git a/doc/salome/gui/SMESH/whgdata/whlstfl6.htm b/doc/salome/gui/SMESH/whgdata/whlstfl6.htm index 8e1828cb4..7a68dcf42 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstfl6.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstfl6.htm @@ -37,7 +37,7 @@ body {background-color:White; } -

^ GE GL GR ^

+

^ GE GH GI GL GO GR ^

diff --git a/doc/salome/gui/SMESH/whgdata/whlstfl7.htm b/doc/salome/gui/SMESH/whgdata/whlstfl7.htm index c7fc1fb24..93f249253 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstfl7.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstfl7.htm @@ -37,7 +37,7 @@ body {background-color:White; } -

^ H HA HE HI HY ^

+

^ H HA HE HI HO HY ^

diff --git a/doc/salome/gui/SMESH/whgdata/whlstfl8.htm b/doc/salome/gui/SMESH/whgdata/whlstfl8.htm index edca63790..c274d4d80 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstfl8.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstfl8.htm @@ -37,7 +37,7 @@ body {background-color:White; } -

^ I IC ID IF IM IN IT ^

+

^ I IC ID IF IM IN IS IT ^

diff --git a/doc/salome/gui/SMESH/whgdata/whlstfl9.htm b/doc/salome/gui/SMESH/whgdata/whlstfl9.htm index 48e8f98b9..32bf89bb5 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstfl9.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstfl9.htm @@ -37,7 +37,7 @@ body {background-color:White; } -

^ J JO ^

+

^ JO JU ^

diff --git a/doc/salome/gui/SMESH/whgdata/whlstt1.htm b/doc/salome/gui/SMESH/whgdata/whlstt1.htm index 7389506d8..6ecc52f02 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstt1.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstt1.htm @@ -42,9 +42,9 @@ A:hover {color:Navy; } A:hover {font-family:Tahoma; } A:hover {font-size:8pt; }     Creating meshes
    Editing meshes
    Quality controls
-    Modifying meshes
-    Mesh info
-    Setting SMESH preferences
+    Grouping elements
+    Modifying meshes
+    Mesh info

diff --git a/doc/salome/gui/SMESH/whgdata/whlstt10.htm b/doc/salome/gui/SMESH/whgdata/whlstt10.htm index cdd508f05..c4b4843da 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstt10.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstt10.htm @@ -42,15 +42,13 @@ A:hover {color:Navy; } A:hover {font-family:Tahoma; } A:hover {font-size:8pt; }     Creating meshes
    Editing meshes
    Quality controls
-    Modifying meshes
-       About modification of meshes
-       Adding nodes and elements
-       Removing nodes and elements
-       Displacing nodes
-       Changing orientation of elements
-       Diagonal inversion of elements
-    Mesh info
-    Setting SMESH preferences
+    Grouping elements
+       Creating groups
+       Editing groups
+       Using operations on groups
+       Constructing groups of specific elements
+    Modifying meshes
+    Mesh info

diff --git a/doc/salome/gui/SMESH/whgdata/whlstt11.htm b/doc/salome/gui/SMESH/whgdata/whlstt11.htm index ca945ce80..a3763bf6e 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstt11.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstt11.htm @@ -42,12 +42,23 @@ A:hover {color:Navy; } A:hover {font-family:Tahoma; } A:hover {font-size:8pt; }     Creating meshes
    Editing meshes
    Quality controls
-    Modifying meshes
-    Mesh info
-       Viewing mesh info
-       Displaying nodes numbers
-       Displaying elements numbers
-    Setting SMESH preferences
+    Grouping elements
+    Modifying meshes
+       Adding nodes and elements
+       Removing nodes and elements
+       Renumbering nodes and elements
+       Transforming meshes
+       Moving nodes
+       Diagonal inversion of elements
+       Uniting two triangles
+       Uniting a set of triangles
+       Changing orientation of elements
+       Cutting quadrangles
+       Smoothing
+       Extrusion
+       Revolution
+       Pattern mapping
+    Mesh info

diff --git a/doc/salome/gui/SMESH/whgdata/whlstt12.htm b/doc/salome/gui/SMESH/whgdata/whlstt12.htm index 6603795ca..2f8657804 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstt12.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstt12.htm @@ -42,13 +42,28 @@ A:hover {color:Navy; } A:hover {font-family:Tahoma; } A:hover {font-size:8pt; }     Creating meshes
    Editing meshes
    Quality controls
-    Modifying meshes
-    Mesh info
-    Setting SMESH preferences
-       Visualization modes
-       Visualization properties
-       View update
-       Scalar Bar properties
+    Grouping elements
+    Modifying meshes
+       Adding nodes and elements
+       Removing nodes and elements
+       Renumbering nodes and elements
+       Transforming meshes
+          Translation
+          Rotation
+          Symmetry
+          Sewing meshes
+          Merging nodes
+       Moving nodes
+       Diagonal inversion of elements
+       Uniting two triangles
+       Uniting a set of triangles
+       Changing orientation of elements
+       Cutting quadrangles
+       Smoothing
+       Extrusion
+       Revolution
+       Pattern mapping
+    Mesh info

diff --git a/doc/salome/gui/SMESH/whgdata/whlstt13.htm b/doc/salome/gui/SMESH/whgdata/whlstt13.htm new file mode 100755 index 000000000..47edf387b --- /dev/null +++ b/doc/salome/gui/SMESH/whgdata/whlstt13.htm @@ -0,0 +1,61 @@ + + + +Content + + + + + + + + + +
+

+ SMESH module
+    Introduction to SMESH
+    Running SMESH module
+    Creating meshes
+    Editing meshes
+    Quality controls
+    Grouping elements
+    Modifying meshes
+    Mesh info
+       Viewing mesh info
+       Displaying nodes numbers
+       Displaying elements numbers
+

+ +
+

+

+ + + + diff --git a/doc/salome/gui/SMESH/whgdata/whlstt2.htm b/doc/salome/gui/SMESH/whgdata/whlstt2.htm index 48c3be721..269cecdc9 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstt2.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstt2.htm @@ -49,9 +49,9 @@ A:hover {color:Navy; } A:hover {font-family:Tahoma; } A:hover {font-size:8pt; }        Computing meshes
    Editing meshes
    Quality controls
-    Modifying meshes
-    Mesh info
-    Setting SMESH preferences
+    Grouping elements
+    Modifying meshes
+    Mesh info

diff --git a/doc/salome/gui/SMESH/whgdata/whlstt3.htm b/doc/salome/gui/SMESH/whgdata/whlstt3.htm index 23fb74a1d..52cd5358c 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstt3.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstt3.htm @@ -44,19 +44,25 @@ A:hover {color:Navy; } A:hover {font-family:Tahoma; } A:hover {font-size:8pt; }        Importing and exporting meshes
       Defining hypotheses
          About hypotheses
-          Local Length hypothesis
-          Number of segments hypothesis
+          Arithmetic 1D hypothesis
+          Average Length hypothesis
+          Deflection 1D hypothesis
+          Length from edges hypothesis
          Max Element Area hypothesis
          Max Element Volume hypothesis
+          Number of segments hypothesis
+          Non conform mesh allowed hypothesis
+          Propagation of 1D Hypothesis on opposite edges
+          Start and End Length hypothesis
       Defining meshing algorithms
       Constructing meshes
       Constructing submeshes
       Computing meshes
    Editing meshes
    Quality controls
-    Modifying meshes
-    Mesh info
-    Setting SMESH preferences
+    Grouping elements
+    Modifying meshes
+    Mesh info

diff --git a/doc/salome/gui/SMESH/whgdata/whlstt4.htm b/doc/salome/gui/SMESH/whgdata/whlstt4.htm index 32e870982..1ae2766f9 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstt4.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstt4.htm @@ -53,9 +53,9 @@ A:hover {color:Navy; } A:hover {font-family:Tahoma; } A:hover {font-size:8pt; }        Computing meshes
    Editing meshes
    Quality controls
-    Modifying meshes
-    Mesh info
-    Setting SMESH preferences
+    Grouping elements
+    Modifying meshes
+    Mesh info

diff --git a/doc/salome/gui/SMESH/whgdata/whlstt5.htm b/doc/salome/gui/SMESH/whgdata/whlstt5.htm index 4a129b809..8d35debfc 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstt5.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstt5.htm @@ -54,9 +54,9 @@ A:hover {color:Navy; } A:hover {font-family:Tahoma; } A:hover {font-size:8pt; }        Computing meshes
    Editing meshes
    Quality controls
-    Modifying meshes
-    Mesh info
-    Setting SMESH preferences
+    Grouping elements
+    Modifying meshes
+    Mesh info

diff --git a/doc/salome/gui/SMESH/whgdata/whlstt6.htm b/doc/salome/gui/SMESH/whgdata/whlstt6.htm index 09f4e99d3..f444902c3 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstt6.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstt6.htm @@ -55,9 +55,9 @@ A:hover {color:Navy; } A:hover {font-family:Tahoma; } A:hover {font-size:8pt; }        Computing meshes
    Editing meshes
    Quality controls
-    Modifying meshes
-    Mesh info
-    Setting SMESH preferences
+    Grouping elements
+    Modifying meshes
+    Mesh info

diff --git a/doc/salome/gui/SMESH/whgdata/whlstt7.htm b/doc/salome/gui/SMESH/whgdata/whlstt7.htm index f4143a422..2881d9255 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstt7.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstt7.htm @@ -50,14 +50,15 @@ A:hover {color:Navy; } A:hover {font-family:Tahoma; } A:hover {font-size:8pt; }           3D meshing algorithms
             Hexahedron meshing algorithm
             Tetrahedron (Netgen) meshing algorithm
+             Tetrahedron (GHS3D) meshing algorithm
       Constructing meshes
       Constructing submeshes
       Computing meshes
    Editing meshes
    Quality controls
-    Modifying meshes
-    Mesh info
-    Setting SMESH preferences
+    Grouping elements
+    Modifying meshes
+    Mesh info

diff --git a/doc/salome/gui/SMESH/whgdata/whlstt8.htm b/doc/salome/gui/SMESH/whgdata/whlstt8.htm index 90c1ebfbb..d80bd4605 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstt8.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstt8.htm @@ -42,11 +42,11 @@ A:hover {color:Navy; } A:hover {font-family:Tahoma; } A:hover {font-size:8pt; }     Creating meshes
    Editing meshes
       Reassigning hypotheses and algorithms
-       Editing hypotheses
+       Editing hypotheses and algorithms
    Quality controls
-    Modifying meshes
-    Mesh info
-    Setting SMESH preferences
+    Grouping elements
+    Modifying meshes
+    Mesh info

diff --git a/doc/salome/gui/SMESH/whgdata/whlstt9.htm b/doc/salome/gui/SMESH/whgdata/whlstt9.htm index 3fced36d3..177d89c3a 100755 --- a/doc/salome/gui/SMESH/whgdata/whlstt9.htm +++ b/doc/salome/gui/SMESH/whgdata/whlstt9.htm @@ -50,9 +50,9 @@ A:hover {color:Navy; } A:hover {font-family:Tahoma; } A:hover {font-size:8pt; }        Minimum angle
       Warping
       Skew angle
-    Modifying meshes
-    Mesh info
-    Setting SMESH preferences
+    Grouping elements
+    Modifying meshes
+    Mesh info

diff --git a/doc/salome/gui/SMESH/whgdata/whnvl32.htm b/doc/salome/gui/SMESH/whgdata/whnvl32.htm index 0e21bdd26..16efc2be3 100755 --- a/doc/salome/gui/SMESH/whgdata/whnvl32.htm +++ b/doc/salome/gui/SMESH/whgdata/whnvl32.htm @@ -54,16 +54,16 @@ body {background-color:White; } N O P - Q + Q R S T U V W - X + X Y - Z + Z

diff --git a/doc/salome/gui/SMESH/whskin_info.htm b/doc/salome/gui/SMESH/whskin_info.htm index 46c2ea732..a7a252fe2 100755 --- a/doc/salome/gui/SMESH/whskin_info.htm +++ b/doc/salome/gui/SMESH/whskin_info.htm @@ -7,9 +7,9 @@

WebHelp 5.00 System Info

- + - + diff --git a/doc/salome/tui/SMESH/HTML/SMESH_BasicHypothesis.html b/doc/salome/tui/SMESH/HTML/SMESH_BasicHypothesis.html index 8a92d45dd..8007326bb 100644 --- a/doc/salome/tui/SMESH/HTML/SMESH_BasicHypothesis.html +++ b/doc/salome/tui/SMESH/HTML/SMESH_BasicHypothesis.html @@ -1,7 +1,7 @@
Start Page smesh.html
Start Page smesh.htm
Skin Name Default
Generating Time 17:39 02/24/2004
Generating Time 18:32 11/11/2004
Language ID 1033
Compile Script webhelp5_compile_script.xml
Compile Build Version 10.00.949
- + @@ -17,7 +17,7 @@
interface SMESH_LocalLength
interface StdMeshers_LocalLength
IDL file
Python

- + @@ -30,10 +30,34 @@ + + + + + + + + +
interface SMESH_NumberOfSegments
interface StdMeshers_NumberOfSegments
IDL file
Python
long GetNumberOfSegments ( )
return_value = GetNumberOfSegments ( )
void SetScaleFactor ( in double scaleFactor )
SetScaleFactor ( scaleFactor )
double GetScaleFactor ( )
return_value = GetScaleFactor ( )

+ + + + + + + + + + + + + + +
interface StdMeshers_Arithmetic1D
IDL file
Python
void SetLength ( in double length, in boolean isStartLength )
SetLength ( length, isStartLength )
double GetLength ( in boolean isStartLength )
return_value = GetLength ( isStartLength )

- + @@ -49,7 +73,55 @@
interface SMESH_MaxElementArea
interface StdMeshers_MaxElementArea
IDL file
Python

- + + + + + + + + + + + + + +
interface SMESH_MaxElementVolume
interface StdMeshers_LengthFromEdges
IDL file
Python
void SetMode ( in long mode )
SetMode ( mode )
long GetMode ( )
return_value = GetMode ( )

+ + + + + + + + + + + + + + + +
interface StdMeshers_StartEndLength
IDL file
Python
void SetLength ( in double length, in boolean isStartLength )
SetLength ( length, isStartLength )
double GetLength ( in boolean isStartLength )
return_value = GetLength ( isStartLength )

+ + + + + + + + + + + + + + + +
interface StdMeshers_Deflection1D
IDL file
Python
void SetDeflection ( in double deflection )
SetDeflection ( deflection )
double GetDeflection ( )
return_value = GetDeflection ( )

+ + + @@ -65,7 +137,23 @@
interface StdMeshers_MaxElementVolume
IDL file
Python

- + + + + + +
interface SMESH_Regular_1D
interface StdMeshers_NotConformAllowed
IDL file
Python

+ + + + + + + +
interface StdMeshers_Propagation
IDL file
Python

+ + + @@ -73,7 +161,7 @@
interface StdMeshers_Regular_1D
IDL file
Python

- + @@ -81,7 +169,7 @@
interface SMESH_MEFISTO_2D
interface StdMeshers_MEFISTO_2D
IDL file
Python

- + @@ -89,7 +177,7 @@
interface SMESH_Quadrangle_2D
interface StdMeshers_Quadrangle_2D
IDL file
Python

- + diff --git a/doc/salome/tui/SMESH/HTML/SMESH_Gen.html b/doc/salome/tui/SMESH/HTML/SMESH_Gen.html index 03b96aba2..8fdf3b2a6 100644 --- a/doc/salome/tui/SMESH/HTML/SMESH_Gen.html +++ b/doc/salome/tui/SMESH/HTML/SMESH_Gen.html @@ -7,24 +7,52 @@ - - + + - - + + - - + + - - + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
interface SMESH_Hexa_3D
interface StdMeshers_Hexa_3D
IDL file
Python
Python
SMESH_Hypothesis CreateHypothesis ( in string anHyp, in long studyId )
return_value = CreateHypothesis ( anHyp, studyId )
FilterManager CreateFilterManager ( )
return_value = CreateFilterManager ( )
SMESH_Mesh Init ( in GEOM_Gen geomEngine, in long studyId, in GEOM_Shape aShape )
return_value = Init ( geomEngine, studyId, aShape )
SMESH_Pattern GetPattern ( )
return_value = GetPattern ( )
boolean Compute ( in SMESH_Mesh aMesh, in GEOM_Shape aSubShape )
return_value = Compute ( aMesh, aSubShape )
void SetCurrentStudy ( in Study theStudy )
SetCurrentStudy ( theStudy )
boolean IsReadyToCompute ( in SMESH_Mesh aMesh, in GEOM_Shape aSubShape )
return_value = IsReadyToCompute ( aMesh, aSubShape )
Study GetCurrentStudy ( )
return_value = GetCurrentStudy ( )
long_array GetSubShapesId ( in GEOM_Gen geomEngine, in long studyId, in GEOM_Shape mainShape, in shape_array listOfSubShape )
return_value = GetSubShapesId ( geomEngine, studyId, mainShape, listOfSubShape )
SMESH_Hypothesis CreateHypothesis ( in string theHypName, in string theLibName )
return_value = CreateHypothesis ( theHypName, theLibName )
SMESH_Mesh CreateMesh ( in GEOM_Object theObject )
return_value = CreateMesh ( theObject )
SMESH_Mesh CreateMeshesFromUNV ( in string theFileName )
return_value = CreateMeshesFromUNV ( theFileName )
mesh_array CreateMeshesFromMED ( in string theFileName, out DriverMED_ReadStatus theStatus )
[ return_value, theStatus ] = CreateMeshesFromMED ( theFileName )
SMESH_Mesh CreateMeshesFromSTL ( in string theFileName )
return_value = CreateMeshesFromSTL ( theFileName )
boolean Compute ( in SMESH_Mesh theMesh, in GEOM_Object theSubObject )
return_value = Compute ( theMesh, theSubObject )
boolean IsReadyToCompute ( in SMESH_Mesh theMesh, in GEOM_Object theSubObject )
return_value = IsReadyToCompute ( theMesh, theSubObject )
long_array GetSubShapesId ( in GEOM_Object theMainObject, in object_array theListOfSubObjects )
return_value = GetSubShapesId ( theMainObject, theListOfSubObjects )

diff --git a/doc/salome/tui/SMESH/HTML/SMESH_Hypothesis.html b/doc/salome/tui/SMESH/HTML/SMESH_Hypothesis.html index 8ffb0b9fb..ff9d3d619 100644 --- a/doc/salome/tui/SMESH/HTML/SMESH_Hypothesis.html +++ b/doc/salome/tui/SMESH/HTML/SMESH_Hypothesis.html @@ -11,6 +11,10 @@
return_value = GetName ( )
+
string GetLibName ( )
+
return_value = GetLibName ( )
+ +
long GetId ( )
return_value = GetId ( )
diff --git a/doc/salome/tui/SMESH/HTML/SMESH_Mesh.html b/doc/salome/tui/SMESH/HTML/SMESH_Mesh.html index b6a66cf43..527298f54 100644 --- a/doc/salome/tui/SMESH/HTML/SMESH_Mesh.html +++ b/doc/salome/tui/SMESH/HTML/SMESH_Mesh.html @@ -7,20 +7,52 @@
Python
-
SMESH_subMesh GetElementsOnShape ( in GEOM_Shape aSubShape )
-
return_value = GetElementsOnShape ( aSubShape )
+
SMESH_subMesh GetSubMesh ( in GEOM_Object aSubObject, in string name )
+
return_value = GetSubMesh ( aSubObject, name )
-
boolean AddHypothesis ( in GEOM_Shape aSubShape, in SMESH_Hypothesis anHyp )
-
return_value = AddHypothesis ( aSubShape, anHyp )
+
void RemoveSubMesh ( in SMESH_subMesh aSubMesh )
+
RemoveSubMesh ( aSubMesh )
-
boolean RemoveHypothesis ( in GEOM_Shape aSubShape, in SMESH_Hypothesis anHyp )
-
return_value = RemoveHypothesis ( aSubShape, anHyp )
+
SMESH_Group CreateGroup ( in ElementType elem_type, in string name )
+
return_value = CreateGroup ( elem_type, name )
-
ListOfHypothesis GetHypothesisList ( in GEOM_Shape aSubShape )
-
return_value = GetHypothesisList ( aSubShape )
+
SMESH_Group CreateGroupFromGEOM ( in ElementType elem_type, in string name, in GEOM_Object theGEOMGroup )
+
return_value = CreateGroupFromGEOM ( elem_type, name, theGEOMGroup )
+ + +
void RemoveGroup ( in SMESH_Group aGroup )
+
RemoveGroup ( aGroup )
+ + +
void RemoveGroupWithContents ( in SMESH_Group aGroup )
+
RemoveGroupWithContents ( aGroup )
+ + +
SMESH_Group UnionGroups ( in SMESH_Group aGroup1, in SMESH_Group aGroup2, in string name )
+
return_value = UnionGroups ( aGroup1, aGroup2, name )
+ + +
SMESH_Group IntersectGroups ( in SMESH_Group aGroup1, in SMESH_Group aGroup2, in string name )
+
return_value = IntersectGroups ( aGroup1, aGroup2, name )
+ + +
SMESH_Group CutGroups ( in SMESH_Group aMainGroup, in SMESH_Group aToolGroup, in string name )
+
return_value = CutGroups ( aMainGroup, aToolGroup, name )
+ + +
Hypothesis_Status AddHypothesis ( in GEOM_Object aSubObject, in SMESH_Hypothesis anHyp )
+
return_value = AddHypothesis ( aSubObject, anHyp )
+ + +
Hypothesis_Status RemoveHypothesis ( in GEOM_Object aSubObject, in SMESH_Hypothesis anHyp )
+
return_value = RemoveHypothesis ( aSubObject, anHyp )
+ + +
ListOfHypothesis GetHypothesisList ( in GEOM_Object aSubObject )
+
return_value = GetHypothesisList ( aSubObject )
log_array GetLog ( in boolean clearAfterGet )
@@ -47,14 +79,18 @@
ExportDAT ( file )
-
void ExportMED ( in string file )
-
ExportMED ( file )
+
void ExportMED ( in string file, in boolean auto_groups )
+
ExportMED ( file, auto_groups )
void ExportUNV ( in string file )
ExportUNV ( file )
+
void ExportSTL ( in string file, in boolean isascii )
+
ExportSTL ( file, isascii )
+ +
MESH GetMEDMesh ( )
return_value = GetMEDMesh ( )
@@ -91,9 +127,21 @@
return_value = NbHexas ( )
+
long NbPyramids ( )
+
return_value = NbPyramids ( )
+ + +
long NbPrisms ( )
+
return_value = NbPrisms ( )
+ +
long NbSubMesh ( )
return_value = NbSubMesh ( )
+ +
string Dump ( )
+
return_value = Dump ( )
+
@@ -107,14 +155,18 @@ - - + + + + + + @@ -162,5 +214,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
return_value = GetNumberOfElements ( )
long GetNumberOfNodes ( )
return_value = GetNumberOfNodes ( )
long GetNumberOfNodes ( in boolean all )
return_value = GetNumberOfNodes ( all )
long_array GetElementsId ( )
return_value = GetElementsId ( )
long_array GetElementsByType ( in ElementType theType )
return_value = GetElementsByType ( theType )
long_array GetNodesId ( )
return_value = GetNodesId ( )
boolean AddVolume ( in long_array IDsOfNodes )
return_value = AddVolume ( IDsOfNodes )
boolean MoveNode ( in long NodeID, in double x, in double y, in double z )
return_value = MoveNode ( NodeID, x, y, z )
boolean InverseDiag ( in long NodeID1, in long NodeID2 )
return_value = InverseDiag ( NodeID1, NodeID2 )
boolean DeleteDiag ( in long NodeID1, in long NodeID2 )
return_value = DeleteDiag ( NodeID1, NodeID2 )
boolean Reorient ( in long_array IDsOfElements )
return_value = Reorient ( IDsOfElements )
boolean TriToQuad ( in long_array IDsOfElements, in NumericalFunctor Criterion, in double MaxAngle )
return_value = TriToQuad ( IDsOfElements, Criterion, MaxAngle )
boolean QuadToTri ( in long_array IDsOfElements, in NumericalFunctor Criterion )
return_value = QuadToTri ( IDsOfElements, Criterion )
boolean SplitQuad ( in long_array IDsOfElements, in boolean Diag13 )
return_value = SplitQuad ( IDsOfElements, Diag13 )
boolean Smooth ( in long_array IDsOfElements, in long_array IDsOfFixedNodes, in long MaxNbOfIterations, in double MaxAspectRatio, in Smooth_Method Method )
return_value = Smooth ( IDsOfElements, IDsOfFixedNodes, MaxNbOfIterations, MaxAspectRatio, Method )
void RenumberNodes ( )
RenumberNodes ( )
void RenumberElements ( )
RenumberElements ( )
void RotationSweep ( in long_array IDsOfElements, in AxisStruct Axix, in double AngleInRadians, in long NbOfSteps, in double Tolerance )
RotationSweep ( IDsOfElements, Axix, AngleInRadians, NbOfSteps, Tolerance )
void ExtrusionSweep ( in long_array IDsOfElements, in DirStruct StepVector, in long NbOfSteps )
ExtrusionSweep ( IDsOfElements, StepVector, NbOfSteps )
void Mirror ( in long_array IDsOfElements, in AxisStruct Mirror, in MirrorType theMirrorType, in boolean Copy )
Mirror ( IDsOfElements, Mirror, theMirrorType, Copy )
void Translate ( in long_array IDsOfElements, in DirStruct Vector, in boolean Copy )
Translate ( IDsOfElements, Vector, Copy )
void Rotate ( in long_array IDsOfElements, in AxisStruct Axis, in double AngleInRadians, in boolean Copy )
Rotate ( IDsOfElements, Axis, AngleInRadians, Copy )
void FindCoincidentNodes ( in double Tolerance, out array_of_long_array GroupsOfNodes )
GroupsOfNodes = FindCoincidentNodes ( Tolerance )
void MergeNodes ( in array_of_long_array GroupsOfNodes )
MergeNodes ( GroupsOfNodes )
void MergeEqualElements ( )
MergeEqualElements ( )
boolean SewFreeBorders ( in long FirstNodeID1, in long SecondNodeID1, in long LastNodeID1, in long FirstNodeID2, in long SecondNodeID2, in long LastNodeID2 )
return_value = SewFreeBorders ( FirstNodeID1, SecondNodeID1, LastNodeID1, FirstNodeID2, SecondNodeID2, LastNodeID2 )
boolean SewConformFreeBorders ( in long FirstNodeID1, in long SecondNodeID1, in long LastNodeID1, in long FirstNodeID2, in long SecondNodeID2 )
return_value = SewConformFreeBorders ( FirstNodeID1, SecondNodeID1, LastNodeID1, FirstNodeID2, SecondNodeID2 )
boolean SewBorderToSide ( in long FirstNodeIDOnFreeBorder, in long SecondNodeIDOnFreeBorder, in long LastNodeIDOnFreeBorder, in long FirstNodeIDOnSide, in long LastNodeIDOnSide )
return_value = SewBorderToSide ( FirstNodeIDOnFreeBorder, SecondNodeIDOnFreeBorder, LastNodeIDOnFreeBorder, FirstNodeIDOnSide, LastNodeIDOnSide )
boolean SewSideElements ( in long_array IDsOfSide1Elements, in long_array IDsOfSide2Elements, in long NodeID1OfSide1ToMerge, in long NodeID1OfSide2ToMerge, in long NodeID2OfSide1ToMerge, in long NodeID2OfSide2ToMerge )
return_value = SewSideElements ( IDsOfSide1Elements, IDsOfSide2Elements, NodeID1OfSide1ToMerge, NodeID1OfSide2ToMerge, NodeID2OfSide1ToMerge, NodeID2OfSide2ToMerge )

diff --git a/doc/salome/tui/SMESH/doxyfile b/doc/salome/tui/SMESH/doxyfile index a4c5be459..883136c2f 100755 --- a/doc/salome/tui/SMESH/doxyfile +++ b/doc/salome/tui/SMESH/doxyfile @@ -3,7 +3,7 @@ #--------------------------------------------------------------------------- # General configuration options #--------------------------------------------------------------------------- -PROJECT_NAME = "SALOME - SMESH - v.2.0.0" +PROJECT_NAME = "SALOME - SMESH - v.2.1.0" PROJECT_NUMBER = id#1.1 OUTPUT_DIRECTORY = ../ OUTPUT_LANGUAGE = English diff --git a/doc/salome/tui/SMESH/sources/static/page2.html b/doc/salome/tui/SMESH/sources/static/page2.html index bfb35c85e..0e5c0ad5e 100755 --- a/doc/salome/tui/SMESH/sources/static/page2.html +++ b/doc/salome/tui/SMESH/sources/static/page2.html @@ -38,6 +38,10 @@
  • Mapping of SMESH_BasicHypothesis functions
  • Mapping of SMESH_Hypothesis functions
  • Mapping of SMESH_Mesh functions
  • +
  • Mapping of SMESH_Filter functions
  • +
  • Mapping of SMESH_Gen functions
  • +
  • Mapping of SMESH_Group functions
  • +
  • Mapping of SMESH_Pattern functions
  • diff --git a/doc/salome/tui/SMESH/sources/static/tree.js b/doc/salome/tui/SMESH/sources/static/tree.js index 8461479c2..e1c95ec93 100755 --- a/doc/salome/tui/SMESH/sources/static/tree.js +++ b/doc/salome/tui/SMESH/sources/static/tree.js @@ -1,4 +1,4 @@ -foldersTree = gFld("SALOME v.2.0.0 ", "", "") +foldersTree = gFld("SALOME v.2.1.0 ", "", "") insDoc(foldersTree, gLnk("Main Page", "", "main.html")) aux1 = insFld(foldersTree, gFld("TUI Reference Guide", "")) diff --git a/idl/Makefile.in b/idl/Makefile.in index 40a4c84f2..8bc4e84d3 100644 --- a/idl/Makefile.in +++ b/idl/Makefile.in @@ -16,7 +16,8 @@ IDL_FILES = \ SMESH_Hypothesis.idl \ SMESH_BasicHypothesis.idl \ SMESH_Filter.idl \ - SMESH_Group.idl + SMESH_Group.idl \ + SMESH_Pattern.idl PY_CLIENT_IDL = $(IDL_FILES) diff --git a/idl/SMESH_BasicHypothesis.idl b/idl/SMESH_BasicHypothesis.idl index 9987c2c44..cd23d2431 100644 --- a/idl/SMESH_BasicHypothesis.idl +++ b/idl/SMESH_BasicHypothesis.idl @@ -80,6 +80,23 @@ module StdMeshers double GetScaleFactor(); }; + /*! + * StdMeshers_Arithmetic1D: interface of "Arithmetic 1D" hypothesis + */ + interface StdMeshers_Arithmetic1D : SMESH::SMESH_Hypothesis + { + /*! + * Sets or parameter value + */ + void SetLength(in double length, in boolean isStartLength) + raises (SALOME::SALOME_Exception); + + /*! + * Returns or parameter value + */ + double GetLength(in boolean isStartLength); + }; + /*! * StdMeshers_MaxElementArea: interface of "Max. Triangle Area" hypothesis */ @@ -114,6 +131,42 @@ module StdMeshers long GetMode(); }; + /*! + * StdMeshers_StartEndLength: interface of "Start and End Length" hypothesis + */ + interface StdMeshers_StartEndLength : SMESH::SMESH_Hypothesis + { + /*! + * Sets or parameter value + */ + void SetLength(in double length, in boolean isStartLength) + raises (SALOME::SALOME_Exception); + + /*! + * Returns or parameter value + */ + double GetLength(in boolean isStartLength); + }; + + + /*! + * StdMeshers_Deflection1D: interface of "Deflection 1D" hypothesis + */ + interface StdMeshers_Deflection1D : SMESH::SMESH_Hypothesis + { + /*! + * Sets parameter value + */ + void SetDeflection(in double deflection) + raises (SALOME::SALOME_Exception); + + /*! + * Returns parameter value + */ + double GetDeflection(); + }; + + /*! * StdMeshers_MaxElementVolume: interface of "Max. Hexahedron or Tetrahedron Volume" hypothesis */ @@ -139,6 +192,16 @@ module StdMeshers { }; + /*! + * StdMeshers_Propagation: interface of "Propagation" hypothesis. + * Presence of this hypothesis on any edge propagates any other 1D + * hypothesis from this edge on all edges, opposite to it. + * It concerns only edges of quadrangle faces. + */ + interface StdMeshers_Propagation : SMESH::SMESH_Hypothesis + { + }; + /*! * StdMeshers_Regular_1D: interface of "Wire discretisation" algorithm */ diff --git a/idl/SMESH_Filter.idl b/idl/SMESH_Filter.idl index e0a5d7739..d1f0c3d9f 100644 --- a/idl/SMESH_Filter.idl +++ b/idl/SMESH_Filter.idl @@ -29,82 +29,351 @@ #include "SALOME_GenericObj.idl" #include "SMESH_Mesh.idl" -module SMESH{ - interface Functor: SALOME::GenericObj{ - void SetMesh(in SMESH_Mesh theMesh); +module GEOM +{ + interface GEOM_Object; +}; + + +module SMESH +{ + + /*! + * Enumeration of functor types + */ + enum FunctorType + { + FT_AspectRatio, + FT_Warping, + FT_MinimumAngle, + FT_Taper, + FT_Skew, + FT_Area, + FT_FreeBorders, + FT_FreeEdges, + FT_MultiConnection, + FT_Length, + FT_BelongToGeom, + FT_BelongToPlane, + FT_BelongToCylinder, + FT_RangeOfIds, + FT_LessThan, + FT_MoreThan, + FT_EqualTo, + FT_LogicalNOT, + FT_LogicalAND, + FT_LogicalOR, + FT_Undefined }; - interface NumericalFunctor: Functor{ - double GetValue(in long theElementId); + /*! + * Base interface for all functors ( i.e. numerical functors and predicates ) + */ + interface Functor: SALOME::GenericObj + { + void SetMesh( in SMESH_Mesh theMesh ); + FunctorType GetFunctorType(); + ElementType GetElementType(); }; - interface MinimumAngle: NumericalFunctor{}; - interface AspectRatio: NumericalFunctor{}; - interface Warping: NumericalFunctor{}; - interface Taper: NumericalFunctor{}; - interface Skew: NumericalFunctor{}; - interface Area: NumericalFunctor{}; - interface Length: NumericalFunctor{}; - interface MultiConnection: NumericalFunctor{}; - interface Predicate: Functor{ - boolean IsSatisfy(in long thEntityId); + + /*! + * Numerical functors are intended for calculating value by Id of mesh entity + */ + interface NumericalFunctor: Functor + { + double GetValue( in long theElementId ); + + /*! + * Set precision for calculation. It is a position after point which is + * used to functor value after calculation. + */ + void SetPrecision( in long thePrecision ); + long GetPrecision(); + }; + interface MinimumAngle : NumericalFunctor{}; + interface AspectRatio : NumericalFunctor{}; + interface Warping : NumericalFunctor{}; + interface Taper : NumericalFunctor{}; + interface Skew : NumericalFunctor{}; + interface Area : NumericalFunctor{}; + interface Length : NumericalFunctor{}; + interface MultiConnection : NumericalFunctor{}; + + /*! + * Predicates are intended for verification of criteria, + * must return bool value by mesh id + */ + interface Predicate: Functor + { + boolean IsSatisfy( in long thEntityId ); + }; + + /*! + * Logical functor (predicate) "Belong To Geometry". + * Verify whether mesh element or node belong to pointed Geom Object + */ + interface BelongToGeom: Predicate + { + void SetGeom( in GEOM::GEOM_Object theGeom ); + void SetElementType( in ElementType theType ); + + void SetShapeName( in string theName ); + string GetShapeName(); + }; + + /*! + * Logical functor (predicate) "Belong To Surface". + * Base interface for "belong to plane" and "belong to cylinder interfaces" + */ + interface BelongToSurface: Predicate + { + void SetTolerance( in double theToler ); + double GetTolerance(); + void SetShapeName( in string theName, in ElementType theType ); + string GetShapeName(); }; + + /*! + * Logical functor (predicate) "Belong To Plane". + * Verify whether mesh element lie in pointed Geom planar object + */ + interface BelongToPlane: BelongToSurface + { + void SetPlane( in GEOM::GEOM_Object theGeom, in ElementType theType ); + }; + + /*! + * Logical functor (predicate) "Belong To Culinder". + * Verify whether mesh element lie in pointed Geom cylindrical object + */ + interface BelongToCylinder: BelongToSurface + { + void SetCylinder( in GEOM::GEOM_Object theGeom, in ElementType theType ); + }; + + /*! + * Logical functor (predicate) "Free borders". + * Verify whether 1D mesh element is free ( i.e. connected to one face only ) + */ interface FreeBorders: Predicate{}; - interface Comparator: Predicate{ - void SetMargin(in double theValue); - void SetNumFunctor(in NumericalFunctor theFunct); + /*! + * Logical functor (predicate) "Free edges". + * Verify whether 2D mesh element has free edges( i.e. edges connected to one face only ) + */ + interface FreeEdges: Predicate + + { + struct Border + { + long myElemId; + long myPnt1, myPnt2; + }; + typedef sequence Borders; + Borders GetBorders(); }; + + /*! + * Abstract logical functor (predicate) "RangeOfIds". + * Verify whether an Entity Id belongs to defined sequence of id's + */ + interface RangeOfIds: Predicate + { + void SetRange( in long_array theIds ); + boolean SetRangeStr( in string theRange ); + string GetRangeStr(); + + void SetElementType( in ElementType theType ); + }; + + /*! + * Comparator. Predicate for compare value calculated + * by numerical functor with threshold value + */ + interface Comparator: Predicate + { + void SetMargin( in double theValue ); + void SetNumFunctor( in NumericalFunctor theFunct ); + double GetMargin(); + }; interface LessThan: Comparator{}; interface MoreThan: Comparator{}; - interface EqualTo: Comparator{ - void SetTolerance(in double theTolerance ); + interface EqualTo : Comparator + { + void SetTolerance( in double theToler ); + double GetTolerance(); }; + /*! + * Logical predicates are intended for compose predicates using boolean operations + */ interface Logical: Predicate{}; - interface LogicalNOT: Logical{ + interface LogicalNOT: Logical + { void SetPredicate(in Predicate thePredicate); }; - interface LogicalBinary: Logical{ - void SetPredicate1(in Predicate thePredicate); - void SetPredicate2(in Predicate thePredicate); + interface LogicalBinary: Logical +{ + void SetPredicate1( in Predicate thePredicate ); + void SetPredicate2( in Predicate thePredicate ); }; - + interface LogicalAND: LogicalBinary{}; - interface LogicalOR: LogicalBinary{}; - interface Filter: SALOME::GenericObj{ - void SetPredicate( in Predicate thePredicate ); - long_array GetElementsId( in SMESH_Mesh theMesh ); - }; - - interface FilterManager: SALOME::GenericObj{ - MinimumAngle CreateMinimumAngle(); - AspectRatio CreateAspectRatio(); - Warping CreateWarping(); - Taper CreateTaper(); - Skew CreateSkew(); - Area CreateArea(); - Length CreateLength(); - MultiConnection CreateMultiConnection(); - - FreeBorders CreateFreeBorders(); - - LessThan CreateLessThan(); - MoreThan CreateMoreThan(); - EqualTo CreateEqualTo(); - - LogicalNOT CreateLogicalNOT(); - LogicalAND CreateLogicalAND(); - LogicalOR CreateLogicalOR(); - Filter CreateFilter(); - }; - + interface LogicalOR : LogicalBinary{}; + + /*! + * Filter + */ + interface Filter: SALOME::GenericObj + { + /*! + * Structure containing information about one criterion + * Type - FT_Taper, FT_Skew ... + * Compare - FT_LessThan, FT_MoreThan, FT_EqualTo + * Threshold - threshold value + * UnaryOp - unary logical operation: FT_LogicalNOT or FT_Undefined + * BinaryOp - binary logical operation FT_LogicalAND, FT_LogicalOR or + * (FT_Undefined must be for the last criterion) + * 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 + * Tolerance - Tolerance is used for comparators (EqualTo comparision) and for + * "Belong to plane" and "Belong to cylinder" predicates + * TypeOfElement - type of element SMESH::NODE, SMESH::FACE (used by BelongToGeom predicate only) + * Precision - Precision of numerical functors + */ + struct Criterion + { + long Type; + long Compare; + double Threshold; + string ThresholdStr; + long UnaryOp; + long BinaryOp; + double Tolerance; + ElementType TypeOfElement; + long Precision; + }; + + typedef sequence Criteria; + + void SetPredicate( in Predicate thePredicate ); + long_array GetElementsId( in SMESH_Mesh theMesh ); + ElementType GetElementType(); + Predicate GetPredicate(); + + boolean GetCriteria( out Criteria theCriteria ); + boolean SetCriteria( in Criteria theCriteria ); + }; + + + /*! + * Interface for working with library of filters + */ + interface FilterLibrary : SALOME::GenericObj + { + /*! + * Copy filter from library by name (new filter is created) + */ + Filter Copy( in string theFilterName ); + + /*! + * Methods for editing library + */ + boolean Add ( in string theFilterName, in Filter theFilter ); + boolean AddEmpty( in string theFilterName, in ElementType theType ); // add empty filter + boolean Delete ( in string theFilterName ); + boolean Replace ( in string theFilterName, in string theNewName, in Filter theFilter ); + + /*! + * Save library on disk + */ + boolean Save(); + boolean SaveAs( in string aFileName ); + + /*! + * Query methods + */ + boolean IsPresent( in string aFilterName ); + long NbFilters( in ElementType aType ); + string_array GetNames( in ElementType aType ); + string_array GetAllNames(); + void SetFileName( in string aFilterName ); + string GetFileName(); + }; + + + /*! + * Interface of Filter manager + */ + interface FilterManager: SALOME::GenericObj + { + /*! + * Create numerical functors + */ + MinimumAngle CreateMinimumAngle(); + AspectRatio CreateAspectRatio(); + Warping CreateWarping(); + Taper CreateTaper(); + Skew CreateSkew(); + Area CreateArea(); + Length CreateLength(); + MultiConnection CreateMultiConnection(); + + /*! + * Create logical functors ( predicates ) + */ + BelongToGeom CreateBelongToGeom(); + BelongToPlane CreateBelongToPlane(); + BelongToCylinder CreateBelongToCylinder(); + + FreeBorders CreateFreeBorders(); + FreeEdges CreateFreeEdges(); + + RangeOfIds CreateRangeOfIds(); + + /*! + * Create comparators ( predicates ) + */ + LessThan CreateLessThan(); + MoreThan CreateMoreThan(); + EqualTo CreateEqualTo(); + + /*! + * Create boolean operations ( predicates ) + */ + LogicalNOT CreateLogicalNOT(); + LogicalAND CreateLogicalAND(); + LogicalOR CreateLogicalOR(); + + /*! + * Create filter + */ + Filter CreateFilter(); + + /*! + * Load filter library. If libary does not exist it is created + */ + FilterLibrary LoadLibrary( in string aFileName ); + + /*! + * Create new library + */ + FilterLibrary CreateLibrary(); + + /*! + * Delete library + */ + boolean DeleteLibrary( in string aFileName ); + }; }; + #endif diff --git a/idl/SMESH_Gen.idl b/idl/SMESH_Gen.idl index 390813d48..32486e5aa 100644 --- a/idl/SMESH_Gen.idl +++ b/idl/SMESH_Gen.idl @@ -31,23 +31,25 @@ #include "SALOMEDS.idl" #include "GEOM_Gen.idl" -#include "GEOM_Shape.idl" #include "SMESH_Mesh.idl" #include "SMESH_Hypothesis.idl" module SMESH { - typedef sequence shape_array; + typedef sequence object_array; typedef sequence mesh_array; interface FilterManager; + interface SMESH_Pattern; interface SMESH_Gen : Engines::Component, SALOMEDS::Driver { FilterManager CreateFilterManager(); + SMESH_Pattern GetPattern(); + /*! Set the current study */ @@ -76,9 +78,15 @@ module SMESH * of TopoDS_Shapes and bind CORBA references of shape & subshapes * with TopoDS_Shapes */ - SMESH_Mesh CreateMesh( in GEOM::GEOM_Shape theShape ) + SMESH_Mesh CreateMesh( in GEOM::GEOM_Object theObject ) raises ( SALOME::SALOME_Exception ); + /*! + * Create Mesh object importing data from given UNV file + */ + SMESH_Mesh CreateMeshesFromUNV( in string theFileName ) + raises ( SALOME::SALOME_Exception ); + /*! * Create Mesh object(s) importing data from given MED file */ @@ -86,6 +94,12 @@ module SMESH out SMESH::DriverMED_ReadStatus theStatus ) raises ( SALOME::SALOME_Exception ); + /*! + * Create Mesh object importing data from given STL file + */ + SMESH_Mesh CreateMeshesFromSTL( in string theFileName ) + raises ( SALOME::SALOME_Exception ); + /*! * Create a Mesh object, without a geometry shape reference */ @@ -98,7 +112,7 @@ module SMESH * return NOK if hypothesis are not sufficient */ boolean Compute( in SMESH_Mesh theMesh, - in GEOM::GEOM_Shape theSubShape ) + in GEOM::GEOM_Object theSubObject ) raises ( SALOME::SALOME_Exception ); /*! @@ -106,23 +120,22 @@ module SMESH */ boolean IsReadyToCompute( in SMESH_Mesh theMesh, - in GEOM::GEOM_Shape theSubShape ) + in GEOM::GEOM_Object theSubObject ) raises ( SALOME::SALOME_Exception ); /*! * */ - long_array GetSubShapesId( in GEOM::GEOM_Shape theMainShape, - in shape_array theListOfSubShape ) + long_array GetSubShapesId( in GEOM::GEOM_Object theMainObject, + in object_array theListOfSubObjects ) raises ( SALOME::SALOME_Exception ); /*! * */ - // long_array GetSubMeshesState( in shape_array theListOfSubShape ) + // long_array GetSubMeshesState( in object_array theListOfSubShape ) // raises ( SALOME::SALOME_Exception ); - }; }; diff --git a/idl/SMESH_Group.idl b/idl/SMESH_Group.idl index 9842df2f6..a39c3445d 100644 --- a/idl/SMESH_Group.idl +++ b/idl/SMESH_Group.idl @@ -22,6 +22,7 @@ // Author : Sergey ANIKIN, OCC // $Header$ + #ifndef _SMESH_GROUP_IDL_ #define _SMESH_GROUP_IDL_ @@ -33,9 +34,9 @@ module SMESH { /*! - * SMESH_Group: interface of group object + * SMESH_Group: base interface of group object */ - interface SMESH_Group : SALOME::GenericObj + interface SMESH_GroupBase : SALOME::GenericObj, SMESH_IDSource { /*! * Sets group name @@ -62,21 +63,11 @@ module SMESH */ boolean IsEmpty(); - /*! - * Clears the group's contents - */ - void Clear(); - /*! * returns true if the group contains an element with ID == */ boolean Contains( in long elem_id ); - /*! - * Adds elements to the group - */ - long Add( in long_array elem_ids ); - /*! * Returns ID of an element at position */ @@ -87,16 +78,41 @@ module SMESH */ long_array GetListOfID(); - /*! - * Removes elements from the group - */ - long Remove( in long_array elem_ids ); - /*! * Returns the mesh object this group belongs to */ SMESH_Mesh GetMesh(); }; + + /*! + * SMESH_Group: interface of group object + */ + interface SMESH_Group : SMESH_GroupBase + { + /*! + * Clears the group's contents + */ + void Clear(); + + /*! + * Adds elements to the group + */ + long Add( in long_array elem_ids ); + + /*! + * Removes elements from the group + */ + long Remove( in long_array elem_ids ); + + }; + /*! + * SMESH_Group: interface of group object linked to geometry + */ + interface SMESH_GroupOnGeom : SMESH_GroupBase + { + GEOM::GEOM_Object GetShape(); + }; + }; diff --git a/idl/SMESH_Mesh.idl b/idl/SMESH_Mesh.idl index b81acf6a0..d64d9389f 100644 --- a/idl/SMESH_Mesh.idl +++ b/idl/SMESH_Mesh.idl @@ -27,15 +27,11 @@ #define _SMESH_MESH_IDL_ #include "SALOME_Exception.idl" -//#include "SMESH_Hypothesis.idl" - #include "SALOME_GenericObj.idl" -//#include "GEOM_Shape.idl" -//#include "MED.idl" module GEOM { - interface GEOM_Shape; + interface GEOM_Object; }; @@ -54,6 +50,7 @@ module SMESH typedef sequence double_array ; typedef sequence long_array ; typedef sequence string_array ; + typedef sequence array_of_long_array ; enum log_command { @@ -66,7 +63,10 @@ module SMESH ADD_PRISM, ADD_HEXAHEDRON, REMOVE_NODE, - REMOVE_ELEMENT + REMOVE_ELEMENT, + MOVE_NODE, + CHANGE_ELEMENT_NODES, + RENUMBER }; struct log_block @@ -77,6 +77,18 @@ module SMESH long_array indexes; }; + struct PointStruct { double x; + double y; + double z; } ; + struct DirStruct { PointStruct PS ; } ; // analog to Occ Direction + + struct AxisStruct { double x; + double y; + double z; + double vx; + double vy; + double vz; } ; + /*! * Enumeration for element type, like in SMDS @@ -122,16 +134,27 @@ module SMESH typedef sequence log_array; + + interface SMESH_IDSource + { + /*! + * Returns a sequence of all element IDs + */ + long_array GetIDs(); + }; + + interface SMESH_GroupBase; interface SMESH_Group; + interface SMESH_GroupOnGeom; interface SMESH_subMesh; interface SMESH_MeshEditor; - interface SMESH_Mesh : SALOME::GenericObj + interface SMESH_Mesh : SALOME::GenericObj, SMESH_IDSource { /*! * Associate a Shape to a Mesh created with NewEmpty */ -// boolean SetMesh(in GEOM::GEOM_Shape aShape) +// boolean SetMesh(in GEOM::GEOM_Object anObject) // raises (SALOME::SALOME_Exception); /*! @@ -140,7 +163,7 @@ module SMESH * SubMesh will be used instead of SubShape in a next idl version to * adress a specific subMesh... */ - SMESH_subMesh GetSubMesh(in GEOM::GEOM_Shape aSubShape, in string name) + SMESH_subMesh GetSubMesh(in GEOM::GEOM_Object aSubObject, in string name) raises (SALOME::SALOME_Exception); /*! @@ -149,6 +172,12 @@ module SMESH // SMESH_subMesh NewEmpty() // raises (SALOME::SALOME_Exception); + /*! + * Get geom shape to mesh. A result may be nil + */ + GEOM::GEOM_Object GetShapeToMesh() + raises (SALOME::SALOME_Exception); + /*! * Remove a submesh */ @@ -162,12 +191,56 @@ module SMESH in string name ) raises (SALOME::SALOME_Exception); + /*! + * Create a group from geometry group + */ + SMESH_GroupOnGeom CreateGroupFromGEOM( in ElementType elem_type, + in string name, + in GEOM::GEOM_Object theGeomObject ) + raises (SALOME::SALOME_Exception); + /*! * Remove a group */ - void RemoveGroup(in SMESH_Group aGroup) + void RemoveGroup(in SMESH_GroupBase aGroup) raises (SALOME::SALOME_Exception); + /*! + * Remove group with its contents + */ + void RemoveGroupWithContents( in SMESH_GroupBase aGroup ) + raises (SALOME::SALOME_Exception); + + /*! + * Union of two groups + * New group is created. All mesh elements that are + * present in initial groups are added to the new one + */ + SMESH_Group UnionGroups (in SMESH_GroupBase aGroup1, + in SMESH_GroupBase aGroup2, + in string name ) + raises (SALOME::SALOME_Exception); + + /*! + * Intersection of two groups + * New group is created. All mesh elements that are + * present in both initial groups are added to the new one. + */ + SMESH_Group IntersectGroups (in SMESH_GroupBase aGroup1, + in SMESH_GroupBase aGroup2, + in string name ) + raises (SALOME::SALOME_Exception); + + /*! + * Cut of two groups + * New group is created. All mesh elements that are present in + * 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 ) + raises (SALOME::SALOME_Exception); + /*! * Add hypothesis to the mesh, under a particular subShape * (or the main shape itself) @@ -185,7 +258,7 @@ module SMESH * (or one previous hypothesis on the subShape) * raises exception if hypothesis has not been created */ - Hypothesis_Status AddHypothesis(in GEOM::GEOM_Shape aSubShape, + Hypothesis_Status AddHypothesis(in GEOM::GEOM_Object aSubObject, in SMESH_Hypothesis anHyp) raises (SALOME::SALOME_Exception); // boolean AddHypothesis(in SMESH_subMesh aSubMesh, in SMESH_Hypothesis anHyp) @@ -195,7 +268,7 @@ module SMESH /*! * Remove an hypothesis previouly added with AddHypothesis. */ - Hypothesis_Status RemoveHypothesis(in GEOM::GEOM_Shape aSubShape, + Hypothesis_Status RemoveHypothesis(in GEOM::GEOM_Object aSubObject, in SMESH_Hypothesis anHyp) raises (SALOME::SALOME_Exception); // boolean RemoveHypothesis(in SMESH_subMesh aSubMesh, @@ -205,7 +278,7 @@ module SMESH /*! * Get the list of hypothesis added on a subShape */ - ListOfHypothesis GetHypothesisList(in GEOM::GEOM_Shape aSubShape) + ListOfHypothesis GetHypothesisList(in GEOM::GEOM_Object aSubObject) raises (SALOME::SALOME_Exception); // ListOfHypothesis GetHypothesisList(in SMESH_subMesh aSubMesh) // raises (SALOME::SALOME_Exception); @@ -250,6 +323,8 @@ module SMESH raises (SALOME::SALOME_Exception); void ExportUNV( in string file ) raises (SALOME::SALOME_Exception); + void ExportSTL( in string file, in boolean isascii ) + raises (SALOME::SALOME_Exception); /*! * Get MED Mesh @@ -293,7 +368,7 @@ module SMESH string Dump(); }; - interface SMESH_subMesh : SALOME::GenericObj + interface SMESH_subMesh : SALOME::GenericObj, SMESH_IDSource { /*! * @@ -304,7 +379,7 @@ module SMESH /*! * */ - long GetNumberOfNodes() + long GetNumberOfNodes( in boolean all ) raises (SALOME::SALOME_Exception); /*! @@ -325,6 +400,12 @@ module SMESH long_array GetNodesId() raises (SALOME::SALOME_Exception); + /*! + * Get geom shape the submesh is dedicated to + */ + GEOM::GEOM_Object GetSubShape() + raises (SALOME::SALOME_Exception); + /*! * Get SMESH_Mesh which stores nodes coordinates & elements definition */ @@ -344,28 +425,166 @@ module SMESH }; /* - * This interface makes modifications on the Mesh - removing elements and nodes - */ + * This interface makes modifications on the Mesh - removing elements and nodes etc. + */ + interface NumericalFunctor; interface SMESH_MeshEditor { - boolean RemoveElements(in long_array IDsOfElements) - raises (SALOME::SALOME_Exception); + boolean RemoveElements(in long_array IDsOfElements); - boolean RemoveNodes(in long_array IDsOfNodes) - raises (SALOME::SALOME_Exception); + boolean RemoveNodes(in long_array IDsOfNodes); - boolean AddNode(in double x, in double y, in double z) - raises (SALOME::SALOME_Exception); + boolean AddNode(in double x, in double y, in double z); - boolean AddEdge(in long_array IDsOfNodes) - raises (SALOME::SALOME_Exception); + boolean AddEdge(in long_array IDsOfNodes); - boolean AddFace(in long_array IDsOfNodes) - raises (SALOME::SALOME_Exception); + boolean AddFace(in long_array IDsOfNodes); + + boolean AddVolume(in long_array IDsOfNodes); + + boolean MoveNode(in long NodeID, in double x, in double y, in double z); + + boolean InverseDiag(in long NodeID1, in long NodeID2); + + boolean DeleteDiag(in long NodeID1, in long NodeID2); + + boolean Reorient(in long_array IDsOfElements); + + boolean ReorientObject(in SMESH_IDSource theObject); + + boolean TriToQuad(in long_array IDsOfElements, + in NumericalFunctor Criterion, + in double MaxAngle); + + boolean TriToQuadObject(in SMESH_IDSource theObject, + in NumericalFunctor Criterion, + in double MaxAngle); + + boolean QuadToTri(in long_array IDsOfElements, + in NumericalFunctor Criterion); + + boolean SplitQuad(in long_array IDsOfElements, + in boolean Diag13); + + boolean SplitQuadObject(in SMESH_IDSource theObject, + in boolean Diag13); + + enum Smooth_Method { LAPLACIAN_SMOOTH, CENTROIDAL_SMOOTH }; + + boolean Smooth(in long_array IDsOfElements, + in long_array IDsOfFixedNodes, + in long MaxNbOfIterations, + in double MaxAspectRatio, + in Smooth_Method Method); + + boolean SmoothObject(in SMESH_IDSource theObject, + in long_array IDsOfFixedNodes, + in long MaxNbOfIterations, + in double MaxAspectRatio, + in Smooth_Method Method); + + void RenumberNodes(); + + void RenumberElements(); + + void RotationSweep(in long_array IDsOfElements, + in AxisStruct Axix, + in double AngleInRadians, + in long NbOfSteps, + in double Tolerance); + + void RotationSweepObject(in SMESH_IDSource theObject, + in AxisStruct Axix, + in double AngleInRadians, + in long NbOfSteps, + in double Tolerance); + + void ExtrusionSweep(in long_array IDsOfElements, + in DirStruct StepVector, + in long NbOfSteps); + + void ExtrusionSweepObject(in SMESH_IDSource theObject, + in DirStruct StepVector, + in long NbOfSteps); + + enum MirrorType { POINT, AXIS, PLANE }; + + void Mirror (in long_array IDsOfElements, + in AxisStruct Mirror, + in MirrorType theMirrorType, + in boolean Copy); + + void MirrorObject (in SMESH_IDSource theObject, + in AxisStruct Mirror, + in MirrorType theMirrorType, + in boolean Copy); + + void Translate (in long_array IDsOfElements, + in DirStruct Vector, + in boolean Copy); + + void TranslateObject (in SMESH_IDSource theObject, + in DirStruct Vector, + in boolean Copy); + + void Rotate (in long_array IDsOfElements, + in AxisStruct Axis, + in double AngleInRadians, + in boolean Copy); + + void RotateObject (in SMESH_IDSource theObject, + in AxisStruct Axis, + in double AngleInRadians, + in boolean Copy); + + void FindCoincidentNodes (in double Tolerance, + out array_of_long_array GroupsOfNodes); + + void MergeNodes (in array_of_long_array GroupsOfNodes); + + void MergeEqualElements(); + + enum Sew_Error { + SEW_OK, + SEW_BORDER1_NOT_FOUND, + SEW_BORDER2_NOT_FOUND, + SEW_BOTH_BORDERS_NOT_FOUND, + SEW_BAD_SIDE_NODES, + SEW_VOLUMES_TO_SPLIT, + // for SewSideElements() only: + SEW_DIFF_NB_OF_ELEMENTS, + SEW_TOPO_DIFF_SETS_OF_ELEMENTS, + SEW_BAD_SIDE1_NODES, + SEW_BAD_SIDE2_NODES + }; + + Sew_Error SewFreeBorders (in long FirstNodeID1, + in long SecondNodeID1, + in long LastNodeID1, + in long FirstNodeID2, + in long SecondNodeID2, + in long LastNodeID2); + + Sew_Error SewConformFreeBorders (in long FirstNodeID1, + in long SecondNodeID1, + in long LastNodeID1, + in long FirstNodeID2, + in long SecondNodeID2); + + Sew_Error SewBorderToSide (in long FirstNodeIDOnFreeBorder, + in long SecondNodeIDOnFreeBorder, + in long LastNodeIDOnFreeBorder, + in long FirstNodeIDOnSide, + in long LastNodeIDOnSide); + + Sew_Error SewSideElements (in long_array IDsOfSide1Elements, + in long_array IDsOfSide2Elements, + in long NodeID1OfSide1ToMerge, + in long NodeID1OfSide2ToMerge, + in long NodeID2OfSide1ToMerge, + in long NodeID2OfSide2ToMerge); - boolean AddVolume(in long_array IDsOfNodes) - raises (SALOME::SALOME_Exception); }; }; diff --git a/idl/SMESH_Pattern.idl b/idl/SMESH_Pattern.idl new file mode 100644 index 000000000..1b626ad5e --- /dev/null +++ b/idl/SMESH_Pattern.idl @@ -0,0 +1,160 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESH_Pattern.idl +// Created : Mon Aug 2 10:48:36 2004 +// Author : Edward AGAPOV (eap) +// $Header: + +#ifndef _SMESH_PATTERN_IDL_ +#define _SMESH_PATTERN_IDL_ + +#include "SMESH_Mesh.idl" + +module SMESH +{ + + typedef sequence point_array; + + /*! + * SMESH_Pattern: interface of mesh pattern + */ + interface SMESH_Pattern { + + /*! + * Load a pattern from the string + */ + boolean LoadFromFile(in string theFileContents); + + /*! + * Create a pattern from the mesh built on . + * ==true makes override nodes positions + * on computed by mesher + */ + boolean LoadFromFace(in SMESH_Mesh theMesh, + in GEOM::GEOM_Object theFace, + in boolean theProject); + + /*! + * Create a pattern from the mesh built on + */ + boolean LoadFrom3DBlock(in SMESH_Mesh theMesh, + in GEOM::GEOM_Object theBlock); + + /*! + * Compute nodes coordinates applying + * the loaded pattern to . The first key-point + * will be mapped into , which must + * be in the outer wire of theFace + */ + point_array ApplyToFace(in GEOM::GEOM_Object theFace, + in GEOM::GEOM_Object theVertexOnKeyPoint1, + in boolean theReverse); + + /*! + * Compute nodes coordinates applying + * the loaded pattern to . The (0,0,0) key-point + * will be mapped into . The (0,0,1) + * key-point will be mapped into . + */ + point_array ApplyTo3DBlock(in GEOM::GEOM_Object theBlock, + in GEOM::GEOM_Object theVertex000, + in GEOM::GEOM_Object theVertex001); + + /*! + * Create nodes and elements in using nodes + * coordinates computed by either of Apply...() methods + */ + boolean MakeMesh(in SMESH_Mesh theMesh); + + /*! + * Return the loaded pattern in the string form to be saved in file + */ + string GetString(); + + /*! + * error code of the last of one of above operations + */ + enum ErrorCode { + ERR_OK, + // Load(file) + ERR_READ_NB_POINTS, // couldn't read nb of points + ERR_READ_POINT_COORDS, // invalid nb of point coordinates + ERR_READ_TOO_FEW_POINTS, // too few points in a pattern + ERR_READ_3D_COORD, // coordinate of 3D point out of [0,1] range + ERR_READ_NO_KEYPOINT, // no key-points in 2D pattern + ERR_READ_BAD_INDEX, // invalid point index + ERR_READ_ELEM_POINTS, // invalid nb of points in element + ERR_READ_NO_ELEMS, // no elements in a pattern + ERR_READ_BAD_KEY_POINT, // a key-point not on a boundary + // Save(file) + ERR_SAVE_NOT_LOADED, // pattern was not loaded + // Load(shape) + ERR_LOAD_EMPTY_SUBMESH, // no elements to load + // Load(face) + ERR_LOADF_NARROW_FACE, // too narrow face + ERR_LOADF_CLOSED_FACE, // closed face + // Load(volume) + ERR_LOADV_BAD_SHAPE, // volume is not a brick of 6 faces + ERR_LOADV_COMPUTE_PARAMS, // cant compute point parameters + // Apply(shape) + ERR_APPL_NOT_LOADED, // pattern was not loaded + ERR_APPL_BAD_DIMENTION, // wrong shape dimention + ERR_APPL_BAD_NB_VERTICES, // keypoints - vertices mismatch + // Apply(face) + ERR_APPLF_BAD_TOPOLOGY, // bad pattern topology + ERR_APPLF_BAD_VERTEX, // first vertex not on an outer face boundary + ERR_APPLF_INTERNAL_EEROR, // program error + // Apply(volume) + ERR_APPLV_BAD_SHAPE, // volume is not a brick of 6 faces + // MakeMesh + ERR_MAKEM_NOT_COMPUTED // mapping failed + }; + + /*! + * Return error code of the last operation + */ + ErrorCode GetErrorCode(); + + /*! + * Return true if the loaded pattern is a 2D one + */ + boolean Is2D(); + + /*! + * Return coordinates of pattern points + */ + point_array GetPoints(); + + /*! + * Return indices of key-points within the arrays returned by + * GetPoints() + */ + long_array GetKeyPoints(); + + /*! + * Return nodal connectivity of the elements of the pattern + */ + array_of_long_array GetElementPoints(); + }; +}; + +#endif diff --git a/resources/SMESHCatalog.xml b/resources/SMESHCatalog.xml index 0e7c64dc3..102ea6ffd 100644 --- a/resources/SMESHCatalog.xml +++ b/resources/SMESHCatalog.xml @@ -16,7 +16,7 @@ Mesh MESH NRI - 1.0 + 2.1.0 New Mesh component 1 ModuleMesh.png diff --git a/resources/SMESH_Meshers.xml b/resources/SMESH_Meshers.xml deleted file mode 100644 index 49aae9d0d..000000000 --- a/resources/SMESH_Meshers.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/SMESH_MeshersWithNETGEN.xml b/resources/SMESH_MeshersWithNETGEN.xml deleted file mode 100644 index 2952c9279..000000000 --- a/resources/SMESH_MeshersWithNETGEN.xml +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/resources/SMESH_en.xml b/resources/SMESH_en.xml index 449962659..0fe9cf4e3 100644 --- a/resources/SMESH_en.xml +++ b/resources/SMESH_en.xml @@ -16,7 +16,7 @@ - + @@ -30,11 +30,19 @@ + + + + + + + + @@ -53,20 +61,26 @@ + + + + + + + - - + @@ -74,7 +88,7 @@ - + @@ -86,9 +100,29 @@ - - + + + + + + + + + + + + + + + + + + + + + + @@ -96,7 +130,7 @@ - + @@ -109,6 +143,8 @@ + + @@ -134,6 +170,7 @@ + @@ -144,6 +181,8 @@ + + @@ -182,7 +221,7 @@ - + @@ -190,17 +229,18 @@ + + - - + @@ -223,7 +263,7 @@ - + @@ -231,17 +271,18 @@ + + - - + @@ -266,7 +307,7 @@ - + @@ -274,17 +315,18 @@ + + - - + @@ -324,20 +366,20 @@ + - - + - + - + @@ -345,12 +387,28 @@ + + + + + + + + + - - + + + + + + + + + diff --git a/resources/SMESH_fr.xml b/resources/SMESH_fr.xml index bef8ea89f..d5dbf4640 100644 --- a/resources/SMESH_fr.xml +++ b/resources/SMESH_fr.xml @@ -70,7 +70,7 @@ - + @@ -82,9 +82,21 @@ + + + + + + + + + + + + @@ -98,7 +110,7 @@ - + @@ -116,7 +128,7 @@ - + @@ -141,6 +153,8 @@ + + @@ -161,7 +175,7 @@ - + @@ -209,7 +223,7 @@ - + @@ -217,12 +231,22 @@ + + + + + + + + + + diff --git a/resources/StdMeshers.xml b/resources/StdMeshers.xml index 49aae9d0d..3bc3bc4c1 100644 --- a/resources/StdMeshers.xml +++ b/resources/StdMeshers.xml @@ -15,20 +15,36 @@ label-id="Average length" icon-id="mesh_hypo_length.png"/> - + + + + + + + + j9Ri9Y0BVd`PbvqY#hpq_ti=9n)4FbD61*!v9S`Td zb-Zo?#SyhH?No;`#%f)+a{6nHs(P+(4d*?rf3br-n~)9)s1Hh*4Z@(amer3hxgGKMCwOv$c~F@|Lb598nTgAQ*`K3O?n0`2~6!2(WS z=V6-`Ef?Ge{R}Jz6p8oo^!;vSwMI1^pPg5DSE;85lL3k&DiWXYt}^%8vlsDqIPYn4 zLyF>v)-P?IKN04+J|8YB{OV3%1;#-O0F`oyQn~afNPkjxVv8k&QwXO^01A(JP6t)i zE8GPg?t(6+X{_8m{2xo7W-~eE_*lZTMeAmkVr*t4#&uV6YF zg!;XGt0JN|orxw9p6jdU`nt}D{YQHeU%AyxW)Gtf!tspzpdWV-K}Cc&FE6Nl&8xZX zPKcuH+)270TCqx4H&XA)=g-Md&t9Fgm_k43u-O|$gw6O&$@|>2zv*ZY>djVZ`}|ZrE5Jevrh3R~RTp$O zX(E>?a{(7A)5T>9ODVw>OJ{e`O$r>c81UjaUm9tE*}tEiKM*xRBl=BTcrP((EOv}#l9(SOhrhb(kAj3%(#H$|-G zo8Hs9eZ1}zeVh#@Sud>BquKB{0qQ$Ls2WpS<_8Ds zjQSS+75`3n(Nd&*ye8PZWSza#pSFu8WtX?_brQO>X`Y^SdUZpwg|}?k@antM-8P{^ r(!`kYBw|O=-i-Dj1VbEn&M)8_glVySwk}B200000NkvXXu0mjfyxgD| diff --git a/resources/mesh_cutGroups.png b/resources/mesh_cutGroups.png new file mode 100644 index 0000000000000000000000000000000000000000..b06bb8052437bc5e722f62d6c1bb4fbf3f15fdc4 GIT binary patch literal 340 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VTavfC3&Vd9T(EcfWS|IVfk$L9 z0|U1Z2s2)~TlWVj$X?><>&kwGLx_*l`1SPbl0cz{o-U3d6?2|WvFAEuAkx0yqh0*P zg^k}Q#vQ%L+>x-SX>mD+?2(h)r5YuIw;U_@wjLGJmfHQZS%>rIr%zA&9cP*fGN>`E zo{_0g5EE~gww6!Q?z`4R1tp!$sr>!-d~2q!TC-uJs-olf`P*ME{^gfNwbE8uK5u*6aDMMR|8(9m3%}0u_eDA|(I-0WL{I zK~#90t&+cP!Y~lVKUW^k5(8sLUVyPrfEe=-EW8HFE1>M1=$0~gqw*6l<^>oTkj$8& z(sgLk+Kz1?;-o0CbN9RN{s=IhYA?^l0djPtaB5=+05D&M#psfq$ojJeNgAOrk=|Y` z)I@=Z0C47s-0HI7^K8btY#0Dn+sgYdbD04^myLIRdoR56ud1*J2N(iku;WUj*vz9o z4^R2H(tqD>@?tYbwXM26?8bgeoePT@5&4UqDkJP$?-#xmsehn3m@Mp;I&(09bb7d0 zE(G9DJA|bw0D!h_0fY-9z9P00000 LNkvXXu0mjfZAz}I literal 0 HcmV?d00001 diff --git a/resources/mesh_deleteGroups.png b/resources/mesh_deleteGroups.png new file mode 100644 index 0000000000000000000000000000000000000000..b7126e002d7aa7ab3a7c9a9265a9f283f1ecfa20 GIT binary patch literal 212 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!9%)r1XI!iqT$l(m|32{Ae-~f>MpMk-+o$V%& z#aI&L7tG-B>_!@hljQC0!qCAg>jC75mAFQf1m~xflqVLYGNfmw85QKED;Vh+=o#9^ z?aKhF@bYwV45^rtoRAQZz`&@=rl@d};fZB~%MKBV8!Qqm2Z9)7c$k=Yboh9Bcz9&^ zc(@NN(ot|a%eZ2eW+U$rp9Y~h!WNPeDv}GT7{z>>C BH68!} literal 0 HcmV?d00001 diff --git a/resources/mesh_extrusion.png b/resources/mesh_extrusion.png new file mode 100644 index 0000000000000000000000000000000000000000..76909c0e119d8f8c0495d7a197023d670343e339 GIT binary patch literal 427 zcmV;c0aX5pP)xd0XRuS zK~#90rIW#NgD?<9-)h{1ThJ{fI7eKQHJD6Ff@8{{g>>PcgAhm{?2zn?1|+S%-u?wc z91nxO8v(cmKfgD@>$J|5EmxQ@6^0?k2>Ehu*vUQ~Mr$qMBvnOHzsoN(E z(fwVlx%pWPrjoD0|C<>&kwGLx_)4uVdow13;mRo-U3d6?2|W*~@v@K)}tORaCuT z;icaa>mM00v-m$WvgY8Q&>F&Vh2@P>fo9L7h>g6KyHAI6-F^J-rF&yxh6#fM=LVjw ze0OeakYFv_n|z5y$tg5^ebnC2?NcR`d=e89(_gD=USRKkXqQmav-#`Ec}(Zs?ma9i zee(L}wy4`Brk~g*1#diTb8_X4#CcD?7$lsMXS%<9&fUGsR+lqKp8DFC-0|Vy;=Nn; z?|r+J&r{eZF<_BM={H`LrdC!#S>``~nhbb#epOAMANQ=pUchMiGJ^`HuN-cckuP+Z QfSzOUboFyt=akR{0G&B~TmS$7 literal 0 HcmV?d00001 diff --git a/resources/mesh_merge_nodes.png b/resources/mesh_merge_nodes.png new file mode 100644 index 0000000000000000000000000000000000000000..275862ed89b7c1129f55d0a59ad2301bb7be9e02 GIT binary patch literal 560 zcmV-00?+-4P)GX7U_cK-9)uj*$DL|~=lJ08&((`m-R44=q*NbNm zw`r|;ni_uJ8MM~!Jgfl3sw)BKlUgccDPWE~vY8rtHYztdt%7(k1w_g|Lo+ob-x8#> zU7byWAP!EpR3|Dxxn#<53~+z|A`8&kZZC-S`F6(PV6PtMk|{gF$cf&XuwmQ#iDSPU z+>lGAa>;@}M!w9&}diuNcd^uQ~d4Oq!;Fw?4E@ zKX#6ak3K8|yiWhS{zI8R0I!9I>3ItMaMAXD(&$-}{qFAtP(95>Vn?IlMDE8%q_}Vq zko&Qzn{Rh6rsOo9TiZpn*=^a0-2vvK;Y8MUdvl=Ex{D&gH-Gk4*Ef=^_7Ka%Satu! zsw;{XE)7O>#3MV745#Oid(kp;M8$DedLn`KMonp(^Y{1hxUwPT8 z33C?)E$^GtX#AaFP9taOt7CF2uIRpF=v*Td<>&kwGO^BCCds*eQJwT!7o-U3d6?3*u3FJCtz|$7|k;kg4 zrP05t`=MtU8~ZxHmreEv9;_*5;*7i~1F?;g}+8zy^_XT2C0RS@4L5_*(v(^20V*BWP350nfmq zzmJl>p3HRdzy0*|QHPbXi|j?z0=Qo=)YyB+N$t!_gX7F_Nb6Mw<&;$T-*o8j; literal 0 HcmV?d00001 diff --git a/resources/mesh_renumbering_nodes.png b/resources/mesh_renumbering_nodes.png new file mode 100644 index 0000000000000000000000000000000000000000..dc1cb3dc8cc98f5e8a2908e13976f2f35d6fa991 GIT binary patch literal 388 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VTavfC3&Vd9T(EcfWS|IVfk$L9 z0|U1Z2s2)~TlWVj$X?><>&kwGO^BC~LGgu+Jp%)ypr?ytNX4ADQyjex2Z*?y&u;eC zQ1lQNII%`y-2$f*W+HE-COO_|UT~X(wKdOS_2LF^jofJolWo}9{(7!b6DWBkeZSn| zfAN3uDURtTI`8CvR696M%&Yyu?ELe@NrMC5U&hpPD{PhxJw568=hSS&1FL7M7IH0c zd?IVIjX~{pZ_2jC3~2_P!KQa7S!`|i+ut_-!p?Vj%WY!sFa`vfeEzNQNu~3${`v)F z?flcfd(327J-_pWdG+(h=qtAYN1FQjg|+wr7wy?%t$)_?>tmwTHfPvy8@@18m(YD@L4 g7szopr0E0E4dH?_b literal 0 HcmV?d00001 diff --git a/resources/mesh_revolution.png b/resources/mesh_revolution.png new file mode 100644 index 0000000000000000000000000000000000000000..3190e5f1bc4434007c99a2a6083db131ec0dc9bd GIT binary patch literal 450 zcmV;z0X_bSP)wZbWk;%5dP zn;$~0Ga!gPi6xs-%}c4ig(kqhdC=mot>PokCCY6)T%BR&X%9;tDzH3j4lwsHjdb*u zXB&ajBQqK=0bfzr00ll~$7ZH5`B%O&fbs{(8T3qH|Cazxosz>% literal 0 HcmV?d00001 diff --git a/resources/mesh_rotation.png b/resources/mesh_rotation.png new file mode 100644 index 0000000000000000000000000000000000000000..b971d45542382a0e4bb2d955d9e69519fbac7a72 GIT binary patch literal 646 zcmV;10(t$3P)CnniXCM-q_&s05=u`H0y7n@fp3{#oF z?`hLwiKgiQgc-i35twoPZ-g(0gvTF_=bDQoMxS=!@FaT)0FLVjWvh2VGk8)KXmwt9 z*4Q1QD_ea89s&4iL-f28llD{Lxt`IvMqB#nGQtYb8-+cG%bDwWC&o`3!gDXch4FJN&VYd)VK-`Y+0S_(UyOa`uXggXt+}ZdUwrXZ74B%p1EZ8Wd zlsQnd0P5>?vOFVh$7|uM+UYoK{GdyYQhn80Q;D`Bf@XlSRi%2rdYbGdLQ0905@oCD zIV}y0wxe58%I>5gXa*O`R(BoOF}~~LyZ#NwbxeJ|PP7%xympZ~yPa=Z>y?>J37Wx~ zvK2}xlu~b$tq7XIkYE^EMtBG4j#m9IPq}+DZpWWWmTs{Q-XEAje?Zz#=e(tVn<7a| gvTCp5;mvt}0OSC_EBH$9Gynhq07*qoM6N<$f<>&kwGU5r~wQ|7Tf2>C;W@ddx~I9WO?!3g z>vD(Shd#l{?<;y`S4MELnQTpqUz_G867@OBM6`QW=`77F6J-ti(>UHx3vIVCg!0EmT) AF#rGn literal 0 HcmV?d00001 diff --git a/resources/mesh_sew_conform_freeborders.png b/resources/mesh_sew_conform_freeborders.png new file mode 100644 index 0000000000000000000000000000000000000000..fff04a28e3a6b4eebd1d2cf012362e10a367ee0a GIT binary patch literal 419 zcmV;U0bKrxP)~!!Qs#T}B(XIle;09k{}^p~6nD{f=i?e}iAt^t%X*uI2Qk3VX}#6$v_95Re%#od&B{Yb zh&$TY^|9vCTyTwxa-&l&52XTbn{8el#dHy&BB?k}K{o9^-GAB(^R{5&ehVOv&LIlb~$$7D)KGvhJfG;lvBG}UGcP;<` N002ovPDHLkV1ij{uonOT literal 0 HcmV?d00001 diff --git a/resources/mesh_sew_freeborders.png b/resources/mesh_sew_freeborders.png new file mode 100644 index 0000000000000000000000000000000000000000..4b0f694dc365d7adf407cca2e7acc7f81595a509 GIT binary patch literal 412 zcmV;N0b~A&P)~!!Qsc!iH(3~>-E`49 z*iIycw)BJWjQJzaXTBxyKm-stt+Jb^h_4Ei(H4MWpVP;Ej;~O0!|ij0zYG!hc+N)e zp5EV3%HJVITLHvqEB9i)rC(QoYqXVF;9Eb!|4TO7PNy1_Jda7(>~fmYV)R#D?DHT$ zC>cNm)s!QP1o^YxKSo>b#Y6Pn`M5?~qLQ1^vf1U~K};}p+Gq_sZI5k~A2;@3v#PEL zaUV8zdu%y(XI$r^+~}06x>CS(v+c|FcT;wq!#M|YSR{)e*Jw*r^2J>MNRyN_Nn`ZC z|CfUY?BVsmGFg%)DeGcAYQuNHdLaT;U2$4vw8!@0E8r7v-XYjVJ8+T!0000<>&kwGU5s0fB{sn1El_BSr;B4q#hkN~4ssqg;BlQF#D5`L zp`^9%(#$S)Fa3R@My=aVtYsGYI$@WIqFCogMfsNfIupJ=~>-ie+?Q>%WV} l+hh+HC*)WMEW3Pw{e$$%+5dP#4guZI;OXk;vd$@?2>_^fZ_EGy literal 0 HcmV?d00001 diff --git a/resources/mesh_smoothing.png b/resources/mesh_smoothing.png new file mode 100644 index 0000000000000000000000000000000000000000..0da777dfa6c5639ae62b80fb4de1328aed58d323 GIT binary patch literal 416 zcmV;R0bl-!P)H zK~#90wUoh1!$1&*ziEoFJrrs{N}fQ3oO}%Fi+J%|DHNgDcknf&kKswEZ=h0$fgHM* z*74A6YU3ttX&eX%JO6&W^Un}TjG@VBHA(~8Rf%=Cr&YNiOXVnF4hw=T{r2SA>uyhj zEEV^z1?I38K)AG?sw9KY+ZiZKdXfmB_!S`D*9+yQGl}d|26}~z~0M3_oueL1$&kwIViNQE7)4g#cPt@?ad3n2m>_wL5Lt9PGK_F;Vuc?CC+kVt8vh z?4t3epo&8Eql(TR=b(pa<&^(nXe~eou)t+v%-cyoUo`Gv%1C5T4*N!%s?0000< KMNUMnLSTYIDzGO2 literal 0 HcmV?d00001 diff --git a/resources/mesh_symmetry_axis.png b/resources/mesh_symmetry_axis.png new file mode 100644 index 0000000000000000000000000000000000000000..dd5e19bcfd80083e8b90672b1e7ceaf6d9db00bb GIT binary patch literal 430 zcmV;f0a5;mP)>dr1qj^5h`Zd1uFcoLkTG@H+i4#}qhy+^2S!+h`k7gFM z05KBl2Rg6;v{PXhJP!20##ZVoxD^IqzUyY4gK)34R8CaycO%T0(gS0awHyOeafYwd zLQ0!#D7S42Der)96QKY7Uef%9l#Be@LzNs7w~)YFqDSgek)G0KbGJ`h3$=-UfZxT7 z0;1Q5s;*c8gki}3ZI9iDxjuyciLom4avcEdUUsCX)Xodzd=m_ys;j!~r=?IA)~)7p zx%3-!4mt(9%D>e%S^qwqP;y9S@564|z@|EW94YgXbABF#OlEBR-$938A#yF*uo;B> Y0k`SNFI^A_zW@LL07*qoM6N<$g1;#!!Qs=pG*oCZDD5I=2wfR^pc1+;Cbvl!E!qTp4WA(k8++k}H?6v` z&_$#&H7tXE~7iQlyu(J>32C-a>7lAK-U&Qb6<; zQPmY2fG`X>z8^7JdHWECH^!>W%WVK~cs-C_QoAmU@m(;0s;=s;pVmUhuzod7(+nHb z2VH{Qfa60~Z3o UFVZ+5f&c&j07*qoM6N<$f`VM9<^TWy literal 0 HcmV?d00001 diff --git a/resources/mesh_symmetry_point.png b/resources/mesh_symmetry_point.png new file mode 100644 index 0000000000000000000000000000000000000000..81a29a73cf673cf5f75b162e9e2a3db8e824c79d GIT binary patch literal 430 zcmV;f0a5;mP)GOoj%Grl7zA;*5UT%GW!|_0RP4&8`j30slRCQH%{j?T3g$=7| znr7UfE~pLG%Y4*2*!VrPC_cx|_iz~2*P$-o7s|ZkmfvPB)`;{MZiEhg1H@LaV>fg8 Y2MuY%E|Wy$cK`qY07*qoM6N<$g2zL*1poj5 literal 0 HcmV?d00001 diff --git a/resources/mesh_translation_points.png b/resources/mesh_translation_points.png new file mode 100644 index 0000000000000000000000000000000000000000..1805c97fbc0ec9f3c6bbde3ec3826597d17d201f GIT binary patch literal 469 zcmV;`0V@89P)3shDU(N?G@aGS>MrAtY;Dj-Oi9rAW!ZR2*+Q%x%UaGv1 z7Lbn;q;G14RX#Du$aYsrrjGN&V1ZEwOzY4vZ8FLM;Jxi!E0EZ5sktYk9AU7q*4C+z zI(|nR)C#O%29#`hHfW>Ex(TFVL|itZTHByrFn3kDFypE}nVk$gk zawA<;sE=K-JDBlC$>#GoWkLus!9)om>f`uTD1k8mYO|j%6V7Yszk%gkegb+D2rM@e z={6m#b_BxND#;o_8RhVn9;-rex=jZwJlHm5l*7OGSrrOHpsk~4LihW9Z=j>0UtLgd zIq%(l=NRTa%oDw*a2vb&T0`cHvIlOaIP)?W6D;7u1}tmJT4*00000 LNkvXXu0mjfbz8x) literal 0 HcmV?d00001 diff --git a/resources/mesh_translation_vector.png b/resources/mesh_translation_vector.png new file mode 100644 index 0000000000000000000000000000000000000000..dc4f08af10fa367e9ad0f474bc80ec41055e87cb GIT binary patch literal 458 zcmV;*0X6=KP))KAQq#fmdZ`iP|=)Zycz5IY|69lc6if9!zR@*{o&lc+= zrwU@cv8R(X(a|butZ-KrP(h4;=j$X*XacQVJrla!Zmofx4Ej|E^~OW%?stkX?|xXG zX*p72e7o7b3)}#Y;XGu}ADp{=_rkyRUu+b91FE#0s;GcV#{d8T07*qoM6N<$g1wr+ AO#lD@ literal 0 HcmV?d00001 diff --git a/resources/mesh_tree_algo_tetra.png b/resources/mesh_tree_algo_tetra.png index cb75b7e9d2c0c540feae86ebd25376f3cda5267d..9c21a58c198111012112d2fe5aafe20404d7c597 100644 GIT binary patch delta 253 zcmV)IZrXCjknNwP z^ke`nX$2C_68Y6Q<+zxumW~0ybpmDAt!;Ia$d3`!j#GiZK&H6^c}4{Zu@;wZNMt~9 zI~)nYnjne%5%|#lB*zD!POHtSQVc#+RZKnI9Gt`(N@_kEpPN=Y00000NkvXXu0mjf DvP@)< delta 119 zcmV--0EqvY0+a!eByd|vL_t(|+GAw+&p;MnB2OCw0}EDBMm+BL50u5K5vXZ%<7EtC z-+Em4U0GnYfgcM*i2-B$~0NQH=I~f`kL~BIX1OkYtCL+?YYou4; Z0074092ocDDDD6N002ovPDHLkV1jU@EGYm0 diff --git a/resources/mesh_union2tri.png b/resources/mesh_union2tri.png new file mode 100644 index 0000000000000000000000000000000000000000..88831b9afc0518e465bb75f11822d924834c76cf GIT binary patch literal 504 zcmVEjJRz7-+4bw1VDg5D{qKSoSwCu#XmE_NE_1Yqc^JL?jSLF|t|4 zf(lo!D^S!_Ez08XLc1yy5r|Valps)Pg#^jL4Wb^<_I+5#i5e__&udkxPE`^oo{D3T uFc8gxib!CDk=L73kki2SXLqgrC;kA{ag{=r^`v?L0000 literal 0 HcmV?d00001 diff --git a/resources/mesh_unionGroups.png b/resources/mesh_unionGroups.png new file mode 100644 index 0000000000000000000000000000000000000000..c3412bb09b2de82799924eaba0f741d1b5b37be8 GIT binary patch literal 425 zcmV;a0apHrP)rNG_V-f4e*WAMSp~orUJCWdmSUU^SK*1m2$BPquoKF8)&3{6$qT2m@Bj74as{%;)ZKcJpx*96S&9hdRyFc;xot(TEL)!_4}A zrj;{1tTfZg86H-eX)f5B-&KZl!Qacz^MZd)RNS<#mjjQLx4bv5?QXd@>C&vXxvsU? z>V$sZC8@zHP83keYC_8s4$*n)CnT)ASt zo|RK_K@l7rM5HnXrk}9F|2TRX;klmS>7|*55kVM~f{kxkY(X^?9^T2AYAF5z;a*{X TI1=ln00000NkvXXu0mjfR))N= literal 0 HcmV?d00001 diff --git a/resources/mesh_uniontri.png b/resources/mesh_uniontri.png new file mode 100644 index 0000000000000000000000000000000000000000..229cb6aa834bbbf42dfe448b0a6577fca39dbfc3 GIT binary patch literal 417 zcmV;S0bc%zP)90WL{I zK~#90t&%-z!$1&)--az_!G)^?atGHwfC;X2jTE|s@fD2l4V+F%;Yv1p0M))jz{apC zRRlIgw9fw95q=<+l{DYXn;8a;yXxV-IDik1WR^D#1^{v|H5+W%imcyj5T^kZCeo|3 zf*1)95dfWeB5$|LgL77^%K6T7nE_zCJUI7aF>&s{Rrw|?pbwa?=V;630y{lDqb-{N zY;?7UZP{F)1{O~{sqYci7>|a*7!g_=&O$Y*~rh%00000 LNkvXXu0mjfhfu2< literal 0 HcmV?d00001 diff --git a/resources/pattern_sample_2d.png b/resources/pattern_sample_2d.png new file mode 100755 index 0000000000000000000000000000000000000000..290872b5105974f199c563435cfaf842f135a1ff GIT binary patch literal 1180 zcmeAS@N?(olHy`uVBq!ia0vp^mwFdgVg_Dt6UpPx4{XPQ&i>9ZGV@SoEw|7r(x@9Hc5co6X z-~Z`T9lbic3*=^OyE5sT)ZN*ROxw(Kr8WAZvKjAvHvGkSfUAXt5f$}m!X{sW)aaEq8?D4?tweIWd`QyHxlX@#QsUu?MY~Fx-_YFBYnK(M%Zk?TQ zyzt8B`u(5E|Ll6)c+f{~drA1VN;M%C0U?_mMVB9b;Ek-9-wCrVkNahfzg*Spz5fp7 zo7H@KPmVnx%=t5$1*`}?)$g4 zeu}nu9^RB*&n75$J?#C~vfD0I-&nHNy086eFt_8%wgb;ium3(;b>jQPbA~hhVy0&D z^8QY`U&)egA#g@H*x~Gl{1dbM_9(sPe*a;Dmt=Y437bvpdqosYw^iF1AFlEc4NBha zuK9EMg~(GAybR}-ncuGTmkvs{dYgK!c&^=&AfM&2XKLz}bF4I+du_`h%eh)0p{r|( z3AEGvSl{vLmlLFJ@3kwlI~Ls%()F@r``!N6W{RfEf_096>VFGVU()sH$KTDV z9=$J1dXvBHU+WAMs+#)v%bjmPRhO^J%wEs=@<>V5xsN~QO_*me_g?`|ou9}28qn+$6Y=tBIWKe_m1UU7L$1sth(p@BeJ8(*j<{at$F7H8W;rEBqB z6B5cax0Ove_|q!$RQ3}0b^Q_#_dHv+$IVJu(AZ0KQpb$YSrc52X!O5VjGg#MYNf4U z{wX7;wO=D1@kSmrxV1am;OsTNG&L0t1u!az_7L1I@^IC?*ZP0f-F+;a@&Elf8QY$y z`fX(b3MNa|A6vOru3UQOzg_zjwU=GDOe?m?>b3QsKeyt##}|XFzdPNU7#<40d>{WN sPnP*>T>bV|7VC{$n;D#%aH9Q;38vqY10B;Xf#nE;r>mdKI;Vst0NdXA$p8QV literal 0 HcmV?d00001 diff --git a/resources/pattern_sample_3D.png b/resources/pattern_sample_3D.png new file mode 100755 index 0000000000000000000000000000000000000000..b3066858ea5779f2aa45a82f28466f78b4fbb22b GIT binary patch literal 2160 zcmds(|3A}fAIG-}$($tjr&+#^CC-{<9Gv-9A&eYSwxpPEAyHyqIJmiwXe3LcgPfx; z>O>it3gI?eYtwFvNwQVG=j)K{Xxtw^-v7e=xE}BK`+B_I*W-OX9@q80o{ua4mt#k@ zcOZ5^AP{YDFZVz&ia=}Jt`7R{lS|`ZP$v_PxfoSP&8dNfz z@f{R3E_?fVX!L19wXhCayz5X&>y* zgJj1wB$Ux&A+y8?SWzTRH6zexW@cKux};;dTde)rUO5^^&hq6rpDs4Bzwxe?W6|td? zMh(pS`V(MD!%B(hqEJ?pN~wH^D6L6=adm}efaOJOFOI+>Zb#h?Mh8mld=t>9QX+RT z)G4C)E@}vmk&Dp&Rq>&XCAlYdo3OcQyM+@=f{n%X$>DlQL`byh{H^L#Gi02n%y`I# zBlF)b!wL8KVM&~8A^b~Dn(@|q>gF}9ls`8YCGt51brWKo6=3O&l>a!}7T{_9uP9YdcXMyU*w>{fDtxK7kkR z%u^`zQ{iHFF}nOhr#m+=*>~DIk|uqc`}uhnWkqS%lEFWC)2L=_Mgs09K-@2#B+@I0 zG5p2?k1y?AQN1?6!{bLR8tjVumDvre$K2fGM-k94*bZvkMm{S z^7um8ePQFs;9Imk7{7XLxyfU-cbLY zWoWs&*AAE(tIViAR2UFZjL9BscbNC#35}&Em4)l(_SjxDn)>!pNUmj`u1dJpH&=se>TPk71)YT~N?{jUN7T7JN` ztR)y$Kn>2|9_$K!vEeFmsefc&JKW|!G35|!p*jxZZm}d``8O87>{)7~i3ZE%K4cTX zOIwN!#vK+6Rf=7{#RB^s->i#82KDfa-kncN=9snp7gyW1J?J$rQweAkCcUy1#kbVo znN+gQtR1V}>J$t33T6Tu92b@;B?c4c2Sh9VA4Be)>Z+KHzL_plxQK=?&ZYJ~v+cTZ zzq6#`x|Bkf^%$^5LSh;ud@^Qg0PD7I+g7*^EX)m?)fv=T4?p_!VK%hd?;kLGlU)ga zg=L-lpLAWpx#MbE-OH`uoSXkY>4wKq)1y%&sc483qqUyUnvS05XJlrgysN|$tAEZJ zr#P$;8fYeOe%_wmK zFU zUIqDL04oh&&@*J1tMZ*z4M8looIUkvvp@GsQ$jr%<5Z=CrYIFpMJkHdYo4p#k(&rjq#+pjtT?6JJvt-I6$f10HrF?k^9vE;md}m7lm&p{k0H zFl|_&^O1h_lYGi69fls&`{WXArYR5O_@+D|A-a^)z(uO5B|H7OViCjWZi;G)bXMly ztMg@hK}#cL7C}N%%_#g<2DMQLF!XeMXDd~YX35j`wWAI(Ez$mb6pLfSL#Cu37`)Xu zT+0;WWmlf#-wb2k_sg5*0r9vwIm=JQgMQslT+mf{@LnDP4WuJV9!qInI$ z<_vPn&Owk%*`MAU8F}V;Si#2Q)WHLWqkyS!?WJWTKj5X;s9hjh(gRCw#(>wiNgc&0 zo69z2H1lcg^o9jPq94h%hW}dGMu|0lGS`(9n~S&u;z)#*B*V-yd)*F5!N(SbZ4KJC z+AbtCv>Vy39@bt6)PrSh)aOEB+tslq@Q$o7NKPiSioQQz#eBB_{tY1B9>?4t9}dg@ EFVL*@A^-pY literal 0 HcmV?d00001 diff --git a/src/Controls/Makefile.in b/src/Controls/Makefile.in new file mode 100644 index 000000000..556958d66 --- /dev/null +++ b/src/Controls/Makefile.in @@ -0,0 +1,52 @@ +# SMESH OBJECT : interactive object for SMESH visualization +# +# 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Module : SMESH + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl + +@COMMENCE@ + +EXPORT_HEADERS = SMESH_Controls.hxx + + +# Libraries targets + +LIB = libSMESHControls.la +LIB_SRC = SMESH_Controls.cxx + +# Executables targets +BIN = SMESHControls +BIN_SRC = + +CPPFLAGS+=$(OCC_INCLUDES) $(BOOST_CPPFLAGS) -I${KERNEL_ROOT_DIR}/include/salome + +LDFLAGS+=$(OCC_KERNEL_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome -lOpUtil -lSMDS -lTKBRep -lTKG3d + +LDFLAGSFORBIN += -lSMDS -L${KERNEL_ROOT_DIR}/lib/salome -lOpUtil -lSALOMELocalTrace $(OCC_KERNEL_LIBS) -lTKBRep -lTKG3d + +@CONCLUDE@ diff --git a/src/SMDS/SMDS_IteratorOfArray.hxx b/src/Controls/SMESHControls.cxx similarity index 69% rename from src/SMDS/SMDS_IteratorOfArray.hxx rename to src/Controls/SMESHControls.cxx index a73fddbf5..10ecd711a 100644 --- a/src/SMDS/SMDS_IteratorOfArray.hxx +++ b/src/Controls/SMESHControls.cxx @@ -1,5 +1,3 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // @@ -19,24 +17,27 @@ // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -#include "SMDS_Iterator.hxx" +#include "SMESH_Controls.hxx" -template class SMDS_IteratorOfArray:public SMDS_Iterator +int main(int argc, char** argv) { - T2 const* myArray; - int index; - public: - SMDS_IteratorOfArray(T2 const* a):myArray(a),index(0) - {} + using namespace SMESH::Controls; + new MinimumAngle(); + new AspectRatio(); + new Warping(); + new Taper(); + new Skew(); + new Area(); + new Length(); + new MultiConnection(); + new FreeBorders(); + new LessThan(); + new MoreThan(); + new EqualTo(); + new LogicalNOT(); + new LogicalAND(); + new LogicalOR(); + new ManifoldPart(); - bool more() - { - return index(myArray[index-1]); - } -}; + return 1; +} diff --git a/src/Controls/SMESH_Controls.cxx b/src/Controls/SMESH_Controls.cxx new file mode 100644 index 000000000..a0dd64e13 --- /dev/null +++ b/src/Controls/SMESH_Controls.cxx @@ -0,0 +1,1762 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include "SMESH_Controls.hxx" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "SMDS_Mesh.hxx" +#include "SMDS_Iterator.hxx" +#include "SMDS_MeshElement.hxx" +#include "SMDS_MeshNode.hxx" + + + +/* + AUXILIARY METHODS +*/ + +static inline double getAngle( const gp_XYZ& P1, const gp_XYZ& P2, const gp_XYZ& P3 ) +{ + gp_Vec v1( P1 - P2 ), v2( P3 - P2 ); + + return v1.Magnitude() < gp::Resolution() || + v2.Magnitude() < gp::Resolution() ? 0 : v1.Angle( v2 ); +} + +static inline double getArea( const gp_XYZ& P1, const gp_XYZ& P2, const gp_XYZ& P3 ) +{ + gp_Vec aVec1( P2 - P1 ); + gp_Vec aVec2( P3 - P1 ); + return ( aVec1 ^ aVec2 ).Magnitude() * 0.5; +} + +static inline double getArea( const gp_Pnt& P1, const gp_Pnt& P2, const gp_Pnt& P3 ) +{ + return getArea( P1.XYZ(), P2.XYZ(), P3.XYZ() ); +} + +static inline double getDistance( const gp_XYZ& P1, const gp_XYZ& P2 ) +{ + double aDist = gp_Pnt( P1 ).Distance( gp_Pnt( P2 ) ); + return aDist; +} + +static int getNbMultiConnection( SMDS_Mesh* theMesh, const int theId ) +{ + if ( theMesh == 0 ) + return 0; + + const SMDS_MeshElement* anEdge = theMesh->FindElement( theId ); + if ( anEdge == 0 || anEdge->GetType() != SMDSAbs_Edge || anEdge->NbNodes() != 2 ) + return 0; + + TColStd_MapOfInteger aMap; + + int aResult = 0; + SMDS_ElemIteratorPtr anIter = anEdge->nodesIterator(); + if ( anIter != 0 ) + { + while( anIter->more() ) + { + const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next(); + if ( aNode == 0 ) + return 0; + SMDS_ElemIteratorPtr anElemIter = aNode->GetInverseElementIterator(); + while( anElemIter->more() ) + { + const SMDS_MeshElement* anElem = anElemIter->next(); + if ( anElem != 0 && anElem->GetType() != SMDSAbs_Edge ) + { + int anId = anElem->GetID(); + + if ( anIter->more() ) // i.e. first node + aMap.Add( anId ); + else if ( aMap.Contains( anId ) ) + aResult++; + } + } + } + } + + return aResult; +} + + +using namespace SMESH::Controls; + +/* + FUNCTORS +*/ + +/* + Class : NumericalFunctor + Description : Base class for numerical functors +*/ +NumericalFunctor::NumericalFunctor(): + myMesh(NULL) +{ + myPrecision = -1; +} + +void NumericalFunctor::SetMesh( SMDS_Mesh* theMesh ) +{ + myMesh = theMesh; +} + +bool NumericalFunctor::GetPoints(const int theId, + TColgp_SequenceOfXYZ& theRes ) const +{ + theRes.Clear(); + + if ( myMesh == 0 ) + return false; + + return GetPoints( myMesh->FindElement( theId ), theRes ); +} + +bool NumericalFunctor::GetPoints(const SMDS_MeshElement* anElem, + TColgp_SequenceOfXYZ& theRes ) +{ + theRes.Clear(); + + if ( anElem == 0) + return false; + + // Get nodes of the element + SMDS_ElemIteratorPtr anIter = anElem->nodesIterator(); + if ( anIter != 0 ) + { + while( anIter->more() ) + { + const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next(); + if ( aNode != 0 ) + theRes.Append( gp_XYZ( aNode->X(), aNode->Y(), aNode->Z() ) ); + } + } + + return true; +} + +long NumericalFunctor::GetPrecision() const +{ + return myPrecision; +} + +void NumericalFunctor::SetPrecision( const long thePrecision ) +{ + myPrecision = thePrecision; +} + +double NumericalFunctor::GetValue( long theId ) +{ + TColgp_SequenceOfXYZ P; + if ( GetPoints( theId, P )) + { + double aVal = GetValue( P ); + if ( myPrecision >= 0 ) + { + double prec = pow( 10., (double)( myPrecision ) ); + aVal = floor( aVal * prec + 0.5 ) / prec; + } + + return aVal; + } + + return 0.; +} + +/* + Class : MinimumAngle + Description : Functor for calculation of minimum angle +*/ + +double MinimumAngle::GetValue( const TColgp_SequenceOfXYZ& P ) +{ + double aMin; + + if ( P.Length() == 3 ) + { + double A0 = getAngle( P( 3 ), P( 1 ), P( 2 ) ); + double A1 = getAngle( P( 1 ), P( 2 ), P( 3 ) ); + double A2 = getAngle( P( 2 ), P( 3 ), P( 1 ) ); + + aMin = Min( A0, Min( A1, A2 ) ); + } + else if ( P.Length() == 4 ) + { + double A0 = getAngle( P( 4 ), P( 1 ), P( 2 ) ); + double A1 = getAngle( P( 1 ), P( 2 ), P( 3 ) ); + double A2 = getAngle( P( 2 ), P( 3 ), P( 4 ) ); + double A3 = getAngle( P( 3 ), P( 4 ), P( 1 ) ); + + aMin = Min( Min( A0, A1 ), Min( A2, A3 ) ); + } + else + return 0.; + + return aMin * 180 / PI; +} + +double MinimumAngle::GetBadRate( double Value, int nbNodes ) const +{ + const double aBestAngle = PI / nbNodes; + return ( fabs( aBestAngle - Value )); +} + +SMDSAbs_ElementType MinimumAngle::GetType() const +{ + return SMDSAbs_Face; +} + + +/* + Class : AspectRatio + Description : Functor for calculating aspect ratio +*/ +double AspectRatio::GetValue( const TColgp_SequenceOfXYZ& P ) +{ + int nbNodes = P.Length(); + + if ( nbNodes != 3 && nbNodes != 4 ) + return 0; + + // Compute lengths of the sides + + double aLen[ nbNodes ]; + for ( int i = 0; i < nbNodes - 1; i++ ) + aLen[ i ] = getDistance( P( i + 1 ), P( i + 2 ) ); + aLen[ nbNodes - 1 ] = getDistance( P( 1 ), P( nbNodes ) ); + + // Compute aspect ratio + + if ( nbNodes == 3 ) + { + double anArea = getArea( P( 1 ), P( 2 ), P( 3 ) ); + if ( anArea <= Precision::Confusion() ) + return 0.; + double aMaxLen = Max( aLen[ 0 ], Max( aLen[ 1 ], aLen[ 2 ] ) ); + static double aCoef = sqrt( 3. ) / 4; + + return aCoef * aMaxLen * aMaxLen / anArea; + } + else + { + double aMinLen = Min( Min( aLen[ 0 ], aLen[ 1 ] ), Min( aLen[ 2 ], aLen[ 3 ] ) ); + if ( aMinLen <= Precision::Confusion() ) + return 0.; + double aMaxLen = Max( Max( aLen[ 0 ], aLen[ 1 ] ), Max( aLen[ 2 ], aLen[ 3 ] ) ); + + return aMaxLen / aMinLen; + } +} + +double AspectRatio::GetBadRate( double Value, int /*nbNodes*/ ) const +{ + // the aspect ratio is in the range [1.0,infinity] + // 1.0 = good + // infinity = bad + return Value / 1000.; +} + +SMDSAbs_ElementType AspectRatio::GetType() const +{ + return SMDSAbs_Face; +} + + +/* + Class : AspectRatio3D + Description : Functor for calculating aspect ratio +*/ + +static inline double getHalfPerimeter(double theTria[3]){ + return (theTria[0] + theTria[1] + theTria[2])/2.0; +} + +static inline double getArea(double theHalfPerim, double theTria[3]){ + return sqrt(theHalfPerim* + (theHalfPerim-theTria[0])* + (theHalfPerim-theTria[1])* + (theHalfPerim-theTria[2])); +} + +static inline double getVolume(double theLen[6]){ + double a2 = theLen[0]*theLen[0]; + double b2 = theLen[1]*theLen[1]; + double c2 = theLen[2]*theLen[2]; + double d2 = theLen[3]*theLen[3]; + double e2 = theLen[4]*theLen[4]; + double f2 = theLen[5]*theLen[5]; + double P = 4.0*a2*b2*d2; + double Q = a2*(b2+d2-e2)-b2*(a2+d2-f2)-d2*(a2+b2-c2); + double R = (b2+d2-e2)*(a2+d2-f2)*(a2+d2-f2); + return sqrt(P-Q+R)/12.0; +} + +static inline double getHeight( const gp_Pnt& P1, const gp_Pnt& P2, + const gp_Pnt& P3, const gp_Pnt& P4) +{ + gp_Vec aVec1( P2.XYZ() - P1.XYZ() ); + gp_Vec aVec2( P3.XYZ() - P1.XYZ() ); + gp_Vec aNorm = aVec1 ^ aVec2; + aNorm /= aNorm.Magnitude(); + gp_Vec aVec3( P4.XYZ() - P1.XYZ() ); + double aDist = aVec1 * aVec2; + return fabs( aDist ); +} + +static inline double getMaxHeight( const TColgp_SequenceOfXYZ& P ) +{ + double aHeight = getHeight(P(1),P(2),P(3),P(4)); + aHeight = max(aHeight,getHeight(P(1),P(2),P(4),P(3))); + aHeight = max(aHeight,getHeight(P(1),P(3),P(4),P(2))); + aHeight = max(aHeight,getHeight(P(2),P(3),P(4),P(1))); + return aHeight; +} + +double AspectRatio3D::GetValue( const TColgp_SequenceOfXYZ& P ) +{ + double aQuality = 0.0; + int nbNodes = P.Length(); + switch(nbNodes){ + case 4:{ + double aLen[6] = { + getDistance(P(1),P(2)), // a + getDistance(P(2),P(3)), // b + getDistance(P(3),P(1)), // c + getDistance(P(2),P(4)), // d + getDistance(P(3),P(4)), // e + getDistance(P(1),P(4)) // f + }; + double aTria[4][3] = { + {aLen[0],aLen[1],aLen[2]}, // abc + {aLen[0],aLen[3],aLen[5]}, // adf + {aLen[1],aLen[3],aLen[4]}, // bde + {aLen[2],aLen[4],aLen[5]} // cef + }; + double aHalfPerim = getHalfPerimeter(aTria[0]); + double anArea = getArea(aHalfPerim,aTria[0]); + aHalfPerim = getHalfPerimeter(aTria[1]); + anArea += getArea(aHalfPerim,aTria[1]); + aHalfPerim = getHalfPerimeter(aTria[2]); + anArea += getArea(aHalfPerim,aTria[2]); + double aVolume = getVolume(aLen); + double aHeight = getMaxHeight(P); + aQuality = 1.0/3.0*aHeight*anArea/aVolume; + break; + } + } + return aQuality; +} + +double AspectRatio3D::GetBadRate( double Value, int /*nbNodes*/ ) const +{ + // the aspect ratio is in the range [1.0,infinity] + // 1.0 = good + // infinity = bad + return Value / 1000.; +} + +SMDSAbs_ElementType AspectRatio3D::GetType() const +{ + return SMDSAbs_Volume; +} + + +/* + Class : Warping + Description : Functor for calculating warping +*/ +double Warping::GetValue( const TColgp_SequenceOfXYZ& P ) +{ + if ( P.Length() != 4 ) + return 0; + + gp_XYZ G = ( P( 1 ) + P( 2 ) + P( 3 ) + P( 4 ) ) / 4; + + double A1 = ComputeA( P( 1 ), P( 2 ), P( 3 ), G ); + double A2 = ComputeA( P( 2 ), P( 3 ), P( 4 ), G ); + double A3 = ComputeA( P( 3 ), P( 4 ), P( 1 ), G ); + double A4 = ComputeA( P( 4 ), P( 1 ), P( 2 ), G ); + + return Max( Max( A1, A2 ), Max( A3, A4 ) ); +} + +double Warping::ComputeA( const gp_XYZ& thePnt1, + const gp_XYZ& thePnt2, + const gp_XYZ& thePnt3, + const gp_XYZ& theG ) const +{ + double aLen1 = gp_Pnt( thePnt1 ).Distance( gp_Pnt( thePnt2 ) ); + double aLen2 = gp_Pnt( thePnt2 ).Distance( gp_Pnt( thePnt3 ) ); + double L = Min( aLen1, aLen2 ) * 0.5; + if ( L < Precision::Confusion()) + return 0.; + + gp_XYZ GI = ( thePnt2 - thePnt1 ) / 2. - theG; + gp_XYZ GJ = ( thePnt3 - thePnt2 ) / 2. - theG; + gp_XYZ N = GI.Crossed( GJ ); + + if ( N.Modulus() < gp::Resolution() ) + return PI / 2; + + N.Normalize(); + + double H = ( thePnt2 - theG ).Dot( N ); + return asin( fabs( H / L ) ) * 180 / PI; +} + +double Warping::GetBadRate( double Value, int /*nbNodes*/ ) const +{ + // the warp is in the range [0.0,PI/2] + // 0.0 = good (no warp) + // PI/2 = bad (face pliee) + return Value; +} + +SMDSAbs_ElementType Warping::GetType() const +{ + return SMDSAbs_Face; +} + + +/* + Class : Taper + Description : Functor for calculating taper +*/ +double Taper::GetValue( const TColgp_SequenceOfXYZ& P ) +{ + if ( P.Length() != 4 ) + return 0; + + // Compute taper + double J1 = getArea( P( 4 ), P( 1 ), P( 2 ) ) / 2; + double J2 = getArea( P( 3 ), P( 1 ), P( 2 ) ) / 2; + double J3 = getArea( P( 2 ), P( 3 ), P( 4 ) ) / 2; + double J4 = getArea( P( 3 ), P( 4 ), P( 1 ) ) / 2; + + double JA = 0.25 * ( J1 + J2 + J3 + J4 ); + if ( JA <= Precision::Confusion() ) + return 0.; + + double T1 = fabs( ( J1 - JA ) / JA ); + double T2 = fabs( ( J2 - JA ) / JA ); + double T3 = fabs( ( J3 - JA ) / JA ); + double T4 = fabs( ( J4 - JA ) / JA ); + + return Max( Max( T1, T2 ), Max( T3, T4 ) ); +} + +double Taper::GetBadRate( double Value, int /*nbNodes*/ ) const +{ + // the taper is in the range [0.0,1.0] + // 0.0 = good (no taper) + // 1.0 = bad (les cotes opposes sont allignes) + return Value; +} + +SMDSAbs_ElementType Taper::GetType() const +{ + return SMDSAbs_Face; +} + + +/* + Class : Skew + Description : Functor for calculating skew in degrees +*/ +static inline double skewAngle( const gp_XYZ& p1, const gp_XYZ& p2, const gp_XYZ& p3 ) +{ + gp_XYZ p12 = ( p2 + p1 ) / 2; + gp_XYZ p23 = ( p3 + p2 ) / 2; + gp_XYZ p31 = ( p3 + p1 ) / 2; + + gp_Vec v1( p31 - p2 ), v2( p12 - p23 ); + + return v1.Magnitude() < gp::Resolution() || v2.Magnitude() < gp::Resolution() ? 0 : v1.Angle( v2 ); +} + +double Skew::GetValue( const TColgp_SequenceOfXYZ& P ) +{ + if ( P.Length() != 3 && P.Length() != 4 ) + return 0; + + // Compute skew + static double PI2 = PI / 2; + if ( P.Length() == 3 ) + { + double A0 = fabs( PI2 - skewAngle( P( 3 ), P( 1 ), P( 2 ) ) ); + double A1 = fabs( PI2 - skewAngle( P( 1 ), P( 2 ), P( 3 ) ) ); + double A2 = fabs( PI2 - skewAngle( P( 2 ), P( 3 ), P( 1 ) ) ); + + return Max( A0, Max( A1, A2 ) ) * 180 / PI; + } + else + { + gp_XYZ p12 = ( P( 1 ) + P( 2 ) ) / 2; + gp_XYZ p23 = ( P( 2 ) + P( 3 ) ) / 2; + gp_XYZ p34 = ( P( 3 ) + P( 4 ) ) / 2; + gp_XYZ p41 = ( P( 4 ) + P( 1 ) ) / 2; + + gp_Vec v1( p34 - p12 ), v2( p23 - p41 ); + double A = v1.Magnitude() <= gp::Resolution() || v2.Magnitude() <= gp::Resolution() + ? 0 : fabs( PI2 - v1.Angle( v2 ) ); + + return A * 180 / PI; + } +} + +double Skew::GetBadRate( double Value, int /*nbNodes*/ ) const +{ + // the skew is in the range [0.0,PI/2]. + // 0.0 = good + // PI/2 = bad + return Value; +} + +SMDSAbs_ElementType Skew::GetType() const +{ + return SMDSAbs_Face; +} + + +/* + Class : Area + Description : Functor for calculating area +*/ +double Area::GetValue( const TColgp_SequenceOfXYZ& P ) +{ + if ( P.Length() == 3 ) + return getArea( P( 1 ), P( 2 ), P( 3 ) ); + else if ( P.Length() == 4 ) + return getArea( P( 1 ), P( 2 ), P( 3 ) ) + getArea( P( 1 ), P( 3 ), P( 4 ) ); + else + return 0; +} + +double Area::GetBadRate( double Value, int /*nbNodes*/ ) const +{ + return Value; +} + +SMDSAbs_ElementType Area::GetType() const +{ + return SMDSAbs_Face; +} + + +/* + Class : Length + Description : Functor for calculating length off edge +*/ +double Length::GetValue( const TColgp_SequenceOfXYZ& P ) +{ + return ( P.Length() == 2 ? getDistance( P( 1 ), P( 2 ) ) : 0 ); +} + +double Length::GetBadRate( double Value, int /*nbNodes*/ ) const +{ + return Value; +} + +SMDSAbs_ElementType Length::GetType() const +{ + return SMDSAbs_Edge; +} + + +/* + Class : MultiConnection + Description : Functor for calculating number of faces conneted to the edge +*/ +double MultiConnection::GetValue( const TColgp_SequenceOfXYZ& P ) +{ + return 0; +} +double MultiConnection::GetValue( long theId ) +{ + return getNbMultiConnection( myMesh, theId ); +} + +double MultiConnection::GetBadRate( double Value, int /*nbNodes*/ ) const +{ + return Value; +} + +SMDSAbs_ElementType MultiConnection::GetType() const +{ + return SMDSAbs_Edge; +} + + +/* + PREDICATES +*/ + +/* + Class : FreeBorders + Description : Predicate for free borders +*/ + +FreeBorders::FreeBorders() +{ + myMesh = 0; +} + +void FreeBorders::SetMesh( SMDS_Mesh* theMesh ) +{ + myMesh = theMesh; +} + +bool FreeBorders::IsSatisfy( long theId ) +{ + return getNbMultiConnection( myMesh, theId ) == 1; +} + +SMDSAbs_ElementType FreeBorders::GetType() const +{ + return SMDSAbs_Edge; +} + + +/* + Class : FreeEdges + Description : Predicate for free Edges +*/ +FreeEdges::FreeEdges() +{ + myMesh = 0; +} + +void FreeEdges::SetMesh( SMDS_Mesh* theMesh ) +{ + myMesh = theMesh; +} + +bool FreeEdges::IsFreeEdge( const SMDS_MeshNode** theNodes, const int theFaceId ) +{ + TColStd_MapOfInteger aMap; + for ( int i = 0; i < 2; i++ ) + { + SMDS_ElemIteratorPtr anElemIter = theNodes[ i ]->GetInverseElementIterator(); + while( anElemIter->more() ) + { + const SMDS_MeshElement* anElem = anElemIter->next(); + if ( anElem != 0 && anElem->GetType() == SMDSAbs_Face ) + { + int anId = anElem->GetID(); + + if ( i == 0 ) + aMap.Add( anId ); + else if ( aMap.Contains( anId ) && anId != theFaceId ) + return false; + } + } + } + return true; +} + +bool FreeEdges::IsSatisfy( long theId ) +{ + if ( myMesh == 0 ) + return false; + + const SMDS_MeshElement* aFace = myMesh->FindElement( theId ); + if ( aFace == 0 || aFace->GetType() != SMDSAbs_Face || aFace->NbNodes() < 3 ) + return false; + + int nbNodes = aFace->NbNodes(); + const SMDS_MeshNode* aNodes[ nbNodes ]; + int i = 0; + SMDS_ElemIteratorPtr anIter = aFace->nodesIterator(); + if ( anIter != 0 ) + { + while( anIter->more() ) + { + const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next(); + if ( aNode == 0 ) + return false; + aNodes[ i++ ] = aNode; + } + } + + for ( int i = 0; i < nbNodes - 1; i++ ) + if ( IsFreeEdge( &aNodes[ i ], theId ) ) + return true; + + aNodes[ 1 ] = aNodes[ nbNodes - 1 ]; + + return IsFreeEdge( &aNodes[ 0 ], theId ); + +} + +SMDSAbs_ElementType FreeEdges::GetType() const +{ + return SMDSAbs_Face; +} + +FreeEdges::Border::Border(long theElemId, long thePntId1, long thePntId2): + myElemId(theElemId) +{ + myPntId[0] = thePntId1; myPntId[1] = thePntId2; + if(thePntId1 > thePntId2){ + myPntId[1] = thePntId1; myPntId[0] = thePntId2; + } +} + +bool FreeEdges::Border::operator<(const FreeEdges::Border& x) const{ + if(myPntId[0] < x.myPntId[0]) return true; + if(myPntId[0] == x.myPntId[0]) + if(myPntId[1] < x.myPntId[1]) return true; + return false; +} + +inline void UpdateBorders(const FreeEdges::Border& theBorder, + FreeEdges::TBorders& theRegistry, + FreeEdges::TBorders& theContainer) +{ + if(theRegistry.find(theBorder) == theRegistry.end()){ + theRegistry.insert(theBorder); + theContainer.insert(theBorder); + }else{ + theContainer.erase(theBorder); + } +} + +void FreeEdges::GetBoreders(TBorders& theBorders) +{ + TBorders aRegistry; + SMDS_FaceIteratorPtr anIter = myMesh->facesIterator(); + for(; anIter->more(); ){ + const SMDS_MeshFace* anElem = anIter->next(); + long anElemId = anElem->GetID(); + SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator(); + long aNodeId[2]; + const SMDS_MeshElement* aNode; + if(aNodesIter->more()){ + aNode = aNodesIter->next(); + aNodeId[0] = aNodeId[1] = aNode->GetID(); + } + for(; aNodesIter->more(); ){ + aNode = aNodesIter->next(); + long anId = aNode->GetID(); + Border aBorder(anElemId,aNodeId[1],anId); + aNodeId[1] = anId; + //std::cout< anIntSeq.Last() ) + { + anIntSeq.Append( aMinId ); + aStrSeq.Append( aStr ); + } + else + for ( int j = 1, k = anIntSeq.Length(); j <= k; j++ ) + if ( aMinId < anIntSeq( j ) ) + { + anIntSeq.InsertBefore( j, aMinId ); + aStrSeq.InsertBefore( j, aStr ); + break; + } + } + } + + if ( aStrSeq.Length() == 0 ) + return; + + theResStr = aStrSeq( 1 ); + for ( int j = 2, k = aStrSeq.Length(); j <= k; j++ ) + { + theResStr += ","; + theResStr += aStrSeq( j ); + } +} + +//======================================================================= +// name : SetRangeStr +// Purpose : Define range with string +// Example of entry string: "1,2,3,50-60,63,67,70-" +//======================================================================= +bool RangeOfIds::SetRangeStr( const TCollection_AsciiString& theStr ) +{ + myMin.Clear(); + myMax.Clear(); + myIds.Clear(); + + TCollection_AsciiString aStr = theStr; + aStr.RemoveAll( ' ' ); + aStr.RemoveAll( '\t' ); + + for ( int aPos = aStr.Search( ",," ); aPos != -1; aPos = aStr.Search( ",," ) ) + aStr.Remove( aPos, 2 ); + + TCollection_AsciiString tmpStr = aStr.Token( ",", 1 ); + int i = 1; + while ( tmpStr != "" ) + { + tmpStr = aStr.Token( ",", i++ ); + int aPos = tmpStr.Search( '-' ); + + if ( aPos == -1 ) + { + if ( tmpStr.IsIntegerValue() ) + myIds.Add( tmpStr.IntegerValue() ); + else + return false; + } + else + { + TCollection_AsciiString aMaxStr = tmpStr.Split( aPos ); + TCollection_AsciiString aMinStr = tmpStr; + + while ( aMinStr.Search( "-" ) != -1 ) aMinStr.RemoveAll( '-' ); + while ( aMaxStr.Search( "-" ) != -1 ) aMaxStr.RemoveAll( '-' ); + + if ( !aMinStr.IsEmpty() && !aMinStr.IsIntegerValue() || + !aMaxStr.IsEmpty() && !aMaxStr.IsIntegerValue() ) + return false; + + myMin.Append( aMinStr.IsEmpty() ? IntegerFirst() : aMinStr.IntegerValue() ); + myMax.Append( aMaxStr.IsEmpty() ? IntegerLast() : aMaxStr.IntegerValue() ); + } + } + + return true; +} + +//======================================================================= +// name : GetType +// Purpose : Get type of supported entities +//======================================================================= +SMDSAbs_ElementType RangeOfIds::GetType() const +{ + return myType; +} + +//======================================================================= +// name : SetType +// Purpose : Set type of supported entities +//======================================================================= +void RangeOfIds::SetType( SMDSAbs_ElementType theType ) +{ + myType = theType; +} + +//======================================================================= +// name : IsSatisfy +// Purpose : Verify whether entity satisfies to this rpedicate +//======================================================================= +bool RangeOfIds::IsSatisfy( long theId ) +{ + if ( !myMesh ) + return false; + + if ( myType == SMDSAbs_Node ) + { + if ( myMesh->FindNode( theId ) == 0 ) + return false; + } + else + { + const SMDS_MeshElement* anElem = myMesh->FindElement( theId ); + if ( anElem == 0 || myType != anElem->GetType() && myType != SMDSAbs_All ) + return false; + } + + if ( myIds.Contains( theId ) ) + return true; + + for ( int i = 1, n = myMin.Length(); i <= n; i++ ) + if ( theId >= myMin( i ) && theId <= myMax( i ) ) + return true; + + return false; +} + +/* + Class : Comparator + Description : Base class for comparators +*/ +Comparator::Comparator(): + myMargin(0) +{} + +Comparator::~Comparator() +{} + +void Comparator::SetMesh( SMDS_Mesh* theMesh ) +{ + if ( myFunctor ) + myFunctor->SetMesh( theMesh ); +} + +void Comparator::SetMargin( double theValue ) +{ + myMargin = theValue; +} + +void Comparator::SetNumFunctor( NumericalFunctorPtr theFunct ) +{ + myFunctor = theFunct; +} + +SMDSAbs_ElementType Comparator::GetType() const +{ + return myFunctor ? myFunctor->GetType() : SMDSAbs_All; +} + +double Comparator::GetMargin() +{ + return myMargin; +} + + +/* + Class : LessThan + Description : Comparator "<" +*/ +bool LessThan::IsSatisfy( long theId ) +{ + return myFunctor && myFunctor->GetValue( theId ) < myMargin; +} + + +/* + Class : MoreThan + Description : Comparator ">" +*/ +bool MoreThan::IsSatisfy( long theId ) +{ + return myFunctor && myFunctor->GetValue( theId ) > myMargin; +} + + +/* + Class : EqualTo + Description : Comparator "=" +*/ +EqualTo::EqualTo(): + myToler(Precision::Confusion()) +{} + +bool EqualTo::IsSatisfy( long theId ) +{ + return myFunctor && fabs( myFunctor->GetValue( theId ) - myMargin ) < myToler; +} + +void EqualTo::SetTolerance( double theToler ) +{ + myToler = theToler; +} + +double EqualTo::GetTolerance() +{ + return myToler; +} + +/* + Class : LogicalNOT + Description : Logical NOT predicate +*/ +LogicalNOT::LogicalNOT() +{} + +LogicalNOT::~LogicalNOT() +{} + +bool LogicalNOT::IsSatisfy( long theId ) +{ + return myPredicate && !myPredicate->IsSatisfy( theId ); +} + +void LogicalNOT::SetMesh( SMDS_Mesh* theMesh ) +{ + if ( myPredicate ) + myPredicate->SetMesh( theMesh ); +} + +void LogicalNOT::SetPredicate( PredicatePtr thePred ) +{ + myPredicate = thePred; +} + +SMDSAbs_ElementType LogicalNOT::GetType() const +{ + return myPredicate ? myPredicate->GetType() : SMDSAbs_All; +} + + +/* + Class : LogicalBinary + Description : Base class for binary logical predicate +*/ +LogicalBinary::LogicalBinary() +{} + +LogicalBinary::~LogicalBinary() +{} + +void LogicalBinary::SetMesh( SMDS_Mesh* theMesh ) +{ + if ( myPredicate1 ) + myPredicate1->SetMesh( theMesh ); + + if ( myPredicate2 ) + myPredicate2->SetMesh( theMesh ); +} + +void LogicalBinary::SetPredicate1( PredicatePtr thePredicate ) +{ + myPredicate1 = thePredicate; +} + +void LogicalBinary::SetPredicate2( PredicatePtr thePredicate ) +{ + myPredicate2 = thePredicate; +} + +SMDSAbs_ElementType LogicalBinary::GetType() const +{ + if ( !myPredicate1 || !myPredicate2 ) + return SMDSAbs_All; + + SMDSAbs_ElementType aType1 = myPredicate1->GetType(); + SMDSAbs_ElementType aType2 = myPredicate2->GetType(); + + return aType1 == aType2 ? aType1 : SMDSAbs_All; +} + + +/* + Class : LogicalAND + Description : Logical AND +*/ +bool LogicalAND::IsSatisfy( long theId ) +{ + return + myPredicate1 && + myPredicate2 && + myPredicate1->IsSatisfy( theId ) && + myPredicate2->IsSatisfy( theId ); +} + + +/* + Class : LogicalOR + Description : Logical OR +*/ +bool LogicalOR::IsSatisfy( long theId ) +{ + return + myPredicate1 && + myPredicate2 && + myPredicate1->IsSatisfy( theId ) || + myPredicate2->IsSatisfy( theId ); +} + + +/* + FILTER +*/ + +Filter::Filter() +{} + +Filter::~Filter() +{} + +void Filter::SetPredicate( PredicatePtr thePredicate ) +{ + myPredicate = thePredicate; +} + + +template +void FillSequence(const TIterator& theIterator, + TPredicate& thePredicate, + Filter::TIdSequence& theSequence) +{ + if ( theIterator ) { + while( theIterator->more() ) { + TElement anElem = theIterator->next(); + long anId = anElem->GetID(); + if ( thePredicate->IsSatisfy( anId ) ) + theSequence.push_back( anId ); + } + } +} + +Filter::TIdSequence +Filter::GetElementsId( SMDS_Mesh* theMesh ) +{ + TIdSequence aSequence; + if ( !theMesh || !myPredicate ) return aSequence; + + myPredicate->SetMesh( theMesh ); + + SMDSAbs_ElementType aType = myPredicate->GetType(); + switch(aType){ + case SMDSAbs_Node:{ + FillSequence(theMesh->nodesIterator(),myPredicate,aSequence); + break; + } + case SMDSAbs_Edge:{ + FillSequence(theMesh->edgesIterator(),myPredicate,aSequence); + break; + } + case SMDSAbs_Face:{ + FillSequence(theMesh->facesIterator(),myPredicate,aSequence); + break; + } + case SMDSAbs_Volume:{ + FillSequence(theMesh->volumesIterator(),myPredicate,aSequence); + break; + } + case SMDSAbs_All:{ + FillSequence(theMesh->edgesIterator(),myPredicate,aSequence); + FillSequence(theMesh->facesIterator(),myPredicate,aSequence); + FillSequence(theMesh->volumesIterator(),myPredicate,aSequence); + break; + } + } + return aSequence; +} + +/* + ManifoldPart +*/ + +typedef std::set TMapOfFacePtr; + +/* + Internal class Link +*/ + +ManifoldPart::Link::Link( SMDS_MeshNode* theNode1, + SMDS_MeshNode* theNode2 ) +{ + myNode1 = theNode1; + myNode2 = theNode2; +} + +ManifoldPart::Link::~Link() +{ + myNode1 = 0; + myNode2 = 0; +} + +bool ManifoldPart::Link::IsEqual( const ManifoldPart::Link& theLink ) const +{ + if ( myNode1 == theLink.myNode1 && + myNode2 == theLink.myNode2 ) + return true; + else if ( myNode1 == theLink.myNode2 && + myNode2 == theLink.myNode1 ) + return true; + else + return false; +} + +bool ManifoldPart::Link::operator<( const ManifoldPart::Link& x ) const +{ + if(myNode1 < x.myNode1) return true; + if(myNode1 == x.myNode1) + if(myNode2 < x.myNode2) return true; + return false; +} + +bool ManifoldPart::IsEqual( const ManifoldPart::Link& theLink1, + const ManifoldPart::Link& theLink2 ) +{ + return theLink1.IsEqual( theLink2 ); +} + +ManifoldPart::ManifoldPart() +{ + myMesh = 0; + myAngToler = Precision::Angular(); + myIsOnlyManifold = true; +} + +ManifoldPart::~ManifoldPart() +{ + myMesh = 0; +} + +void ManifoldPart::SetMesh( SMDS_Mesh* theMesh ) +{ + myMesh = theMesh; + process(); +} + +SMDSAbs_ElementType ManifoldPart::GetType() const +{ return SMDSAbs_Face; } + +bool ManifoldPart::IsSatisfy( long theElementId ) +{ + return myMapIds.Contains( theElementId ); +} + +void ManifoldPart::SetAngleTolerance( const double theAngToler ) +{ myAngToler = theAngToler; } + +double ManifoldPart::GetAngleTolerance() const +{ return myAngToler; } + +void ManifoldPart::SetIsOnlyManifold( const bool theIsOnly ) +{ myIsOnlyManifold = theIsOnly; } + +void ManifoldPart::SetStartElem( const long theStartId ) +{ myStartElemId = theStartId; } + +bool ManifoldPart::process() +{ + myMapIds.Clear(); + myMapBadGeomIds.Clear(); + + myAllFacePtr.clear(); + myAllFacePtrIntDMap.clear(); + if ( !myMesh ) + return false; + + // collect all faces into own map + SMDS_FaceIteratorPtr anFaceItr = myMesh->facesIterator(); + for (; anFaceItr->more(); ) + { + SMDS_MeshFace* aFacePtr = (SMDS_MeshFace*)anFaceItr->next(); + myAllFacePtr.push_back( aFacePtr ); + myAllFacePtrIntDMap[aFacePtr] = myAllFacePtr.size()-1; + } + + SMDS_MeshFace* aStartFace = (SMDS_MeshFace*)myMesh->FindElement( myStartElemId ); + if ( !aStartFace ) + return false; + + // the map of non manifold links and bad geometry + TMapOfLink aMapOfNonManifold; + TColStd_MapOfInteger aMapOfTreated; + + // begin cycle on faces from start index and run on vector till the end + // and from begin to start index to cover whole vector + const int aStartIndx = myAllFacePtrIntDMap[aStartFace]; + bool isStartTreat = false; + for ( int fi = aStartIndx; !isStartTreat || fi != aStartIndx ; fi++ ) + { + if ( fi == aStartIndx ) + isStartTreat = true; + // as result next time when fi will be equal to aStartIndx + + SMDS_MeshFace* aFacePtr = myAllFacePtr[ fi ]; + if ( aMapOfTreated.Contains( aFacePtr->GetID() ) ) + continue; + + aMapOfTreated.Add( aFacePtr->GetID() ); + TColStd_MapOfInteger aResFaces; + if ( !findConnected( myAllFacePtrIntDMap, aFacePtr, + aMapOfNonManifold, aResFaces ) ) + continue; + TColStd_MapIteratorOfMapOfInteger anItr( aResFaces ); + for ( ; anItr.More(); anItr.Next() ) + { + int aFaceId = anItr.Key(); + aMapOfTreated.Add( aFaceId ); + myMapIds.Add( aFaceId ); + } + + if ( fi == ( myAllFacePtr.size() - 1 ) ) + fi = 0; + } // end run on vector of faces + return !myMapIds.IsEmpty(); +} + +static void getLinks( const SMDS_MeshFace* theFace, + ManifoldPart::TVectorOfLink& theLinks ) +{ + int aNbNode = theFace->NbNodes(); + SMDS_ElemIteratorPtr aNodeItr = theFace->nodesIterator(); + int i = 1; + SMDS_MeshNode* aNode = 0; + for ( ; aNodeItr->more() && i <= aNbNode; ) + { + + SMDS_MeshNode* aN1 = (SMDS_MeshNode*)aNodeItr->next(); + if ( i == 1 ) + aNode = aN1; + i++; + SMDS_MeshNode* aN2 = ( i >= aNbNode ) ? aNode : (SMDS_MeshNode*)aNodeItr->next(); + i++; + ManifoldPart::Link aLink( aN1, aN2 ); + theLinks.push_back( aLink ); + } +} + +static gp_XYZ getNormale( const SMDS_MeshFace* theFace ) +{ + gp_XYZ n; + int aNbNode = theFace->NbNodes(); + TColgp_Array1OfXYZ anArrOfXYZ(1,4); + gp_XYZ p1, p2, p3, p4; + 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; +} + +bool ManifoldPart::findConnected + ( const ManifoldPart::TDataMapFacePtrInt& theAllFacePtrInt, + SMDS_MeshFace* theStartFace, + ManifoldPart::TMapOfLink& theNonManifold, + TColStd_MapOfInteger& theResFaces ) +{ + theResFaces.Clear(); + if ( !theAllFacePtrInt.size() ) + return false; + + if ( getNormale( theStartFace ).SquareModulus() <= gp::Resolution() ) + { + myMapBadGeomIds.Add( theStartFace->GetID() ); + return false; + } + + ManifoldPart::TMapOfLink aMapOfBoundary, aMapToSkip; + ManifoldPart::TVectorOfLink aSeqOfBoundary; + theResFaces.Add( theStartFace->GetID() ); + ManifoldPart::TDataMapOfLinkFacePtr aDMapLinkFace; + + expandBoundary( aMapOfBoundary, aSeqOfBoundary, + aDMapLinkFace, theNonManifold, theStartFace ); + + bool isDone = false; + while ( !isDone && aMapOfBoundary.size() != 0 ) + { + bool isToReset = false; + ManifoldPart::TVectorOfLink::iterator pLink = aSeqOfBoundary.begin(); + for ( ; !isToReset && pLink != aSeqOfBoundary.end(); ++pLink ) + { + ManifoldPart::Link aLink = *pLink; + if ( aMapToSkip.find( aLink ) != aMapToSkip.end() ) + continue; + // each link could be treated only once + aMapToSkip.insert( aLink ); + + ManifoldPart::TVectorOfFacePtr aFaces; + // find next + if ( myIsOnlyManifold && + (theNonManifold.find( aLink ) != theNonManifold.end()) ) + continue; + else + { + getFacesByLink( aLink, aFaces ); + // filter the element to keep only indicated elements + ManifoldPart::TVectorOfFacePtr aFiltered; + ManifoldPart::TVectorOfFacePtr::iterator pFace = aFaces.begin(); + for ( ; pFace != aFaces.end(); ++pFace ) + { + SMDS_MeshFace* aFace = *pFace; + if ( myAllFacePtrIntDMap.find( aFace ) != myAllFacePtrIntDMap.end() ) + aFiltered.push_back( aFace ); + } + aFaces = aFiltered; + if ( aFaces.size() < 2 ) // no neihgbour faces + continue; + else if ( myIsOnlyManifold && aFaces.size() > 2 ) // non manifold case + { + theNonManifold.insert( aLink ); + continue; + } + } + + // compare normal with normals of neighbor element + SMDS_MeshFace* aPrevFace = aDMapLinkFace[ aLink ]; + ManifoldPart::TVectorOfFacePtr::iterator pFace = aFaces.begin(); + for ( ; pFace != aFaces.end(); ++pFace ) + { + SMDS_MeshFace* aNextFace = *pFace; + if ( aPrevFace == aNextFace ) + continue; + int anNextFaceID = aNextFace->GetID(); + if ( myIsOnlyManifold && theResFaces.Contains( anNextFaceID ) ) + // should not be with non manifold restriction. probably bad topology + continue; + // check if face was treated and skipped + if ( myMapBadGeomIds.Contains( anNextFaceID ) || + !isInPlane( aPrevFace, aNextFace ) ) + continue; + // add new element to connected and extend the boundaries. + theResFaces.Add( anNextFaceID ); + expandBoundary( aMapOfBoundary, aSeqOfBoundary, + aDMapLinkFace, theNonManifold, aNextFace ); + isToReset = true; + } + } + isDone = !isToReset; + } + + return !theResFaces.IsEmpty(); +} + +bool ManifoldPart::isInPlane( const SMDS_MeshFace* theFace1, + const SMDS_MeshFace* theFace2 ) +{ + gp_Dir aNorm1 = gp_Dir( getNormale( theFace1 ) ); + gp_XYZ aNorm2XYZ = getNormale( theFace2 ); + if ( aNorm2XYZ.SquareModulus() <= gp::Resolution() ) + { + myMapBadGeomIds.Add( theFace2->GetID() ); + return false; + } + if ( aNorm1.IsParallel( gp_Dir( aNorm2XYZ ), myAngToler ) ) + return true; + + return false; +} + +void ManifoldPart::expandBoundary + ( ManifoldPart::TMapOfLink& theMapOfBoundary, + ManifoldPart::TVectorOfLink& theSeqOfBoundary, + ManifoldPart::TDataMapOfLinkFacePtr& theDMapLinkFacePtr, + ManifoldPart::TMapOfLink& theNonManifold, + SMDS_MeshFace* theNextFace ) const +{ + ManifoldPart::TVectorOfLink aLinks; + getLinks( theNextFace, aLinks ); + int aNbLink = aLinks.size(); + for ( int i = 0; i < aNbLink; i++ ) + { + ManifoldPart::Link aLink = aLinks[ i ]; + if ( myIsOnlyManifold && (theNonManifold.find( aLink ) != theNonManifold.end()) ) + continue; + if ( theMapOfBoundary.find( aLink ) != theMapOfBoundary.end() ) + { + if ( myIsOnlyManifold ) + { + // remove from boundary + theMapOfBoundary.erase( aLink ); + ManifoldPart::TVectorOfLink::iterator pLink = theSeqOfBoundary.begin(); + for ( ; pLink != theSeqOfBoundary.end(); ++pLink ) + { + ManifoldPart::Link aBoundLink = *pLink; + if ( aBoundLink.IsEqual( aLink ) ) + { + theSeqOfBoundary.erase( pLink ); + break; + } + } + } + } + else + { + theMapOfBoundary.insert( aLink ); + theSeqOfBoundary.push_back( aLink ); + theDMapLinkFacePtr[ aLink ] = theNextFace; + } + } +} + +void ManifoldPart::getFacesByLink( const ManifoldPart::Link& theLink, + ManifoldPart::TVectorOfFacePtr& theFaces ) const +{ + SMDS_Mesh::SetOfFaces aSetOfFaces; + // take all faces that shared first node + SMDS_ElemIteratorPtr anItr = theLink.myNode1->facesIterator(); + for ( ; anItr->more(); ) + { + SMDS_MeshFace* aFace = (SMDS_MeshFace*)anItr->next(); + if ( !aFace ) + continue; + aSetOfFaces.insert( aFace ); + } + // take all faces that shared second node + anItr = theLink.myNode2->facesIterator(); + // find the common part of two sets + for ( ; anItr->more(); ) + { + SMDS_MeshFace* aFace = (SMDS_MeshFace*)anItr->next(); + if ( aSetOfFaces.find( aFace ) != aSetOfFaces.end() ) + theFaces.push_back( aFace ); + } +} + + +/* + ElementsOnSurface +*/ + +ElementsOnSurface::ElementsOnSurface() +{ + myMesh = 0; + myIds.Clear(); + myType = SMDSAbs_All; + mySurf.Nullify(); + myToler = Precision::Confusion(); +} + +ElementsOnSurface::~ElementsOnSurface() +{ + myMesh = 0; +} + +void ElementsOnSurface::SetMesh( SMDS_Mesh* theMesh ) +{ + if ( myMesh == theMesh ) + return; + myMesh = theMesh; + myIds.Clear(); + process(); +} + +bool ElementsOnSurface::IsSatisfy( long theElementId ) +{ + return myIds.Contains( theElementId ); +} + +SMDSAbs_ElementType ElementsOnSurface::GetType() const +{ return myType; } + +void ElementsOnSurface::SetTolerance( const double theToler ) +{ myToler = theToler; } + +double ElementsOnSurface::GetTolerance() const +{ + return myToler; +} + +void ElementsOnSurface::SetSurface( const TopoDS_Shape& theShape, + const SMDSAbs_ElementType theType ) +{ + myType = theType; + mySurf.Nullify(); + if ( theShape.IsNull() || theShape.ShapeType() != TopAbs_FACE ) + { + mySurf.Nullify(); + return; + } + TopoDS_Face aFace = TopoDS::Face( theShape ); + mySurf = BRep_Tool::Surface( aFace ); +} + +void ElementsOnSurface::process() +{ + myIds.Clear(); + if ( mySurf.IsNull() ) + return; + + if ( myMesh == 0 ) + return; + + if ( myType == SMDSAbs_Face || myType == SMDSAbs_All ) + { + SMDS_FaceIteratorPtr anIter = myMesh->facesIterator(); + for(; anIter->more(); ) + process( anIter->next() ); + } + + if ( myType == SMDSAbs_Edge || myType == SMDSAbs_All ) + { + SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator(); + for(; anIter->more(); ) + process( anIter->next() ); + } + + if ( myType == SMDSAbs_Node ) + { + SMDS_NodeIteratorPtr anIter = myMesh->nodesIterator(); + for(; anIter->more(); ) + process( anIter->next() ); + } +} + +void ElementsOnSurface::process( const SMDS_MeshElement* theElemPtr ) +{ + SMDS_ElemIteratorPtr aNodeItr = theElemPtr->nodesIterator(); + bool isSatisfy = true; + for ( ; aNodeItr->more(); ) + { + SMDS_MeshNode* aNode = (SMDS_MeshNode*)aNodeItr->next(); + if ( !isOnSurface( aNode ) ) + { + isSatisfy = false; + break; + } + } + if ( isSatisfy ) + myIds.Add( theElemPtr->GetID() ); +} + +bool ElementsOnSurface::isOnSurface( const SMDS_MeshNode* theNode ) const +{ + if ( mySurf.IsNull() ) + return false; + + gp_Pnt aPnt( theNode->X(), theNode->Y(), theNode->Z() ); + double aToler2 = myToler * myToler; + if ( mySurf->IsKind(STANDARD_TYPE(Geom_Plane))) + { + gp_Pln aPln = Handle(Geom_Plane)::DownCast(mySurf)->Pln(); + if ( aPln.SquareDistance( aPnt ) > aToler2 ) + return false; + } + else if ( mySurf->IsKind(STANDARD_TYPE(Geom_CylindricalSurface))) + { + gp_Cylinder aCyl = Handle(Geom_CylindricalSurface)::DownCast(mySurf)->Cylinder(); + double aRad = aCyl.Radius(); + gp_Ax3 anAxis = aCyl.Position(); + gp_XYZ aLoc = aCyl.Location().XYZ(); + double aXDist = anAxis.XDirection().XYZ() * ( aPnt.XYZ() - aLoc ); + double aYDist = anAxis.YDirection().XYZ() * ( aPnt.XYZ() - aLoc ); + if ( fabs(aXDist*aXDist + aYDist*aYDist - aRad*aRad) > aToler2 ) + return false; + } + else + return false; + + return true; +} diff --git a/src/Controls/SMESH_Controls.hxx b/src/Controls/SMESH_Controls.hxx new file mode 100644 index 000000000..491e59b66 --- /dev/null +++ b/src/Controls/SMESH_Controls.hxx @@ -0,0 +1,527 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#ifndef _SMESH_CONTROLS_HXX_ +#define _SMESH_CONTROLS_HXX_ + +#include +#include +#include +#include +#include "SMDSAbs_ElementType.hxx" +#include "SMDS_MeshNode.hxx" +#include +#include +#include +#include + +class SMDS_Mesh; +class SMESHDS_Mesh; +class SMESHDS_SubMesh; +class gp_Pnt; +class gp_XYZ; +class TColgp_SequenceOfXYZ; +class TopoDS_Shape; +class SMDS_MeshElement; +class SMDS_MeshFace; +class SMDS_MeshNode; + +namespace SMESH{ + namespace Controls{ + class Functor + { + public: + ~Functor(){} + virtual void SetMesh( SMDS_Mesh* theMesh ) = 0; + virtual SMDSAbs_ElementType GetType() const = 0; + }; + typedef boost::shared_ptr FunctorPtr; + + class NumericalFunctor: public virtual Functor{ + public: + NumericalFunctor(); + virtual void SetMesh( SMDS_Mesh* theMesh ); + virtual double GetValue( long theElementId ); + virtual double GetValue( const TColgp_SequenceOfXYZ& thePoints ) = 0; + virtual SMDSAbs_ElementType GetType() const = 0; + virtual double GetBadRate( double Value, int nbNodes ) const = 0; + long GetPrecision() const; + void SetPrecision( const long thePrecision ); + + bool GetPoints (const int theId, + TColgp_SequenceOfXYZ& theRes ) const; + static bool GetPoints (const SMDS_MeshElement* theElem, + TColgp_SequenceOfXYZ& theRes ); + protected: + SMDS_Mesh* myMesh; + long myPrecision; + }; + typedef boost::shared_ptr NumericalFunctorPtr; + + + /* + Class : SMESH_MinimumAngle + Description : Functor for calculation of minimum angle + */ + class MinimumAngle: public virtual NumericalFunctor{ + public: + virtual double GetValue( const TColgp_SequenceOfXYZ& thePoints ); + virtual double GetBadRate( double Value, int nbNodes ) const; + virtual SMDSAbs_ElementType GetType() const; + }; + + + /* + Class : AspectRatio + Description : Functor for calculating aspect ratio + */ + class AspectRatio: public virtual NumericalFunctor{ + public: + virtual double GetValue( const TColgp_SequenceOfXYZ& thePoints ); + virtual double GetBadRate( double Value, int nbNodes ) const; + virtual SMDSAbs_ElementType GetType() const; + }; + + + /* + Class : AspectRatio3D + Description : Functor for calculating aspect ratio of 3D elems. + */ + class AspectRatio3D: public virtual NumericalFunctor{ + public: + virtual double GetValue( const TColgp_SequenceOfXYZ& thePoints ); + virtual double GetBadRate( double Value, int nbNodes ) const; + virtual SMDSAbs_ElementType GetType() const; + }; + + + /* + Class : Warping + Description : Functor for calculating warping + */ + class Warping: public virtual NumericalFunctor{ + public: + virtual double GetValue( const TColgp_SequenceOfXYZ& thePoints ); + virtual double GetBadRate( double Value, int nbNodes ) const; + virtual SMDSAbs_ElementType GetType() const; + + private: + double ComputeA( const gp_XYZ&, const gp_XYZ&, const gp_XYZ&, const gp_XYZ& ) const; + }; + + + /* + Class : Taper + Description : Functor for calculating taper + */ + class Taper: public virtual NumericalFunctor{ + public: + virtual double GetValue( const TColgp_SequenceOfXYZ& thePoints ); + virtual double GetBadRate( double Value, int nbNodes ) const; + virtual SMDSAbs_ElementType GetType() const; + }; + + + /* + Class : Skew + Description : Functor for calculating skew in degrees + */ + class Skew: public virtual NumericalFunctor{ + public: + virtual double GetValue( const TColgp_SequenceOfXYZ& thePoints ); + virtual double GetBadRate( double Value, int nbNodes ) const; + virtual SMDSAbs_ElementType GetType() const; + }; + + + /* + Class : Area + Description : Functor for calculating area + */ + class Area: public virtual NumericalFunctor{ + public: + virtual double GetValue( const TColgp_SequenceOfXYZ& thePoints ); + virtual double GetBadRate( double Value, int nbNodes ) const; + virtual SMDSAbs_ElementType GetType() const; + }; + + + /* + Class : Length + Description : Functor for calculating length of edge + */ + class Length: public virtual NumericalFunctor{ + public: + virtual double GetValue( const TColgp_SequenceOfXYZ& thePoints ); + virtual double GetBadRate( double Value, int nbNodes ) const; + virtual SMDSAbs_ElementType GetType() const; + }; + + + /* + Class : MultiConnection + Description : Functor for calculating number of faces conneted to the edge + */ + class MultiConnection: public virtual NumericalFunctor{ + public: + virtual double GetValue( long theElementId ); + virtual double GetValue( const TColgp_SequenceOfXYZ& thePoints ); + virtual double GetBadRate( double Value, int nbNodes ) const; + virtual SMDSAbs_ElementType GetType() const; + }; + + + /* + PREDICATES + */ + /* + Class : Predicate + Description : Base class for all predicates + */ + class Predicate: public virtual Functor{ + public: + virtual bool IsSatisfy( long theElementId ) = 0; + virtual SMDSAbs_ElementType GetType() const = 0; + }; + typedef boost::shared_ptr PredicatePtr; + + + + /* + Class : FreeBorders + Description : Predicate for free borders + */ + class FreeBorders: public virtual Predicate{ + public: + FreeBorders(); + virtual void SetMesh( SMDS_Mesh* theMesh ); + virtual bool IsSatisfy( long theElementId ); + virtual SMDSAbs_ElementType GetType() const; + + protected: + SMDS_Mesh* myMesh; + }; + + + /* + Class : FreeEdges + Description : Predicate for free Edges + */ + class FreeEdges: public virtual Predicate{ + public: + FreeEdges(); + virtual void SetMesh( SMDS_Mesh* theMesh ); + virtual bool IsSatisfy( long theElementId ); + virtual SMDSAbs_ElementType GetType() const; + static bool IsFreeEdge( const SMDS_MeshNode** theNodes, const int theFaceId ); + typedef long TElemId; + struct Border{ + TElemId myElemId; + TElemId myPntId[2]; + Border(long theElemId, long thePntId1, long thePntId2); + bool operator<(const Border& x) const; + }; + typedef std::set TBorders; + void GetBoreders(TBorders& theBorders); + + protected: + SMDS_Mesh* myMesh; + }; + typedef boost::shared_ptr FreeEdgesPtr; + + + /* + Class : RangeOfIds + Description : Predicate for Range of Ids. + Range may be specified with two ways. + 1. Using AddToRange method + 2. With SetRangeStr method. Parameter of this method is a string + like as "1,2,3,50-60,63,67,70-" + */ + class RangeOfIds: public virtual Predicate + { + public: + RangeOfIds(); + virtual void SetMesh( SMDS_Mesh* theMesh ); + virtual bool IsSatisfy( long theNodeId ); + virtual SMDSAbs_ElementType GetType() const; + virtual void SetType( SMDSAbs_ElementType theType ); + + bool AddToRange( long theEntityId ); + void GetRangeStr( TCollection_AsciiString& ); + bool SetRangeStr( const TCollection_AsciiString& ); + + protected: + SMDS_Mesh* myMesh; + + TColStd_SequenceOfInteger myMin; + TColStd_SequenceOfInteger myMax; + TColStd_MapOfInteger myIds; + + SMDSAbs_ElementType myType; + }; + + typedef boost::shared_ptr RangeOfIdsPtr; + + + /* + Class : Comparator + Description : Base class for comparators + */ + class Comparator: public virtual Predicate{ + public: + Comparator(); + virtual ~Comparator(); + virtual void SetMesh( SMDS_Mesh* theMesh ); + virtual void SetMargin(double theValue); + virtual void SetNumFunctor(NumericalFunctorPtr theFunct); + virtual bool IsSatisfy( long theElementId ) = 0; + virtual SMDSAbs_ElementType GetType() const; + double GetMargin(); + + protected: + double myMargin; + NumericalFunctorPtr myFunctor; + }; + typedef boost::shared_ptr ComparatorPtr; + + + /* + Class : LessThan + Description : Comparator "<" + */ + class LessThan: public virtual Comparator{ + public: + virtual bool IsSatisfy( long theElementId ); + }; + + + /* + Class : MoreThan + Description : Comparator ">" + */ + class MoreThan: public virtual Comparator{ + public: + virtual bool IsSatisfy( long theElementId ); + }; + + + /* + Class : EqualTo + Description : Comparator "=" + */ + class EqualTo: public virtual Comparator{ + public: + EqualTo(); + virtual bool IsSatisfy( long theElementId ); + virtual void SetTolerance( double theTol ); + virtual double GetTolerance(); + + private: + double myToler; + }; + typedef boost::shared_ptr EqualToPtr; + + + /* + Class : LogicalNOT + Description : Logical NOT predicate + */ + class LogicalNOT: public virtual Predicate{ + public: + LogicalNOT(); + virtual ~LogicalNOT(); + virtual bool IsSatisfy( long theElementId ); + virtual void SetMesh( SMDS_Mesh* theMesh ); + virtual void SetPredicate(PredicatePtr thePred); + virtual SMDSAbs_ElementType GetType() const; + + private: + PredicatePtr myPredicate; + }; + typedef boost::shared_ptr LogicalNOTPtr; + + + /* + Class : LogicalBinary + Description : Base class for binary logical predicate + */ + class LogicalBinary: public virtual Predicate{ + public: + LogicalBinary(); + virtual ~LogicalBinary(); + virtual void SetMesh( SMDS_Mesh* theMesh ); + virtual void SetPredicate1(PredicatePtr thePred); + virtual void SetPredicate2(PredicatePtr thePred); + virtual SMDSAbs_ElementType GetType() const; + + protected: + PredicatePtr myPredicate1; + PredicatePtr myPredicate2; + }; + typedef boost::shared_ptr LogicalBinaryPtr; + + + /* + Class : LogicalAND + Description : Logical AND + */ + class LogicalAND: public virtual LogicalBinary{ + public: + virtual bool IsSatisfy( long theElementId ); + }; + + + /* + Class : LogicalOR + Description : Logical OR + */ + class LogicalOR: public virtual LogicalBinary{ + public: + virtual bool IsSatisfy( long theElementId ); + }; + + + /* + Class : ManifoldPart + Description : Predicate for manifold part of mesh + */ + class ManifoldPart: public virtual Predicate{ + public: + + /* internal class for algorithm uses */ + class Link + { + public: + Link( SMDS_MeshNode* theNode1, + SMDS_MeshNode* theNode2 ); + ~Link(); + + bool IsEqual( const ManifoldPart::Link& theLink ) const; + bool operator<(const ManifoldPart::Link& x) const; + + SMDS_MeshNode* myNode1; + SMDS_MeshNode* myNode2; + }; + + bool IsEqual( const ManifoldPart::Link& theLink1, + const ManifoldPart::Link& theLink2 ); + + typedef std::set TMapOfLink; + typedef std::vector TVectorOfFacePtr; + typedef std::vector TVectorOfLink; + typedef std::map TDataMapFacePtrInt; + typedef std::map TDataMapOfLinkFacePtr; + + ManifoldPart(); + ~ManifoldPart(); + virtual void SetMesh( SMDS_Mesh* theMesh ); + // inoke when all parameters already set + virtual bool IsSatisfy( long theElementId ); + virtual SMDSAbs_ElementType GetType() const; + + void SetAngleTolerance( const double theAngToler ); + double GetAngleTolerance() const; + void SetIsOnlyManifold( const bool theIsOnly ); + void SetStartElem( const long theStartElemId ); + + private: + bool process(); + bool findConnected( const TDataMapFacePtrInt& theAllFacePtrInt, + SMDS_MeshFace* theStartFace, + TMapOfLink& theNonManifold, + TColStd_MapOfInteger& theResFaces ); + bool isInPlane( const SMDS_MeshFace* theFace1, + const SMDS_MeshFace* theFace2 ); + void expandBoundary( TMapOfLink& theMapOfBoundary, + TVectorOfLink& theSeqOfBoundary, + TDataMapOfLinkFacePtr& theDMapLinkFacePtr, + TMapOfLink& theNonManifold, + SMDS_MeshFace* theNextFace ) const; + + void getFacesByLink( const Link& theLink, + TVectorOfFacePtr& theFaces ) const; + + private: + SMDS_Mesh* myMesh; + TColStd_MapOfInteger myMapIds; + TColStd_MapOfInteger myMapBadGeomIds; + TVectorOfFacePtr myAllFacePtr; + TDataMapFacePtrInt myAllFacePtrIntDMap; + double myAngToler; + bool myIsOnlyManifold; + long myStartElemId; + + }; + typedef boost::shared_ptr ManifoldPartPtr; + + + /* + Class : ElementsOnSurface + Description : Predicate elements that lying on indicated surface + (plane or cylinder) + */ + class ElementsOnSurface : public virtual Predicate { + public: + ElementsOnSurface(); + ~ElementsOnSurface(); + virtual void SetMesh( SMDS_Mesh* theMesh ); + virtual bool IsSatisfy( long theElementId ); + virtual SMDSAbs_ElementType GetType() const; + + void SetTolerance( const double theToler ); + double GetTolerance() const; + void SetSurface( const TopoDS_Shape& theShape, + const SMDSAbs_ElementType theType ); + + private: + void process(); + void process( const SMDS_MeshElement* theElem ); + bool isOnSurface( const SMDS_MeshNode* theNode ) const; + + private: + SMDS_Mesh* myMesh; + TColStd_MapOfInteger myIds; + SMDSAbs_ElementType myType; + Handle(Geom_Surface) mySurf; + double myToler; + }; + + typedef boost::shared_ptr ElementsOnSurfacePtr; + + + /* + FILTER + */ + class Filter{ + public: + Filter(); + virtual ~Filter(); + virtual void SetPredicate(PredicatePtr thePred); + typedef std::vector TIdSequence; + virtual TIdSequence GetElementsId( SMDS_Mesh* theMesh ); + + protected: + PredicatePtr myPredicate; + }; + }; +}; + + +#endif diff --git a/src/Driver/Document_Reader.h b/src/Driver/Document_Reader.h deleted file mode 100644 index 2766466c2..000000000 --- a/src/Driver/Document_Reader.h +++ /dev/null @@ -1,44 +0,0 @@ -// SMESH Driver : implementaion of driver for reading and writing -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : Document_Reader.h -// Module : SMESH - -#ifndef _INCLUDE_DOCUMENT_READER -#define _INCLUDE_DOCUMENT_READER - -#include "SMESHDS_Document.hxx" -#include - -class Document_Reader -{ - public: - virtual void Read() = 0; - void SetFile(string); - void SetDocument(SMESHDS_Document *); - - protected: - SMESHDS_Document * myDocument; - string myFile; -}; -#endif diff --git a/src/Driver/Driver_Document.cxx b/src/Driver/Driver_Document.cxx new file mode 100644 index 000000000..159c1a85a --- /dev/null +++ b/src/Driver/Driver_Document.cxx @@ -0,0 +1,36 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include "Driver_Document.h" + +Driver_Document::Driver_Document(): + myDocument(NULL) +{} + + +void Driver_Document::SetFile(const std::string& theFileName) +{ + myFile = theFileName; +} + + +void Driver_Document::SetDocument(SMESHDS_Document * theDocument) +{ + myDocument = theDocument; +} diff --git a/src/Driver/Mesh_Reader.h b/src/Driver/Driver_Document.h similarity index 71% rename from src/Driver/Mesh_Reader.h rename to src/Driver/Driver_Document.h index 251f2bb9d..8d4ff5a68 100644 --- a/src/Driver/Mesh_Reader.h +++ b/src/Driver/Driver_Document.h @@ -1,5 +1,3 @@ -// SMESH Driver : implementaion of driver for reading and writing -// // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // @@ -18,26 +16,29 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : Mesh_Reader.h -// Module : SMESH -#ifndef _INCLUDE_MESH_READER -#define _INCLUDE_MESH_READER +#ifndef _INCLUDE_DRIVER_DOCUMENT +#define _INCLUDE_DRIVER_DOCUMENT #include -#include "SMDS_Mesh.hxx" -class Mesh_Reader +class SMESHDS_Document; + +class Driver_Document { + public: + Driver_Document(); + virtual ~Driver_Document(){} + + virtual void Perform() = 0; + void SetFile(const std::string& theFileName); + void SetDocument(SMESHDS_Document *theDocument); - public:virtual void Add() = 0; - virtual void Read() = 0; - virtual void SetMesh(SMDS_Mesh *) = 0; - virtual void SetMeshId(int) = 0; - virtual void SetFile(string) = 0; + protected: + SMESHDS_Document * myDocument; + std::string myFile; }; + + #endif diff --git a/src/Driver/Document_Reader.cxx b/src/Driver/Driver_Mesh.cxx similarity index 79% rename from src/Driver/Document_Reader.cxx rename to src/Driver/Driver_Mesh.cxx index 26dcf1450..f656bdd5d 100644 --- a/src/Driver/Document_Reader.cxx +++ b/src/Driver/Driver_Mesh.cxx @@ -1,4 +1,4 @@ -// SMESH Driver : implementaion of driver for reading and writing +// SMESH Driver : implementaion of driver for reading and writing // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -21,20 +21,26 @@ // // // -// File : Document_Reader.cxx +// File : Mesh_Reader.cxx // Module : SMESH +#include "Driver_Mesh.h" + using namespace std; -#include "Document_Reader.h" -#include "utilities.h" +Driver_Mesh::Driver_Mesh(): + myFile(""), + myMeshId(-1) +{} + -void Document_Reader::SetFile(string aFile) +void Driver_Mesh::SetMeshId(int theMeshId) { - myFile = aFile; + myMeshId = theMeshId; } -void Document_Reader::SetDocument(SMESHDS_Document * aDoc) + +void Driver_Mesh::SetFile(const std::string& theFileName) { - myDocument = aDoc; + myFile = theFileName; } diff --git a/src/Driver/Document_Writer.h b/src/Driver/Driver_Mesh.h similarity index 60% rename from src/Driver/Document_Writer.h rename to src/Driver/Driver_Mesh.h index 4aea9605c..0bfac0cd8 100644 --- a/src/Driver/Document_Writer.h +++ b/src/Driver/Driver_Mesh.h @@ -21,24 +21,37 @@ // // // -// File : Document_Writer.h +// File : Mesh_Reader.h // Module : SMESH -#ifndef _INCLUDE_DOCUMENT_WRITER -#define _INCLUDE_DOCUMENT_WRITER +#ifndef _INCLUDE_DRIVER_MESH +#define _INCLUDE_DRIVER_MESH -#include "SMESHDS_Document.hxx" #include -class Document_Writer +class Driver_Mesh { + public: + Driver_Mesh(); + virtual ~Driver_Mesh(){} - public:virtual void Write() = 0; - void SetFile(string); - void SetDocument(SMESHDS_Document *); + enum Status { + DRS_OK, + DRS_EMPTY, // a file contains no mesh with the given name + DRS_WARN_RENUMBER, // a file has overlapped ranges of element numbers, + // so the numbers from the file are ignored + DRS_WARN_SKIP_ELEM, // some elements were skipped due to incorrect file data + DRS_FAIL // general failure (exception etc.) + }; - protected: SMESHDS_Document * myDocument; - string myFile; + virtual Status Perform() = 0; + void SetMeshId(int theMeshId); + void SetFile(const std::string& theFileName); + + protected: + std::string myFile; + int myMeshId; }; + #endif diff --git a/src/Driver/Mesh_Reader.cxx b/src/Driver/Driver_SMDS_Mesh.cxx similarity index 85% rename from src/Driver/Mesh_Reader.cxx rename to src/Driver/Driver_SMDS_Mesh.cxx index ba18cf04f..dae030df0 100644 --- a/src/Driver/Mesh_Reader.cxx +++ b/src/Driver/Driver_SMDS_Mesh.cxx @@ -1,5 +1,3 @@ -// SMESH Driver : implementaion of driver for reading and writing -// // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // @@ -18,12 +16,16 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : Mesh_Reader.cxx -// Module : SMESH + +#include "Driver_SMDS_Mesh.h" using namespace std; -#include "Mesh_Reader.h" +Driver_SMDS_Mesh::Driver_SMDS_Mesh(): + myMesh(NULL) +{} + +void Driver_SMDS_Mesh::SetMesh(SMDS_Mesh *theMesh) +{ + myMesh = theMesh; +} diff --git a/src/Driver/Driver_SMDS_Mesh.h b/src/Driver/Driver_SMDS_Mesh.h new file mode 100644 index 000000000..1ea37562d --- /dev/null +++ b/src/Driver/Driver_SMDS_Mesh.h @@ -0,0 +1,38 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#ifndef _INCLUDE_DRIVER_SMDS_MESH +#define _INCLUDE_DRIVER_SMDS_MESH + +#include "Driver_Mesh.h" + +class SMDS_Mesh; + +class Driver_SMDS_Mesh: public Driver_Mesh +{ + public: + Driver_SMDS_Mesh(); + void SetMesh(SMDS_Mesh *theMesh); + + protected: + SMDS_Mesh *myMesh; + +}; + +#endif diff --git a/src/Driver/Document_Writer.cxx b/src/Driver/Driver_SMESHDS_Mesh.cxx similarity index 75% rename from src/Driver/Document_Writer.cxx rename to src/Driver/Driver_SMESHDS_Mesh.cxx index 8704c1284..2bf88277d 100644 --- a/src/Driver/Document_Writer.cxx +++ b/src/Driver/Driver_SMESHDS_Mesh.cxx @@ -1,5 +1,3 @@ -// SMESH Driver : implementaion of driver for reading and writing -// // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // @@ -18,21 +16,16 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : Document_Writer.cxx -// Module : SMESH + +#include "Driver_SMESHDS_Mesh.h" using namespace std; -#include "Document_Writer.h" -void Document_Writer::SetFile(string aFile) -{ - myFile = aFile; -} +Driver_SMESHDS_Mesh::Driver_SMESHDS_Mesh(): + myMesh(NULL) +{} -void Document_Writer::SetDocument(SMESHDS_Document * aDoc) +void Driver_SMESHDS_Mesh::SetMesh(SMESHDS_Mesh *theMesh) { - myDocument = aDoc; + myMesh = theMesh; } diff --git a/src/Driver/Driver_SMESHDS_Mesh.h b/src/Driver/Driver_SMESHDS_Mesh.h new file mode 100644 index 000000000..b401dbd1c --- /dev/null +++ b/src/Driver/Driver_SMESHDS_Mesh.h @@ -0,0 +1,38 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#ifndef _INCLUDE_DRIVER_SMESHDS_MESH +#define _INCLUDE_DRIVER_SMESHDS_MESH + +#include "Driver_Mesh.h" + +class SMESHDS_Mesh; + +class Driver_SMESHDS_Mesh: public Driver_Mesh +{ + public: + Driver_SMESHDS_Mesh(); + void SetMesh(SMESHDS_Mesh *theMesh); + + protected: + SMESHDS_Mesh *myMesh; + +}; + +#endif diff --git a/src/Driver/Driver_dl.cxx b/src/Driver/Driver_dl.cxx deleted file mode 100644 index f372d69b7..000000000 --- a/src/Driver/Driver_dl.cxx +++ /dev/null @@ -1,209 +0,0 @@ -// SMESH Driver : implementaion of driver for reading and writing -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : Driver_dl.cxx -// Module : SMESH - -using namespace std; -#include "Driver.h" - -#include -#include -#include - -#include "DriverDAT_R_SMESHDS_Document.h" -#include "Test.h" - -/*! extern "C" -{ - void test() { - - void *handle; - double (*cosine)(double); - char *error; - - handle = dlopen ("/usr/lib/libm.so", RTLD_LAZY); - if (!handle) { - fputs (dlerror(), stderr); - exit(1); - } - - cosine = dlsym(handle, "cos"); - if ((error = dlerror()) != NULL) { - fprintf (stderr, "%s\n", error); - exit(1); - } - - printf ("%f\n", (*cosine)(2.0)); - dlclose(handle); - - char* error; - string Extension=string("DAT"); - string Class=string("SMESHDS_Document"); - string myLibrary = string("/home/barberou/barberou/SALOME_3105/build/lib/libMeshDriver")+Extension+string(".so"); - SCRUTE(myLibrary); - //Document_Reader* myDriver;//a caster ??? - DriverDAT_R_SMESHDS_Document* myDriver; - - string myClass = string("Driver")+Extension+string("_R_")+Class; - SCRUTE(myClass); - - void* handle = dlopen (myLibrary.c_str(), RTLD_LAZY); - if (!handle) { - fputs (dlerror(), stderr); - exit(1); - } - MESSAGE("Open ok"); - - //int* res = (int*)dlsym(handle, "getOne"); - //SCRUTE(res); - SCRUTE(dlsym(handle, "getOne")); - //int res2= (*res)(); - myDriver = (DriverDAT_R_SMESHDS_Document*) dlsym(handle, myClass.c_str()); - MESSAGE("Reading 1"); - SCRUTE(myDriver); - if ((error = dlerror()) != NULL) { - fprintf (stderr, "%s\n", error); - exit(1); - } - MESSAGE("Reading 2"); - - dlclose(handle); - MESSAGE("after close"); - - } - }*/ - -Document_Reader* Driver::GetDocumentReader(string Extension, string Class) { - test(); - //p-e extern C ? - /*! - char* error; - string myLibrary = string("/home/barberou/barberou/SALOME_3105/build/lib/libMeshDriver")+Extension+string(".so"); - SCRUTE(myLibrary); - //Document_Reader* myDriver;//a caster ??? - DriverDAT_R_SMESHDS_Document* myDriver; - - string myClass = string("Driver")+Extension+string("_R_")+Class; - SCRUTE(myClass); - - void* handle = dlopen (myLibrary.c_str(), RTLD_LAZY); - if (!handle) { - fputs (dlerror(), stderr); - exit(1); - } - MESSAGE("Open ok"); - //myDriver = (Document_Reader*) dlsym(handle, myClass.c_str()); - int* res = (int*) dlsym(handle, "getOne"); - SCRUTE(res); - myDriver = (DriverDAT_R_SMESHDS_Document*) dlsym(handle, myClass.c_str()); - MESSAGE("Reading 1"); - SCRUTE(myDriver); - if ((error = dlerror()) != NULL) { - fprintf (stderr, "%s\n", error); - exit(1); - } - MESSAGE("Reading 2"); - - dlclose(handle); - MESSAGE("after close"); - return (myDriver); - */ - -} - -Document_Writer* Driver::GetDocumentWriter(string Extension, string Class) { - - char* error; - string myLibrary = string("libMeshDriver")+Extension+string(".so"); - Document_Writer* myDriver;//a caster ??? - string myClass = string("Driver")+Extension+string("_W_")+Class; - - void* handle = dlopen (myLibrary.c_str(), RTLD_LAZY); - if (!handle) { - fputs (dlerror(), stderr); - exit(1); - } - - myDriver = (Document_Writer*) dlsym(handle, myClass.c_str()); - if ((error = dlerror()) != NULL) { - fprintf (stderr, "%s\n", error); - exit(1); - } - - dlclose(handle); - - return (myDriver); - -} - -Mesh_Reader* Driver::GetMeshReader(string Extension, string Class) { - - char* error; - string myLibrary = string("libMeshDriver")+Extension+string(".so"); - Mesh_Reader* myDriver;//a caster ??? - string myClass = string("Driver")+Extension+string("_R_")+Class; - - void* handle = dlopen (myLibrary.c_str(), RTLD_LAZY); - if (!handle) { - fputs (dlerror(), stderr); - exit(1); - } - - myDriver = (Mesh_Reader*) dlsym(handle, myClass.c_str()); - if ((error = dlerror()) != NULL) { - fprintf (stderr, "%s\n", error); - exit(1); - } - - dlclose(handle); - - return (myDriver); - -} - -Mesh_Writer* Driver::GetMeshWriter(string Extension, string Class) { - - char* error; - string myLibrary = string("libMeshDriver")+Extension+string(".so"); - Mesh_Writer* myDriver;//a caster ??? - string myClass = string("Driver")+Extension+string("_W_")+Class; - - void* handle = dlopen (myLibrary.c_str(), RTLD_LAZY); - if (!handle) { - fputs (dlerror(), stderr); - exit(1); - } - - myDriver = (Mesh_Writer*) dlsym(handle, myClass.c_str()); - if ((error = dlerror()) != NULL) { - fprintf (stderr, "%s\n", error); - exit(1); - } - - dlclose(handle); - - return (myDriver); - -} - diff --git a/src/Driver/Makefile.in b/src/Driver/Makefile.in index 252d53062..d1c71416d 100644 --- a/src/Driver/Makefile.in +++ b/src/Driver/Makefile.in @@ -35,24 +35,24 @@ VPATH=.:@srcdir@ @COMMENCE@ # header files -EXPORT_HEADERS= Document_Reader.h Document_Writer.h Mesh_Reader.h Mesh_Writer.h +EXPORT_HEADERS= Driver_Document.h Driver_Mesh.h \ + Driver_SMDS_Mesh.h Driver_SMESHDS_Mesh.h # Libraries targets LIB = libMeshDriver.la -LIB_SRC = Document_Reader.cxx Document_Writer.cxx Mesh_Reader.cxx Mesh_Writer.cxx +LIB_SRC = Driver_Document.cxx Driver_Mesh.cxx \ + Driver_SMDS_Mesh.cxx Driver_SMESHDS_Mesh.cxx LIB_CLIENT_IDL = LIB_SERVER_IDL = # additionnal information to compil and link file -CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS) -CXXFLAGS += $(OCC_CXXFLAGS) $(MED2_INCLUDES) -rdynamic -ldl -I${KERNEL_ROOT_DIR}/include/salome +CPPFLAGS += +CXXFLAGS += -LDFLAGS += $(MED2_LIBS) -lSMESHDS -lSMDS +LDFLAGS += $(OCC_KERNEL_LIBS) -lTKTopAlgo -lSMESHDS -L${KERNEL_ROOT_DIR}/lib/salome -lOpUtil -%_moc.cxx: %.h - $(MOC) $< -o $@ @CONCLUDE@ diff --git a/src/Driver/SMESHDriver.cxx b/src/Driver/SMESHDriver.cxx deleted file mode 100644 index 83e9037a5..000000000 --- a/src/Driver/SMESHDriver.cxx +++ /dev/null @@ -1,139 +0,0 @@ -// SMESH Driver : implementaion of driver for reading and writing -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMESHDriver.cxx -// Module : SMESH - -using namespace std; -#include "SMESHDriver.h" - -#include -#include - -//A enlever -#include "DriverMED_R_SMESHDS_Document.h" -#include "DriverMED_R_SMESHDS_Mesh.h" -#include "DriverMED_R_SMDS_Mesh.h" -#include "DriverMED_W_SMESHDS_Document.h" -#include "DriverMED_W_SMESHDS_Mesh.h" -#include "DriverMED_W_SMDS_Mesh.h" - -#include "DriverDAT_R_SMESHDS_Document.h" -#include "DriverDAT_R_SMESHDS_Mesh.h" -#include "DriverDAT_R_SMDS_Mesh.h" -#include "DriverDAT_W_SMESHDS_Document.h" -#include "DriverDAT_W_SMESHDS_Mesh.h" -#include "DriverDAT_W_SMDS_Mesh.h" -// - -Document_Reader* SMESHDriver::GetDocumentReader(string Extension, string Class) { - if (Extension==string("MED")) { - DriverMED_R_SMESHDS_Document* myDriver = new DriverMED_R_SMESHDS_Document(); - return (myDriver); - } - else if (Extension==string("DAT")) { - DriverDAT_R_SMESHDS_Document* myDriver = new DriverDAT_R_SMESHDS_Document(); - return (myDriver); - } - else { - MESSAGE("No driver known for this extension"); - return (Document_Reader*)NULL; - } - - -} - -Document_Writer* SMESHDriver::GetDocumentWriter(string Extension, string Class) { - if (Extension==string("MED")) { - DriverMED_W_SMESHDS_Document* myDriver = new DriverMED_W_SMESHDS_Document(); - return (myDriver); - } - else if (Extension==string("DAT")) { - DriverDAT_W_SMESHDS_Document* myDriver = new DriverDAT_W_SMESHDS_Document(); - return (myDriver); - } - else { - MESSAGE("No driver known for this extension"); - return (Document_Writer*)NULL; - } - - -} - -Mesh_Reader* SMESHDriver::GetMeshReader(string Extension, string Class) { - if (Extension==string("MED")) { - - if (strcmp(Class.c_str(),"SMESHDS_Mesh")==0) { - DriverMED_R_SMESHDS_Mesh* myDriver = new DriverMED_R_SMESHDS_Mesh(); - return (myDriver); - } - else if (strcmp(Class.c_str(),"SMDS_Mesh")==0) { - DriverMED_R_SMDS_Mesh* myDriver = new DriverMED_R_SMDS_Mesh(); - return (myDriver); - } - - } - else if (Extension==string("DAT")) { - - if (strcmp(Class.c_str(),"SMESHDS_Mesh")==0) { - DriverDAT_R_SMESHDS_Mesh* myDriver = new DriverDAT_R_SMESHDS_Mesh(); - return (myDriver); - } - else if (strcmp(Class.c_str(),"SMDS_Mesh")==0) { - DriverDAT_R_SMDS_Mesh* myDriver = new DriverDAT_R_SMDS_Mesh(); - return (myDriver); - } - - } - - -} - -Mesh_Writer* SMESHDriver::GetMeshWriter(string Extension, string Class) { - if (Extension==string("MED")) { - - if (strcmp(Class.c_str(),"SMESHDS_Mesh")==0) { - DriverMED_W_SMESHDS_Mesh* myDriver = new DriverMED_W_SMESHDS_Mesh(); - return (myDriver); - } - else if (strcmp(Class.c_str(),"SMDS_Mesh")==0) { - DriverMED_W_SMDS_Mesh* myDriver = new DriverMED_W_SMDS_Mesh(); - return (myDriver); - } - - } - else if (Extension==string("DAT")) { - - if (strcmp(Class.c_str(),"SMESHDS_Mesh")==0) { - DriverDAT_W_SMESHDS_Mesh* myDriver = new DriverDAT_W_SMESHDS_Mesh(); - return (myDriver); - } - else if (strcmp(Class.c_str(),"SMDS_Mesh")==0) { - DriverDAT_W_SMDS_Mesh* myDriver = new DriverDAT_W_SMDS_Mesh(); - return (myDriver); - } - - } - -} - diff --git a/src/DriverDAT/DAT_Test.cxx b/src/DriverDAT/DAT_Test.cxx new file mode 100644 index 000000000..a36b4dd10 --- /dev/null +++ b/src/DriverDAT/DAT_Test.cxx @@ -0,0 +1,28 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include "DriverDAT_R_SMDS_Mesh.h" +#include "DriverDAT_W_SMDS_Mesh.h" + +int main(int argc, char** argv) +{ + DriverDAT_R_SMDS_Mesh aR; + DriverDAT_W_SMDS_Mesh aW; + return 1; +} diff --git a/src/DriverDAT/DriverDAT_R_SMDS_Mesh.cxx b/src/DriverDAT/DriverDAT_R_SMDS_Mesh.cxx index bd95f49fb..a49d7dbf3 100644 --- a/src/DriverDAT/DriverDAT_R_SMDS_Mesh.cxx +++ b/src/DriverDAT/DriverDAT_R_SMDS_Mesh.cxx @@ -1,5 +1,3 @@ -// SMESH DriverDAT : driver to read and write 'dat' files -// // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // @@ -18,208 +16,155 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : DriverDAT_R_SMDS_Mesh.cxx -// Module : SMESH -using namespace std; +#include + #include "DriverDAT_R_SMDS_Mesh.h" +#include "SMDS_Mesh.hxx" #include "utilities.h" -DriverDAT_R_SMDS_Mesh::DriverDAT_R_SMDS_Mesh() -{ - ; -} - -DriverDAT_R_SMDS_Mesh::~DriverDAT_R_SMDS_Mesh() -{ - ; -} - -void DriverDAT_R_SMDS_Mesh::SetMesh(SMDS_Mesh * aMesh) -{ - myMesh = aMesh; -} - -void DriverDAT_R_SMDS_Mesh::SetFile(string aFile) -{ - myFile = aFile; -} - -void DriverDAT_R_SMDS_Mesh::SetFileId(FILE * aFileId) -{ - myFileId = aFileId; -} - -void DriverDAT_R_SMDS_Mesh::SetMeshId(int aMeshId) -{ - myMeshId = aMeshId; -} - -void DriverDAT_R_SMDS_Mesh::Add() -{ - ; -} +using namespace std; -void DriverDAT_R_SMDS_Mesh::Read() +Driver_Mesh::Status DriverDAT_R_SMDS_Mesh::Perform() { - - int i, j; - int nbNodes, nbCells; - int intNumPoint; - float coordX, coordY, coordZ; - int nbNoeuds; - - int intNumMaille, Degre; - int ValElement; - int ValDegre; - int NoeudsMaille[20]; - int NoeudMaille; - - bool ok; - - MESSAGE("in DriverDAT_R_SMDS_Mesh::Read()"); + Status aResult = DRS_OK; + + int i, j; + int nbNodes, nbCells; + int intNumPoint; + float coordX, coordY, coordZ; + int nbNoeuds; + + int intNumMaille, Degre; + int ValElement; + int ValDegre; + int NoeudsMaille[20]; + int NoeudMaille; + + bool ok; + + MESSAGE("in DriverDAT_R_SMDS_Mesh::Read()"); /**************************************************************************** - * OUVERTURE DU FICHIER EN LECTURE * - ****************************************************************************/ - char *file2Read = (char *)myFile.c_str(); - myFileId = fopen(file2Read, "r"); - if (myFileId < 0) - { - fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read); - exit(EXIT_FAILURE); - } - - fscanf(myFileId, "%d %d\n", &nbNodes, &nbCells); - + * OUVERTURE DU FICHIER EN LECTURE * + ****************************************************************************/ + char *file2Read = (char *)myFile.c_str(); + FILE* aFileId = fopen(file2Read, "r"); + if (aFileId < 0) { + fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read); + return DRS_FAIL; + } + + fscanf(aFileId, "%d %d\n", &nbNodes, &nbCells); + /**************************************************************************** - * LECTURE DES NOEUDS * - ****************************************************************************/ - fprintf(stdout, "\n(************************)\n"); - fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n"); - fprintf(stdout, "(************************)\n"); - - for (i = 0; i < nbNodes; i++) - { - fscanf(myFileId, "%d %e %e %e\n", &intNumPoint, &coordX, &coordY, - &coordZ); - ok = myMesh->AddNodeWithID(coordX, coordY, coordZ, intNumPoint); - } - - fprintf(stdout, "%d noeuds\n", myMesh->NbNodes()); + * LECTURE DES NOEUDS * + ****************************************************************************/ + fprintf(stdout, "\n(************************)\n"); + fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n"); + fprintf(stdout, "(************************)\n"); + + for (i = 0; i < nbNodes; i++){ + fscanf(aFileId, "%d %e %e %e\n", &intNumPoint, &coordX, &coordY, &coordZ); + ok = myMesh->AddNodeWithID(coordX, coordY, coordZ, intNumPoint); + } + + fprintf(stdout, "%d noeuds\n", myMesh->NbNodes()); /**************************************************************************** - * LECTURE DES ELEMENTS * - ****************************************************************************/ - fprintf(stdout, "\n(**************************)\n"); - fprintf(stdout, "(* ELEMENTS DU MAILLAGE : *)\n"); - fprintf(stdout, "(**************************)"); - - fprintf(stdout, "%d elements\n", nbCells); - - for (i = 0; i < nbCells; i++) - { - fscanf(myFileId, "%d %d", &intNumMaille, &ValElement); - Degre = abs(ValElement / 100); - nbNoeuds = ValElement - (Degre * 100); - - // Recuperation des noeuds de la maille - for (j = 0; j < nbNoeuds; j++) - { - fscanf(myFileId, "%d", &NoeudMaille); - NoeudsMaille[j] = NoeudMaille; - } - - // Analyse des cas de cellules - switch (ValElement) - { - case 102:; - case 103:; - { - ValDegre = 3; - nbNoeuds = 2; - ok = myMesh->AddEdgeWithID(NoeudsMaille[0], NoeudsMaille[1], - intNumMaille); - break; - } - case 204:; - case 208:; - { - ValDegre = 9; - nbNoeuds = 4; - ok = myMesh->AddFaceWithID(NoeudsMaille[0], NoeudsMaille[1], - NoeudsMaille[2], NoeudsMaille[3], intNumMaille); - break; - } - case 203:; - case 206:; - { - ValDegre = 5; - nbNoeuds = 3; - ok = myMesh->AddFaceWithID(NoeudsMaille[0], NoeudsMaille[1], - NoeudsMaille[2], intNumMaille); - break; - } - case 308:; - case 320:; - { - ValDegre = 12; - nbNoeuds = 8; - if (ValElement == 320) - { - //A voir, correspondance VTK - NoeudsMaille[4] = NoeudsMaille[8]; - NoeudsMaille[5] = NoeudsMaille[9]; - NoeudsMaille[6] = NoeudsMaille[10]; - NoeudsMaille[7] = NoeudsMaille[11]; - } - ok = myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1], - NoeudsMaille[2], NoeudsMaille[3], NoeudsMaille[4], - NoeudsMaille[5], NoeudsMaille[6], NoeudsMaille[7], - intNumMaille); + * LECTURE DES ELEMENTS * + ****************************************************************************/ + fprintf(stdout, "\n(**************************)\n"); + fprintf(stdout, "(* ELEMENTS DU MAILLAGE : *)\n"); + fprintf(stdout, "(**************************)"); + + fprintf(stdout, "%d elements\n", nbCells); + + for (i = 0; i < nbCells; i++) { + fscanf(aFileId, "%d %d", &intNumMaille, &ValElement); + Degre = abs(ValElement / 100); + nbNoeuds = ValElement - (Degre * 100); + + // Recuperation des noeuds de la maille + for (j = 0; j < nbNoeuds; j++) { + fscanf(aFileId, "%d", &NoeudMaille); + NoeudsMaille[j] = NoeudMaille; + } + + // Analyse des cas de cellules + switch (ValElement) { + case 102: + case 103: + ValDegre = 3; + nbNoeuds = 2; + ok = myMesh->AddEdgeWithID(NoeudsMaille[0], NoeudsMaille[1], + intNumMaille); + break; + case 204: + case 208: + ValDegre = 9; + nbNoeuds = 4; + ok = myMesh->AddFaceWithID(NoeudsMaille[0], NoeudsMaille[1], + NoeudsMaille[2], NoeudsMaille[3], + intNumMaille); + break; + case 203: + case 206: + ValDegre = 5; + nbNoeuds = 3; + ok = myMesh->AddFaceWithID(NoeudsMaille[0], NoeudsMaille[1], + NoeudsMaille[2], intNumMaille); + break; + case 308: + case 320: + ValDegre = 12; + nbNoeuds = 8; + if (ValElement == 320){ + //A voir, correspondance VTK + NoeudsMaille[4] = NoeudsMaille[8]; + NoeudsMaille[5] = NoeudsMaille[9]; + NoeudsMaille[6] = NoeudsMaille[10]; + NoeudsMaille[7] = NoeudsMaille[11]; + } + ok = myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1], + NoeudsMaille[2], NoeudsMaille[3], + NoeudsMaille[4], NoeudsMaille[5], + NoeudsMaille[6], NoeudsMaille[7], + intNumMaille); + break; + case 304: + case 310: + ValDegre = 10; + nbNoeuds = 4; + if (ValElement == 310) + NoeudsMaille[3] = NoeudsMaille[6]; + ok = myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1], + NoeudsMaille[2], NoeudsMaille[3], + intNumMaille); + break; + case 306: + case 315: + ValDegre = 12; + nbNoeuds = 8; + if (ValElement == 315) { + NoeudsMaille[3] = NoeudsMaille[6]; + NoeudsMaille[4] = NoeudsMaille[7]; + NoeudsMaille[5] = NoeudsMaille[8]; + } + NoeudsMaille[7] = NoeudsMaille[5]; + NoeudsMaille[6] = NoeudsMaille[5]; + NoeudsMaille[5] = NoeudsMaille[4]; + NoeudsMaille[4] = NoeudsMaille[3]; + NoeudsMaille[3] = NoeudsMaille[2]; + ok = myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1], + NoeudsMaille[2], NoeudsMaille[3], + NoeudsMaille[4], NoeudsMaille[5], + intNumMaille); break; - } - case 304:; - case 310:; - { - ValDegre = 10; - nbNoeuds = 4; - if (ValElement == 310) - NoeudsMaille[3] = NoeudsMaille[6]; - ok = myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1], - NoeudsMaille[2], NoeudsMaille[3], intNumMaille); - break; - } - case 306:; - case 315:; - { - ValDegre = 12; - nbNoeuds = 8; - if (ValElement == 315) - { - NoeudsMaille[3] = NoeudsMaille[6]; - NoeudsMaille[4] = NoeudsMaille[7]; - NoeudsMaille[5] = NoeudsMaille[8]; - } - NoeudsMaille[7] = NoeudsMaille[5]; - NoeudsMaille[6] = NoeudsMaille[5]; - NoeudsMaille[5] = NoeudsMaille[4]; - NoeudsMaille[4] = NoeudsMaille[3]; - NoeudsMaille[3] = NoeudsMaille[2]; - ok = myMesh->AddVolumeWithID(NoeudsMaille[0], NoeudsMaille[1], - NoeudsMaille[2], NoeudsMaille[3], NoeudsMaille[4], - NoeudsMaille[5], intNumMaille); - break; - } - - } - } - + } + } /**************************************************************************** - * FERMETURE DU FICHIER * - ****************************************************************************/ - fclose(myFileId); - + * FERMETURE DU FICHIER * + ****************************************************************************/ + fclose(aFileId); + return aResult; } diff --git a/src/DriverDAT/DriverDAT_R_SMDS_Mesh.h b/src/DriverDAT/DriverDAT_R_SMDS_Mesh.h index 63811bd34..d955cf7b7 100644 --- a/src/DriverDAT/DriverDAT_R_SMDS_Mesh.h +++ b/src/DriverDAT/DriverDAT_R_SMDS_Mesh.h @@ -1,5 +1,3 @@ -// SMESH DriverDAT : driver to read and write 'dat' files -// // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // @@ -18,38 +16,16 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : DriverDAT_R_SMDS_Mesh.h -// Module : SMESH #ifndef _INCLUDE_DRIVERDAT_R_SMDS_MESH #define _INCLUDE_DRIVERDAT_R_SMDS_MESH -#include +#include "Driver_SMDS_Mesh.h" -#include "SMDS_Mesh.hxx" -#include "Mesh_Reader.h" - -class DriverDAT_R_SMDS_Mesh:public Mesh_Reader +class DriverDAT_R_SMDS_Mesh: public Driver_SMDS_Mesh { - - public:DriverDAT_R_SMDS_Mesh(); - ~DriverDAT_R_SMDS_Mesh(); - - void Add(); - void Read(); - void SetMesh(SMDS_Mesh * aMesh); - void SetFile(string); - - void SetFileId(FILE *); - void SetMeshId(int); - - private: SMDS_Mesh * myMesh; - string myFile; - FILE *myFileId; - int myMeshId; - + public: + virtual Status Perform(); }; + #endif diff --git a/src/DriverDAT/DriverDAT_R_SMESHDS_Document.cxx b/src/DriverDAT/DriverDAT_R_SMESHDS_Document.cxx index fe3603697..c7d9b2230 100644 --- a/src/DriverDAT/DriverDAT_R_SMESHDS_Document.cxx +++ b/src/DriverDAT/DriverDAT_R_SMESHDS_Document.cxx @@ -1,5 +1,3 @@ -// SMESH DriverDAT : driver to read and write 'dat' files -// // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // @@ -18,100 +16,5 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : DriverDAT_R_SMESHDS_Document.cxx -// Module : SMESH -using namespace std; #include "DriverDAT_R_SMESHDS_Document.h" -#include "DriverDAT_R_SMESHDS_Mesh.h" - -#include "utilities.h" - -int getOne() -{ - printf("in getOne"); - return (1); -} - -extern "C" -{ - // Document_Reader* maker() { - DriverDAT_R_SMESHDS_Document *maker() - { - fprintf(stdout, "here in maker\n"); - return new DriverDAT_R_SMESHDS_Document; - } -} - -DriverDAT_R_SMESHDS_Document::DriverDAT_R_SMESHDS_Document() -{ - myFile = string(""); -} - -DriverDAT_R_SMESHDS_Document::~DriverDAT_R_SMESHDS_Document() -{ - ; -} - -//void DriverDAT_R_SMESHDS_Document::SetFile(string aFile) { -//myFile = aFile; -//} - -//void DriverDAT_R_SMESHDS_Document::SetDocument(Handle(SMESHDS_Document)& aDoc) { -//myDocument = aDoc; -//} - -void DriverDAT_R_SMESHDS_Document::Read() -{ - - int myMeshId; - MESSAGE("in read"); - SCRUTE(myFile); - //Handle(SMESHDS_Document) myDocument = new SMESHDS_Document(1); - - /**************************************************************************** - * OUVERTURE DU FICHIER EN LECTURE * - ****************************************************************************/ - char *file2Read = (char *)myFile.c_str(); - FILE *fid = fopen(file2Read, "r"); - if (fid < 0) - { - fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read); - exit(EXIT_FAILURE); - } - - /**************************************************************************** - * COMBIEN DE MAILLAGES ? * - ****************************************************************************/ - int nmaa = 1; - - /**************************************************************************** - * FERMETURE DU FICHIER * - ****************************************************************************/ - fclose(fid); - - printf("Nombre de maillages = %d\n", nmaa); - - string myClass = string("SMESHDS_Mesh"); - string myExtension = string("DAT"); - - for (int meshIt = 1; meshIt <= nmaa; meshIt++) - { - myMeshId = myDocument->NewMesh(); - - SMDS_Mesh * myMesh = myDocument->GetMesh(myMeshId); - - DriverDAT_R_SMESHDS_Mesh *myReader = new DriverDAT_R_SMESHDS_Mesh; - - myReader->SetMesh(myMesh); - myReader->SetFile(myFile); - //myReader->SetFileId(fid); - - myReader->Read(); - - } - -} diff --git a/src/DriverDAT/DriverDAT_R_SMESHDS_Document.h b/src/DriverDAT/DriverDAT_R_SMESHDS_Document.h index 68bef913b..3d63ced6a 100644 --- a/src/DriverDAT/DriverDAT_R_SMESHDS_Document.h +++ b/src/DriverDAT/DriverDAT_R_SMESHDS_Document.h @@ -1,5 +1,3 @@ -// SMESH DriverDAT : driver to read and write 'dat' files -// // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // @@ -18,33 +16,13 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : DriverDAT_R_SMESHDS_Document.h -// Module : SMESH #ifndef _INCLUDE_DRIVERDAT_R_SMESHDS_DOCUMENT #define _INCLUDE_DRIVERDAT_R_SMESHDS_DOCUMENT -#include +#include "Driver_Document.h" -#include "SMESHDS_Document.hxx" -#include "Document_Reader.h" +class DriverDAT_R_SMESHDS_Document : public Driver_Document +{}; -class DriverDAT_R_SMESHDS_Document : public Document_Reader { - -public : - DriverDAT_R_SMESHDS_Document(); - ~DriverDAT_R_SMESHDS_Document(); - - void Read(); - //void SetFile(string); - //void SetDocument(Handle_SMESHDS_Document&); - -private : - //Handle_SMESHDS_Document myDocument; - //string myFile; - -}; #endif diff --git a/src/DriverDAT/DriverDAT_R_SMESHDS_Mesh.cxx b/src/DriverDAT/DriverDAT_R_SMESHDS_Mesh.cxx index 65151a2a0..a7e974f52 100644 --- a/src/DriverDAT/DriverDAT_R_SMESHDS_Mesh.cxx +++ b/src/DriverDAT/DriverDAT_R_SMESHDS_Mesh.cxx @@ -1,5 +1,3 @@ -// SMESH DriverDAT : driver to read and write 'dat' files -// // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // @@ -18,69 +16,5 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : DriverDAT_R_SMESHDS_Mesh.cxx -// Module : SMESH -using namespace std; #include "DriverDAT_R_SMESHDS_Mesh.h" -#include "DriverDAT_R_SMDS_Mesh.h" - -#include "utilities.h" - -DriverDAT_R_SMESHDS_Mesh::DriverDAT_R_SMESHDS_Mesh() -{ - ; -} - -DriverDAT_R_SMESHDS_Mesh::~DriverDAT_R_SMESHDS_Mesh() -{ - ; -} - -void DriverDAT_R_SMESHDS_Mesh::SetMesh(SMDS_Mesh * aMesh) -{ - //myMesh = SMESHDS_Mesh *::DownCast(aMesh); - myMesh = aMesh; -} - -void DriverDAT_R_SMESHDS_Mesh::SetFile(string aFile) -{ - myFile = aFile; -} - -void DriverDAT_R_SMESHDS_Mesh::SetFileId(FILE * aFileId) -{ - myFileId = aFileId; -} - -void DriverDAT_R_SMESHDS_Mesh::SetMeshId(int aMeshId) -{ - myMeshId = aMeshId; -} - -void DriverDAT_R_SMESHDS_Mesh::Add() -{ - ; -} - -void DriverDAT_R_SMESHDS_Mesh::Read() -{ - string myClass = string("SMDS_Mesh"); - string myExtension = string("DAT"); - - MESSAGE("in DriverDAT_R_SMESHDS_Mesh::Read() 1"); - DriverDAT_R_SMDS_Mesh *myReader = new DriverDAT_R_SMDS_Mesh; - - MESSAGE("in DriverDAT_R_SMESHDS_Mesh::Read() 2"); - myReader->SetMesh(myMesh); - MESSAGE("in DriverDAT_R_SMESHDS_Mesh::Read() 3"); - myReader->SetFile(myFile); - //myReader->SetFileId(myFileId); - - MESSAGE("in DriverDAT_R_SMESHDS_Mesh::Read() 4"); - myReader->Read(); - -} diff --git a/src/DriverDAT/DriverDAT_R_SMESHDS_Mesh.h b/src/DriverDAT/DriverDAT_R_SMESHDS_Mesh.h index f9f265494..e74967581 100644 --- a/src/DriverDAT/DriverDAT_R_SMESHDS_Mesh.h +++ b/src/DriverDAT/DriverDAT_R_SMESHDS_Mesh.h @@ -1,5 +1,3 @@ -// SMESH DriverDAT : driver to read and write 'dat' files -// // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // @@ -18,38 +16,13 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : DriverDAT_R_SMESHDS_Mesh.h -// Module : SMESH #ifndef _INCLUDE_DRIVERDAT_R_SMESHDS_MESH #define _INCLUDE_DRIVERDAT_R_SMESHDS_MESH -#include +#include "Driver_SMESHDS_Mesh.h" -#include "SMESHDS_Mesh.hxx" -#include "Mesh_Reader.h" +class DriverDAT_R_SMESHDS_Mesh: public Driver_SMESHDS_Mesh +{}; -class DriverDAT_R_SMESHDS_Mesh:public Mesh_Reader -{ - - public:DriverDAT_R_SMESHDS_Mesh(); - ~DriverDAT_R_SMESHDS_Mesh(); - - void Add(); - void Read(); - void SetMesh(SMDS_Mesh * aMesh); - void SetFile(string); - - void SetFileId(FILE *); - void SetMeshId(int); - - private: SMDS_Mesh * myMesh; - string myFile; - FILE *myFileId; - int myMeshId; - -}; #endif diff --git a/src/DriverDAT/DriverDAT_W_SMDS_Mesh.cxx b/src/DriverDAT/DriverDAT_W_SMDS_Mesh.cxx index 8f6a7068d..1f8d5ab61 100644 --- a/src/DriverDAT/DriverDAT_W_SMDS_Mesh.cxx +++ b/src/DriverDAT/DriverDAT_W_SMDS_Mesh.cxx @@ -1,5 +1,3 @@ -// SMESH DriverDAT : driver to read and write 'dat' files -// // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // @@ -18,189 +16,129 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : DriverDAT_W_SMDS_Mesh.cxx -// Module : SMESH -using namespace std; +#include + #include "DriverDAT_W_SMDS_Mesh.h" -#include "SMDS_MeshElement.hxx" -#include "SMDS_MeshNode.hxx" +#include "SMDS_Mesh.hxx" #include "utilities.h" -DriverDAT_W_SMDS_Mesh::DriverDAT_W_SMDS_Mesh() -{ - ; -} - -DriverDAT_W_SMDS_Mesh::~DriverDAT_W_SMDS_Mesh() -{ - ; -} - -void DriverDAT_W_SMDS_Mesh::SetMesh(SMDS_Mesh * aMesh) -{ - myMesh = aMesh; -} - -void DriverDAT_W_SMDS_Mesh::SetFile(string aFile) -{ - myFile = aFile; -} - -void DriverDAT_W_SMDS_Mesh::SetFileId(FILE * aFileId) -{ - myFileId = aFileId; -} - -void DriverDAT_W_SMDS_Mesh::SetMeshId(int aMeshId) -{ - myMeshId = aMeshId; -} - -void DriverDAT_W_SMDS_Mesh::Add() -{ - ; -} +using namespace std; -void DriverDAT_W_SMDS_Mesh::Write() +Driver_Mesh::Status DriverDAT_W_SMDS_Mesh::Perform() { - - int nbNodes, nbCells; - int i; - - char *file2Read = (char *)myFile.c_str(); - myFileId = fopen(file2Read, "w+"); - if (myFileId < 0) - { - fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read); - exit(EXIT_FAILURE); - } - SCRUTE(myMesh); + Status aResult = DRS_OK; + + int nbNodes, nbCells; + int i; + + char *file2Read = (char *)myFile.c_str(); + FILE* aFileId = fopen(file2Read, "w+"); + if (aFileId < 0) { + fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read); + return DRS_FAIL; + } + SCRUTE(myMesh); /**************************************************************************** - * NOMBRES D'OBJETS * - ****************************************************************************/ - fprintf(stdout, "\n(****************************)\n"); - fprintf(stdout, "(* INFORMATIONS GENERALES : *)\n"); - fprintf(stdout, "(****************************)\n"); - - /* Combien de noeuds ? */ - nbNodes = myMesh->NbNodes(); - - /* Combien de mailles, faces ou aretes ? */ - int nb_of_nodes, nb_of_edges, nb_of_faces, nb_of_volumes; - nb_of_edges = myMesh->NbEdges(); - nb_of_faces = myMesh->NbFaces(); - nb_of_volumes = myMesh->NbVolumes(); - nbCells = nb_of_edges + nb_of_faces + nb_of_volumes; - SCRUTE(nb_of_edges); - SCRUTE(nb_of_faces); - SCRUTE(nb_of_volumes); - - fprintf(stdout, "%d %d\n", nbNodes, nbCells); - fprintf(myFileId, "%d %d\n", nbNodes, nbCells); - + * NOMBRES D'OBJETS * + ****************************************************************************/ + fprintf(stdout, "\n(****************************)\n"); + fprintf(stdout, "(* INFORMATIONS GENERALES : *)\n"); + fprintf(stdout, "(****************************)\n"); + + /* Combien de noeuds ? */ + nbNodes = myMesh->NbNodes(); + + /* Combien de mailles, faces ou aretes ? */ + int nb_of_nodes, nb_of_edges, nb_of_faces, nb_of_volumes; + nb_of_edges = myMesh->NbEdges(); + nb_of_faces = myMesh->NbFaces(); + nb_of_volumes = myMesh->NbVolumes(); + nbCells = nb_of_edges + nb_of_faces + nb_of_volumes; + SCRUTE(nb_of_edges); + SCRUTE(nb_of_faces); + SCRUTE(nb_of_volumes); + + fprintf(stdout, "%d %d\n", nbNodes, nbCells); + fprintf(aFileId, "%d %d\n", nbNodes, nbCells); + /**************************************************************************** - * ECRITURE DES NOEUDS * - ****************************************************************************/ - fprintf(stdout, "\n(************************)\n"); - fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n"); - fprintf(stdout, "(************************)\n"); - - SMDS_NodeIteratorPtr itNodes=myMesh->nodesIterator(); - while(itNodes->more()) - { - const SMDS_MeshNode * node = itNodes->next(); - fprintf(myFileId, "%d %e %e %e\n", node->GetID(), node->X(), - node->Y(), node->Z()); - } + * ECRITURE DES NOEUDS * + ****************************************************************************/ + fprintf(stdout, "\n(************************)\n"); + fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n"); + fprintf(stdout, "(************************)\n"); + + SMDS_NodeIteratorPtr itNodes=myMesh->nodesIterator(); + while(itNodes->more()){ + const SMDS_MeshNode * node = itNodes->next(); + fprintf(aFileId, "%d %e %e %e\n", node->GetID(), node->X(), node->Y(), node->Z()); + } /**************************************************************************** - * ECRITURE DES ELEMENTS * - ****************************************************************************/ - fprintf(stdout, "\n(**************************)\n"); - fprintf(stdout, "(* ELEMENTS DU MAILLAGE : *)\n"); - fprintf(stdout, "(**************************)"); - /* Ecriture des connectivites, noms, numeros des mailles */ - - SMDS_EdgeIteratorPtr itEdges=myMesh->edgesIterator(); - while(itEdges->more()) - { - const SMDS_MeshElement * elem = itEdges->next(); - - switch (elem->NbNodes()) - { - case 2: - { - fprintf(myFileId, "%d %d ", elem->GetID(), 102); - break; - } - case 3: - { - fprintf(myFileId, "%d %d ", elem->GetID(), 103); - break; - } - } - - SMDS_ElemIteratorPtr it=elem->nodesIterator(); - while(it->more()) fprintf(myFileId, "%d ", it->next()->GetID()); - - fprintf(myFileId, "\n"); - } - - SMDS_FaceIteratorPtr itFaces=myMesh->facesIterator(); - while(itFaces->more()) - { - const SMDS_MeshElement * elem = itFaces->next(); - - switch (elem->NbNodes()) - { - case 3: - { - fprintf(myFileId, "%d %d ", elem->GetID(), 203); - break; - } - case 4: - { - fprintf(myFileId, "%d %d ", elem->GetID(), 204); - break; - } - case 6: - { - fprintf(myFileId, "%d %d ", elem->GetID(), 206); - break; - } - } - - SMDS_ElemIteratorPtr it=elem->nodesIterator(); - while(it->more()) fprintf(myFileId, "%d ", it->next()->GetID()); - - fprintf(myFileId, "\n"); - } - - SMDS_VolumeIteratorPtr itVolumes=myMesh->volumesIterator(); - while(itVolumes->more()) - { - const SMDS_MeshElement * elem = itVolumes->next(); - - switch (elem->NbNodes()) - { - case 8: - { - fprintf(myFileId, "%d %d ", elem->GetID(), 308); - break; - } - } - - SMDS_ElemIteratorPtr it=elem->nodesIterator(); - while(it->more()) fprintf(myFileId, "%d ", it->next()->GetID()); - - fprintf(myFileId, "\n"); - } - - fclose(myFileId); + * ECRITURE DES ELEMENTS * + ****************************************************************************/ + fprintf(stdout, "\n(**************************)\n"); + fprintf(stdout, "(* ELEMENTS DU MAILLAGE : *)\n"); + fprintf(stdout, "(**************************)"); + /* Ecriture des connectivites, noms, numeros des mailles */ + + SMDS_EdgeIteratorPtr itEdges=myMesh->edgesIterator(); + while(itEdges->more()){ + const SMDS_MeshElement * elem = itEdges->next(); + switch (elem->NbNodes()) { + case 2: + fprintf(aFileId, "%d %d ", elem->GetID(), 102); + break; + case 3: + fprintf(aFileId, "%d %d ", elem->GetID(), 103); + break; + } + SMDS_ElemIteratorPtr it=elem->nodesIterator(); + while(it->more()) + fprintf(aFileId, "%d ", it->next()->GetID()); + fprintf(aFileId, "\n"); + } + + SMDS_FaceIteratorPtr itFaces=myMesh->facesIterator(); + while(itFaces->more()){ + const SMDS_MeshElement * elem = itFaces->next(); + switch (elem->NbNodes()) { + case 3: + fprintf(aFileId, "%d %d ", elem->GetID(), 203); + break; + case 4: + fprintf(aFileId, "%d %d ", elem->GetID(), 204); + break; + case 6: + fprintf(aFileId, "%d %d ", elem->GetID(), 206); + break; + } + SMDS_ElemIteratorPtr it=elem->nodesIterator(); + while(it->more()) + fprintf(aFileId, "%d ", it->next()->GetID()); + fprintf(aFileId, "\n"); + } + + SMDS_VolumeIteratorPtr itVolumes=myMesh->volumesIterator(); + while(itVolumes->more()){ + const SMDS_MeshElement * elem = itVolumes->next(); + switch (elem->NbNodes()) { + case 8: + fprintf(aFileId, "%d %d ", elem->GetID(), 308); + break; + } + + SMDS_ElemIteratorPtr it=elem->nodesIterator(); + while(it->more()) + fprintf(aFileId, "%d ", it->next()->GetID()); + + fprintf(aFileId, "\n"); + } + + fclose(aFileId); + + return aResult; } diff --git a/src/DriverDAT/DriverDAT_W_SMDS_Mesh.h b/src/DriverDAT/DriverDAT_W_SMDS_Mesh.h index 9acabe8c8..ebd3d642e 100644 --- a/src/DriverDAT/DriverDAT_W_SMDS_Mesh.h +++ b/src/DriverDAT/DriverDAT_W_SMDS_Mesh.h @@ -27,30 +27,12 @@ #ifndef _INCLUDE_DRIVERDAT_W_SMDS_MESH #define _INCLUDE_DRIVERDAT_W_SMDS_MESH -#include -#include +#include "Driver_SMDS_Mesh.h" -#include "SMDS_Mesh.hxx" -#include "Mesh_Writer.h" - -class DriverDAT_W_SMDS_Mesh:public Mesh_Writer +class DriverDAT_W_SMDS_Mesh: public Driver_SMDS_Mesh { - - public:DriverDAT_W_SMDS_Mesh(); - ~DriverDAT_W_SMDS_Mesh(); - - void Add(); - void Write(); - void SetMesh(SMDS_Mesh * aMesh); - void SetFile(string); - - void SetFileId(FILE *); - void SetMeshId(int); - - private: SMDS_Mesh * myMesh; - string myFile; - FILE *myFileId; - int myMeshId; - + public: + virtual Status Perform(); }; + #endif diff --git a/src/DriverDAT/DriverDAT_W_SMESHDS_Document.cxx b/src/DriverDAT/DriverDAT_W_SMESHDS_Document.cxx index b6c6195aa..1cd9699af 100644 --- a/src/DriverDAT/DriverDAT_W_SMESHDS_Document.cxx +++ b/src/DriverDAT/DriverDAT_W_SMESHDS_Document.cxx @@ -1,5 +1,3 @@ -// SMESH DriverDAT : driver to read and write 'dat' files -// // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // @@ -18,92 +16,5 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : DriverDAT_W_SMESHDS_Document.cxx -// Module : SMESH -using namespace std; #include "DriverDAT_W_SMESHDS_Document.h" -#include "DriverDAT_W_SMESHDS_Mesh.h" - -#include "utilities.h" - -extern "C" -{ - Document_Writer *Wmaker() - { - return new DriverDAT_W_SMESHDS_Document; - } -} - -DriverDAT_W_SMESHDS_Document::DriverDAT_W_SMESHDS_Document() -{ - ; -} - -DriverDAT_W_SMESHDS_Document::~DriverDAT_W_SMESHDS_Document() -{ - ; -} - -//void DriverDAT_W_SMESHDS_Document::SetFile(string aFile) { -//myFile = aFile; -//} - -//void DriverDAT_W_SMESHDS_Document::SetDocument(Handle(SMESHDS_Document)& aDocument) { -//myDocument = aDocument; -//} - -void DriverDAT_W_SMESHDS_Document::Write() -{ - - SMESHDS_Mesh * myMesh; - - /**************************************************************************** - * OUVERTURE DU FICHIER EN ECRITURE * - ****************************************************************************/ - char *file2Write = (char *)myFile.c_str(); - FILE *fid = fopen(file2Write, "w+"); - if (fid < 0) - { - fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Write); - exit(EXIT_FAILURE); - } - - /**************************************************************************** - * FERMETURE DU FICHIER * - ****************************************************************************/ - - fclose(fid); - - /******** Nombre de maillages ********/ - int nb_of_meshes = myDocument->NbMeshes(); //voir avec Yves - //nb_of_meshes = 1; - int numero = 0; - - string myClass = string("SMESHDS_Mesh"); - string myExtension = string("DAT"); - - //while (numeroGetMesh(numero); - myDocument->InitMeshesIterator(); - while(myDocument->MoreMesh()) - { - numero++; - myMesh = myDocument->NextMesh(); - - DriverDAT_W_SMESHDS_Mesh *myWriter = new DriverDAT_W_SMESHDS_Mesh; - //Mesh_Writer* myWriter = Driver::GetMeshWriter(myExtension, myClass); - - myWriter->SetMesh(myMesh); - myWriter->SetFile(myFile); - SCRUTE(myMesh); - //myWriter->SetFileId(fid); - myWriter->SetMeshId(numero); - myWriter->Write(); - } - -} diff --git a/src/DriverDAT/DriverDAT_W_SMESHDS_Document.h b/src/DriverDAT/DriverDAT_W_SMESHDS_Document.h index 4e744deb9..6b2bad5a0 100644 --- a/src/DriverDAT/DriverDAT_W_SMESHDS_Document.h +++ b/src/DriverDAT/DriverDAT_W_SMESHDS_Document.h @@ -1,5 +1,3 @@ -// SMESH DriverDAT : driver to read and write 'dat' files -// // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // @@ -18,34 +16,13 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : DriverDAT_W_SMESHDS_Document.h -// Module : SMESH #ifndef _INCLUDE_DRIVERDAT_W_SMESHDS_DOCUMENT #define _INCLUDE_DRIVERDAT_W_SMESHDS_DOCUMENT -#include -#include +#include "Driver_Document.h" -#include "SMESHDS_Document.hxx" -#include "Document_Writer.h" +class DriverDAT_W_SMESHDS_Document: public Driver_Document +{}; -class DriverDAT_W_SMESHDS_Document : public Document_Writer { - -public : - DriverDAT_W_SMESHDS_Document(); - ~DriverDAT_W_SMESHDS_Document(); - - void Write(); - //void SetFile(string); - //void SetDocument(Handle(SMESHDS_Document)&); - -private : - //Handle_SMESHDS_Document myDocument; - //string myFile; - -}; #endif diff --git a/src/DriverDAT/DriverDAT_W_SMESHDS_Mesh.cxx b/src/DriverDAT/DriverDAT_W_SMESHDS_Mesh.cxx index 9518e2f78..e17c6cdd2 100644 --- a/src/DriverDAT/DriverDAT_W_SMESHDS_Mesh.cxx +++ b/src/DriverDAT/DriverDAT_W_SMESHDS_Mesh.cxx @@ -1,5 +1,3 @@ -// SMESH DriverDAT : driver to read and write 'dat' files -// // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // @@ -18,206 +16,5 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : DriverDAT_W_SMESHDS_Mesh.cxx -// Module : SMESH -using namespace std; #include "DriverDAT_W_SMESHDS_Mesh.h" -#include "DriverDAT_W_SMDS_Mesh.h" - -#include "SMDS_MeshElement.hxx" -#include "SMDS_MeshNode.hxx" - - - - - -#include "utilities.h" - -DriverDAT_W_SMESHDS_Mesh::DriverDAT_W_SMESHDS_Mesh() -{ - ; -} - -DriverDAT_W_SMESHDS_Mesh::~DriverDAT_W_SMESHDS_Mesh() -{ - ; -} - -void DriverDAT_W_SMESHDS_Mesh::SetMesh(SMDS_Mesh * aMesh) -{ - //myMesh = SMESHDS_Mesh *::DownCast(aMesh); - myMesh = aMesh; -} - -void DriverDAT_W_SMESHDS_Mesh::SetFile(string aFile) -{ - myFile = aFile; -} - -void DriverDAT_W_SMESHDS_Mesh::SetFileId(FILE * aFileId) -{ - myFileId = aFileId; -} - -void DriverDAT_W_SMESHDS_Mesh::SetMeshId(int aMeshId) -{ - myMeshId = aMeshId; -} - -void DriverDAT_W_SMESHDS_Mesh::Write() -{ - - string myClass = string("SMDS_Mesh"); - string myExtension = string("DAT"); - - DriverDAT_W_SMDS_Mesh *myWriter = new DriverDAT_W_SMDS_Mesh; - - myWriter->SetMesh(myMesh); - myWriter->SetFile(myFile); - myWriter->SetMeshId(myMeshId); - //myWriter->SetFileId(myFileId); - - myWriter->Write(); - -} - -void DriverDAT_W_SMESHDS_Mesh::Add() -{ - int nbNodes, nbCells; - int i; - - char *file2Read = (char *)myFile.c_str(); - myFileId = fopen(file2Read, "w+"); - if (myFileId < 0) - { - fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read); - exit(EXIT_FAILURE); - } - - /**************************************************************************** - * NOMBRES D'OBJETS * - ****************************************************************************/ - fprintf(stdout, "\n(****************************)\n"); - fprintf(stdout, "(* INFORMATIONS GENERALES : *)\n"); - fprintf(stdout, "(****************************)\n"); - - /* Combien de noeuds ? */ - nbNodes = myMesh->NbNodes(); - - /* Combien de mailles, faces ou aretes ? */ - int nb_of_nodes, nb_of_edges, nb_of_faces, nb_of_volumes; - nb_of_edges = myMesh->NbEdges(); - nb_of_faces = myMesh->NbFaces(); - nb_of_volumes = myMesh->NbVolumes(); - nbCells = nb_of_edges + nb_of_faces + nb_of_volumes; - - fprintf(stdout, "%d %d\n", nbNodes, nbCells); - fprintf(myFileId, "%d %d\n", nbNodes, nbCells); - - /**************************************************************************** - * ECRITURE DES NOEUDS * - ****************************************************************************/ - fprintf(stdout, "\n(************************)\n"); - fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n"); - fprintf(stdout, "(************************)\n"); - - SMDS_NodeIteratorPtr itNodes=myMesh->nodesIterator(); - while(itNodes->more()) - { - const SMDS_MeshNode * node = itNodes->next(); - fprintf(myFileId, "%d %e %e %e\n", node->GetID(), node->X(), - node->Y(), node->Z()); - } - - /**************************************************************************** - * ECRITURE DES ELEMENTS * - ****************************************************************************/ - fprintf(stdout, "\n(**************************)\n"); - fprintf(stdout, "(* ELEMENTS DU MAILLAGE : *)\n"); - fprintf(stdout, "(**************************)"); - /* Ecriture des connectivites, noms, numeros des mailles */ - - SMDS_EdgeIteratorPtr itEdges=myMesh->edgesIterator(); - while(itEdges->more()) - { - const SMDS_MeshEdge * elem = itEdges->next(); - - switch (elem->NbNodes()) - { - case 2: - { - fprintf(myFileId, "%d %d ", elem->GetID(), 102); - break; - } - case 3: - { - fprintf(myFileId, "%d %d ", elem->GetID(), 103); - break; - } - } - - SMDS_ElemIteratorPtr itNodes=elem->nodesIterator(); - while(itNodes->more()) - fprintf(myFileId, "%d ", itNodes->next()->GetID()); - - fprintf(myFileId, "\n"); - } - - SMDS_FaceIteratorPtr itFaces=myMesh->facesIterator(); - while(itFaces->more()) - { - const SMDS_MeshElement * elem = itFaces->next(); - - switch (elem->NbNodes()) - { - case 3: - { - fprintf(myFileId, "%d %d ", elem->GetID(), 203); - break; - } - case 4: - { - fprintf(myFileId, "%d %d ", elem->GetID(), 204); - break; - } - case 6: - { - fprintf(myFileId, "%d %d ", elem->GetID(), 206); - break; - } - } - - SMDS_ElemIteratorPtr itNodes=elem->nodesIterator(); - while(itNodes->more()) - fprintf(myFileId, "%d ", itNodes->next()->GetID()); - - fprintf(myFileId, "\n"); - } - - SMDS_VolumeIteratorPtr itVolumes=myMesh->volumesIterator(); - while(itVolumes->more()) - { - const SMDS_MeshElement * elem = itVolumes->next(); - - switch (elem->NbNodes()) - { - case 8: - { - fprintf(myFileId, "%d %d ", elem->GetID(), 308); - break; - } - } - - SMDS_ElemIteratorPtr itNodes=elem->nodesIterator(); - while(itNodes->more()) - fprintf(myFileId, "%d ", itNodes->next()->GetID()); - - fprintf(myFileId, "\n"); - } - - fclose(myFileId); -} diff --git a/src/DriverDAT/DriverDAT_W_SMESHDS_Mesh.h b/src/DriverDAT/DriverDAT_W_SMESHDS_Mesh.h index af13808fb..b9b9130c2 100644 --- a/src/DriverDAT/DriverDAT_W_SMESHDS_Mesh.h +++ b/src/DriverDAT/DriverDAT_W_SMESHDS_Mesh.h @@ -27,30 +27,9 @@ #ifndef _INCLUDE_DRIVERDAT_W_SMESHDS_MESH #define _INCLUDE_DRIVERDAT_W_SMESHDS_MESH -#include -#include +#include "Driver_SMESHDS_Mesh.h" -#include "SMESHDS_Mesh.hxx" -#include "Mesh_Writer.h" +class DriverDAT_W_SMESHDS_Mesh: public Driver_SMESHDS_Mesh +{}; -class DriverDAT_W_SMESHDS_Mesh:public Mesh_Writer -{ - - public:DriverDAT_W_SMESHDS_Mesh(); - ~DriverDAT_W_SMESHDS_Mesh(); - - void Add(); - void Write(); - void SetMesh(SMDS_Mesh * aMesh); - void SetFile(string); - - void SetFileId(FILE *); - void SetMeshId(int); - - private: SMDS_Mesh * myMesh; - string myFile; - FILE *myFileId; - int myMeshId; - -}; #endif diff --git a/src/DriverDAT/Makefile.in b/src/DriverDAT/Makefile.in index 12dd8b7ca..a5d1daf61 100644 --- a/src/DriverDAT/Makefile.in +++ b/src/DriverDAT/Makefile.in @@ -41,17 +41,19 @@ EXPORT_HEADERS= DriverDAT_R_SMDS_Mesh.h DriverDAT_R_SMESHDS_Mesh.h DriverDAT_R_S LIB = libMeshDriverDAT.la LIB_SRC = DriverDAT_R_SMDS_Mesh.cxx DriverDAT_R_SMESHDS_Mesh.cxx DriverDAT_R_SMESHDS_Document.cxx DriverDAT_W_SMDS_Mesh.cxx DriverDAT_W_SMESHDS_Mesh.cxx DriverDAT_W_SMESHDS_Document.cxx +# Executables targets +BIN = DAT_Test + LIB_CLIENT_IDL = LIB_SERVER_IDL = # additionnal information to compil and link file -CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS) -CXXFLAGS += $(OCC_CXXFLAGS) $(MED2_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -LDFLAGS += $(MED2_LIBS) -lMeshDriver +CPPFLAGS += -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS) +CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome +LDFLAGS += -lMeshDriver -%_moc.cxx: %.h - $(MOC) $< -o $@ +LDFLAGSFORBIN += -lMeshDriver -lSMDS -L${KERNEL_ROOT_DIR}/lib/salome -lOpUtil -lSALOMELocalTrace @CONCLUDE@ diff --git a/src/DriverMED/DriverMED_Family.cxx b/src/DriverMED/DriverMED_Family.cxx index ee1123ccd..f40810c94 100644 --- a/src/DriverMED/DriverMED_Family.cxx +++ b/src/DriverMED/DriverMED_Family.cxx @@ -28,6 +28,8 @@ #include "DriverMED_Family.h" #include +using namespace std; + //============================================================================= /*! * Split each group from list on some parts (families) @@ -37,7 +39,7 @@ //============================================================================= list DriverMED_Family::MakeFamilies (const map & theSubMeshes, - const list& theGroups, + const list& theGroups, const bool doGroupOfNodes, const bool doGroupOfEdges, const bool doGroupOfFaces, @@ -60,6 +62,8 @@ list DriverMED_Family::MakeFamilies map::const_iterator aSMIter = theSubMeshes.begin(); for (; aSMIter != theSubMeshes.end(); aSMIter++) { + if ( aSMIter->second->IsComplexSubmesh() ) + continue; // submesh containing other submeshs list aSMFams = SplitByType((*aSMIter).second, (*aSMIter).first); list::iterator aSMFamsIter = aSMFams.begin(); for (; aSMFamsIter != aSMFams.end(); aSMFamsIter++) @@ -95,7 +99,7 @@ list DriverMED_Family::MakeFamilies } // Process groups - list::const_iterator aGroupsIter = theGroups.begin(); + list::const_iterator aGroupsIter = theGroups.begin(); for (; aGroupsIter != theGroups.end(); aGroupsIter++) { DriverMED_FamilyPtr aFam2 (new DriverMED_Family); @@ -239,25 +243,25 @@ MEDA::PFamilyInfo DriverMED_Family::GetFamilyInfo //============================================================================= /*! - * Initialize the tool by SMESHDS_Group + * Initialize the tool by SMESHDS_GroupBase */ //============================================================================= -void DriverMED_Family::Init (SMESHDS_Group* group) +void DriverMED_Family::Init (SMESHDS_GroupBase* theGroup) { // Elements myElements.clear(); - group->InitIterator(); - while (group->More()) + SMDS_ElemIteratorPtr elemIt = theGroup->GetElements(); + while (elemIt->more()) { - myElements.insert(group->Next()); + myElements.insert(elemIt->next()); } // Type - myType = group->GetType(); + myType = theGroup->GetType(); // Groups list myGroupNames.clear(); - myGroupNames.insert(string(group->GetStoreName())); + myGroupNames.insert(string(theGroup->GetStoreName())); } //============================================================================= diff --git a/src/DriverMED/DriverMED_Family.h b/src/DriverMED/DriverMED_Family.h index cca2bf075..b5fc51f2e 100644 --- a/src/DriverMED/DriverMED_Family.h +++ b/src/DriverMED/DriverMED_Family.h @@ -29,15 +29,13 @@ #define _INCLUDE_DRIVERMED_FAMILY #include "SMDS_Mesh.hxx" -#include "SMESHDS_Group.hxx" +#include "SMESHDS_GroupBase.hxx" #include "SMESHDS_SubMesh.hxx" #include "MEDA_Wrapper.hxx" #include #include -using namespace std; - #define REST_NODES_FAMILY 1 #define REST_EDGES_FAMILY -1 #define REST_FACES_FAMILY -2 @@ -54,12 +52,12 @@ class DriverMED_Family // Methods for groups storing to MED - static list MakeFamilies (const map & theSubMeshes, - const list& theGroups, - const bool doGroupOfNodes, - const bool doGroupOfEdges, - const bool doGroupOfFaces, - const bool doGroupOfVolumes); + static std::list MakeFamilies (const std::map & theSubMeshes, + const std::list& theGroups, + const bool doGroupOfNodes, + const bool doGroupOfEdges, + const bool doGroupOfFaces, + const bool doGroupOfVolumes); // Split each group from list and each sub-mesh from list // on some parts (families) on the basis of the elements membership in other groups // from and other sub-meshes from . @@ -68,7 +66,7 @@ class DriverMED_Family MEDA::PFamilyInfo GetFamilyInfo (const MEDA::PMeshInfo& theMeshInfo) const; // Create TFamilyInfo for this family - const set& GetElements () const { return myElements; } + const std::set& GetElements () const { return myElements; } // Returns elements of this family int GetId () const { return myId; } @@ -80,22 +78,22 @@ class DriverMED_Family void AddElement (const SMDS_MeshElement* theElement) { myElements.insert(theElement); } - void AddGroupName (string theGroupName) { myGroupNames.insert(theGroupName); } + void AddGroupName (std::string theGroupName) { myGroupNames.insert(theGroupName); } void SetType (const SMDSAbs_ElementType theType) { myType = theType; } SMDSAbs_ElementType GetType () { return myType; } - bool MemberOf (string theGroupName) const + bool MemberOf (std::string theGroupName) const { return (myGroupNames.find(theGroupName) != myGroupNames.end()); } const MED::TStringSet& GetGroupNames () const { return myGroupNames; } private: - void Init (SMESHDS_Group* group); - // Initialize the tool by SMESHDS_Group + void Init (SMESHDS_GroupBase* group); + // Initialize the tool by SMESHDS_GroupBase - static list SplitByType (SMESHDS_SubMesh* theSubMesh, - const int theId); + static std::list SplitByType (SMESHDS_SubMesh* theSubMesh, + const int theId); // Split on some parts (families) // on the basis of the elements type. @@ -114,7 +112,7 @@ class DriverMED_Family private: int myId; SMDSAbs_ElementType myType; - set myElements; + std::set myElements; MED::TStringSet myGroupNames; }; diff --git a/src/DriverMED/DriverMED_R_SMDS_Mesh.cxx b/src/DriverMED/DriverMED_R_SMDS_Mesh.cxx index 032e0547e..cac48ff45 100644 --- a/src/DriverMED/DriverMED_R_SMDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_R_SMDS_Mesh.cxx @@ -1,5 +1,3 @@ -// SMESH DriverMED : driver to read and write 'med' files -// // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // @@ -18,603 +16,5 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : DriverMED_R_SMDS_Mesh.cxx -// Module : SMESH -using namespace std; #include "DriverMED_R_SMDS_Mesh.h" -#include "utilities.h" - -DriverMED_R_SMDS_Mesh::DriverMED_R_SMDS_Mesh() -{ -} - -DriverMED_R_SMDS_Mesh::~DriverMED_R_SMDS_Mesh() -{ - ; -} - -void DriverMED_R_SMDS_Mesh::SetMesh(SMDS_Mesh * aMesh) -{ - myMesh = aMesh; -} - -void DriverMED_R_SMDS_Mesh::SetFile(string aFile) -{ - myFileId = -1; - myFile = aFile; -} - -void DriverMED_R_SMDS_Mesh::SetFileId(med_idt aFileId) -{ - myFileId = aFileId; -} - -void DriverMED_R_SMDS_Mesh::SetMeshId(int aMeshId) -{ - myMeshId = aMeshId; -} - -void DriverMED_R_SMDS_Mesh::Add() -{ - ; -} - -void DriverMED_R_SMDS_Mesh::Read() -{ - - med_err ret = 0; - int i, j, k, l; - int numero; - char message[200]; - bool ok; - /* nombre d'objets MED */ - char nom_universel[MED_TAILLE_LNOM + 1]; - med_int long_fichier_en_tete; - char *fichier_en_tete; - char version_hdf[10]; - char version_med[10]; - med_int nmaa, mdim, nnoe; - med_int nmai[MED_NBR_GEOMETRIE_MAILLE], nfac[MED_NBR_GEOMETRIE_FACE]; - med_int nare[MED_NBR_GEOMETRIE_ARETE]; - /* nom du maillage */ - char nommaa[MED_TAILLE_NOM + 1]; - /* noeuds */ - med_float *coo; - char nomcoo[3 * MED_TAILLE_PNOM + 1]; - char unicoo[3 * MED_TAILLE_PNOM + 1]; - char *nomnoe; - med_int *numnoe; - med_int *nufano; - med_repere rep; - med_booleen inonoe, inunoe; - med_mode_switch mode_coo; - char str[MED_TAILLE_PNOM + 1]; - /* elements */ - med_int nsup; - med_int edim; - med_int taille; - med_int elem_id; - med_int cmpt = 0; - med_int *connectivite; - char *nomele; - med_int *numele; - med_int *nufael; - med_booleen inoele, inuele; - med_connectivite typ_con; - med_geometrie_element typgeo; - med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE] = - { MED_POINT1, MED_SEG2, - MED_SEG3, MED_TRIA3, - MED_TRIA6, MED_QUAD4, - MED_QUAD8, MED_TETRA4, - MED_TETRA10, MED_HEXA8, - MED_HEXA20, MED_PENTA6, - MED_PENTA15, MED_PYRA5, - MED_PYRA13 - }; - med_int desmai[MED_NBR_GEOMETRIE_MAILLE] = - { 0, 2, 3, 3, 3, 4, 4, 4, 4, 6, 6, 5, 5, 5, 5 }; - med_int nmailles[MED_NBR_GEOMETRIE_MAILLE]; - char nommai[MED_NBR_GEOMETRIE_MAILLE][MED_TAILLE_NOM + 1] = { "MED_POINT1", - "MED_SEG2", - "MED_SEG3", - "MED_TRIA3", - "MED_TRIA6", - "MED_QUAD4", - "MED_QUAD8", - "MED_TETRA4", - "MED_TETRA10", - "MED_HEXA8", - "MED_HEXA20", - "MED_PENTA6", - "MED_PENTA15", - "MED_PYRA5", - "MED_PYRA13" - }; - med_geometrie_element typfac[MED_NBR_GEOMETRIE_FACE] = - { MED_TRIA3, MED_TRIA6, - MED_QUAD4, MED_QUAD8 - }; - med_int desfac[MED_NBR_GEOMETRIE_FACE] = { 3, 3, 4, 4 }; - med_int nfaces[MED_NBR_GEOMETRIE_FACE]; - char nomfac[MED_NBR_GEOMETRIE_FACE][MED_TAILLE_NOM + 1] = - { "MED_TRIA3", "MED_TRIA6", - "MED_QUAD4", "MED_QUAD8" - }; - med_geometrie_element typare[MED_NBR_GEOMETRIE_ARETE] = - { MED_SEG2, MED_SEG3 }; - med_int desare[MED_NBR_GEOMETRIE_ARETE] = { 2, 3 }; - med_int naretes[MED_NBR_GEOMETRIE_ARETE]; - char nomare[MED_NBR_GEOMETRIE_ARETE][MED_TAILLE_NOM + 1] = - { "MED_SEG2", "MED_SEG3" }; - /* familles */ - med_int nfam; - med_int natt, ngro; - char *attdes, *gro; - med_int *attval, *attide; - char nomfam[MED_TAILLE_NOM + 1]; - med_int numfam; - char str1[MED_TAILLE_DESC + 1]; - char str2[MED_TAILLE_LNOM + 1]; - - char *file2Read; - bool locally_managed; - SCRUTE(myFileId); - if (myFileId == -1) - locally_managed = true; - else - locally_managed = false; - - if (locally_managed) - { - file2Read = (char *)myFile.c_str(); - myFileId = MEDouvrir(file2Read, MED_LECT); - if (myFileId < 0) - { - fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", - file2Read); - exit(EXIT_FAILURE); - } - numero = 1; - } - else - numero = myMeshId; - - typ_con = MED_NOD; - mode_coo = MED_FULL_INTERLACE; - - /**************************************************************************** - * NOMBRES D'OBJETS MED * - ****************************************************************************/ - fprintf(stdout, "\n(****************************)\n"); - fprintf(stdout, "(* INFORMATIONS GENERALES : *)\n"); - fprintf(stdout, "(****************************)\n"); - - /* lecture du nom et de la dimension du maillage */ - fprintf(stdout, "%d %d\n", myFileId, numero); - ret = MEDmaaInfo(myFileId, numero, nommaa, &mdim); - fprintf(stdout, "%d\n", ret); - if (ret < 0) - { - fprintf(stderr, ">> ERREUR : lecture du nom du maillage \n"); - exit(EXIT_FAILURE); - } - fprintf(stdout, "- Nom du maillage : <<%s>>\n", nommaa); - fprintf(stdout, "- Dimension du maillage : %d\n", mdim); - - /* Combien de noeuds ? */ - nnoe = - MEDnEntMaa(myFileId, nommaa, MED_COOR, MED_NOEUD, MED_POINT1, typ_con); - if (nnoe < 0) - { - fprintf(stderr, ">> ERREUR : lecture du nombre de noeuds \n"); - exit(EXIT_FAILURE); - } - fprintf(stdout, "- Nombre de noeuds : %d \n", nnoe); - - /* Combien de mailles, faces ou aretes ? */ - for (i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++) - { - nmailles[i] = - MEDnEntMaa(myFileId, nommaa, MED_CONN, MED_MAILLE, typmai[i], - typ_con); - if (nmailles[i] < 0) - { - fprintf(stderr, ">> ERREUR : lecture du nombre de mailles \n"); - exit(EXIT_FAILURE); - } - fprintf(stdout, "- Nombre de mailles de type %s : %d \n", nommai[i], - nmailles[i]); - } - - for (i = 0; i < MED_NBR_GEOMETRIE_FACE; i++) - { - nfaces[i] = MEDnEntMaa(myFileId, nommaa, MED_CONN, MED_FACE, typfac[i], - typ_con); - if (nfaces[i] < 0) - { - fprintf(stderr, ">> ERREUR : lecture du nombre de faces \n"); - exit(EXIT_FAILURE); - } - fprintf(stdout, "- Nombre de faces de type %s : %d \n", nomfac[i], - nfaces[i]); - } - - for (i = 0; i < MED_NBR_GEOMETRIE_ARETE; i++) - { - naretes[i] = - MEDnEntMaa(myFileId, nommaa, MED_CONN, MED_ARETE, typare[i], - typ_con); - if (naretes[i] < 0) - { - fprintf(stderr, ">> ERREUR : lecture du nombre d'aretes \n"); - exit(EXIT_FAILURE); - } - fprintf(stdout, "- Nombre d'aretes de type %s : %d \n", nomare[i], - naretes[i]); - } - - /* nombre de familles */ - nfam = MEDnFam(myFileId, nommaa, 0, MED_FAMILLE); - if (nfam < 0) - { - fprintf(stderr, ">> ERREUR : lecture du nombre de familles \n"); - exit(EXIT_FAILURE); - } - fprintf(stdout, "- Nombre de familles : %d \n", nfam); - - /**************************************************************************** - * LECTURE DES NOEUDS * - ****************************************************************************/ - fprintf(stdout, "\n(************************)\n"); - fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n"); - fprintf(stdout, "(************************)\n"); - - /* Allocations memoires */ - /* table des coordonnees - * profil : (dimension * nombre de noeuds ) */ - coo = (med_float *) malloc(sizeof(med_float) * nnoe * mdim); - /* table des numeros, des numeros de familles des noeuds - * profil : (nombre de noeuds) */ - numnoe = (med_int *) malloc(sizeof(med_int) * nnoe); - nufano = (med_int *) malloc(sizeof(med_int) * nnoe); - /* table des noms des noeuds - * profil : (nnoe*MED_TAILLE_PNOM+1) */ - nomnoe = (char *)malloc(MED_TAILLE_PNOM * nnoe + 1); - - /* lecture des noeuds : - * - coordonnees - * - noms (optionnel dans un fichier MED) - * - numeros (optionnel dans un fichier MED) - * - numeros des familles */ - ret = MEDnoeudsLire(myFileId, nommaa, mdim, coo, mode_coo, &rep, - nomcoo, unicoo, nomnoe, &inonoe, numnoe, &inunoe, nufano, nnoe); - if (ret < 0) - strcpy(message, ">> ERREUR : lecture des noeuds \n"); - - if (inunoe) - { - for (int i = 0; i < nnoe; i++) - { - ok = myMesh->AddNodeWithID(coo[i * 3], coo[i * 3 + 1], - coo[i * 3 + 2], numnoe[i]); - //fprintf(Out,"%d %f %f %f\n",numnoe[i],coo[i*3],coo[i*3+1],coo[i*3+2]); - } - } - else - { - for (int i = 0; i < nnoe; i++) - { - ok = myMesh->AddNodeWithID(coo[i * 3], coo[i * 3 + 1], - coo[i * 3 + 2], i + 1); - //fprintf(Out,"%d %f %f %f\n",numnoe[i],coo[i*3],coo[i*3+1],i); - } - } - - //fprintf(stdout,"\n- Numeros des familles des noeuds : \n"); - //for (i=0;iNbNodes()); - - /* liberation memoire */ - free(coo); - free(nomnoe); - free(numnoe); - free(nufano); - - /**************************************************************************** - * LECTURE DES ELEMENTS * - ****************************************************************************/ - fprintf(stdout, "\n(**************************)\n"); - fprintf(stdout, "(* ELEMENTS DU MAILLAGE : *)\n"); - fprintf(stdout, "(**************************)"); - //fprintf(Out,"CELLS\n"); - /* Lecture des connectivites, noms, numeros des mailles */ - //printf("%d %d %d %d\n",nmailles[3],nmailles[4],nmailles[5],nmailles[9]); - - if (ret == 0) - for (i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++) - { - if (nmailles[i] > 0 && ret == 0) - { - /* dimension de la maille */ - edim = typmai[i] / 100; - nsup = 0; - if (mdim == 2 || mdim == 3) - if (edim == 1) - nsup = 1; - if (mdim == 3) - if (edim == 2) - nsup = 1; - - taille = nsup + typmai[i] % 100; - //taille = typmai[i]%100; - - /* allocation memoire */ - connectivite = (med_int *) malloc(sizeof(med_int) * - taille * nmailles[i]); - nomele = (char *)malloc(sizeof(char) * MED_TAILLE_PNOM * - nmailles[i] + 1); - numele = (med_int *) malloc(sizeof(med_int) * nmailles[i]); - nufael = (med_int *) malloc(sizeof(med_int) * nmailles[i]); - - /* lecture des données */ - ret = - MEDelementsLire(myFileId, nommaa, mdim, connectivite, - mode_coo, nomele, &inoele, numele, &inuele, nufael, - nmailles[i], MED_MAILLE, typmai[i], typ_con); - SCRUTE(typmai[i]); - switch (typmai[i]) - { - case MED_SEG2: - { - if (inuele) - { - for (j = 0; j < nmailles[i]; j++) - { - elem_id = *(numele + j); - ok = myMesh->AddEdgeWithID(*(connectivite + - j * (taille)), - *(connectivite + j * (taille) + 1), elem_id); - } - } - else - { - for (j = 0; j < nmailles[i]; j++) - { - cmpt++; - ok = myMesh->AddEdgeWithID(*(connectivite + - j * (taille)), - *(connectivite + j * (taille) + 1), cmpt); - } - } - - break; - } - case MED_TRIA3: - { - if (inuele) - { - for (j = 0; j < nmailles[i]; j++) - { - elem_id = *(numele + j); - ok = myMesh->AddFaceWithID(*(connectivite + - j * (taille)), - *(connectivite + j * (taille) + 1), - *(connectivite + j * (taille) + 2), elem_id); - //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2)); - } - } - else - { - for (j = 0; j < nmailles[i]; j++) - { - cmpt++; - ok = myMesh->AddFaceWithID(*(connectivite + - j * (taille)), - *(connectivite + j * (taille) + 1), - *(connectivite + j * (taille) + 2), cmpt); - //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2)); - } - } - - break; - } - case MED_QUAD4: - { - if (inuele) - { - for (j = 0; j < nmailles[i]; j++) - { - elem_id = *(numele + j); - ok = myMesh->AddFaceWithID(*(connectivite + - j * (taille)), - *(connectivite + j * (taille) + 1), - *(connectivite + j * (taille) + 2), - *(connectivite + j * (taille) + 3), elem_id); - //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3)); - } - } - else - { - for (j = 0; j < nmailles[i]; j++) - { - cmpt++; - ok = myMesh->AddFaceWithID(*(connectivite + - j * (taille)), - *(connectivite + j * (taille) + 1), - *(connectivite + j * (taille) + 2), - *(connectivite + j * (taille) + 3), cmpt); - //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3)); - } - } - break; - } - case MED_TETRA4: - { - if (inuele) - { - for (j = 0; j < nmailles[i]; j++) - { - elem_id = *(numele + j); - ok = myMesh->AddVolumeWithID(*(connectivite + - j * (taille)), - *(connectivite + j * (taille) + 1), - *(connectivite + j * (taille) + 2), - *(connectivite + j * (taille) + 3), elem_id); - //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3)); - } - } - else - { - for (j = 0; j < nmailles[i]; j++) - { - cmpt++; - ok = myMesh->AddVolumeWithID(*(connectivite + - j * (taille)), - *(connectivite + j * (taille) + 1), - *(connectivite + j * (taille) + 2), - *(connectivite + j * (taille) + 3), cmpt); - //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3)); - } - } - break; - } - case MED_HEXA8: - { - if (inuele) - { - for (j = 0; j < nmailles[i]; j++) - { - elem_id = *(numele + j); - ok = myMesh->AddVolumeWithID(*(connectivite + - j * (taille)), - *(connectivite + j * (taille) + 1), - *(connectivite + j * (taille) + 2), - *(connectivite + j * (taille) + 3), - *(connectivite + j * (taille) + 4), - *(connectivite + j * (taille) + 5), - *(connectivite + j * (taille) + 6), - *(connectivite + j * (taille) + 7), elem_id); - //fprintf(Out,"%d %d %d %d\n",elem_id,*(connectivite+j*(taille-nsup)),*(connectivite+j*(taille-nsup)+1),*(connectivite+j*(taille-nsup)+2),*(connectivite+j*(taille-nsup)+3),*(connectivite+j*(taille-nsup)+4),*(connectivite+j*(taille-nsup)+5),*(connectivite+j*(taille-nsup)+6),*(connectivite+j*(taille-nsup)+7)); - } - } - else - { - for (j = 0; j < nmailles[i]; j++) - { - cmpt++; - ok = myMesh->AddVolumeWithID(*(connectivite + - j * (taille)), - *(connectivite + j * (taille) + 1), - *(connectivite + j * (taille) + 2), - *(connectivite + j * (taille) + 3), - *(connectivite + j * (taille) + 4), - *(connectivite + j * (taille) + 5), - *(connectivite + j * (taille) + 6), - *(connectivite + j * (taille) + 7), cmpt); - //fprintf(Out,"%d %d %d %d\n",j,*(connectivite+j*(taille)),*(connectivite+j*(taille)+1),*(connectivite+j*(taille)+2),*(connectivite+j*(taille)+3),*(connectivite+j*(taille)+4),*(connectivite+j*(taille)+5),*(connectivite+j*(taille)+6),*(connectivite+j*(taille)+7)); - } - } - break; - } - default: - { - break; - } - } - - //fprintf(stdout,"\n - Numéros de familles : \n"); - //for (j=0;jNbEdges()); - SCRUTE(myMesh->NbFaces()); - /**************************************************************************** - * LECTURE DES FAMILLES * - ****************************************************************************/ - printf("\n(*************************)\n"); - printf("(* FAMILLES DU MAILLAGE : *)\n"); - printf("(*************************)\n"); - if (ret == 0) - for (i = 0; i < nfam; i++) - { - - /* nombre de groupes */ - ngro = MEDnFam(myFileId, nommaa, i + 1, MED_GROUPE); - if (ngro < 0) - { - ret = -1; - strcpy(message, - ">> ERREUR : lecture du nombre de groupes d'une famille \n"); - } - - /* nombre d'attributs */ - if (ret == 0) - { - natt = MEDnFam(myFileId, nommaa, i + 1, MED_ATTR); - if (natt < 0) - { - ret = -1; - strcpy(message, - ">> ERREUR : lecture du nombre d'attributs d'une famille\n"); - } - } - - if (ret == 0) - fprintf(stdout, "- Famille %d a %d attributs et %d groupes \n", - i + 1, natt, ngro); - - /* nom,numero,attributs,groupes */ - if (ret == 0) - { - attide = (med_int *) malloc(sizeof(med_int) * natt); - attval = (med_int *) malloc(sizeof(med_int) * natt); - attdes = (char *)malloc(MED_TAILLE_DESC * natt + 1); - gro = (char *)malloc(MED_TAILLE_LNOM * ngro + 1); - ret = - MEDfamInfo(myFileId, nommaa, i + 1, nomfam, &numfam, attide, - attval, attdes, &natt, gro, &ngro); - fprintf(stdout, " - Famille de nom %s et de numero %d : \n", - nomfam, numfam); - fprintf(stdout, " - Attributs : \n"); - for (j = 0; j < natt; j++) - { - strncpy(str1, attdes + j * MED_TAILLE_DESC, - MED_TAILLE_DESC); - str1[MED_TAILLE_DESC] = '\0'; - fprintf(stdout, " ide = %d - val = %d - des = %s\n", - *(attide + j), *(attval + j), str1); - } - free(attide); - free(attval); - free(attdes); - fprintf(stdout, " - Groupes :\n"); - for (j = 0; j < ngro; j++) - { - strncpy(str2, gro + j * MED_TAILLE_LNOM, MED_TAILLE_LNOM); - str2[MED_TAILLE_LNOM] = '\0'; - fprintf(stdout, " gro = %s\n", str2); - } - free(gro); - } - } - - if (locally_managed) - ret = MEDfermer(myFileId); - -} diff --git a/src/DriverMED/DriverMED_R_SMDS_Mesh.h b/src/DriverMED/DriverMED_R_SMDS_Mesh.h index 4f9bb7d4e..a6ece3039 100644 --- a/src/DriverMED/DriverMED_R_SMDS_Mesh.h +++ b/src/DriverMED/DriverMED_R_SMDS_Mesh.h @@ -1,5 +1,3 @@ -// SMESH DriverMED : driver to read and write 'med' files -// // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // @@ -18,41 +16,13 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : DriverMED_R_SMDS_Mesh.h -// Module : SMESH #ifndef _INCLUDE_DRIVERMED_R_SMDS_MESH #define _INCLUDE_DRIVERMED_R_SMDS_MESH -#include "SMDS_Mesh.hxx" -#include "Mesh_Reader.h" +#include "Driver_SMDS_Mesh.h" -extern "C" -{ -#include -} +class DriverMED_R_SMDS_Mesh: public Driver_SMDS_Mesh +{}; -class DriverMED_R_SMDS_Mesh:public Mesh_Reader -{ - - public:DriverMED_R_SMDS_Mesh(); - ~DriverMED_R_SMDS_Mesh(); - - void Add(); - void Read(); - void SetMesh(SMDS_Mesh * aMesh); - void SetFile(string); - - void SetFileId(med_idt); - void SetMeshId(int); - - private: SMDS_Mesh * myMesh; - string myFile; - med_idt myFileId; - int myMeshId; - -}; #endif diff --git a/src/DriverMED/DriverMED_R_SMESHDS_Document.cxx b/src/DriverMED/DriverMED_R_SMESHDS_Document.cxx index ca50c550e..9527382ad 100644 --- a/src/DriverMED/DriverMED_R_SMESHDS_Document.cxx +++ b/src/DriverMED/DriverMED_R_SMESHDS_Document.cxx @@ -1,5 +1,3 @@ -// SMESH DriverMED : driver to read and write 'med' files -// // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // @@ -18,106 +16,5 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : DriverMED_R_SMESHDS_Document.cxx -// Module : SMESH -using namespace std; #include "DriverMED_R_SMESHDS_Document.h" -#include "DriverMED_R_SMESHDS_Mesh.h" -#include "utilities.h" - -extern "C" -{ - Document_Reader *maker() - { - return new DriverMED_R_SMESHDS_Document; - } -} - -DriverMED_R_SMESHDS_Document::DriverMED_R_SMESHDS_Document() -{ - ; -} - -DriverMED_R_SMESHDS_Document::~DriverMED_R_SMESHDS_Document() -{ - ; -} - -//void DriverMED_R_SMESHDS_Document::SetFile(string aFile) { -// myFile = aFile; -//} - -void DriverMED_R_SMESHDS_Document::Read() -{ - - med_err ret = 0; - med_idt fid; - med_int nmaa; - - int myMeshId; - - //string myFile = string("/home/home_users/cai/projects/salome_prev04/SALOME_ROOT/data/fra1.med"); - -/**************************************************************************** - * OUVERTURE DU FICHIER EN LECTURE * - ****************************************************************************/ - char *file2Read = (char *)myFile.c_str(); - fid = MEDouvrir(file2Read, MED_LECT); - if (fid < 0) - { - fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read); - exit(EXIT_FAILURE); - } - - /**************************************************************************** - * COMBIEN DE MAILLAGES ? * - ****************************************************************************/ - nmaa = MEDnMaa(fid); - if (nmaa < 0) - { - fprintf(stderr, ">> ERREUR : lecture du nombre de maillages \n"); - exit(EXIT_FAILURE); - } - printf("Nombre de maillages = %d\n", nmaa); - - string myClass = string("SMESHDS_Mesh"); - string myExtension = string("MED"); - - for (int meshIt = 1; meshIt <= nmaa; meshIt++) - { - myMeshId = myDocument->NewMesh(); - printf("MeshId = %d\n", myMeshId); - - SMDS_Mesh * myMesh = myDocument->GetMesh(myMeshId); - SCRUTE(myMesh); - - // Handle (SMDS_Mesh) MMM =......... - //ex SMESHDS_Mesh * myMesh2 =SMESHDS_Mesh *::DownCast(MMM); - - DriverMED_R_SMESHDS_Mesh *myReader = new DriverMED_R_SMESHDS_Mesh; - - myReader->SetMesh(myMesh); - myReader->SetMeshId(myMeshId); - - //myReader->SetFile(myFile); - SCRUTE(fid); - myReader->SetFileId(fid); - - myReader->Add(); - - } - - /**************************************************************************** - * FERMETURE DU FICHIER * - ****************************************************************************/ - ret = MEDfermer(fid); - - if (ret != 0) - fprintf(stderr, ">> ERREUR : erreur a la fermeture du fichier %s\n", - file2Read); - -} diff --git a/src/DriverMED/DriverMED_R_SMESHDS_Document.h b/src/DriverMED/DriverMED_R_SMESHDS_Document.h index 8c5ef31fb..c933e0c4a 100644 --- a/src/DriverMED/DriverMED_R_SMESHDS_Document.h +++ b/src/DriverMED/DriverMED_R_SMESHDS_Document.h @@ -1,5 +1,3 @@ -// SMESH DriverMED : driver to read and write 'med' files -// // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // @@ -18,35 +16,13 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : DriverMED_R_SMESHDS_Document.h -// Module : SMESH #ifndef _INCLUDE_DRIVERMED_R_SMESHDS_DOCUMENT #define _INCLUDE_DRIVERMED_R_SMESHDS_DOCUMENT -#include "SMESHDS_Document.hxx" -#include "Document_Reader.h" +#include "Driver_Document.h" -extern "C" -{ -#include -} +class DriverMED_R_SMESHDS_Document : public Driver_Document +{}; -class DriverMED_R_SMESHDS_Document : public Document_Reader { - -public : - DriverMED_R_SMESHDS_Document(); - ~DriverMED_R_SMESHDS_Document(); - - void Read(); - //void SetFile(string); - -private : - //Handle_SMESHDS_Document myDocument; - //string myFile; - -}; #endif diff --git a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx index 5ae85bd8b..513454316 100644 --- a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.cxx @@ -26,6 +26,7 @@ #include "DriverMED_R_SMESHDS_Mesh.h" #include "DriverMED_R_SMDS_Mesh.h" +#include "SMESHDS_Mesh.hxx" #include "utilities.h" #include "DriverMED_Family.h" @@ -39,82 +40,11 @@ #define _EDF_NODE_IDS_ -DriverMED_R_SMESHDS_Mesh::DriverMED_R_SMESHDS_Mesh() - : - myMesh (NULL), - myFile (""), - myFileId (-1), - myMeshId (-1) -{ -} - -DriverMED_R_SMESHDS_Mesh::~DriverMED_R_SMESHDS_Mesh() -{ -// map::iterator aFamsIter = myFamilies.begin(); -// for (; aFamsIter != myFamilies.end(); aFamsIter++) -// { -// delete (*aFamsIter).second; -// } -} - -void DriverMED_R_SMESHDS_Mesh::SetMesh(SMDS_Mesh * aMesh) -{ - myMesh = aMesh; -} - -void DriverMED_R_SMESHDS_Mesh::SetFile(string aFile) -{ - myFile = aFile; -} - -void DriverMED_R_SMESHDS_Mesh::SetFileId(med_idt aFileId) -{ - myFileId = aFileId; -} - -void DriverMED_R_SMESHDS_Mesh::SetMeshId(int aMeshId) -{ - myMeshId = aMeshId; -} - void DriverMED_R_SMESHDS_Mesh::SetMeshName(string theMeshName) { myMeshName = theMeshName; } -void DriverMED_R_SMESHDS_Mesh::Read() -{ - - string myClass = string("SMDS_Mesh"); - string myExtension = string("MED"); - - DriverMED_R_SMDS_Mesh *myReader = new DriverMED_R_SMDS_Mesh; - - myReader->SetMesh(myMesh); - myReader->SetMeshId(myMeshId); - myReader->SetFile(myFile); - myReader->SetFileId(-1); - - myReader->Read(); -} - -void DriverMED_R_SMESHDS_Mesh::Add() -{ - string myClass = string("SMDS_Mesh"); - string myExtension = string("MED"); - - DriverMED_R_SMDS_Mesh *myReader = new DriverMED_R_SMDS_Mesh; - - myReader->SetMesh(myMesh); - myReader->SetMeshId(myMeshId); - - SCRUTE(myFileId); - myReader->SetFileId(myFileId); - - myReader->Read(); -} - - static const SMDS_MeshNode* FindNode(const SMDS_Mesh* theMesh, med_int theId){ const SMDS_MeshNode* aNode = theMesh->FindNode(theId); @@ -199,17 +129,17 @@ public: typedef boost::shared_ptr TCoordHelperPtr; -DriverMED_R_SMESHDS_Mesh::ReadStatus DriverMED_R_SMESHDS_Mesh::ReadMySelf() +Driver_Mesh::Status DriverMED_R_SMESHDS_Mesh::Perform() { - ReadStatus result = DRS_FAIL; + Status aResult = DRS_FAIL; try{ using namespace MEDA; myFamilies.clear(); - MESSAGE("ReadMySelf - myFile : "<GetName()); + MESSAGE("Perform - aMeshName : "<GetName()); if(aMeshName != aMeshInfo->GetName()) continue; - result = DRS_OK; - + aResult = DRS_OK; + med_int aMeshDim = aMeshInfo->GetDim(); + // Reading MED families to the temporary structure //------------------------------------------------ med_int aNbFams = aMed.GetNbFamilies(aMeshInfo); @@ -290,7 +221,7 @@ DriverMED_R_SMESHDS_Mesh::ReadStatus DriverMED_R_SMESHDS_Mesh::ReadMySelf() med_booleen anIsNodeNum = aNodeInfo->IsElemNum(); med_int aNbElems = aNodeInfo->GetNbElem(); - MESSAGE("ReadMySelf - aNodeInfo->GetNbElem() = "<GetNbElem() = "< DriverMED_R_SMESHDS_Mesh::GetMeshNames() } }catch(const std::exception& exc){ INFOS("Follow exception was cought:\n\t"<& anElements = aFamily->GetElements(); set::iterator anElemsIter = anElements.begin(); + const SMDS_MeshElement * element = 0; for (; anElemsIter != anElements.end(); anElemsIter++) { - theGroup->SMDS_MeshGroup::Add(*anElemsIter); + element = *anElemsIter; + theGroup->SMDSGroup().Add(element); } + if ( element ) + theGroup->SetType( element->GetType() ); } } } @@ -670,10 +608,6 @@ void DriverMED_R_SMESHDS_Mesh::GetSubMesh (SMESHDS_SubMesh* theSubMesh, void DriverMED_R_SMESHDS_Mesh::CreateAllSubMeshes () { - SMESHDS_Mesh* aSMESHDSMesh = dynamic_cast(myMesh); - if (!aSMESHDSMesh) { - EXCEPTION(runtime_error,"Can not cast SMDS_Mesh to SMESHDS_Mesh"); - } map::iterator aFamsIter = myFamilies.begin(); for (; aFamsIter != myFamilies.end(); aFamsIter++) { @@ -693,18 +627,28 @@ void DriverMED_R_SMESHDS_Mesh::CreateAllSubMeshes () { for (; anElemsIter != anElements.end(); anElemsIter++) { - const SMDS_MeshNode* node = static_cast(*anElemsIter); - aSMESHDSMesh->SetNodeInVolume(node, Id); -// aSMESHDSMesh->SetNodeOnFace(node, Id); -// aSMESHDSMesh->SetNodeOnEdge(node, Id); -// aSMESHDSMesh->SetNodeOnVertex(node, Id); + SMDS_MeshNode* node = const_cast + ( static_cast( *anElemsIter )); + // find out a shape type + TopoDS_Shape aShape = myMesh->IndexToShape( Id ); + int aShapeType = ( aShape.IsNull() ? -1 : aShape.ShapeType() ); + switch ( aShapeType ) { + case TopAbs_FACE: + myMesh->SetNodeOnFace(node, Id); break; + case TopAbs_EDGE: + myMesh->SetNodeOnEdge(node, Id); break; + case TopAbs_VERTEX: + myMesh->SetNodeOnVertex(node, Id); break; + default: + myMesh->SetNodeInVolume(node, Id); + } } } else { for (; anElemsIter != anElements.end(); anElemsIter++) { - aSMESHDSMesh->SetMeshElementOnShape(*anElemsIter, Id); + myMesh->SetMeshElementOnShape(*anElemsIter, Id); } } } diff --git a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.h b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.h index c592c3034..fe1322b12 100644 --- a/src/DriverMED/DriverMED_R_SMESHDS_Mesh.h +++ b/src/DriverMED/DriverMED_R_SMESHDS_Mesh.h @@ -27,62 +27,32 @@ #ifndef _INCLUDE_DRIVERMED_R_SMESHDS_MESH #define _INCLUDE_DRIVERMED_R_SMESHDS_MESH -#include "SMESHDS_Mesh.hxx" -#include "Mesh_Reader.h" +#include "Driver_SMESHDS_Mesh.h" #include "DriverMED_Family.h" #include -extern "C" -{ -#include -} - -using namespace std; +class SMESHDS_Mesh; class SMESHDS_Group; class SMESHDS_SubMesh; -class DriverMED_R_SMESHDS_Mesh:public Mesh_Reader +class DriverMED_R_SMESHDS_Mesh: public Driver_SMESHDS_Mesh { public: + virtual Status Perform(); - DriverMED_R_SMESHDS_Mesh(); - ~DriverMED_R_SMESHDS_Mesh(); - - enum ReadStatus { - DRS_OK, - DRS_EMPTY, // a MED file contains no mesh with the given name - DRS_WARN_RENUMBER, // a MED file has overlapped ranges of element numbers, - // so the numbers from the file are ignored - DRS_WARN_SKIP_ELEM, // some elements were skipped due to incorrect file data - DRS_FAIL // general failure (exception etc.) - }; - - void Read(); - ReadStatus ReadMySelf(); - void Add(); - - list GetGroupNames(); + std::list GetGroupNames(); void GetGroup(SMESHDS_Group* theGroup); void CreateAllSubMeshes(); void GetSubMesh(SMESHDS_SubMesh* theSubMesh, const int theId); - list GetMeshNames(); - - void SetMesh(SMDS_Mesh * aMesh); - void SetFile(string); - void SetFileId(med_idt); - void SetMeshId(int); - void SetMeshName(string theMeshName); + std::list GetMeshNames(Status& theStatus); + void SetMeshName(std::string theMeshName); private: - - SMDS_Mesh * myMesh; - string myFile; - med_idt myFileId; - int myMeshId; - string myMeshName; - map myFamilies; + std::string myMeshName; + std::map myFamilies; }; + #endif diff --git a/src/DriverMED/DriverMED_W_SMDS_Mesh.cxx b/src/DriverMED/DriverMED_W_SMDS_Mesh.cxx index eaa287e3b..d48e08547 100644 --- a/src/DriverMED/DriverMED_W_SMDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_W_SMDS_Mesh.cxx @@ -1,5 +1,3 @@ -// SMESH DriverMED : driver to read and write 'med' files -// // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // @@ -18,398 +16,5 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : DriverMED_W_SMDS_Mesh.cxx -// Module : SMESH -using namespace std; #include "DriverMED_W_SMDS_Mesh.h" - -#include "SMDS_MeshElement.hxx" -#include "SMDS_MeshNode.hxx" - - - - -#include "utilities.h" -#include - -DriverMED_W_SMDS_Mesh::DriverMED_W_SMDS_Mesh() -{ - ; -} - -DriverMED_W_SMDS_Mesh::~DriverMED_W_SMDS_Mesh() -{ - ; -} - -void DriverMED_W_SMDS_Mesh::SetMesh(SMDS_Mesh * aMesh) -{ - myMesh = aMesh; -} - -void DriverMED_W_SMDS_Mesh::SetFile(string aFile) -{ - myFile = aFile; -} - -void DriverMED_W_SMDS_Mesh::SetFileId(med_idt aFileId) -{ - myFileId = aFileId; -} - -void DriverMED_W_SMDS_Mesh::SetMeshId(int aMeshId) -{ - myMeshId = aMeshId; -} - -void DriverMED_W_SMDS_Mesh::Add() -{ - ; -} - -void DriverMED_W_SMDS_Mesh::Write() -{ - - med_err ret = 0; - int i, j, k, l; - int numero; - char message[200]; - bool ok; - /* nombre d'objets MED */ - char nom_universel[MED_TAILLE_LNOM + 1]; - med_int long_fichier_en_tete; - char *fichier_en_tete; - char version_hdf[10]; - char version_med[10]; - med_int nmaa, mdim, nnoe; - med_int nmai[MED_NBR_GEOMETRIE_MAILLE], nfac[MED_NBR_GEOMETRIE_FACE]; - med_int nare[MED_NBR_GEOMETRIE_ARETE]; - /* nom du maillage */ - char nommaa[MED_TAILLE_NOM + 1]; - /* noeuds */ - med_float *coo; - char nomcoo[3 * MED_TAILLE_PNOM + 1]; - char unicoo[3 * MED_TAILLE_PNOM + 1]; - char *nomnoe; - med_int *numnoe; - med_int *nufano; - med_repere rep; - med_booleen inonoe, inunoe; - med_mode_switch mode_coo; - char str[MED_TAILLE_PNOM + 1]; - med_int nbNodes; - /* elements */ - med_int nsup; - med_int edim; - med_int taille; - med_int elem_id, myId; - med_int *connectivite; - char *nomele; - med_int *numele; - med_int *nufael; - med_booleen inoele, inuele; - med_connectivite typ_con; - med_geometrie_element typgeo; - med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE] = - { MED_POINT1, MED_SEG2, - MED_SEG3, MED_TRIA3, - MED_TRIA6, MED_QUAD4, - MED_QUAD8, MED_TETRA4, - MED_TETRA10, MED_HEXA8, - MED_HEXA20, MED_PENTA6, - MED_PENTA15, MED_PYRA5, - MED_PYRA13 - }; - med_int desmai[MED_NBR_GEOMETRIE_MAILLE] = - { 0, 2, 3, 3, 3, 4, 4, 4, 4, 6, 6, 5, 5, 5, 5 }; - med_int nmailles[MED_NBR_GEOMETRIE_MAILLE]; - char nommai[MED_NBR_GEOMETRIE_MAILLE][MED_TAILLE_NOM + 1] = { "MED_POINT1", - "MED_SEG2", - "MED_SEG3", - "MED_TRIA3", - "MED_TRIA6", - "MED_QUAD4", - "MED_QUAD8", - "MED_TETRA4", - "MED_TETRA10", - "MED_HEXA8", - "MED_HEXA20", - "MED_PENTA6", - "MED_PENTA15", - "MED_PYRA5", - "MED_PYRA13" - }; - med_geometrie_element typfac[MED_NBR_GEOMETRIE_FACE] = - { MED_TRIA3, MED_TRIA6, - MED_QUAD4, MED_QUAD8 - }; - med_int desfac[MED_NBR_GEOMETRIE_FACE] = { 3, 3, 4, 4 }; - med_int nfaces[MED_NBR_GEOMETRIE_FACE]; - char nomfac[MED_NBR_GEOMETRIE_FACE][MED_TAILLE_NOM + 1] = - { "MED_TRIA3", "MED_TRIA6", - "MED_QUAD4", "MED_QUAD8" - }; - med_geometrie_element typare[MED_NBR_GEOMETRIE_ARETE] = - { MED_SEG2, MED_SEG3 }; - med_int desare[MED_NBR_GEOMETRIE_ARETE] = { 2, 3 }; - med_int naretes[MED_NBR_GEOMETRIE_ARETE]; - char nomare[MED_NBR_GEOMETRIE_ARETE][MED_TAILLE_NOM + 1] = - { "MED_SEG2", "MED_SEG3" }; - /* familles */ - med_int nfam; - med_int natt, ngro; - char *attdes, *gro; - med_int *attval, *attide; - char nomfam[MED_TAILLE_NOM + 1]; - med_int numfam; - char str1[MED_TAILLE_DESC + 1]; - char str2[MED_TAILLE_LNOM + 1]; - - /**************************************************************************** - * OUVERTURE DU FICHIER EN ECRITURE * - ****************************************************************************/ - /*! char* file2Read = (char*)myFile.c_str(); - * myFileId = MEDouvrir(file2Read,MED_REMP); - * if (myFileId < 0) - * { - * fprintf(stderr,">> ERREUR : ouverture du fichier %s \n",file2Read); - * exit(EXIT_FAILURE); - * } - */ - typ_con = MED_NOD; - mode_coo = MED_FULL_INTERLACE; - numero = myMeshId; - - /**************************************************************************** - * NOMBRES D'OBJETS MED * - ****************************************************************************/ - fprintf(stdout, "\n(****************************)\n"); - fprintf(stdout, "(* INFORMATIONS GENERALES : *)\n"); - fprintf(stdout, "(****************************)\n"); - - /* creation du maillage */ - mdim = 3; - //nommaa = QString("Mesh "+myMeshId).latin1(); - //nommaa = ""; - //plutot recuperer le nom du maillage dans l'etude - if (ret == 0) - ret = MEDmaaCr(myFileId, nommaa, mdim); - printf("%d\n", ret); - - /* Combien de noeuds ? */ - nnoe = myMesh->NbNodes(); - //SCRUTE(nnoe); - /* Combien de mailles, faces ou aretes ? */ - for (i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++) - nmailles[i] = 0; - - SMDS_FaceIteratorPtr itFaces=myMesh->facesIterator(); - int nb_of_nodes, nb_of_faces; - nb_of_faces = myMesh->NbFaces(); - //SCRUTE(nb_of_faces); - - //med_int elem_Id[MED_NBR_GEOMETRIE_FACE][nb_of_faces]; - vector elem_Id[MED_NBR_GEOMETRIE_MAILLE]; - //typedef vector Integer_vector; - //vector elem_Id; - //elem_Id.resize(MED_NBR_GEOMETRIE_MAILLE); - - while(itFaces->more()) - { - const SMDS_MeshFace * elem = itFaces->next(); - - nb_of_nodes = elem->NbNodes(); - - switch (nb_of_nodes) - { - case 3: - { - //elem_Id[3][nmailles[3]] = elem->GetID(); - elem_Id[3].push_back(elem->GetID()); - nmailles[3]++; - break; - } - case 4: - { - //elem_Id[5][nmailles[5]] = elem->GetID(); - elem_Id[5].push_back(elem->GetID()); - nmailles[5]++; - break; - } - case 6: - { - //elem_Id[4][nmailles[4]] = elem->GetID(); - elem_Id[4].push_back(elem->GetID()); - nmailles[4]++; - break; - } - } - - } - - SMDS_VolumeIteratorPtr itVolumes=myMesh->volumesIterator(); - while(itVolumes->more()) - { - const SMDS_MeshVolume * elem = itVolumes->next(); - - nb_of_nodes = elem->NbNodes(); - switch (nb_of_nodes) - { - case 8: - { - //elem_Id[9][nmailles[9]] = elem->GetID(); - elem_Id[9].push_back(elem->GetID()); - nmailles[9]++; - break; - } - case 4 : - { - elem_Id[7].push_back(elem->GetID()); - nmailles[7]++; - break; - } - } - } - - /**************************************************************************** - * ECRITURE DES NOEUDS * - ****************************************************************************/ - fprintf(stdout, "\n(************************)\n"); - fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n"); - fprintf(stdout, "(************************)\n"); - - /* Allocations memoires */ - /* table des coordonnees - * profil : (dimension * nombre de noeuds ) */ - coo = (med_float *) malloc(sizeof(med_float) * nnoe * mdim); - /* table des numeros, des numeros de familles des noeuds - * profil : (nombre de noeuds) */ - numnoe = (med_int *) malloc(sizeof(med_int) * nnoe); - nufano = (med_int *) malloc(sizeof(med_int) * nnoe); - /* table des noms des noeuds - * profil : (nnoe*MED_TAILLE_PNOM+1) */ - nomnoe = ""; - - i = 0; - SMDS_NodeIteratorPtr itNodes=myMesh->nodesIterator(); - while(itNodes->more()) - { - const SMDS_MeshNode * node = itNodes->next(); - coo[i * 3] = node->X(); - coo[i * 3 + 1] = node->Y(); - coo[i * 3 + 2] = node->Z(); - numnoe[i] = node->GetID(); - nufano[i] = 0; - i++; - } - - /* ecriture des noeuds : - * - coordonnees - * - noms (optionnel dans un fichier MED) - * - numeros (optionnel dans un fichier MED) - * - numeros des familles */ - ret = MEDnoeudsEcr(myFileId, nommaa, mdim, coo, mode_coo, MED_CART, - nomcoo, unicoo, nomnoe, MED_FAUX, numnoe, MED_VRAI, - nufano, nnoe, MED_REMP); - - /* liberation memoire */ - free(coo); - //free(nomnoe); - free(numnoe); - free(nufano); - - /**************************************************************************** - * ECRITURE DES ELEMENTS * - ****************************************************************************/ - fprintf(stdout, "\n(**************************)\n"); - fprintf(stdout, "(* ELEMENTS DU MAILLAGE : *)\n"); - fprintf(stdout, "(**************************)"); - //fprintf(Out,"CELLS\n"); - /* Ecriture des connectivites, noms, numeros des mailles */ - - if (ret == 0) - for (i = 0; i < MED_NBR_GEOMETRIE_MAILLE; i++) - { - if (nmailles[i] > 0 && ret == 0) - { - MESSAGE(" Start " << typmai[i]); - /* dimension de la maille */ - edim = typmai[i] / 100; - nsup = 0; - if (mdim == 2 || mdim == 3) - if (edim == 1) - nsup = 1; - if (mdim == 3) - if (edim == 2) - nsup = 1; - - taille = nsup + typmai[i] % 100; - //taille = typmai[i]%100; - - /* allocation memoire */ - connectivite = (med_int *) malloc(sizeof(med_int) * - taille * nmailles[i]); - nomele = (char *)malloc(sizeof(char) * MED_TAILLE_PNOM * - nmailles[i] + 1); - numele = (med_int *) malloc(sizeof(med_int) * nmailles[i]); - nufael = (med_int *) malloc(sizeof(med_int) * nmailles[i]); - nomele = ""; - nbNodes = typmai[i] % 100; - - //penser a mater les (taille-nsup) - for (j = 0; j < nmailles[i]; j++) - { - myId = elem_Id[i][j]; - const SMDS_MeshElement * elem = - myMesh->FindElement(myId); - *(numele + j) = myId; - //elem_id=*(numele+j); - //fprintf(stdout,"%d \n",myId); - - SMDS_ElemIteratorPtr itNode= elem->nodesIterator(); - - while(itNode->more()) - { - //*(connectivite+j*(taille-1)+k)=cnx[k]; - *(connectivite + j * (taille - nsup) + k) = - itNode->next()->GetID(); - //fprintf(stdout,"%d ",*(connectivite+j*(taille-nsup)+k)); - } - nufael[j] = 0; - //fprintf(stdout,"\n"); - } - - /* ecriture des données */ - - ret = - MEDelementsEcr(myFileId, nommaa, mdim, connectivite, - mode_coo, nomele, MED_FAUX, numele, MED_VRAI, nufael, - nmailles[i], MED_MAILLE, typmai[i], typ_con, MED_REMP); - - if (ret < 0) - MESSAGE(">> ERREUR : lecture des mailles \n"); - - /* liberation memoire */ - free(connectivite); - //free(nomele); - free(numele); - free(nufael); - MESSAGE(" End " << typmai[i]); - } - } - - /**************************************************************************** - * FERMETURE DU FICHIER * - ****************************************************************************/ - - /*! ret = MEDfermer(myFileId); - * - * if (ret != 0) - * fprintf(stderr,">> ERREUR : erreur a la fermeture du fichier %s\n",file2Read); - */ - -} diff --git a/src/DriverMED/DriverMED_W_SMDS_Mesh.h b/src/DriverMED/DriverMED_W_SMDS_Mesh.h index 4610d6c53..2151ae672 100644 --- a/src/DriverMED/DriverMED_W_SMDS_Mesh.h +++ b/src/DriverMED/DriverMED_W_SMDS_Mesh.h @@ -1,5 +1,3 @@ -// SMESH DriverMED : driver to read and write 'med' files -// // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // @@ -18,43 +16,13 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : DriverMED_W_SMDS_Mesh.h -// Module : SMESH #ifndef _INCLUDE_DRIVERMED_W_SMDS_MESH #define _INCLUDE_DRIVERMED_W_SMDS_MESH -#include "SMDS_Mesh.hxx" -#include "Mesh_Writer.h" +#include "Driver_SMDS_Mesh.h" -#include +class DriverMED_W_SMDS_Mesh: public Driver_SMDS_Mesh +{}; -extern "C" -{ -#include -} - -class DriverMED_W_SMDS_Mesh:public Mesh_Writer -{ - - public:DriverMED_W_SMDS_Mesh(); - ~DriverMED_W_SMDS_Mesh(); - - void Add(); - void Write(); - void SetMesh(SMDS_Mesh * aMesh); - void SetFile(string); - - void SetFileId(med_idt); - void SetMeshId(int); - - private: SMDS_Mesh * myMesh; - string myFile; - med_idt myFileId; - int myMeshId; - -}; #endif diff --git a/src/DriverMED/DriverMED_W_SMESHDS_Document.cxx b/src/DriverMED/DriverMED_W_SMESHDS_Document.cxx index e04bac218..d0537c23a 100644 --- a/src/DriverMED/DriverMED_W_SMESHDS_Document.cxx +++ b/src/DriverMED/DriverMED_W_SMESHDS_Document.cxx @@ -24,80 +24,4 @@ // File : DriverMED_W_SMESHDS_Document.cxx // Module : SMESH -using namespace std; #include "DriverMED_W_SMESHDS_Document.h" -#include "DriverMED_W_SMESHDS_Mesh.h" -#include "utilities.h" - -#include - -extern "C" -{ - Document_Writer *Wmaker() - { - return new DriverMED_W_SMESHDS_Document; - } -} - -DriverMED_W_SMESHDS_Document::DriverMED_W_SMESHDS_Document() -{ - ; -} - -DriverMED_W_SMESHDS_Document::~DriverMED_W_SMESHDS_Document() -{ - ; -} - -//void DriverMED_W_SMESHDS_Document::SetFile(string aFile) { -//myFile = aFile; -//} - -//void DriverMED_W_SMESHDS_Document::SetDocument(Handle(SMESHDS_Document)& aDocument) { -//myDocument = aDocument; -//} - -void DriverMED_W_SMESHDS_Document::Write() -{ - - med_err ret = 0; - med_idt fid; - med_int nmaa, numero, nb_of_meshes; - med_mode_switch mode_coo; - med_connectivite typ_con; - - SCRUTE(myFile); - SMESHDS_Mesh * myMesh; - - /******** Nombre de maillages ********/ - nb_of_meshes = myDocument->NbMeshes(); //voir avec Yves - MESSAGE("nb_of_meshes = " << nb_of_meshes << "\n"); - SCRUTE(nb_of_meshes); - //nb_of_meshes = 1; - numero = 0; - - string myClass = string("SMESHDS_Mesh"); - string myExtension = string("MED"); - - //while (numeroGetMesh(numero); - - myDocument->InitMeshesIterator(); - if (nb_of_meshes != 0) - while(myDocument->MoreMesh()) - { - numero++; - myMesh = myDocument->NextMesh(); - - DriverMED_W_SMESHDS_Mesh *myWriter = new DriverMED_W_SMESHDS_Mesh; - - myWriter->SetMesh(myMesh); - myWriter->SetFile(myFile); - //myWriter->SetFileId(fid); - myWriter->SetMeshId(numero); - - //myWriter->Write(); - myWriter->Add(); - } -} diff --git a/src/DriverMED/DriverMED_W_SMESHDS_Document.h b/src/DriverMED/DriverMED_W_SMESHDS_Document.h index 23e265714..2f0cce3bc 100644 --- a/src/DriverMED/DriverMED_W_SMESHDS_Document.h +++ b/src/DriverMED/DriverMED_W_SMESHDS_Document.h @@ -1,5 +1,3 @@ -// SMESH DriverMED : driver to read and write 'med' files -// // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // @@ -18,38 +16,13 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : DriverMED_W_SMESHDS_Document.h -// Module : SMESH #ifndef _INCLUDE_DRIVERMED_W_SMESHDS_DOCUMENT #define _INCLUDE_DRIVERMED_W_SMESHDS_DOCUMENT -#include "SMESHDS_Document.hxx" -#include "Document_Writer.h" +#include "Driver_Document.h" -#include +class DriverMED_W_SMESHDS_Document : public Driver_Document +{}; -extern "C" -{ -#include -} - -class DriverMED_W_SMESHDS_Document : public Document_Writer { - -public : - DriverMED_W_SMESHDS_Document(); - ~DriverMED_W_SMESHDS_Document(); - - void Write(); - //void SetFile(string); - //void SetDocument(Handle(SMESHDS_Document)&); - -private : - //Handle_SMESHDS_Document myDocument; - //string myFile; - -}; #endif diff --git a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx index e918f8428..69afde963 100644 --- a/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx +++ b/src/DriverMED/DriverMED_W_SMESHDS_Mesh.cxx @@ -24,66 +24,39 @@ // File : DriverMED_W_SMESHDS_Mesh.cxx // Module : SMESH +#include + #include "DriverMED_W_SMESHDS_Mesh.h" #include "DriverMED_W_SMDS_Mesh.h" #include "DriverMED_Family.h" +#include "SMESHDS_Mesh.hxx" #include "SMDS_MeshElement.hxx" #include "SMDS_MeshNode.hxx" #include "utilities.h" #include "MEDA_Wrapper.hxx" -#include - #include "MED_Utilities.hxx" #define _EDF_NODE_IDS_ #define _ELEMENTS_BY_DIM_ -DriverMED_W_SMESHDS_Mesh::DriverMED_W_SMESHDS_Mesh() - : - myMesh (NULL), - myFile (""), - myFileId (-1), - myMeshId (-1), - myAllSubMeshes (false), - myDoGroupOfNodes (false), - myDoGroupOfEdges (false), - myDoGroupOfFaces (false), - myDoGroupOfVolumes (false) -{ -} - -DriverMED_W_SMESHDS_Mesh::~DriverMED_W_SMESHDS_Mesh() -{ -} - -void DriverMED_W_SMESHDS_Mesh::SetMesh(SMDS_Mesh * aMesh) -{ - myMesh = aMesh; -} - -void DriverMED_W_SMESHDS_Mesh::SetFile(string aFile) -{ - myFile = aFile; -} - -void DriverMED_W_SMESHDS_Mesh::SetFileId(med_idt aFileId) -{ - myFileId = aFileId; -} +using namespace std; -void DriverMED_W_SMESHDS_Mesh::SetMeshId(int aMeshId) -{ - myMeshId = aMeshId; -} +DriverMED_W_SMESHDS_Mesh::DriverMED_W_SMESHDS_Mesh(): + myAllSubMeshes (false), + myDoGroupOfNodes (false), + myDoGroupOfEdges (false), + myDoGroupOfFaces (false), + myDoGroupOfVolumes (false) +{} -void DriverMED_W_SMESHDS_Mesh::SetMeshName(string theMeshName) +void DriverMED_W_SMESHDS_Mesh::SetMeshName(const std::string& theMeshName) { myMeshName = theMeshName; } -void DriverMED_W_SMESHDS_Mesh::AddGroup(SMESHDS_Group* theGroup) +void DriverMED_W_SMESHDS_Mesh::AddGroup(SMESHDS_GroupBase* theGroup) { myGroups.push_back(theGroup); } @@ -118,22 +91,6 @@ void DriverMED_W_SMESHDS_Mesh::AddGroupOfVolumes() myDoGroupOfVolumes = true; } -void DriverMED_W_SMESHDS_Mesh::Write() -{ - string myClass = string("SMDS_Mesh"); - string myExtension = string("MED"); - - DriverMED_W_SMDS_Mesh *myWriter = new DriverMED_W_SMDS_Mesh; - - myWriter->SetMesh(myMesh); - // myWriter->SetFile(myFile); - myWriter->SetMeshId(myMeshId); - myWriter->SetFileId(myFileId); - - myWriter->Write(); -} - - typedef double (SMDS_MeshNode::* TGetCoord)() const; typedef const char* TName; typedef const char* TUnit; @@ -208,7 +165,7 @@ public: return myCurrentNode; } MED::TIntVector::value_type GetID(){ - myCurrentNode->GetID(); + return myCurrentNode->GetID(); } MED::TFloatVector::value_type GetCoord(med_int theCoodId){ return (myCurrentNode->*myGetCoord[theCoodId])(); @@ -223,17 +180,18 @@ public: typedef boost::shared_ptr TCoordHelperPtr; -void DriverMED_W_SMESHDS_Mesh::Add() +Driver_Mesh::Status DriverMED_W_SMESHDS_Mesh::Perform() { + Status aResult = DRS_OK; if (myMesh->hasConstructionEdges() || myMesh->hasConstructionFaces()) { INFOS("SMDS_MESH with hasConstructionEdges() or hasConstructionFaces() do not supports!!!"); - return; + return DRS_FAIL; } try{ using namespace MEDA; using namespace boost; - MESSAGE("Add - myFile : "< anElemFamMap; list aFamilies; if (myAllSubMeshes) { - SMESHDS_Mesh* aSMESHDSMesh = dynamic_cast(myMesh); - if (!aSMESHDSMesh) { - EXCEPTION(runtime_error,"Can not cast SMDS_Mesh to SMESHDS_Mesh"); - } aFamilies = DriverMED_Family::MakeFamilies - (aSMESHDSMesh->SubMeshes(), myGroups, + (myMesh->SubMeshes(), myGroups, myDoGroupOfNodes, myDoGroupOfEdges, myDoGroupOfFaces, myDoGroupOfVolumes); } else { aFamilies = DriverMED_Family::MakeFamilies @@ -404,7 +358,7 @@ void DriverMED_W_SMESHDS_Mesh::Add() aCoordUnits, aFamilyNums, anElemNums); - MESSAGE("Add - aNodeInfo->GetNbElem() = "<GetNbElem() = "< #include #include -extern "C" -{ -#include -} - -using namespace std; - -class SMESHDS_Group; +class SMESHDS_Mesh; +class SMESHDS_GroupBase; class SMESHDS_SubMesh; -class DriverMED_W_SMESHDS_Mesh:public Mesh_Writer +class DriverMED_W_SMESHDS_Mesh: public Driver_SMESHDS_Mesh { public: DriverMED_W_SMESHDS_Mesh(); - ~DriverMED_W_SMESHDS_Mesh(); /*! sets file name; only for usage with Add(), not Write() */ - void SetFile(string); void AddGroupOfNodes(); void AddGroupOfEdges(); void AddGroupOfFaces(); @@ -61,36 +52,27 @@ class DriverMED_W_SMESHDS_Mesh:public Mesh_Writer /*! functions to prepare adding one mesh */ - void SetMesh(SMDS_Mesh * aMesh); - void SetMeshId(int); - void SetMeshName(string theMeshName); - void AddGroup(SMESHDS_Group* theGroup); + void SetMeshName(const std::string& theMeshName); + void AddGroup(SMESHDS_GroupBase * theGroup); void AddAllSubMeshes(); void AddSubMesh(SMESHDS_SubMesh* theSubMesh, int theID); /*! add one mesh */ - void Add(); - - /*! functions to write via DriverMED_W_SMDS_Mesh (no groups) - */ - void SetFileId(med_idt); - void Write(); + virtual Status Perform(); private: - SMDS_Mesh * myMesh; - string myFile; - med_idt myFileId; - int myMeshId; - string myMeshName; - list myGroups; + std::string myMeshName; + std::list myGroups; bool myAllSubMeshes; - map mySubMeshes; + std::map mySubMeshes; bool myDoGroupOfNodes; bool myDoGroupOfEdges; bool myDoGroupOfFaces; bool myDoGroupOfVolumes; }; + + #endif diff --git a/src/DriverMED/MED_Test.cxx b/src/DriverMED/MED_Test.cxx new file mode 100644 index 000000000..7d6c3cd21 --- /dev/null +++ b/src/DriverMED/MED_Test.cxx @@ -0,0 +1,28 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include "DriverMED_R_SMESHDS_Mesh.h" +#include "DriverMED_W_SMESHDS_Mesh.h" + +int main(int argc, char** argv) +{ + DriverMED_R_SMESHDS_Mesh aR; + DriverMED_W_SMESHDS_Mesh aW; + return 1; +} diff --git a/src/DriverMED/Makefile.in b/src/DriverMED/Makefile.in index 18d72045c..beca72c92 100644 --- a/src/DriverMED/Makefile.in +++ b/src/DriverMED/Makefile.in @@ -51,16 +51,19 @@ LIB_SRC = \ DriverMED_W_SMESHDS_Mesh.cxx \ DriverMED_Family.cxx +# Executables targets +BIN = MED_Test + LIB_CLIENT_IDL = + LIB_SERVER_IDL = # additionnal information to compil and link file -CPPFLAGS += $(OCC_INCLUDES) $(QT_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS) +CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS) CXXFLAGS += $(OCC_CXXFLAGS) $(MED2_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -LDFLAGS += $(MED2_LIBS) -lMeshDriver -L${KERNEL_ROOT_DIR}/lib/salome -lMEDWrapper +LDFLAGS += -lMeshDriver -L${KERNEL_ROOT_DIR}/lib/salome -lMEDWrapper -%_moc.cxx: %.h - $(MOC) $< -o $@ +LDFLAGSFORBIN += -lMeshDriver -lSMDS -lSMESHDS -L${KERNEL_ROOT_DIR}/lib/salome -lMEDWrapper -lOpUtil -lSALOMELocalTrace @CONCLUDE@ diff --git a/src/DriverSTL/DriverSTL_R_SMDS_Mesh.cxx b/src/DriverSTL/DriverSTL_R_SMDS_Mesh.cxx new file mode 100644 index 000000000..93c2cff5b --- /dev/null +++ b/src/DriverSTL/DriverSTL_R_SMDS_Mesh.cxx @@ -0,0 +1,344 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include + +#include "DriverSTL_R_SMDS_Mesh.h" + +#include "SMDS_Mesh.hxx" +#include "SMDS_MeshElement.hxx" +#include "SMDS_MeshNode.hxx" +#include +#include +#include +#include +#include +#include +#include +#include + +#include "utilities.h" + +static const int HEADER_SIZE = 84; +static const int SIZEOF_STL_FACET = 50; +//static const int STL_MIN_FILE_SIZE = 284; +static const int ASCII_LINES_PER_FACET = 7; + +static Standard_Real tab1[3]; +static Standard_Real tab2[3]; + +typedef NCollection_DataMap DriverSTL_DataMapOfPntNodePtr; +//typedef NCollection_BaseCollection DriverSTL_ColOfNodePtr; + +//======================================================================= +//function : HashCode +//purpose : +//======================================================================= +inline Standard_Integer HashCode + (const gp_Pnt& point, const Standard_Integer Upper) +{ + union + { + Standard_Real R[3]; + Standard_Integer I[6]; + } U; + + point.Coord(U.R[0],U.R[1],U.R[2]); + + return ::HashCode(U.I[0]/23+U.I[1]/19+U.I[2]/17+U.I[3]/13+U.I[4]/11+U.I[5]/7,Upper); +} + +//======================================================================= +//function : IsEqual +//purpose : +//======================================================================= +inline Standard_Boolean IsEqual + (const gp_Pnt& point1, const gp_Pnt& point2) +{ + point1.Coord(tab1[0],tab1[1],tab1[2]); + point2.Coord(tab2[0],tab2[1],tab2[2]); + return (memcmp(tab1,tab2,sizeof(tab1)) == 0); +} + +//======================================================================= +//function : DriverSTL_R_SMDS_Mesh +//purpose : +//======================================================================= + +DriverSTL_R_SMDS_Mesh::DriverSTL_R_SMDS_Mesh() +{ + myIsCreateFaces = true; + myIsAscii = Standard_True; +} + +//======================================================================= +//function : SetIsCreateFaces +//purpose : +//======================================================================= + +void DriverSTL_R_SMDS_Mesh::SetIsCreateFaces( const bool theIsCreate ) +{ myIsCreateFaces = theIsCreate; } + +//======================================================================= +//function : Perform +//purpose : +//======================================================================= + +Driver_Mesh::Status DriverSTL_R_SMDS_Mesh::Perform() +{ + Status aResult = DRS_OK; + + TCollection_AsciiString aFileName( (char *)myFile.c_str() ); + if ( aFileName.IsEmpty() ) { + fprintf(stderr, ">> ERREOR : invalid file name \n"); + return DRS_FAIL; + } + + filebuf fic; + Standard_IStream is(&fic); + if (!fic.open(aFileName.ToCString(),ios::in)) { + fprintf(stderr, ">> ERROR : cannot open file %s \n", aFileName.ToCString()); + return DRS_FAIL; + } + + + OSD_Path aPath( aFileName ); + OSD_File file = OSD_File( aPath ); + file.Open(OSD_ReadOnly,OSD_Protection(OSD_RWD,OSD_RWD,OSD_RWD,OSD_RWD)); + unsigned char str[128]; + Standard_Integer lread,i; + Standard_Address ach; + ach = (Standard_Address)str; + // we skip the header which is in Ascii for both modes + file.Read(ach,HEADER_SIZE,lread); + + // we read 128 characters to detect if we have a non-ascii char + file.Read(ach,sizeof(str),lread); + + myIsAscii = Standard_True; + for (i = 0; i < lread; ++i) { + if (str[i] > '~') { + myIsAscii = Standard_False; + break; + } + } + + file.Close(); + + if ( !myMesh ) { + fprintf(stderr, ">> ERREOR : cannot create mesh \n"); + return DRS_FAIL; + } + + if ( myIsAscii ) + aResult = readAscii(); + else + aResult = readBinary(); + + return aResult; +} + +// static methods + +static Standard_Real readFloat(OSD_File& theFile) +{ + union { + Standard_Boolean i; + Standard_ShortReal f; + }u; + + char c[4]; + Standard_Address adr; + adr = (Standard_Address)c; + Standard_Integer lread; + theFile.Read(adr,4,lread); + u.i = c[0] & 0xFF; + u.i |= (c[1] & 0xFF) << 0x08; + u.i |= (c[2] & 0xFF) << 0x10; + u.i |= (c[3] & 0xFF) << 0x18; + + return u.f; +} + +static SMDS_MeshNode* addNode(const gp_Pnt& P, + DriverSTL_DataMapOfPntNodePtr& uniqnodes, + SMDS_Mesh* theMesh) +{ + SMDS_MeshNode* node = 0; + if ( uniqnodes.IsBound(P) ) { + node = uniqnodes.Find(P); + } else { + node = theMesh->AddNode(P.X(), P.Y(), P.Z() ); + uniqnodes.Bind(P,node); + } + + return node; +} + +static SMDS_MeshNode* readNode(FILE* file, + DriverSTL_DataMapOfPntNodePtr& uniqnodes, + SMDS_Mesh* theMesh) +{ + Standard_ShortReal coord[3]; + // reading vertex + fscanf(file,"%*s %f %f %f\n",&coord[0],&coord[1],&coord[2]); + + gp_Pnt P(coord[0],coord[1],coord[2]); + return addNode( P, uniqnodes, theMesh ); +} + +static SMDS_MeshNode* readNode(OSD_File& theFile, + DriverSTL_DataMapOfPntNodePtr& uniqnodes, + SMDS_Mesh* theMesh) +{ + Standard_ShortReal coord[3]; + coord[0] = readFloat(theFile); + coord[1] = readFloat(theFile); + coord[2] = readFloat(theFile); + + gp_Pnt P(coord[0],coord[1],coord[2]); + return addNode( P, uniqnodes, theMesh ); +} + +//======================================================================= +//function : readAscii +//purpose : +//======================================================================= + +Driver_Mesh::Status DriverSTL_R_SMDS_Mesh::readAscii() const +{ + Status aResult = DRS_OK; + long ipos; + Standard_Integer nbLines = 0; + + // Open the file + TCollection_AsciiString aFileName( (char *)myFile.c_str() ); + FILE* file = fopen(aFileName.ToCString(),"r"); + fseek(file,0L,SEEK_END); + // get the file size + long filesize = ftell(file); + fclose(file); + file = fopen(aFileName.ToCString(),"r"); + + // count the number of lines + for (ipos = 0; ipos < filesize; ++ipos) { + if (getc(file) == '\n') + nbLines++; + } + + // go back to the beginning of the file +// fclose(file); +// file = fopen(aFileName.ToCString(),"r"); + rewind(file); + + Standard_Integer nbTri = (nbLines / ASCII_LINES_PER_FACET); + + DriverSTL_DataMapOfPntNodePtr uniqnodes; + // skip header + while (getc(file) != '\n'); + + // main reading + for (Standard_Integer iTri = 0; iTri < nbTri; ++iTri) { + + // skipping the facet normal + Standard_ShortReal normal[3]; + fscanf(file,"%*s %*s %f %f %f\n",&normal[0],&normal[1],&normal[2]); + + // skip the keywords "outer loop" + fscanf(file,"%*s %*s"); + + // reading nodes + SMDS_MeshNode* node1 = readNode( file, uniqnodes, myMesh ); + SMDS_MeshNode* node2 = readNode( file, uniqnodes, myMesh ); + SMDS_MeshNode* node3 = readNode( file, uniqnodes, myMesh ); + + if (myIsCreateFaces) + myMesh->AddFace(node1,node2,node3); + + // skip the keywords "endloop" + fscanf(file,"%*s"); + + // skip the keywords "endfacet" + fscanf(file,"%*s"); + } + + fclose(file); + return aResult; +} + +//======================================================================= +//function : readBinary +//purpose : +//======================================================================= + +Driver_Mesh::Status DriverSTL_R_SMDS_Mesh::readBinary() const +{ + Status aResult = DRS_OK; + + char buftest[5]; + Standard_Address adr; + adr = (Standard_Address)buftest; + + TCollection_AsciiString aFileName( (char *)myFile.c_str() ); + OSD_File aFile = OSD_File(OSD_Path( aFileName )); + aFile.Open(OSD_ReadOnly,OSD_Protection(OSD_RWD,OSD_RWD,OSD_RWD,OSD_RWD)); + + // the size of the file (minus the header size) + // must be a multiple of SIZEOF_STL_FACET + + // compute file size + Standard_Integer filesize = aFile.Size(); + + if ( (filesize - HEADER_SIZE) % SIZEOF_STL_FACET !=0 + // Commented to allow reading small files (ex: 1 face) + /*|| (filesize < STL_MIN_FILE_SIZE)*/) { + Standard_NoMoreObject::Raise("DriverSTL_R_SMDS_MESH::readBinary (wrong file size)"); + } + + // don't trust the number of triangles which is coded in the file + // sometimes it is wrong, and with this technique we don't need to swap endians for integer + Standard_Integer nbTri = ((filesize - HEADER_SIZE) / SIZEOF_STL_FACET); + + // skip the header + aFile.Seek(HEADER_SIZE,OSD_FromBeginning); + + DriverSTL_DataMapOfPntNodePtr uniqnodes; + Standard_Integer lread; + + for (Standard_Integer iTri = 0; iTri < nbTri; ++iTri) { + + // ignore normals + readFloat(aFile); + readFloat(aFile); + readFloat(aFile); + + // read vertices + SMDS_MeshNode* node1 = readNode( aFile, uniqnodes, myMesh ); + SMDS_MeshNode* node2 = readNode( aFile, uniqnodes, myMesh ); + SMDS_MeshNode* node3 = readNode( aFile, uniqnodes, myMesh ); + + if (myIsCreateFaces) + myMesh->AddFace(node1,node2,node3); + + // skip extra bytes + aFile.Read(adr,2,lread); + } + aFile.Close(); + return aResult; +} diff --git a/idl/SMESH_NetgenAlgorithm.idl b/src/DriverSTL/DriverSTL_R_SMDS_Mesh.h similarity index 65% rename from idl/SMESH_NetgenAlgorithm.idl rename to src/DriverSTL/DriverSTL_R_SMDS_Mesh.h index afe23ad72..14afd3c21 100644 --- a/idl/SMESH_NetgenAlgorithm.idl +++ b/src/DriverSTL/DriverSTL_R_SMDS_Mesh.h @@ -16,30 +16,30 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMESH_NetgenAlgorithm.idl -// Author : Julia DOROVSKIKH -// $Header$ -#ifndef _SMESH_NETGENALGORITHM_IDL_ -#define _SMESH_NETGENALGORITHM_IDL_ +#ifndef _INCLUDE_DRIVERSTL_R_SMDS_MESH +#define _INCLUDE_DRIVERSTL_R_SMDS_MESH -#include "SMESH_Hypothesis.idl" +#include "Driver_SMDS_Mesh.h" -/*! - * NETGENPlugin: interfaces to NETGEN related hypotheses and algorithms - */ -module NETGENPlugin -{ - /*! - * NETGENPlugin_NETGEN_3D: interface of "Tetrahedron (Netgen)" algorithm - */ - interface NETGENPlugin_NETGEN_3D : SMESH::SMESH_3D_Algo - { - }; +#include +class DriverSTL_R_SMDS_Mesh: public Driver_SMDS_Mesh +{ + public: + DriverSTL_R_SMDS_Mesh(); + virtual Status Perform(); + void SetIsCreateFaces( const bool theIsCreate = true ); + + private: + // PRIVATE METHODS + Status readAscii() const; + Status readBinary() const; + + private: + // PRIVATE FIELDS + bool myIsCreateFaces; + bool myIsAscii; }; #endif diff --git a/src/DriverSTL/DriverSTL_W_SMDS_Mesh.cxx b/src/DriverSTL/DriverSTL_W_SMDS_Mesh.cxx new file mode 100644 index 000000000..04ce4058a --- /dev/null +++ b/src/DriverSTL/DriverSTL_W_SMDS_Mesh.cxx @@ -0,0 +1,261 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include + +#include "DriverSTL_W_SMDS_Mesh.h" + +#include "SMDS_Mesh.hxx" +#include "SMDS_MeshElement.hxx" +#include "SMDS_MeshNode.hxx" +#include +#include +#include +#include +#include +#include +#include +#include + +#include "utilities.h" + +//using namespace std; + +// definition des constantes +static const int LABEL_SIZE = 80; + +DriverSTL_W_SMDS_Mesh::DriverSTL_W_SMDS_Mesh() +{ + myIsAscii = false; +} + +void DriverSTL_W_SMDS_Mesh::SetIsAscii( const bool theIsAscii ) +{ + myIsAscii = theIsAscii; +} + +Driver_Mesh::Status DriverSTL_W_SMDS_Mesh::Perform() +{ + Status aResult = DRS_OK; + + if ( !myMesh ) { + fprintf(stderr, ">> ERROR : Mesh is null \n"); + return DRS_FAIL; + } + if ( myIsAscii ) + aResult = writeAscii(); + else + aResult = writeBinary(); + + return aResult; +} + +// static methods + +static void writeInteger( const Standard_Integer& theVal, + OSD_File& ofile ) +{ + union { + Standard_Integer i; + char c[4]; + }u; + + u.i = theVal; + + Standard_Integer entier; + entier = u.c[0] & 0xFF; + entier |= (u.c[1] & 0xFF) << 0x08; + entier |= (u.c[2] & 0xFF) << 0x10; + entier |= (u.c[3] & 0xFF) << 0x18; + + ofile.Write((char *)&entier,sizeof(u.c)); +} + +static void writeFloat ( const Standard_ShortReal& theVal, + OSD_File& ofile) +{ + union { + Standard_ShortReal f; + char c[4]; + }u; + + u.f = theVal; + + Standard_Integer entier; + + entier = u.c[0] & 0xFF; + entier |= (u.c[1] & 0xFF) << 0x08; + entier |= (u.c[2] & 0xFF) << 0x10; + entier |= (u.c[3] & 0xFF) << 0x18; + + ofile.Write((char *)&entier,sizeof(u.c)); +} + +static gp_XYZ getNormale( const SMDS_MeshFace* theFace ) +{ + gp_XYZ n; + int aNbNode = theFace->NbNodes(); + TColgp_Array1OfXYZ anArrOfXYZ(1,4); + gp_XYZ p1, p2, p3, p4; + 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; +} + +// private methods + +Driver_Mesh::Status DriverSTL_W_SMDS_Mesh::writeAscii() const +{ + Status aResult = DRS_OK; + TCollection_AsciiString aFileName( (char *)myFile.c_str() ); + if ( aFileName.IsEmpty() ) { + fprintf(stderr, ">> ERREOR : invalid file name \n"); + return DRS_FAIL; + } + + OSD_File aFile = OSD_File(OSD_Path(aFileName)); + aFile.Build(OSD_WriteOnly,OSD_Protection()); + TCollection_AsciiString buf = TCollection_AsciiString ("solid\n"); + aFile.Write (buf,buf.Length());buf.Clear(); + char sval[16]; + + SMDS_FaceIteratorPtr itFaces = myMesh->facesIterator(); + + for (; itFaces->more() ;) { + SMDS_MeshFace* aFace = (SMDS_MeshFace*)itFaces->next(); + + if (aFace->NbNodes() == 3) { + gp_XYZ normale = getNormale( aFace ); + + buf += " facet normal "; + sprintf (sval,"% 12e",normale.X()); + buf += sval; + buf += " "; + sprintf (sval,"% 12e",normale.Y()); + buf += sval; + buf += " "; + sprintf (sval,"% 12e",normale.Z()); + buf += sval; + buf += '\n'; + aFile.Write (buf,buf.Length());buf.Clear(); + buf += " outer loop\n"; + aFile.Write (buf,buf.Length());buf.Clear(); + + SMDS_ElemIteratorPtr aNodeIter = aFace->nodesIterator(); + for (; aNodeIter->more(); ) { + SMDS_MeshNode* node = (SMDS_MeshNode*)aNodeIter->next(); + buf += " vertex "; + sprintf (sval,"% 12e",node->X()); + buf += sval; + buf += " "; + sprintf (sval,"% 12e",node->Y()); + buf += sval; + buf += " "; + sprintf (sval,"% 12e",node->Z()); + buf += sval; + buf += '\n'; + aFile.Write (buf,buf.Length());buf.Clear(); + } + buf += " endloop\n"; + aFile.Write (buf,buf.Length());buf.Clear(); + buf += " endfacet\n"; + aFile.Write (buf,buf.Length());buf.Clear(); + } + } + buf += "endsolid\n"; + aFile.Write (buf,buf.Length());buf.Clear(); + + aFile.Close (); + + return aResult; +} + +Driver_Mesh::Status DriverSTL_W_SMDS_Mesh::writeBinary() const +{ + Status aResult = DRS_OK; + TCollection_AsciiString aFileName( (char *)myFile.c_str() ); + if ( aFileName.IsEmpty() ) { + fprintf(stderr, ">> ERREOR : invalid filename \n"); + return DRS_FAIL; + } + + OSD_File aFile = OSD_File(OSD_Path(aFileName)); + aFile.Build(OSD_WriteOnly,OSD_Protection()); + + char sval[80]; + Standard_Integer nbTri = 0; + SMDS_FaceIteratorPtr itFaces = myMesh->facesIterator(); + + // we first count the number of triangles + for (;itFaces->more();) { + SMDS_MeshFace* aFace = (SMDS_MeshFace*)itFaces->next(); + if (aFace->NbNodes() == 3) + nbTri++; + } + + // write number of triangles + unsigned int NBT = nbTri; + aFile.Write((Standard_Address)sval,LABEL_SIZE); + writeInteger(nbTri,aFile); + + // loop writing nodes. take face iterator again + int dum=0; + itFaces = myMesh->facesIterator(); + + for (;itFaces->more();) { + SMDS_MeshFace* aFace = (SMDS_MeshFace*)itFaces->next(); + + if (aFace->NbNodes() == 3) { + gp_XYZ aNorm = getNormale( aFace ); + writeFloat(aNorm.X(),aFile); + writeFloat(aNorm.Y(),aFile); + writeFloat(aNorm.Z(),aFile); + + SMDS_ElemIteratorPtr aNodeIter = aFace->nodesIterator(); + for (; aNodeIter->more(); ) { + SMDS_MeshNode* node = (SMDS_MeshNode*)aNodeIter->next(); + writeFloat(node->X(),aFile); + writeFloat(node->Y(),aFile); + writeFloat(node->Z(),aFile); + } + aFile.Write (&dum,2); + } + } + aFile.Close (); + + return aResult; +} diff --git a/src/Driver/Mesh_Writer.h b/src/DriverSTL/DriverSTL_W_SMDS_Mesh.h similarity index 59% rename from src/Driver/Mesh_Writer.h rename to src/DriverSTL/DriverSTL_W_SMDS_Mesh.h index e382f27b6..49d752083 100644 --- a/src/Driver/Mesh_Writer.h +++ b/src/DriverSTL/DriverSTL_W_SMDS_Mesh.h @@ -1,6 +1,6 @@ -// SMESH Driver : implementaion of driver for reading and writing +// SMESH DriverSTL : driver to read and write 'stl' files // -// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// Copyright (C) 2004 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 @@ -21,23 +21,31 @@ // // // -// File : Mesh_Writer.h +// File : DriverSTL_W_SMDS_Mesh.h // Module : SMESH -#ifndef _INCLUDE_MESH_WRITER -#define _INCLUDE_MESH_WRITER +#ifndef _INCLUDE_DRIVERSTL_W_SMDS_MESH +#define _INCLUDE_DRIVERSTL_W_SMDS_MESH -#include -#include "SMDS_Mesh.hxx" +#include "Driver_SMDS_Mesh.h" +#include -class Mesh_Writer +class DriverSTL_W_SMDS_Mesh: public Driver_SMDS_Mesh { + public: + + DriverSTL_W_SMDS_Mesh(); + virtual Status Perform(); + void SetIsAscii( const bool theIsAscii = false ); - public:virtual void Add() = 0; - virtual void Write() = 0; - virtual void SetMesh(SMDS_Mesh *) = 0; - virtual void SetFile(string) = 0; - virtual void SetMeshId(int) = 0; + private: + // PRIVATE METHODS + Status writeAscii () const; + Status writeBinary () const; + private: + // PRIVATE FIELDS + bool myIsAscii; }; + #endif diff --git a/src/DriverSTL/Makefile.in b/src/DriverSTL/Makefile.in new file mode 100644 index 000000000..9597604e8 --- /dev/null +++ b/src/DriverSTL/Makefile.in @@ -0,0 +1,61 @@ +# SMESH DriverSTL : driver to read and write 'stl' files +# +# 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : Makefile.in +# Author : Marc Tajchman (CEA) +# Module : SMESH +# $Header$ + +top_srcdir=@top_srcdir@ +top_builddir=../.. +srcdir=@srcdir@ +VPATH=.:@srcdir@ + + +@COMMENCE@ + +# header files +EXPORT_HEADERS= DriverSTL_R_SMDS_Mesh.h DriverSTL_W_SMDS_Mesh.h + +# Libraries targets +LIB = libMeshDriverSTL.la +LIB_SRC = DriverSTL_R_SMDS_Mesh.cxx DriverSTL_W_SMDS_Mesh.cxx + +# Executables targets +BIN = STL_Test + +LIB_CLIENT_IDL = + +LIB_SERVER_IDL = + +# additionnal information to compil and link file +CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS) +CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome +LDFLAGS += $(OCC_KERNEL_LIBS) -lMeshDriver -lTKSTL + +LDFLAGSFORBIN += -lMeshDriver -lSMDS -L${KERNEL_ROOT_DIR}/lib/salome -lOpUtil -lSALOMELocalTrace $(OCC_KERNEL_LIBS) -lTKSTL -lTKBO + +@CONCLUDE@ + + + diff --git a/src/DriverSTL/STL_Test.cxx b/src/DriverSTL/STL_Test.cxx new file mode 100644 index 000000000..78dc0df71 --- /dev/null +++ b/src/DriverSTL/STL_Test.cxx @@ -0,0 +1,28 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +//#include "DriverSTL_R_SMDS_Mesh.h" +#include "DriverSTL_W_SMDS_Mesh.h" + +int main(int argc, char** argv) +{ +// DriverSTL_R_SMDS_Mesh aR; + DriverSTL_W_SMDS_Mesh aW; + return 1; +} diff --git a/src/DriverUNV/DriverUNV_R_SMDS_Mesh.cxx b/src/DriverUNV/DriverUNV_R_SMDS_Mesh.cxx index c6286a7b3..af39482b5 100644 --- a/src/DriverUNV/DriverUNV_R_SMDS_Mesh.cxx +++ b/src/DriverUNV/DriverUNV_R_SMDS_Mesh.cxx @@ -1,186 +1,164 @@ -using namespace std; #include "DriverUNV_R_SMDS_Mesh.h" +#include "SMDS_Mesh.hxx" #include "utilities.h" -DriverUNV_R_SMDS_Mesh::DriverUNV_R_SMDS_Mesh() -{ - ; -} +#include "UNV2411_Structure.hxx" +#include "UNV2412_Structure.hxx" +#include "UNV_Utilities.hxx" -DriverUNV_R_SMDS_Mesh::~DriverUNV_R_SMDS_Mesh() -{ - ; -} +using namespace std; -void DriverUNV_R_SMDS_Mesh::SetMesh(SMDS_Mesh * aMesh) -{ - myMesh = aMesh; -} -void DriverUNV_R_SMDS_Mesh::SetFile(string aFile) -{ - myFile = aFile; -} +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif -void DriverUNV_R_SMDS_Mesh::SetFileId(FILE * aFileId) -{ - myFileId = aFileId; -} -void DriverUNV_R_SMDS_Mesh::SetMeshId(int aMeshId) -{ - myMeshId = aMeshId; +static const SMDS_MeshNode* +FindNode(const SMDS_Mesh* theMesh, int theId){ + const SMDS_MeshNode* aNode = theMesh->FindNode(theId); + if(aNode) return aNode; + EXCEPTION(runtime_error,"SMDS_Mesh::FindNode - cannot find a SMDS_MeshNode for ID = "<> ERREUR : ouverture du fichier %s \n", file2Read); - exit(EXIT_FAILURE); + Status aResult = DRS_OK; + std::ifstream in_stream(myFile.c_str()); + try{ + { + using namespace UNV2411; + TDataSet aDataSet2411; + UNV2411::Read(in_stream,aDataSet2411); + if(MYDEBUG) MESSAGE("Perform - aDataSet2411.size() = "<first; + const TRecord& aRec = anIter->second; + const SMDS_MeshNode* aNode = + myMesh->AddNodeWithID(aRec.coord[0],aRec.coord[1],aRec.coord[2],aLabel); + } + } + { + using namespace UNV2412; + in_stream.seekg(0); + TDataSet aDataSet2412; + UNV2412::Read(in_stream,aDataSet2412); + TDataSet::const_iterator anIter = aDataSet2412.begin(); + if(MYDEBUG) MESSAGE("Perform - aDataSet2412.size() = "<first; + const TRecord& aRec = anIter->second; + int aNbNodes = aRec.node_labels.size(); + if(IsBeam(aRec.fe_descriptor_id)){ + anElement = myMesh->AddEdgeWithID(aRec.node_labels[0], + aRec.node_labels[1], + aLabel); + }else if(IsFace(aRec.fe_descriptor_id)){ + switch(aRec.fe_descriptor_id){ + case 71: // TRI3 + case 72: + case 74: + + case 41: // Plane Stress Linear Triangle - TRI3 + case 91: // Thin Shell Linear Triangle - TRI3 + + case 42: // Plane Stress Quadratic Triangle - TRI6 + case 92: // Thin Shell Quadratic Triangle - TRI6 + + anElement = myMesh->AddFaceWithID(aRec.node_labels[0], + aRec.node_labels[1], + aRec.node_labels[2], + aLabel); + break; + + case 44: // Plane Stress Linear Quadrilateral - QUAD4 + case 94: // Thin Shell Linear Quadrilateral - QUAD4 + + case 45: // Plane Stress Quadratic Quadrilateral - QUAD8 + case 95: // Thin Shell Quadratic Quadrilateral - QUAD8 + anElement = myMesh->AddFaceWithID(aRec.node_labels[0], + aRec.node_labels[1], + aRec.node_labels[2], + aRec.node_labels[3], + aLabel); + break; + } + }else if(IsVolume(aRec.fe_descriptor_id)){ + switch(aRec.fe_descriptor_id){ + + case 111: // Solid Linear Tetrahedron - TET4 + case 118: // Solid Quadratic Tetrahedron - TET10 + + anElement = myMesh->AddVolumeWithID(aRec.node_labels[0], + aRec.node_labels[1], + aRec.node_labels[2], + aRec.node_labels[3], + aLabel); + break; + + case 112: // Solid Linear Prism - PRISM6 + + anElement = myMesh->AddVolumeWithID(aRec.node_labels[0], + aRec.node_labels[2], + aRec.node_labels[1], + aRec.node_labels[3], + aRec.node_labels[5], + aRec.node_labels[4], + aLabel); + break; + + case 113: // Solid Quadratic Prism - PRISM15 + + anElement = myMesh->AddVolumeWithID(aRec.node_labels[0], + aRec.node_labels[4], + aRec.node_labels[2], + aRec.node_labels[9], + aRec.node_labels[13], + aRec.node_labels[11], + aLabel); + break; + + case 115: // Solid Linear Brick - HEX8 + + anElement = myMesh->AddVolumeWithID(aRec.node_labels[0], + aRec.node_labels[1], + aRec.node_labels[2], + aRec.node_labels[3], + aRec.node_labels[4], + aRec.node_labels[5], + aRec.node_labels[6], + aRec.node_labels[7], + aLabel); + break; + + case 116: // Solid Quadratic Brick - HEX20 + + anElement = myMesh->AddVolumeWithID(aRec.node_labels[0], + aRec.node_labels[2], + aRec.node_labels[4], + aRec.node_labels[6], + aRec.node_labels[12], + aRec.node_labels[14], + aRec.node_labels[16], + aRec.node_labels[18], + aLabel); + break; + } } - - s1 = (char *)malloc(sizeof(char) * 100); - s2 = (char *)malloc(sizeof(char) * 100); - s3 = (char *)malloc(sizeof(char) * 100); - - found_block2411 = false; - found_block2412 = false; - - do - { - - while (i1 == -1) - { - fscanf(myFileId, "%d\n", &blockId); - switch (blockId) - { - case 2411: - { - MESSAGE("BlockId " << blockId); - fscanf(myFileId, "%d", &node); - //MESSAGE("Node "<AddNodeWithID(atof(str1.c_str()), - atof(str2.c_str()), atof(str3.c_str()), node); - fscanf(myFileId, "%d", &node); - } - i1 = 0; - found_block2411 = true; - break; - } - case 2412: - { - MESSAGE("BlockId " << blockId); - fscanf(myFileId, "%d", &cell); - //MESSAGE("Cell "<AddFaceWithID(nodes[0], nodes[1], - nodes[2], cell); - } - else if (n_nodes == 6) - { //206 - for (i = 1; i <= n_nodes; i++) - fscanf(myFileId, "%d", &nodes[i - 1]); - ok = myMesh->AddFaceWithID(nodes[0], nodes[2], - nodes[4], cell); - } - } - - else if ((n1 == 11) || (n1 == 21) || (n1 == 24) || - (n1 == 25)) - { //103 - fgets(s2, 100, myFileId); - if (n_nodes == 3) - { - for (i = 1; i <= n_nodes; i++) - fscanf(myFileId, "%d", &nodes[i - 1]); - ok = myMesh->AddEdgeWithID(nodes[0], nodes[1], - cell); - //MESSAGE("in 103 "<AddEdgeWithID(nodes[0], nodes[1], - cell); - //MESSAGE("in 102 "< +#include "Driver_SMDS_Mesh.h" -#include "SMDS_Mesh.hxx" -#include "Mesh_Reader.h" +class SMDS_Mesh; -class DriverUNV_R_SMDS_Mesh:public Mesh_Reader +class DriverUNV_R_SMDS_Mesh: public Driver_SMDS_Mesh { - - public:DriverUNV_R_SMDS_Mesh(); - ~DriverUNV_R_SMDS_Mesh(); - - void Add(); - void Read(); - void SetMesh(SMDS_Mesh * aMesh); - void SetFile(string); - - void SetFileId(FILE *); - void SetMeshId(int); - - private: SMDS_Mesh * myMesh; - string myFile; - FILE *myFileId; - int myMeshId; - + public: + virtual Status Perform(); }; + #endif diff --git a/src/DriverUNV/DriverUNV_R_SMESHDS_Document.cxx b/src/DriverUNV/DriverUNV_R_SMESHDS_Document.cxx index 8b904cf4c..0e1b871fc 100644 --- a/src/DriverUNV/DriverUNV_R_SMESHDS_Document.cxx +++ b/src/DriverUNV/DriverUNV_R_SMESHDS_Document.cxx @@ -1,90 +1,20 @@ -using namespace std; -#include "DriverUNV_R_SMESHDS_Document.h" -#include "DriverUNV_R_SMESHDS_Mesh.h" - -#include "utilities.h" - -int getOne() -{ - printf("in getOne"); - return (1); -} - -extern "C" -{ - // Document_Reader* maker() { - DriverUNV_R_SMESHDS_Document *maker() - { - fprintf(stdout, "here in maker\n"); - return new DriverUNV_R_SMESHDS_Document; - } -} - -DriverUNV_R_SMESHDS_Document::DriverUNV_R_SMESHDS_Document() -{ - myFile = string(""); -} - -DriverUNV_R_SMESHDS_Document::~DriverUNV_R_SMESHDS_Document() -{ - ; -} - -//void DriverUNV_R_SMESHDS_Document::SetFile(string aFile) { -//myFile = aFile; -//} - -//void DriverUNV_R_SMESHDS_Document::SetDocument(Handle(SMESHDS_Document)& aDoc) { -//myDocument = aDoc; -//} - -void DriverUNV_R_SMESHDS_Document::Read() -{ - - int myMeshId; - SCRUTE(myFile); - //Handle(SMESHDS_Document) myDocument = new SMESHDS_Document(1); - - /**************************************************************************** - * OUVERTURE DU FICHIER EN LECTURE * - ****************************************************************************/ - char *file2Read = (char *)myFile.c_str(); - FILE *fid = fopen(file2Read, "r"); - if (fid < 0) - { - fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read); - exit(EXIT_FAILURE); - } +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org - /**************************************************************************** - * COMBIEN DE MAILLAGES ? * - ****************************************************************************/ - int nmaa = 1; - - /**************************************************************************** - * FERMETURE DU FICHIER * - ****************************************************************************/ - fclose(fid); - - printf("Nombre de maillages = %d\n", nmaa); - - string myClass = string("SMESHDS_Mesh"); - string myExtension = string("UNV"); - - for (int meshIt = 1; meshIt <= nmaa; meshIt++) - { - myMeshId = myDocument->NewMesh(); - - SMDS_Mesh * myMesh = myDocument->GetMesh(myMeshId); - - DriverUNV_R_SMESHDS_Mesh *myReader = new DriverUNV_R_SMESHDS_Mesh; - - myReader->SetMesh(myMesh); - myReader->SetFile(myFile); - //myReader->SetFileId(fid); - - myReader->Read(); - - } - -} +#include "DriverUNV_R_SMESHDS_Document.h" diff --git a/src/DriverUNV/DriverUNV_R_SMESHDS_Document.h b/src/DriverUNV/DriverUNV_R_SMESHDS_Document.h index 9fbd04f3a..4d38a67c3 100644 --- a/src/DriverUNV/DriverUNV_R_SMESHDS_Document.h +++ b/src/DriverUNV/DriverUNV_R_SMESHDS_Document.h @@ -1,24 +1,28 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + #ifndef _INCLUDE_DRIVERUNV_R_SMESHDS_DOCUMENT #define _INCLUDE_DRIVERUNV_R_SMESHDS_DOCUMENT -#include - -#include "SMESHDS_Document.hxx" -#include "Document_Reader.h" - -class DriverUNV_R_SMESHDS_Document : public Document_Reader { - -public : - DriverUNV_R_SMESHDS_Document(); - ~DriverUNV_R_SMESHDS_Document(); - - void Read(); - //void SetFile(string); - //void SetDocument(Handle_SMESHDS_Document&); +#include "Driver_Document.h" -private : - //Handle_SMESHDS_Document myDocument; - //string myFile; +class DriverUNV_R_SMESHDS_Document: public Driver_Document +{}; -}; #endif diff --git a/src/DriverUNV/DriverUNV_R_SMESHDS_Mesh.cxx b/src/DriverUNV/DriverUNV_R_SMESHDS_Mesh.cxx index 752e786e4..e4fcbf3e0 100644 --- a/src/DriverUNV/DriverUNV_R_SMESHDS_Mesh.cxx +++ b/src/DriverUNV/DriverUNV_R_SMESHDS_Mesh.cxx @@ -1,56 +1,20 @@ -using namespace std; -#include "DriverUNV_R_SMESHDS_Mesh.h" -#include "DriverUNV_R_SMDS_Mesh.h" - -#include "utilities.h" - -DriverUNV_R_SMESHDS_Mesh::DriverUNV_R_SMESHDS_Mesh() -{ - ; -} - -DriverUNV_R_SMESHDS_Mesh::~DriverUNV_R_SMESHDS_Mesh() -{ - ; -} - -void DriverUNV_R_SMESHDS_Mesh::SetMesh(SMDS_Mesh * aMesh) -{ - //myMesh = SMESHDS_Mesh *::DownCast(aMesh); - myMesh = aMesh; -} - -void DriverUNV_R_SMESHDS_Mesh::SetFile(string aFile) -{ - myFile = aFile; -} - -void DriverUNV_R_SMESHDS_Mesh::SetFileId(FILE * aFileId) -{ - myFileId = aFileId; -} +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -void DriverUNV_R_SMESHDS_Mesh::SetMeshId(int aMeshId) -{ - myMeshId = aMeshId; -} - -void DriverUNV_R_SMESHDS_Mesh::Add() -{ - ; -} - -void DriverUNV_R_SMESHDS_Mesh::Read() -{ - string myClass = string("SMDS_Mesh"); - string myExtension = string("UNV"); - - DriverUNV_R_SMDS_Mesh *myReader = new DriverUNV_R_SMDS_Mesh; - - myReader->SetMesh(myMesh); - myReader->SetFile(myFile); - //myReader->SetFileId(myFileId); - - myReader->Read(); - -} +#include "DriverUNV_R_SMESHDS_Mesh.h" diff --git a/src/DriverUNV/DriverUNV_R_SMESHDS_Mesh.h b/src/DriverUNV/DriverUNV_R_SMESHDS_Mesh.h index e2ce3e2a7..fce4b66bd 100644 --- a/src/DriverUNV/DriverUNV_R_SMESHDS_Mesh.h +++ b/src/DriverUNV/DriverUNV_R_SMESHDS_Mesh.h @@ -1,29 +1,28 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + #ifndef _INCLUDE_DRIVERUNV_R_SMESHDS_MESH #define _INCLUDE_DRIVERUNV_R_SMESHDS_MESH -#include - -#include "SMESHDS_Mesh.hxx" -#include "Mesh_Reader.h" - -class DriverUNV_R_SMESHDS_Mesh:public Mesh_Reader -{ - - public:DriverUNV_R_SMESHDS_Mesh(); - ~DriverUNV_R_SMESHDS_Mesh(); - - void Add(); - void Read(); - void SetMesh(SMDS_Mesh * aMesh); - void SetFile(string); - - void SetFileId(FILE *); - void SetMeshId(int); +#include "Driver_SMESHDS_Mesh.h" - private: SMDS_Mesh * myMesh; - string myFile; - FILE *myFileId; - int myMeshId; +class DriverUNV_R_SMESHDS_Mesh: public Driver_SMESHDS_Mesh +{}; -}; #endif diff --git a/src/DriverUNV/DriverUNV_W_SMDS_Mesh.cxx b/src/DriverUNV/DriverUNV_W_SMDS_Mesh.cxx index 80c02b461..6d834b3fd 100644 --- a/src/DriverUNV/DriverUNV_W_SMDS_Mesh.cxx +++ b/src/DriverUNV/DriverUNV_W_SMDS_Mesh.cxx @@ -1,223 +1,150 @@ -using namespace std; -#include "DriverUNV_W_SMDS_Mesh.h" - -#include "SMDS_MeshElement.hxx" -#include "SMDS_MeshNode.hxx" - - - - +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include -#include - -#define sNODE_UNV_ID " 2411" -#define sELT_UNV_ID " 2412" -#define sUNV_SEPARATOR " -1" -#define sNODE_UNV_DESCR "%10d 1 1 11\n" -#define sELT_SURF_DESC "%10d %2d 1 1 11 %1d\n" -#define sELT_VOLU_DESC "%10d %2d 1 1 9 %1d\n" -#define sELT_BEAM_DESC1 "%10d %2d 1 1 7 %1d\n" -#define sELT_BEAM_DESC2 " 0 1 1\n" - -DriverUNV_W_SMDS_Mesh::DriverUNV_W_SMDS_Mesh() -{ - ; -} - -DriverUNV_W_SMDS_Mesh::~DriverUNV_W_SMDS_Mesh() -{ - ; -} +#include "DriverUNV_W_SMDS_Mesh.h" -void DriverUNV_W_SMDS_Mesh::SetMesh(SMDS_Mesh * aMesh) -{ - myMesh = aMesh; -} +#include "SMDS_Mesh.hxx" -void DriverUNV_W_SMDS_Mesh::SetFile(string aFile) -{ - myFile = aFile; -} +#include "utilities.h" -void DriverUNV_W_SMDS_Mesh::SetFileId(FILE * aFileId) -{ - myFileId = aFileId; -} +#include "UNV2411_Structure.hxx" +#include "UNV2412_Structure.hxx" +#include "UNV_Utilities.hxx" -void DriverUNV_W_SMDS_Mesh::SetMeshId(int aMeshId) -{ - myMeshId = aMeshId; -} - -void DriverUNV_W_SMDS_Mesh::Add() -{ - ; -} +using namespace std; -void DriverUNV_W_SMDS_Mesh::Write() +Driver_Mesh::Status DriverUNV_W_SMDS_Mesh::Perform() { - - int nbNodes, nbCells; - int i; - - char *file2Read = (char *)myFile.c_str(); - myFileId = fopen(file2Read, "w+"); - if (myFileId < 0) - { - fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read); - exit(EXIT_FAILURE); + Status aResult = DRS_OK; + std::ofstream out_stream(myFile.c_str()); + try{ + { + using namespace UNV2411; + TDataSet aDataSet2411; + // Storing SMDS nodes to the UNV file + //----------------------------------- + MESSAGE("Perform - myMesh->NbNodes() = "<NbNodes()); + SMDS_NodeIteratorPtr aNodesIter = myMesh->nodesIterator(); + for(; aNodesIter->more();){ + const SMDS_MeshNode* aNode = aNodesIter->next(); + TRecord aRec; + aRec.coord[0] = aNode->X(); + aRec.coord[1] = aNode->Y(); + aRec.coord[2] = aNode->Z(); + const TNodeLab& aLabel = aNode->GetID(); + aDataSet2411.insert(TDataSet::value_type(aLabel,aRec)); + } + MESSAGE("Perform - aDataSet2411.size() = "<NbEdges() = "<NbEdges()); + if(myMesh->NbEdges()){ + SMDS_EdgeIteratorPtr anIter = myMesh->edgesIterator(); + for(; anIter->more();){ + const SMDS_MeshEdge* anElem = anIter->next(); + const TElementLab& aLabel = anElem->GetID(); + int aNbNodes = anElem->NbNodes(); + TRecord aRec; + aRec.node_labels.reserve(aNbNodes); + SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator(); + for(; aNodesIter->more();){ + const SMDS_MeshElement* aNode = aNodesIter->next(); + aRec.node_labels.push_back(aNode->GetID()); + } + aRec.fe_descriptor_id = 11; + aDataSet2412.insert(TDataSet::value_type(aLabel,aRec)); } - SCRUTE(myMesh); - /**************************************************************************** - * NOMBRES D'OBJETS * - ****************************************************************************/ - fprintf(stdout, "\n(****************************)\n"); - fprintf(stdout, "(* INFORMATIONS GENERALES : *)\n"); - fprintf(stdout, "(****************************)\n"); - - /* Combien de noeuds ? */ - nbNodes = myMesh->NbNodes(); - - /* Combien de mailles, faces ou aretes ? */ - int nb_of_nodes, nb_of_edges, nb_of_faces, nb_of_volumes; - nb_of_edges = myMesh->NbEdges(); - nb_of_faces = myMesh->NbFaces(); - nb_of_volumes = myMesh->NbVolumes(); - nbCells = nb_of_edges + nb_of_faces + nb_of_volumes; - SCRUTE(nb_of_edges); - SCRUTE(nb_of_faces); - SCRUTE(nb_of_volumes); - - fprintf(stdout, "%d %d\n", nbNodes, nbCells); - fprintf(myFileId, "%d %d\n", nbNodes, nbCells); - - /**************************************************************************** - * ECRITURE DES NOEUDS * - ****************************************************************************/ - fprintf(stdout, "\n(************************)\n"); - fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n"); - fprintf(stdout, "(************************)\n"); - - fprintf(myFileId, "%s\n", sUNV_SEPARATOR); - fprintf(myFileId, "%s\n", sNODE_UNV_ID); - - SMDS_NodeIteratorPtr itNodes=myMesh->nodesIterator(); - while(itNodes->more()) - { - const SMDS_MeshNode * node = itNodes->next(); - - fprintf(myFileId, sNODE_UNV_DESCR, node->GetID()); - fprintf(myFileId, "%25.16E%25.16E%25.16E\n", node->X(), node->Y(), - node->Z()); + MESSAGE("Perform - aDataSet2412.size() = "<NbFaces() = "<NbFaces()); + if(myMesh->NbFaces()){ + SMDS_FaceIteratorPtr anIter = myMesh->facesIterator(); + for(; anIter->more();){ + const SMDS_MeshFace* anElem = anIter->next(); + const TElementLab& aLabel = anElem->GetID(); + int aNbNodes = anElem->NbNodes(); + TRecord aRec; + aRec.node_labels.reserve(aNbNodes); + SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator(); + for(; aNodesIter->more();){ + const SMDS_MeshElement* aNode = aNodesIter->next(); + aRec.node_labels.push_back(aNode->GetID()); + } + switch(aNbNodes){ + case 3: + aRec.fe_descriptor_id = 41; + break; + case 4: + aRec.fe_descriptor_id = 44; + break; + default: + continue; + } + aDataSet2412.insert(TDataSet::value_type(aLabel,aRec)); } - fprintf(myFileId, "%s\n", sUNV_SEPARATOR); - - /**************************************************************************** - * ECRITURE DES ELEMENTS * - ****************************************************************************/ - fprintf(stdout, "\n(**************************)\n"); - fprintf(stdout, "(* ELEMENTS DU MAILLAGE : *)\n"); - fprintf(stdout, "(**************************)"); - /* Ecriture des connectivites, noms, numeros des mailles */ - - fprintf(myFileId, "%s\n", sUNV_SEPARATOR); - fprintf(myFileId, "%s\n", sELT_UNV_ID); - - SMDS_EdgeIteratorPtr itEdges=myMesh->edgesIterator(); - while(itEdges->more()) - { - const SMDS_MeshElement * elem = itEdges->next(); - SMDS_ElemIteratorPtr itn=elem->nodesIterator(); - - switch (elem->NbNodes()) - { - case 2: - fprintf(myFileId, sELT_BEAM_DESC1, elem->GetID(), 21, - elem->NbNodes()); - fprintf(myFileId, sELT_BEAM_DESC2); - fprintf(myFileId, "%10d%10d\n", itn->next()->GetID(), - itn->next()->GetID()); - break; - - case 3: - fprintf(myFileId, sELT_BEAM_DESC1, elem->GetID(), 24, - elem->NbNodes()); - fprintf(myFileId, sELT_BEAM_DESC2); - fprintf(myFileId, "%10d%10d%10d\n", itn->next()->GetID(), - itn->next()->GetID(), itn->next()->GetID()); - - break; - } + MESSAGE("Perform - aDataSet2412.size() = "<NbVolumes() = "<NbVolumes()); + if(myMesh->NbVolumes()){ + SMDS_VolumeIteratorPtr anIter = myMesh->volumesIterator(); + for(; anIter->more();){ + const SMDS_MeshVolume* anElem = anIter->next(); + const TElementLab& aLabel = anElem->GetID(); + int aNbNodes = anElem->NbNodes(); + TRecord aRec; + aRec.node_labels.reserve(aNbNodes); + SMDS_ElemIteratorPtr aNodesIter = anElem->nodesIterator(); + for(; aNodesIter->more();){ + const SMDS_MeshElement* aNode = aNodesIter->next(); + aRec.node_labels.push_back(aNode->GetID()); + } + switch(aNbNodes){ + case 4: + aRec.fe_descriptor_id = 111; + break; + case 6: + aRec.fe_descriptor_id = 112; + swap(aRec.node_labels[1],aRec.node_labels[2]); + swap(aRec.node_labels[4],aRec.node_labels[5]); + break; + case 8: + aRec.fe_descriptor_id = 115; + break; + default: + continue; + } + aDataSet2412.insert(TDataSet::value_type(aLabel,aRec)); } - - SMDS_FaceIteratorPtr itFaces=myMesh->facesIterator(); - while(itFaces->more()) - { - const SMDS_MeshElement * elem = itFaces->next(); - - switch (elem->NbNodes()) - { - case 3: - // linear triangle - fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 74, - elem->NbNodes()); - break; - case 4: - // linear quadrilateral - fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 71, - elem->NbNodes()); - break; - case 6: - // parabolic triangle - fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 72, - elem->NbNodes()); - break; - case 8: - // parabolic quadrilateral - fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 75, - elem->NbNodes()); - break; - default: - fprintf(myFileId, "element not registered\n"); - } - - SMDS_ElemIteratorPtr itn=elem->nodesIterator(); - while(itn->more()) fprintf(myFileId, "%10d", itn->next()->GetID()); - - fprintf(myFileId, "\n"); - } - - SMDS_VolumeIteratorPtr itVolumes=myMesh->volumesIterator(); - while(itVolumes->more()) - { - const SMDS_MeshElement * elem = itVolumes->next(); - - switch (elem->NbNodes()) - { - case 4: - // linear tetrahedron - fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 111, - elem->NbNodes()); - break; - case 6: - // linear tetrahedron - fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 112, - elem->NbNodes()); - break; - case 8: - // linear brick - fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 115, - elem->NbNodes()); - break; - } - - SMDS_ElemIteratorPtr itn=elem->nodesIterator(); - while(itn->more()) fprintf(myFileId, "%10d", itn->next()->GetID()); - - fprintf(myFileId, "\n"); - } - - fprintf(myFileId, "%s\n", sUNV_SEPARATOR); - - fclose(myFileId); + MESSAGE("Perform - aDataSet2412.size() = "< -#include - -#include "SMDS_Mesh.hxx" -#include "Mesh_Writer.h" +#include "Driver_SMDS_Mesh.h" -class DriverUNV_W_SMDS_Mesh:public Mesh_Writer +class DriverUNV_W_SMDS_Mesh: public Driver_SMDS_Mesh { + public: + virtual Status Perform(); +}; - public:DriverUNV_W_SMDS_Mesh(); - ~DriverUNV_W_SMDS_Mesh(); - - void Add(); - void Write(); - void SetMesh(SMDS_Mesh * aMesh); - void SetFile(string); - - void SetFileId(FILE *); - void SetMeshId(int); - - private: SMDS_Mesh * myMesh; - string myFile; - FILE *myFileId; - int myMeshId; -}; #endif diff --git a/src/DriverUNV/DriverUNV_W_SMESHDS_Document.cxx b/src/DriverUNV/DriverUNV_W_SMESHDS_Document.cxx index 97e6d6d21..0e73e1cae 100644 --- a/src/DriverUNV/DriverUNV_W_SMESHDS_Document.cxx +++ b/src/DriverUNV/DriverUNV_W_SMESHDS_Document.cxx @@ -1,83 +1,20 @@ -using namespace std; -#include "DriverUNV_W_SMESHDS_Document.h" -#include "DriverUNV_W_SMESHDS_Mesh.h" - -#include "utilities.h" - -extern "C" -{ - Document_Writer *Wmaker() - { - return new DriverUNV_W_SMESHDS_Document; - } -} - -DriverUNV_W_SMESHDS_Document::DriverUNV_W_SMESHDS_Document() -{ - ; -} - -DriverUNV_W_SMESHDS_Document::~DriverUNV_W_SMESHDS_Document() -{ - ; -} - -//void DriverUNV_W_SMESHDS_Document::SetFile(string aFile) { -//myFile = aFile; -//} - -//void DriverUNV_W_SMESHDS_Document::SetDocument(Handle(SMESHDS_Document)& aDocument) { -//myDocument = aDocument; -//} - -void DriverUNV_W_SMESHDS_Document::Write() -{ - - SMESHDS_Mesh * myMesh; +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org - /**************************************************************************** - * OUVERTURE DU FICHIER EN ECRITURE * - ****************************************************************************/ - char *file2Write = (char *)myFile.c_str(); - FILE *fid = fopen(file2Write, "w+"); - if (fid < 0) - { - fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Write); - exit(EXIT_FAILURE); - } - - /**************************************************************************** - * FERMETURE DU FICHIER * - ****************************************************************************/ - - fclose(fid); - - /******** Nombre de maillages ********/ - int nb_of_meshes = myDocument->NbMeshes(); //voir avec Yves - //nb_of_meshes = 1; - int numero = 0; - - string myClass = string("SMESHDS_Mesh"); - string myExtension = string("UNV"); - - //while (numeroGetMesh(numero); - myDocument->InitMeshesIterator(); - while(myDocument->MoreMesh()) - { - numero++; - myMesh = myDocument->NextMesh(); - - DriverUNV_W_SMESHDS_Mesh *myWriter = new DriverUNV_W_SMESHDS_Mesh; - //Mesh_Writer* myWriter = Driver::GetMeshWriter(myExtension, myClass); - - myWriter->SetMesh(myMesh); - myWriter->SetFile(myFile); - SCRUTE(myMesh); - //myWriter->SetFileId(fid); - myWriter->SetMeshId(numero); - myWriter->Write(); - } - -} +#include "DriverUNV_W_SMESHDS_Document.h" diff --git a/src/DriverUNV/DriverUNV_W_SMESHDS_Document.h b/src/DriverUNV/DriverUNV_W_SMESHDS_Document.h index 7b71287d1..77feb0ede 100644 --- a/src/DriverUNV/DriverUNV_W_SMESHDS_Document.h +++ b/src/DriverUNV/DriverUNV_W_SMESHDS_Document.h @@ -1,25 +1,28 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + #ifndef _INCLUDE_DRIVERUNV_W_SMESHDS_DOCUMENT #define _INCLUDE_DRIVERUNV_W_SMESHDS_DOCUMENT -#include -#include - -#include "SMESHDS_Document.hxx" -#include "Document_Writer.h" - -class DriverUNV_W_SMESHDS_Document : public Document_Writer { - -public : - DriverUNV_W_SMESHDS_Document(); - ~DriverUNV_W_SMESHDS_Document(); - - void Write(); - //void SetFile(string); - //void SetDocument(Handle(SMESHDS_Document)&); +#include "Driver_Document.h" -private : - //Handle_SMESHDS_Document myDocument; - //string myFile; +class DriverUNV_W_SMESHDS_Document : public Driver_Document +{}; -}; #endif diff --git a/src/DriverUNV/DriverUNV_W_SMESHDS_Mesh.cxx b/src/DriverUNV/DriverUNV_W_SMESHDS_Mesh.cxx index 905eed9ca..2cbfe4dc9 100644 --- a/src/DriverUNV/DriverUNV_W_SMESHDS_Mesh.cxx +++ b/src/DriverUNV/DriverUNV_W_SMESHDS_Mesh.cxx @@ -1,232 +1,20 @@ -using namespace std; -#include "DriverUNV_W_SMESHDS_Mesh.h" -#include "DriverUNV_W_SMDS_Mesh.h" - -#include "SMDS_MeshElement.hxx" -#include "SMDS_MeshNode.hxx" - - - - - -#include "utilities.h" - -#define sNODE_UNV_ID " 2411" -#define sELT_UNV_ID " 2412" -#define sUNV_SEPARATOR " -1" -#define sNODE_UNV_DESCR "%10d 1 1 11\n" -#define sELT_SURF_DESC "%10d %2d 1 1 11 %1d\n" -#define sELT_VOLU_DESC "%10d %2d 1 1 9 %1d\n" -#define sELT_BEAM_DESC1 "%10d %2d 1 1 7 %1d\n" -#define sELT_BEAM_DESC2 " 0 1 1\n" - -DriverUNV_W_SMESHDS_Mesh::DriverUNV_W_SMESHDS_Mesh() -{ - ; -} - -DriverUNV_W_SMESHDS_Mesh::~DriverUNV_W_SMESHDS_Mesh() -{ - ; -} - -void DriverUNV_W_SMESHDS_Mesh::SetMesh(SMDS_Mesh * aMesh) -{ - //myMesh = SMESHDS_Mesh *::DownCast(aMesh); - myMesh = aMesh; -} - -void DriverUNV_W_SMESHDS_Mesh::SetFile(string aFile) -{ - myFile = aFile; -} - -void DriverUNV_W_SMESHDS_Mesh::SetFileId(FILE * aFileId) -{ - myFileId = aFileId; -} - -void DriverUNV_W_SMESHDS_Mesh::SetMeshId(int aMeshId) -{ - myMeshId = aMeshId; -} - -void DriverUNV_W_SMESHDS_Mesh::Write() -{ - - string myClass = string("SMDS_Mesh"); - string myExtension = string("UNV"); - - DriverUNV_W_SMDS_Mesh *myWriter = new DriverUNV_W_SMDS_Mesh; - - myWriter->SetMesh(myMesh); - myWriter->SetFile(myFile); - myWriter->SetMeshId(myMeshId); - //myWriter->SetFileId(myFileId); - - myWriter->Write(); - -} - -void DriverUNV_W_SMESHDS_Mesh::Add() -{ - int nbNodes, nbCells; - int i; - - char *file2Read = (char *)myFile.c_str(); - myFileId = fopen(file2Read, "w+"); - if (myFileId < 0) - { - fprintf(stderr, ">> ERREUR : ouverture du fichier %s \n", file2Read); - exit(EXIT_FAILURE); - } - - /**************************************************************************** - * NOMBRES D'OBJETS * - ****************************************************************************/ - fprintf(stdout, "\n(****************************)\n"); - fprintf(stdout, "(* INFORMATIONS GENERALES : *)\n"); - fprintf(stdout, "(****************************)\n"); +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org - /* Combien de noeuds ? */ - nbNodes = myMesh->NbNodes(); - - /* Combien de mailles, faces ou aretes ? */ - int nb_of_nodes, nb_of_edges, nb_of_faces, nb_of_volumes; - nb_of_edges = myMesh->NbEdges(); - nb_of_faces = myMesh->NbFaces(); - nb_of_volumes = myMesh->NbVolumes(); - nbCells = nb_of_edges + nb_of_faces + nb_of_volumes; - - fprintf(stdout, "%d %d\n", nbNodes, nbCells); -//fprintf(myFileId,"%d %d\n",nbNodes,nbCells); - - /**************************************************************************** - * ECRITURE DES NOEUDS * - ****************************************************************************/ - fprintf(stdout, "\n(************************)\n"); - fprintf(stdout, "(* NOEUDS DU MAILLAGE : *)\n"); - fprintf(stdout, "(************************)\n"); - - - fprintf(myFileId, "%s\n", sUNV_SEPARATOR); - fprintf(myFileId, "%s\n", sNODE_UNV_ID); - - SMDS_NodeIteratorPtr itNodes=myMesh->nodesIterator(); - while(itNodes->more()) - { - const SMDS_MeshNode * node = itNodes->next(); - - fprintf(myFileId, sNODE_UNV_DESCR, node->GetID()); - fprintf(myFileId, "%25.16E%25.16E%25.16E\n", node->X(), node->Y(), - node->Z()); - } - fprintf(myFileId, "%s\n", sUNV_SEPARATOR); - - /**************************************************************************** - * ECRITURE DES ELEMENTS * - ****************************************************************************/ - fprintf(stdout, "\n(**************************)\n"); - fprintf(stdout, "(* ELEMENTS DU MAILLAGE : *)\n"); - fprintf(stdout, "(**************************)"); - /* Ecriture des connectivites, noms, numeros des mailles */ - - fprintf(myFileId, "%s\n", sUNV_SEPARATOR); - fprintf(myFileId, "%s\n", sELT_UNV_ID); - - SMDS_EdgeIteratorPtr itEdges=myMesh->edgesIterator(); - while(itEdges->more()) - { - const SMDS_MeshEdge * elem = itEdges->next(); - SMDS_ElemIteratorPtr itn=elem->nodesIterator(); - - switch (elem->NbNodes()) - { - case 2: - fprintf(myFileId, sELT_BEAM_DESC1, elem->GetID(), 21, - elem->NbNodes()); - fprintf(myFileId, sELT_BEAM_DESC2); - fprintf(myFileId, "%10d%10d\n", itn->next()->GetID(), - itn->next()->GetID()); - break; - - case 3: - fprintf(myFileId, sELT_BEAM_DESC1, elem->GetID(), 24, - elem->NbNodes()); - fprintf(myFileId, sELT_BEAM_DESC2); - fprintf(myFileId, "%10d%10d%10d\n", itn->next()->GetID(), - itn->next()->GetID(), itn->next()->GetID()); - break; - } - } - - SMDS_FaceIteratorPtr itFaces=myMesh->facesIterator(); - while(itFaces->more()) - { - const SMDS_MeshElement * elem = itFaces->next(); - - switch (elem->NbNodes()) - { - case 3: - // linear triangle - fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 74, - elem->NbNodes()); - break; - case 4: - // linear quadrilateral - fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 71, - elem->NbNodes()); - break; - case 6: - // parabolic triangle - fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 72, - elem->NbNodes()); - break; - case 8: - // parabolic quadrilateral - fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 75, - elem->NbNodes()); - break; - default: - fprintf(myFileId, "element not registered\n"); - } - - SMDS_ElemIteratorPtr itn=elem->nodesIterator(); - while(itn->more()) fprintf(myFileId, "%10d", itn->next()->GetID()); - - fprintf(myFileId, "\n"); - } - - SMDS_VolumeIteratorPtr itVolumes=myMesh->volumesIterator(); - while(itVolumes->more()) - { - const SMDS_MeshElement * elem = itVolumes->next(); - - switch (elem->NbNodes()) - { - case 4: - // linear tetrahedron - fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 111, - elem->NbNodes()); - break; - case 6: - // linear tetrahedron - fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 112, - elem->NbNodes()); - break; - case 8: - // linear brick - fprintf(myFileId, sELT_SURF_DESC, elem->GetID(), 115, - elem->NbNodes()); - break; - } - - SMDS_ElemIteratorPtr itn=elem->nodesIterator(); - while(itn->more()) fprintf(myFileId, "%10d", itn->next()->GetID()); - - fprintf(myFileId, "\n"); - } - fprintf(myFileId, "%s\n", sUNV_SEPARATOR); - - fclose(myFileId); -} +#include "DriverUNV_W_SMESHDS_Mesh.h" diff --git a/src/DriverUNV/DriverUNV_W_SMESHDS_Mesh.h b/src/DriverUNV/DriverUNV_W_SMESHDS_Mesh.h index d0b2c84e9..8bc728451 100644 --- a/src/DriverUNV/DriverUNV_W_SMESHDS_Mesh.h +++ b/src/DriverUNV/DriverUNV_W_SMESHDS_Mesh.h @@ -1,30 +1,28 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + #ifndef _INCLUDE_DRIVERUNV_W_SMESHDS_MESH #define _INCLUDE_DRIVERUNV_W_SMESHDS_MESH -#include -#include - -#include "SMESHDS_Mesh.hxx" -#include "Mesh_Writer.h" - -class DriverUNV_W_SMESHDS_Mesh:public Mesh_Writer -{ - - public:DriverUNV_W_SMESHDS_Mesh(); - ~DriverUNV_W_SMESHDS_Mesh(); - - void Add(); - void Write(); - void SetMesh(SMDS_Mesh * aMesh); - void SetFile(string); - - void SetFileId(FILE *); - void SetMeshId(int); +#include "Driver_SMESHDS_Mesh.h" - private: SMDS_Mesh * myMesh; - string myFile; - FILE *myFileId; - int myMeshId; +class DriverUNV_W_SMESHDS_Mesh: public Driver_SMESHDS_Mesh +{}; -}; #endif diff --git a/src/DriverUNV/Makefile.in b/src/DriverUNV/Makefile.in index 038ab87f1..8d6bac47e 100644 --- a/src/DriverUNV/Makefile.in +++ b/src/DriverUNV/Makefile.in @@ -35,8 +35,12 @@ VPATH=.:@srcdir@ @COMMENCE@ # header files -EXPORT_HEADERS= DriverUNV_R_SMDS_Mesh.h DriverUNV_R_SMESHDS_Mesh.h DriverUNV_R_SMESHDS_Document.h \ - DriverUNV_W_SMDS_Mesh.h DriverUNV_W_SMESHDS_Mesh.h DriverUNV_W_SMESHDS_Document.h +EXPORT_HEADERS= DriverUNV_R_SMDS_Mesh.h \ + DriverUNV_R_SMESHDS_Mesh.h \ + DriverUNV_R_SMESHDS_Document.h \ + DriverUNV_W_SMDS_Mesh.h \ + DriverUNV_W_SMESHDS_Mesh.h \ + DriverUNV_W_SMESHDS_Document.h # Libraries targets LIB = libMeshDriverUNV.la @@ -46,19 +50,22 @@ LIB_SRC = \ DriverUNV_R_SMESHDS_Document.cxx \ DriverUNV_W_SMESHDS_Document.cxx \ DriverUNV_W_SMDS_Mesh.cxx \ - DriverUNV_W_SMESHDS_Mesh.cxx + DriverUNV_W_SMESHDS_Mesh.cxx \ + UNV_Utilities.cxx UNV2411_Structure.cxx UNV2412_Structure.cxx + +# Executables targets +BIN = UNV_Test LIB_CLIENT_IDL = LIB_SERVER_IDL = # additionnal information to compil and link file -CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS) -CXXFLAGS += $(OCC_CXXFLAGS) $(MED2_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -LDFLAGS += $(MED2_LIBS) -lMeshDriver +CPPFLAGS += -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS) +CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome +LDFLAGS += -lMeshDriver -%_moc.cxx: %.h - $(MOC) $< -o $@ +LDFLAGSFORBIN += -lMeshDriver -lSMDS -L${KERNEL_ROOT_DIR}/lib/salome -lOpUtil -lSALOMELocalTrace @CONCLUDE@ diff --git a/src/DriverUNV/UNV2411_Structure.cxx b/src/DriverUNV/UNV2411_Structure.cxx new file mode 100644 index 000000000..9b78920fc --- /dev/null +++ b/src/DriverUNV/UNV2411_Structure.cxx @@ -0,0 +1,124 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include +#include + +#include "UNV2411_Structure.hxx" +#include "UNV_Utilities.hxx" + +using namespace std; +using namespace UNV; +using namespace UNV2411; + +#ifdef _DEBUG_ +static int MYDEBUG = 1; +#else +static int MYDEBUG = 0; +#endif + +static string _label_dataset = "2411"; + +UNV2411::TRecord::TRecord(): + exp_coord_sys_num(0), + disp_coord_sys_num(0), + color(0) +{} + +void UNV2411::Read(std::ifstream& in_stream, TDataSet& theDataSet) +{ + if(!in_stream.good()) + EXCEPTION(runtime_error,"ERROR: Input file not good."); + + /* + * adjust the \p istream to our + * position + */ + if(!beginning_of_dataset(in_stream,_label_dataset)) + EXCEPTION(runtime_error,"ERROR: Could not find "<<_label_dataset<<" dataset!"); + + /** + * always 3 coordinates in the UNV file, no matter + * which dimensionality libMesh is in + */ + TNodeLab aLabel; + std::string num_buf; + for(; !in_stream.eof();){ + in_stream >> aLabel ; + if(aLabel == -1){ + // end of dataset is reached + break; + } + + TRecord aRec; + in_stream>>aRec.exp_coord_sys_num; + in_stream>>aRec.disp_coord_sys_num; + in_stream>>aRec.color; + + /* + * take care of the + * floating-point data + */ + for(int d = 0; d < 3; d++){ + in_stream>>num_buf; + aRec.coord[d] = D_to_e(num_buf); + } + + theDataSet.insert(TDataSet::value_type(aLabel,aRec)); + } +} + + +void UNV2411::Write(std::ofstream& out_stream, const TDataSet& theDataSet) +{ + if(!out_stream.good()) + EXCEPTION(runtime_error,"ERROR: Output file not good."); + + /* + * Write beginning of dataset + */ + out_stream<<" -1\n"; + out_stream<<" "<<_label_dataset<<"\n"; + + TDataSet::const_iterator anIter = theDataSet.begin(); + for(; anIter != theDataSet.end(); anIter++){ + const TNodeLab& aLabel = anIter->first; + const TRecord& aRec = anIter->second; + char buf[78]; + sprintf(buf, "%10d%10d%10d%10d\n", + aLabel, + aRec.exp_coord_sys_num, + aRec.disp_coord_sys_num, + aRec.color); + out_stream< +#include -class SMESHDriver { +namespace UNV2411{ + + struct TRecord{ + TRecord(); + int exp_coord_sys_num; // export coordinate system number + int disp_coord_sys_num; // displacement coordinate system number + int color; // color + double coord[3]; // node coordinates in the part coordinate system + }; + + typedef int TNodeLab; // type of node label + typedef std::map TDataSet; - public : - static Document_Reader* GetDocumentReader(string Extension, string Class); - static Document_Writer* GetDocumentWriter(string Extension, string Class); + void Read(std::ifstream& in_stream, TDataSet& theDataSet); - static Mesh_Reader* GetMeshReader(string Extension, string Class); - static Mesh_Writer* GetMeshWriter(string Extension, string Class); + void Write(std::ofstream& out_stream, const TDataSet& theDataSet); }; + + #endif diff --git a/src/DriverUNV/UNV2412_Structure.cxx b/src/DriverUNV/UNV2412_Structure.cxx new file mode 100644 index 000000000..0160d7b68 --- /dev/null +++ b/src/DriverUNV/UNV2412_Structure.cxx @@ -0,0 +1,203 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include +#include + +#include "UNV2412_Structure.hxx" +#include "UNV_Utilities.hxx" + +using namespace std; +using namespace UNV; +using namespace UNV2412; + +#ifdef _DEBUG_ +static int MYDEBUG = 1; +#else +static int MYDEBUG = 0; +#endif + +static string _label_dataset = "2412"; + +UNV2412::TRecord::TRecord(): + phys_prop_tab_num(2), + mat_prop_tab_num(1), + color(7), + beam_orientation(0), + beam_fore_end(0), + beam_aft_end(0) +{} + +void UNV2412::Read(std::ifstream& in_stream, TDataSet& theDataSet) +{ + if(!in_stream.good()) + EXCEPTION(runtime_error,"ERROR: Input file not good."); + + /* + * adjust the \p istream to our + * position + */ + if(!beginning_of_dataset(in_stream,_label_dataset)) + EXCEPTION(runtime_error,"ERROR: Could not find "<<_label_dataset<<" dataset!"); + + TElementLab aLabel; + for(; !in_stream.eof();){ + in_stream >> aLabel ; + if(aLabel == -1){ + // end of dataset is reached + break; + } + + int n_nodes; + TRecord aRec; + in_stream>>aRec.fe_descriptor_id; + in_stream>>aRec.phys_prop_tab_num; + in_stream>>aRec.mat_prop_tab_num; + in_stream>>aRec.color; + in_stream>>n_nodes; + + if(IsBeam(aRec.fe_descriptor_id)){ + in_stream>>aRec.beam_orientation; + in_stream>>aRec.beam_fore_end; + in_stream>>aRec.beam_aft_end; + } + + aRec.node_labels.resize(n_nodes); + for(int j=0; j < n_nodes; j++){ + // read node labels + in_stream>>aRec.node_labels[j]; + } + + theDataSet.insert(TDataSet::value_type(aLabel,aRec)); + } + +} + + +void UNV2412::Write(std::ofstream& out_stream, const TDataSet& theDataSet) +{ + if(!out_stream.good()) + EXCEPTION(runtime_error,"ERROR: Output file not good."); + + /* + * Write beginning of dataset + */ + out_stream<<" -1\n"; + out_stream<<" "<<_label_dataset<<"\n"; + + TDataSet::const_iterator anIter = theDataSet.begin(); + for(; anIter != theDataSet.end(); anIter++){ + const TElementLab& aLabel = anIter->first; + const TRecord& aRec = anIter->second; + out_stream< +#include +#include + + +namespace UNV2412{ + + typedef std::vector TNodeLabels; // Nodal connectivities + + struct TRecord{ + TRecord(); + + int fe_descriptor_id; // FE descriptor id + int phys_prop_tab_num; // physical property table number + int mat_prop_tab_num; // material property table number + int color; // color + TNodeLabels node_labels; // node labels defining element + + //FOR BEAM ELEMENTS ONLY + int beam_orientation; // beam orientation node number + int beam_fore_end; // beam fore-end cross section number + int beam_aft_end; // beam aft-end cross section number + }; + + typedef int TElementLab; // type of element label + typedef std::map TDataSet; + + void Read(std::ifstream& in_stream, TDataSet& theDataSet); + + void Write(std::ofstream& out_stream, const TDataSet& theDataSet); + + bool IsBeam(int theFeDescriptorId); + bool IsFace(int theFeDescriptorId); + bool IsVolume(int theFeDescriptorId); + +}; + + +#endif diff --git a/src/DriverUNV/UNV_Test.cxx b/src/DriverUNV/UNV_Test.cxx new file mode 100644 index 000000000..0156b5051 --- /dev/null +++ b/src/DriverUNV/UNV_Test.cxx @@ -0,0 +1,69 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include "UNV2411_Structure.hxx" +#include "UNV2412_Structure.hxx" +#include "UNV_Utilities.hxx" + +#include "DriverUNV_R_SMDS_Mesh.h" +#include "DriverUNV_W_SMDS_Mesh.h" + +using namespace std; + +#ifdef DEBUG +static int MYDEBUG = 1; +#else +static int MYDEBUG = 0; +#endif + + +void ReadMed(const char* theFileName){ + std::ifstream in_stream(theFileName); + + UNV2411::TDataSet aDataSet2411; + UNV2411::Read(in_stream,aDataSet2411); + + in_stream.seekg(0); + UNV2412::TDataSet aDataSet2412; + UNV2412::Read(in_stream,aDataSet2412); + + string aFileName(theFileName); + aFileName += "-"; + std::ofstream out_stream(aFileName.c_str()); + + UNV2411::Write(out_stream,aDataSet2411); + UNV2412::Write(out_stream,aDataSet2412); +} + + +int main(int argc, char** argv){ + DriverUNV_R_SMDS_Mesh aR; + DriverUNV_W_SMDS_Mesh aW; + try{ + if(argc > 1){ + ReadMed(argv[1]); + } + return 0; + }catch(std::exception& exc){ + MESSAGE("Follow exception was accured :\n"< +#include +#include +#include + + +namespace UNV{ + using namespace std; + + class PrefixPrinter{ + static int myCounter; + public: + PrefixPrinter(); + ~PrefixPrinter(); + + static string GetPrefix(); + }; + + /** + * @returns \p false when error occured, \p true otherwise. + * Adjusts the \p in_stream to the beginning of the + * dataset \p ds_name. + */ + inline bool beginning_of_dataset(std::istream& in_file, const std::string& ds_name) + { + assert (in_file.good()); + assert (!ds_name.empty()); + + std::string olds, news; + + while(true){ + in_file >> olds >> news; + /* + * a "-1" followed by a number means the beginning of a dataset + * stop combing at the end of the file + */ + while( ((olds != "-1") || (news == "-1") ) && !in_file.eof() ){ + olds = news; + in_file >> news; + } + if(in_file.eof()) + return false; + if (news == ds_name) + return true; + } + // should never end up here + return false; + } + + /** + * Method for converting exponential notation + * from "D" to "e", for example + * \p 3.141592654D+00 \p --> \p 3.141592654e+00 + * in order to make it readable for C++. + */ + inline double D_to_e(std::string& number) + { + /* find "D" in string, start looking at + * 6th element, to improve speed. + * We dont expect a "D" earlier + */ + const int position = number.find("D",6); + if(position != std::string::npos){ + number.replace(position, 1, "e"); + } + return atof (number.c_str()); + } + +}; + + +#ifndef MESSAGE + +#define MESSAGE(msg) std::cout<<__FILE__<<"["<<__LINE__<<"]::"< #include -using namespace std; template inline T Abs (const T &a){return a <0 ? -a : a;} template inline void Echange (T& a,T& b) {T c=a;a=b;b=c;} @@ -81,14 +80,14 @@ typedef double R; //============ class R2 { - friend ostream& operator << (ostream& f, const R2 & P) + friend std::ostream& operator << (std::ostream& f, const R2 & P) { f << P.x << ' ' << P.y ; return f; } - friend istream& operator >> (istream& f, R2 & P) + friend std::istream& operator >> (std::istream& f, R2 & P) { f >> P.x >> P.y ; return f; } - friend ostream& operator << (ostream& f, const R2 * P) + friend std::ostream& operator << (std::ostream& f, const R2 * P) { f << P->x << ' ' << P->y ; return f; } - friend istream& operator >> (istream& f, R2 * P) + friend std::istream& operator >> (std::istream& f, R2 * P) { f >> P->x >> P->y ; return f; } public: @@ -120,14 +119,14 @@ public: //============ class R3 { - friend ostream& operator << (ostream& f, const R3 & P) + friend std::ostream& operator << (std::ostream& f, const R3 & P) { f << P.x << ' ' << P.y << ' ' << P.z ; return f; } - friend istream& operator >> (istream& f, R3 & P) + friend std::istream& operator >> (std::istream& f, R3 & P) { f >> P.x >> P.y >> P.z ; return f; } - friend ostream& operator << (ostream& f, const R3 * P) + friend std::ostream& operator << (std::ostream& f, const R3 * P) { f << P->x << ' ' << P->y << ' ' << P->z ; return f; } - friend istream& operator >> (istream& f, R3 * P) + friend std::istream& operator >> (std::istream& f, R3 * P) { f >> P->x >> P->y >> P->z ; return f; } public: @@ -173,12 +172,12 @@ public: //============ class R4: public R3 { - friend ostream& operator <<(ostream& f, const R4 & P ) + friend std::ostream& operator <<(std::ostream& f, const R4 & P ) { f << P.x << ' ' << P.y << ' ' << P.z << ' ' << P.omega; return f; } friend istream& operator >>(istream& f, R4 & P) { f >> P.x >> P.y >> P.z >> P.omega ; return f; } - friend ostream& operator <<(ostream& f, const R4 * P ) + friend std::ostream& operator <<(std::ostream& f, const R4 * P ) { f << P->x << ' ' << P->y << ' ' << P->z << ' ' << P->omega; return f; } friend istream& operator >>(istream& f, R4 * P) { f >> P->x >> P->y >> P->z >> P->omega ; return f; } diff --git a/src/MEFISTO2/aptrte.cxx b/src/MEFISTO2/aptrte.cxx index bb597b6e4..40c090523 100755 --- a/src/MEFISTO2/aptrte.cxx +++ b/src/MEFISTO2/aptrte.cxx @@ -23,11 +23,12 @@ // Module : SMESH // Author: Alain PERRONNET -using namespace std; #include "Rn.h" #include "aptrte.h" #include "utilities.h" +using namespace std; + extern "C" { R aretemaxface_; @@ -223,8 +224,8 @@ void aptrte( Z nutysu, R aretmx, mnpxyd[ns0].x = uvslf[ns0].x; mnpxyd[ns0].y = uvslf[ns0].y; mnpxyd[ns0].z = areteideale_( mnpxyd[ns0], direction ); -// cout << "Sommet " << ns0 << ": " << mnpxyd[ns0].x -// << " " << mnpxyd[ns0].y << " longueur arete=" << mnpxyd[ns0].z << endl; +// MESSAGE("Sommet " << ns0 << ": " << mnpxyd[ns0].x +// << " " << mnpxyd[ns0].y << " longueur arete=" << mnpxyd[ns0].z); //carre de la longueur de l'arete 1 de la ligne fermee n d = pow( uvslf[ns0+1].x - uvslf[ns0].x, 2 ) @@ -275,8 +276,8 @@ void aptrte( Z nutysu, R aretmx, mnpxyd[ns].x = uvslf[ns].x; mnpxyd[ns].y = uvslf[ns].y; mnpxyd[ns].z = areteideale_( mnpxyd[ns], direction ); -// cout << "Sommet " << ns << ": " << mnpxyd[ns].x -// << " " << mnpxyd[ns].y << " longueur arete=" << mnpxyd[ns].z << endl; +// MESSAGE("Sommet " << ns << ": " << mnpxyd[ns].x +// << " " << mnpxyd[ns].y << " longueur arete=" << mnpxyd[ns].z); //carre de la longueur de l'arete d = pow( uvslf[ns2-1].x - uvslf[ns1-1].x, 2) @@ -308,8 +309,8 @@ void aptrte( Z nutysu, R aretmx, aremax = sqrt( aremax ); //longueur maximale d'une arete aretmx = Min( aretmx, aremax ); //pour homogeneiser - cout << "nutysu=" << nutysu << " aretmx=" << aretmx - << " arete min=" << aremin << " arete max=" << aremax << endl; + MESSAGE("nutysu=" << nutysu << " aretmx=" << aretmx + << " arete min=" << aremin << " arete max=" << aremax); //chainage des aretes frontalieres : la derniere arete frontaliere mnsoar[ mosoar * noar - mosoar + 5 ] = 0; @@ -391,8 +392,8 @@ void aptrte( Z nutysu, R aretmx, deltacpu_( d ); tcpu += d; - cout << "Temps de l'adaptation et l'homogeneisation de l'arbre-4 des TE=" - << d << " secondes" << endl; + MESSAGE("Temps de l'adaptation et l'homogeneisation de l'arbre-4 des TE=" + << d << " secondes"); if( ierr != 0 ) { //destruction du tableau auxiliaire et de l'arbre @@ -448,8 +449,8 @@ void aptrte( Z nutysu, R aretmx, MESSAGE( "Nombre d'echanges des diagonales de 2 triangles=" << n ); deltacpu_( d ); tcpu += d; - cout << "Temps de la triangulation Delaunay par echange des diagonales=" - << d << " secondes" << endl; + MESSAGE("Temps de la triangulation Delaunay par echange des diagonales=" + << d << " secondes"); //qualites de la triangulation actuelle qualitetrte( mnpxyd, mosoar, mxsoar, mnsoar, moartr, mxartr, mnartr, @@ -481,8 +482,8 @@ void aptrte( Z nutysu, R aretmx, MESSAGE( "Restauration de " << n << " aretes perdues de la frontiere" ); deltacpu_( d ); tcpu += d; - cout << "Temps de la recuperation des aretes perdues de la frontiere=" - << d << " secondes" << endl; + MESSAGE("Temps de la recuperation des aretes perdues de la frontiere=" + << d << " secondes"); if( ierr != 0 ) goto ERREUR; @@ -648,8 +649,8 @@ void aptrte( Z nutysu, R aretmx, } } nbt /= 4; //le nombre final de triangles de la surface - cout << "Nombre de sommets=" << nbst - << " Nombre de triangles=" << nbt << endl; + MESSAGE("Nombre de sommets=" << nbst + << " Nombre de triangles=" << nbt); deltacpu_( d ); tcpu += d; @@ -762,9 +763,9 @@ void qualitetrte( R3 *mnpxyd, { //un triangle d'aire negative de plus nbtrianeg++; - cout << "ATTENTION: le triangle " << nt << " de sommets:" + MESSAGE("ATTENTION: le triangle " << nt << " de sommets:" << nosotr[0] << " " << nosotr[1] << " " << nosotr[2] - << " a une aire " << d <<"<=0" << endl; + << " a une aire " << d <<"<=0"); } //aire des triangles actuels @@ -774,10 +775,10 @@ void qualitetrte( R3 *mnpxyd, //les affichages quamoy /= nbtria; - cout << "Qualite moyenne=" << quamoy + MESSAGE("Qualite moyenne=" << quamoy << " Qualite minimale=" << quamin << " des " << nbtria << " triangles de surface totale=" - << aire << endl; + << aire); if( nbtrianeg>0 ) MESSAGE( "ATTENTION: nombre de triangles d'aire negative=" << nbtrianeg ); diff --git a/src/Makefile.in b/src/Makefile.in index 0527a7abe..c4bbfd85f 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -32,7 +32,7 @@ VPATH=.:@srcdir@ @COMMENCE@ SUBDIRS = \ - SMDS SMESHDS Driver DriverMED DriverDAT DriverUNV \ + SMDS SMESHDS Controls Driver DriverMED DriverDAT DriverUNV DriverSTL \ SMESH SMESH_I OBJECT SMESHFiltersSelection SMESHGUI SMESH_SWIG \ MEFISTO2 StdMeshers StdMeshers_I StdMeshersGUI diff --git a/src/OBJECT/Makefile.in b/src/OBJECT/Makefile.in index ac9be864c..46b6224af 100644 --- a/src/OBJECT/Makefile.in +++ b/src/OBJECT/Makefile.in @@ -31,18 +31,18 @@ VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl @COMMENCE@ -EXPORT_HEADERS = SMESH_Actor.h SMESH_Object.h +EXPORT_HEADERS = SMESH_Actor.h SMESH_Object.h SMESH_ActorUtils.h # Libraries targets LIB = libSMESHObject.la -LIB_SRC = SMESH_Object.cxx SMESH_DeviceActor.cxx SMESH_Actor.cxx +LIB_SRC = SMESH_Object.cxx SMESH_DeviceActor.cxx SMESH_Actor.cxx \ + SMESH_ExtractGeometry.cxx SMESH_ActorUtils.cxx LIB_CLIENT_IDL = SALOME_Exception.idl \ SALOME_GenericObj.idl \ SMESH_Mesh.idl \ - SMESH_Filter.idl \ SMESH_Group.idl @@ -53,6 +53,6 @@ BIN_SRC = CPPFLAGS+=$(OCC_INCLUDES) $(VTK_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome \ $(BOOST_CPPFLAGS) $(QT_INCLUDES) LDFLAGS+=$(OCC_KERNEL_LIBS) $(VTK_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome -lSMDS \ - -lSalomeGUI -lSalomeObject -lOpUtil + -lSalomeGUI -lSalomeObject -lSMESHControls @CONCLUDE@ diff --git a/src/OBJECT/SMESH_Actor.cxx b/src/OBJECT/SMESH_Actor.cxx index 29a1f094b..5d80d26fa 100644 --- a/src/OBJECT/SMESH_Actor.cxx +++ b/src/OBJECT/SMESH_Actor.cxx @@ -28,6 +28,7 @@ #include "SMESH_Actor.h" +#include "SMESH_ActorUtils.h" #include "SMESH_DeviceActor.h" #include "SALOME_ExtractUnstructuredGrid.h" @@ -35,11 +36,25 @@ #include "utilities.h" #include +#include #include #include #include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include + #include +#include #include #include #include @@ -49,25 +64,21 @@ #include #include -#include + +#include +#include +#include #ifdef _DEBUG_ -static int MYDEBUG = 1; +static int MYDEBUG = 0; static int MYDEBUGWITHFILES = 0; #else static int MYDEBUG = 0; static int MYDEBUGWITHFILES = 0; #endif -using namespace std; - - -inline float GetFloat(const QString& theValue, float theDefault = 0){ - if(theValue.isEmpty()) return theDefault; - QString aValue = QAD_CONFIG->getSetting(theValue); - if(aValue.isEmpty()) return theDefault; - return aValue.toFloat(); -} +static int aLineWidthInc = 2; +static int aPointSizeInc = 2; SMESH_Actor* SMESH_Actor::New(){ @@ -76,13 +87,15 @@ SMESH_Actor* SMESH_Actor::New(){ SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj, - SMESH::FilterManager_ptr theFilterMgr, const char* theEntry, const char* theName, int theIsClear) { SMESH_Actor* anActor = SMESH_Actor::New(); - anActor->Init(theVisualObj,theFilterMgr,theEntry,theName,theIsClear); + if(!anActor->Init(theVisualObj,theEntry,theName,theIsClear)){ + anActor->Delete(); + anActor = NULL; + } return anActor; } @@ -90,13 +103,17 @@ SMESH_Actor* SMESH_Actor::New(TVisualObjPtr theVisualObj, SMESH_Actor::SMESH_Actor(){ if(MYDEBUG) MESSAGE("SMESH_Actor"); + myTimeStamp = vtkTimeStamp::New(); + myIsPointsVisible = false; myIsShrinkable = false; myIsShrunk = false; - float aPointSize = GetFloat("SMESH:SettingsNodesSize",3); - float aLineWidth = GetFloat("SMESH:SettingsWidth",1); + myControlsPrecision = (long)SMESH::GetFloat( "SMESH:ControlsPrecision", -1 ); + + float aPointSize = SMESH::GetFloat("SMESH:SettingsNodesSize",3); + float aLineWidth = SMESH::GetFloat("SMESH:SettingsWidth",1); vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New(); SALOME_ExtractUnstructuredGrid* aFilter = NULL; @@ -105,15 +122,15 @@ SMESH_Actor::SMESH_Actor(){ //----------------------------------------- float anRGB[3] = {1,1,1}; mySurfaceProp = vtkProperty::New(); - anRGB[0] = GetFloat("SMESH:SettingsFillColorRed", 0)/255.; - anRGB[1] = GetFloat("SMESH:SettingsFillColorGreen", 170)/255.; - anRGB[2] = GetFloat("SMESH:SettingsFillColorBlue", 255)/255.; + anRGB[0] = SMESH::GetFloat("SMESH:SettingsFillColorRed", 0)/255.; + anRGB[1] = SMESH::GetFloat("SMESH:SettingsFillColorGreen", 170)/255.; + anRGB[2] = SMESH::GetFloat("SMESH:SettingsFillColorBlue", 255)/255.; mySurfaceProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); myBackSurfaceProp = vtkProperty::New(); - anRGB[0] = GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.; - anRGB[1] = GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.; - anRGB[2] = GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.; + anRGB[0] = SMESH::GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.; + anRGB[1] = SMESH::GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.; + anRGB[2] = SMESH::GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.; myBackSurfaceProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); my2DActor = SMESH_DeviceActor::New(); @@ -151,9 +168,9 @@ SMESH_Actor::SMESH_Actor(){ myEdgeProp->SetAmbient(1.0); myEdgeProp->SetDiffuse(0.0); myEdgeProp->SetSpecular(0.0); - anRGB[0] = GetFloat("SMESH:SettingsOutlineColorRed", 0)/255.; - anRGB[1] = GetFloat("SMESH:SettingsOutlineColorGreen", 170)/255.; - anRGB[2] = GetFloat("SMESH:SettingsOutlineColorBlue", 255)/255.; + anRGB[0] = SMESH::GetFloat("SMESH:SettingsOutlineColorRed", 0)/255.; + anRGB[1] = SMESH::GetFloat("SMESH:SettingsOutlineColorGreen", 170)/255.; + anRGB[2] = SMESH::GetFloat("SMESH:SettingsOutlineColorBlue", 255)/255.; myEdgeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); myEdgeProp->SetLineWidth(aLineWidth); @@ -161,6 +178,7 @@ SMESH_Actor::SMESH_Actor(){ my1DActor->SetUserMatrix(aMatrix); my1DActor->SetStoreMapping(true); my1DActor->PickableOff(); + my1DActor->SetHighlited(true); my1DActor->SetProperty(myEdgeProp); my1DActor->SetRepresentation(SMESH_DeviceActor::eSurface); aFilter = my1DActor->GetExtractUnstructuredGrid(); @@ -169,8 +187,7 @@ SMESH_Actor::SMESH_Actor(){ my1DProp = vtkProperty::New(); my1DProp->DeepCopy(myEdgeProp); - static int aCotnrolLineWidth = 3; - my1DProp->SetLineWidth(aCotnrolLineWidth); + my1DProp->SetLineWidth(aLineWidth + aLineWidthInc); my1DProp->SetPointSize(aPointSize); my1DExtProp = vtkProperty::New(); @@ -179,12 +196,14 @@ SMESH_Actor::SMESH_Actor(){ anRGB[1] = 1 - anRGB[1]; anRGB[2] = 1 - anRGB[2]; my1DExtProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); - my1DExtProp->SetLineWidth(aCotnrolLineWidth); + my1DExtProp->SetLineWidth(aLineWidth + aLineWidthInc); + my1DExtProp->SetPointSize(aPointSize + aPointSizeInc); my1DExtActor = SMESH_DeviceActor::New(); my1DExtActor->SetUserMatrix(aMatrix); my1DExtActor->SetStoreMapping(true); my1DExtActor->PickableOff(); + my1DExtActor->SetHighlited(true); my1DExtActor->SetVisibility(false); my1DExtActor->SetProperty(my1DExtProp); my1DExtActor->SetRepresentation(SMESH_DeviceActor::eInsideframe); @@ -196,9 +215,9 @@ SMESH_Actor::SMESH_Actor(){ //Definition 0D divice of the actor //--------------------------------- myNodeProp = vtkProperty::New(); - anRGB[0] = GetFloat("SMESH:SettingsNodeColorRed",255)/255.; - anRGB[1] = GetFloat("SMESH:SettingsNodeColorGreen",0)/255.; - anRGB[2] = GetFloat("SMESH:SettingsNodeColorBlue",0)/255.; + anRGB[0] = SMESH::GetFloat("SMESH:SettingsNodeColorRed",255)/255.; + anRGB[1] = SMESH::GetFloat("SMESH:SettingsNodeColorGreen",0)/255.; + anRGB[2] = SMESH::GetFloat("SMESH:SettingsNodeColorBlue",0)/255.; myNodeProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); myNodeProp->SetPointSize(aPointSize); @@ -227,9 +246,9 @@ SMESH_Actor::SMESH_Actor(){ myHighlightProp->SetAmbient(1.0); myHighlightProp->SetDiffuse(0.0); myHighlightProp->SetSpecular(0.0); - anRGB[0] = GetFloat("SMESH:SettingsSelectColorRed", 255)/255.; // 1; - anRGB[1] = GetFloat("SMESH:SettingsSelectColorGreen", 255)/255.; // 1; - anRGB[2] = GetFloat("SMESH:SettingsSelectColorBlue", 255)/255.; // 1; + anRGB[0] = SMESH::GetFloat("SMESH:SettingsSelectColorRed", 255)/255.; // 1; + anRGB[1] = SMESH::GetFloat("SMESH:SettingsSelectColorGreen", 255)/255.; // 1; + anRGB[2] = SMESH::GetFloat("SMESH:SettingsSelectColorBlue", 255)/255.; // 1; myHighlightProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); myHighlightProp->SetPointSize(aPointSize); myHighlightProp->SetRepresentation(1); @@ -238,9 +257,9 @@ SMESH_Actor::SMESH_Actor(){ myPreselectProp->SetAmbient(1.0); myPreselectProp->SetDiffuse(0.0); myPreselectProp->SetSpecular(0.0); - anRGB[0] = GetFloat("SMESH:SettingsPreSelectColorRed", 0)/255.; // 0; - anRGB[1] = GetFloat("SMESH:SettingsPreSelectColorGreen", 255)/255.; // 1; - anRGB[2] = GetFloat("SMESH:SettingsPreSelectColorBlue", 255)/255.; // 1; + anRGB[0] = SMESH::GetFloat("SMESH:SettingsPreSelectColorRed", 0)/255.; // 0; + anRGB[1] = SMESH::GetFloat("SMESH:SettingsPreSelectColorGreen", 255)/255.; // 1; + anRGB[2] = SMESH::GetFloat("SMESH:SettingsPreSelectColorBlue", 255)/255.; // 1; myPreselectProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); myPreselectProp->SetPointSize(aPointSize); myPreselectProp->SetRepresentation(1); @@ -251,15 +270,19 @@ SMESH_Actor::SMESH_Actor(){ myHighlitableActor->PickableOff(); myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe); + myNodeHighlitableActor = SMESH_DeviceActor::New(); + myNodeHighlitableActor->SetUserMatrix(aMatrix); + myNodeHighlitableActor->SetStoreMapping(false); + myNodeHighlitableActor->PickableOff(); + myNodeHighlitableActor->SetRepresentation(SMESH_DeviceActor::ePoint); + aFilter = myNodeHighlitableActor->GetExtractUnstructuredGrid(); + aFilter->SetModeOfExtraction(SALOME_ExtractUnstructuredGrid::ePoints); + - SetShrinkFactor(GetFloat("SMESH:SettingsShrinkCoeff", 75)/100.); + SetShrinkFactor(SMESH::GetFloat("SMESH:SettingsShrinkCoeff", 75)/100.); myName = ""; myIO = NULL; - myDisplayMode = 0; - - ishighlighted = false; - ispreselected = false; myColorMode = eNone; my1DColorMode = e1DNone; @@ -461,6 +484,10 @@ SMESH_Actor::SMESH_Actor(){ myCellsLabels->SetMapper(myClsLabeledDataMapper); myCellsLabels->GetProperty()->SetColor(0,1,0); myCellsLabels->SetVisibility(myIsCellsLabeled); + + // Clipping planes + myImplicitBoolean = vtkImplicitBoolean::New(); + myImplicitBoolean->SetOperationTypeToIntersection(); } @@ -490,7 +517,9 @@ SMESH_Actor::~SMESH_Actor(){ myNodeActor->Delete(); myBaseActor->Delete(); + myHighlitableActor->Delete(); + myNodeHighlitableActor->Delete(); //Deleting of pints numbering pipeline @@ -526,16 +555,21 @@ SMESH_Actor::~SMESH_Actor(){ myCellCenters->Delete(); myCellsLabels->Delete(); + + myImplicitBoolean->Delete(); + + myTimeStamp->Delete(); } void SMESH_Actor::SetPointsLabeled( bool theIsPointsLabeled ) { - myIsPointsLabeled = theIsPointsLabeled; + vtkUnstructuredGrid* aGrid = GetUnstructuredGrid(); + myIsPointsLabeled = theIsPointsLabeled && aGrid->GetNumberOfPoints(); if ( myIsPointsLabeled ) { - myPointsNumDataSet->ShallowCopy( GetUnstructuredGrid() ); + myPointsNumDataSet->ShallowCopy(aGrid); vtkDataSet *aDataSet = myPointsNumDataSet; int aNbElem = aDataSet->GetNumberOfPoints(); @@ -558,15 +592,16 @@ void SMESH_Actor::SetPointsLabeled( bool theIsPointsLabeled ) { myPointLabels->SetVisibility( false ); } - - SetRepresentation( GetRepresentation() ); + SetRepresentation(GetRepresentation()); + myTimeStamp->Modified(); } void SMESH_Actor::SetCellsLabeled(bool theIsCellsLabeled){ - myIsCellsLabeled = theIsCellsLabeled; + vtkUnstructuredGrid* aGrid = GetUnstructuredGrid(); + myIsCellsLabeled = theIsCellsLabeled && aGrid->GetNumberOfPoints(); if(myIsCellsLabeled){ - myCellsNumDataSet->ShallowCopy(GetUnstructuredGrid()); + myCellsNumDataSet->ShallowCopy(aGrid); vtkDataSet *aDataSet = myCellsNumDataSet; int aNbElem = aDataSet->GetNumberOfCells(); vtkIntArray *anArray = vtkIntArray::New(); @@ -581,6 +616,7 @@ void SMESH_Actor::SetCellsLabeled(bool theIsCellsLabeled){ }else{ myCellsLabels->SetVisibility(false); } + myTimeStamp->Modified(); } @@ -596,120 +632,97 @@ void SMESH_Actor::SetControlMode(eControl theMode){ bool anIsScalarVisible = theMode > eNone; if(anIsScalarVisible){ - SMESH::NumericalFunctor_var aFunctor; - SMESH::Predicate_var aPredicate; - + SMESH::Controls::FunctorPtr aFunctor; switch(theMode){ case eLengthEdges: - aFunctor = myFilterMgr->CreateLength(); + { + SMESH::Controls::Length* aControl = new SMESH::Controls::Length(); + aControl->SetPrecision( myControlsPrecision ); + aFunctor.reset( aControl ); myControlActor = my1DActor; break; + } case eFreeBorders: - aPredicate = myFilterMgr->CreateFreeBorders(); + aFunctor.reset(new SMESH::Controls::FreeBorders()); myControlActor = my1DActor; break; + case eFreeEdges: + aFunctor.reset(new SMESH::Controls::FreeEdges()); + myControlActor = my2DActor; + break; case eMultiConnection: - aFunctor = myFilterMgr->CreateMultiConnection(); + aFunctor.reset(new SMESH::Controls::MultiConnection()); myControlActor = my1DActor; break; case eArea: - aFunctor = myFilterMgr->CreateArea(); + { + SMESH::Controls::Area* aControl = new SMESH::Controls::Area(); + aControl->SetPrecision( myControlsPrecision ); + aFunctor.reset( aControl ); myControlActor = my2DActor; break; + } case eTaper: - aFunctor = myFilterMgr->CreateTaper(); + { + SMESH::Controls::Taper* aControl = new SMESH::Controls::Taper(); + aControl->SetPrecision( myControlsPrecision ); + aFunctor.reset( aControl ); myControlActor = my2DActor; break; + } case eAspectRatio: - aFunctor = myFilterMgr->CreateAspectRatio(); + { + SMESH::Controls::AspectRatio* aControl = new SMESH::Controls::AspectRatio(); + aControl->SetPrecision( myControlsPrecision ); + aFunctor.reset( aControl ); myControlActor = my2DActor; break; + } case eMinimumAngle: - aFunctor = myFilterMgr->CreateMinimumAngle(); + { + SMESH::Controls::MinimumAngle* aControl = new SMESH::Controls::MinimumAngle(); + aControl->SetPrecision( myControlsPrecision ); + aFunctor.reset( aControl ); myControlActor = my2DActor; break; + } case eWarping: - aFunctor = myFilterMgr->CreateWarping(); + { + SMESH::Controls::Warping* aControl = new SMESH::Controls::Warping(); + aControl->SetPrecision( myControlsPrecision ); + aFunctor.reset( aControl ); myControlActor = my2DActor; break; + } case eSkew: - aFunctor = myFilterMgr->CreateSkew(); + { + SMESH::Controls::Skew* aControl = new SMESH::Controls::Skew(); + aControl->SetPrecision( myControlsPrecision ); + aFunctor.reset( aControl ); myControlActor = my2DActor; break; + } default: return; } - + vtkUnstructuredGrid* aGrid = myControlActor->GetUnstructuredGrid(); vtkIdType aNbCells = aGrid->GetNumberOfCells(); if(aNbCells){ - if(theMode == eFreeBorders){ - if(!aPredicate->_is_nil()){ - myVisualObj->UpdateFunctor(aPredicate); - SALOME_ExtractUnstructuredGrid* aFilter = - my1DExtActor->GetExtractUnstructuredGrid(); - aFilter->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding); - aFilter->ClearRegisteredCells(); - for( vtkIdType i = 0; i < aNbCells; i++ ){ - vtkIdType anObjId = myControlActor->GetElemObjId( i ); - CORBA::Boolean aValue = aPredicate->IsSatisfy(anObjId); - if(aValue) - aFilter->RegisterCell(i); - } - if(!aFilter->IsCellsRegistered()) - aFilter->RegisterCell(-1); - aPredicate->Destroy(); - } - myColorMode = theMode; + myColorMode = theMode; + if(theMode == eFreeBorders || theMode == eFreeEdges){ my1DColorMode = e1DHighlited; + my1DExtActor->SetExtControlMode(aFunctor,myControlActor); }else{ - myColorMode = theMode; if(myControlActor == my1DActor) my1DColorMode = e1DColored; - - vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New(); - aDataSet->ShallowCopy(aGrid); - myScalarBarActor->SetVisibility(true); - myControlActor->GetMapper()->SetScalarVisibility(true); - - vtkDoubleArray *aScalars = vtkDoubleArray::New(); - aScalars->SetNumberOfComponents( 1 ); - aScalars->SetNumberOfTuples(aNbCells); - - if(!aFunctor->_is_nil()){ - myVisualObj->UpdateFunctor(aFunctor); - for( vtkIdType i = 0; i < aNbCells; i++ ){ - vtkIdType anObjId = myControlActor->GetElemObjId( i ); - CORBA::Double aValue = aFunctor->GetValue(anObjId); - aScalars->SetValue( i, aValue ); - } - aFunctor->Destroy(); - }else if(!aPredicate->_is_nil()){ - myVisualObj->UpdateFunctor(aPredicate); - for( vtkIdType i = 0; i < aNbCells; i++ ){ - vtkIdType anObjId = myControlActor->GetElemObjId( i ); - CORBA::Boolean aValue = aPredicate->IsSatisfy(anObjId); - aScalars->SetValue( i, aValue ); - } - aPredicate->Destroy(); - } - aDataSet->GetCellData()->SetScalars(aScalars); - aScalars->Delete(); - - float aRange[2]; - aScalars->GetRange(aRange); - myLookupTable->SetRange(aRange); - myLookupTable->Build(); - - myControlActor->GetMergeFilter()->SetScalars(aDataSet); - aDataSet->Delete(); - if(MYDEBUGWITHFILES) - WriteUnstructuredGrid(aDataSet,"/tmp/SetControlMode.vtk"); + myControlActor->SetControlMode(aFunctor,myScalarBarActor,myLookupTable); } } } SetRepresentation(GetRepresentation()); - + + myTimeStamp->Modified(); Modified(); } @@ -727,6 +740,7 @@ void SMESH_Actor::AddToRender(vtkRenderer* theRenderer){ theRenderer->AddActor(my1DExtActor); theRenderer->AddActor(myHighlitableActor); + theRenderer->AddActor(myNodeHighlitableActor); theRenderer->AddActor2D(myScalarBarActor); @@ -742,7 +756,9 @@ void SMESH_Actor::RemoveFromRender(vtkRenderer* theRenderer){ theRenderer->RemoveActor(myNodeActor); theRenderer->RemoveActor(myBaseActor); + theRenderer->RemoveActor(myHighlitableActor); + theRenderer->RemoveActor(myNodeHighlitableActor); theRenderer->RemoveActor(my1DActor); theRenderer->RemoveActor(my1DExtActor); @@ -756,21 +772,21 @@ void SMESH_Actor::RemoveFromRender(vtkRenderer* theRenderer){ } -void SMESH_Actor::Init(TVisualObjPtr theVisualObj, - SMESH::FilterManager_ptr theFilterMgr, +bool SMESH_Actor::Init(TVisualObjPtr theVisualObj, const char* theEntry, const char* theName, int theIsClear) { - Handle(SALOME_InteractiveObject) anIO = - new SALOME_InteractiveObject(strdup(theEntry),strdup("MESH"),strdup(theName)); + Handle(SALOME_InteractiveObject) anIO = new SALOME_InteractiveObject(theEntry,"SMESH",theName); setIO(anIO); - setName(strdup(theName)); + setName(theName); myVisualObj = theVisualObj; myNodeActor->myVisualObj = myVisualObj; myBaseActor->myVisualObj = myVisualObj; + myHighlitableActor->myVisualObj = myVisualObj; + myNodeHighlitableActor->myVisualObj = myVisualObj; my1DActor->myVisualObj = myVisualObj; my1DExtActor->myVisualObj = myVisualObj; @@ -779,10 +795,30 @@ void SMESH_Actor::Init(TVisualObjPtr theVisualObj, my3DActor->myVisualObj = myVisualObj; myVisualObj->Update(theIsClear); - SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid()); + + myNodeActor->Init(myVisualObj,myImplicitBoolean); + myBaseActor->Init(myVisualObj,myImplicitBoolean); + + myHighlitableActor->Init(myVisualObj,myImplicitBoolean); + myNodeHighlitableActor->Init(myVisualObj,myImplicitBoolean); + + my1DActor->Init(myVisualObj,myImplicitBoolean); + my1DExtActor->Init(myVisualObj,myImplicitBoolean); + + my2DActor->Init(myVisualObj,myImplicitBoolean); + my3DActor->Init(myVisualObj,myImplicitBoolean); - myFilterMgr = SMESH::FilterManager::_duplicate(theFilterMgr); + my1DActor->GetMapper()->SetLookupTable(myLookupTable); + my2DActor->GetMapper()->SetLookupTable(myLookupTable); + my3DActor->GetMapper()->SetLookupTable(myLookupTable); + + float aFactor, aUnits; + my2DActor->GetPolygonOffsetParameters(aFactor,aUnits); + my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75); + //SetIsShrunkable(theGrid->GetNumberOfCells() > 10); + SetIsShrunkable(true); + QString aMode = QAD_CONFIG->getSetting("SMESH:DisplayMode"); SetRepresentation(-1); if(aMode.compare("Wireframe") == 0){ @@ -798,19 +834,28 @@ void SMESH_Actor::Init(TVisualObjPtr theVisualObj, SetShrink(); } + myTimeStamp->Modified(); Modified(); + return true; } -vtkPolyData* SMESH_Actor::GetPolyDataInput(){ - return myPickableActor->GetPolyDataInput(); +float* SMESH_Actor::GetBounds(){ + return myNodeActor->GetBounds(); +} + + +vtkDataSet* SMESH_Actor::GetInput(){ + return GetUnstructuredGrid(); } void SMESH_Actor::SetTransform(SALOME_Transform* theTransform){ myNodeActor->SetTransform(theTransform); myBaseActor->SetTransform(theTransform); + myHighlitableActor->SetTransform(theTransform); + myNodeHighlitableActor->SetTransform(theTransform); my1DActor->SetTransform(theTransform); my1DExtActor->SetTransform(theTransform); @@ -822,34 +867,6 @@ void SMESH_Actor::SetTransform(SALOME_Transform* theTransform){ } -void SMESH_Actor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){ - if(theGrid){ - myNodeActor->SetUnstructuredGrid(theGrid); - myBaseActor->SetUnstructuredGrid(theGrid); - myHighlitableActor->SetUnstructuredGrid(theGrid); - - my1DActor->SetUnstructuredGrid(theGrid); - my1DExtActor->SetUnstructuredGrid(theGrid); - - my2DActor->SetUnstructuredGrid(theGrid); - my3DActor->SetUnstructuredGrid(theGrid); - - my1DActor->GetMapper()->SetLookupTable(myLookupTable); - my2DActor->GetMapper()->SetLookupTable(myLookupTable); - my3DActor->GetMapper()->SetLookupTable(myLookupTable); - - float aFactor, aUnits; - my2DActor->GetPolygonOffsetParameters(aFactor,aUnits); - my2DActor->SetPolygonOffsetParameters(aFactor,aUnits*0.75); - - //SetIsShrunkable(theGrid->GetNumberOfCells() > 10); - SetIsShrunkable(true); - - Modified(); - } -} - - void SMESH_Actor::SetMapper(vtkMapper* theMapper){ vtkLODActor::SetMapper(theMapper); } @@ -873,7 +890,9 @@ vtkUnstructuredGrid* SMESH_Actor::GetUnstructuredGrid(){ bool SMESH_Actor::IsInfinitive(){ vtkDataSet *aDataSet = myPickableActor->GetUnstructuredGrid(); aDataSet->Update(); - myIsInfinite = aDataSet->GetNumberOfCells() == 0; + myIsInfinite = aDataSet->GetNumberOfCells() == 0 || + aDataSet->GetNumberOfCells() == 1 && + aDataSet->GetCell(0)->GetCellType() == VTK_VERTEX; return SALOME_Actor::IsInfinitive(); } @@ -930,29 +949,12 @@ void SMESH_Actor::UnShrink(){ } -int SMESH_Actor::GetObjId(int theVtkID){ - if (GetRepresentation() == 0){ - return GetNodeObjId(theVtkID); - }else{ - return GetElemObjId(theVtkID); - } -} - -SALOME_Actor::TVectorId SMESH_Actor::GetVtkId(int theObjID){ - if (GetRepresentation() == 0){ - return GetNodeVtkId(theObjID); - }else{ - return GetElemVtkId(theObjID); - } -} - - int SMESH_Actor::GetNodeObjId(int theVtkID){ return myPickableActor->GetNodeObjId(theVtkID); } -SALOME_Actor::TVectorId SMESH_Actor::GetNodeVtkId(int theObjID){ - return myPickableActor->GetNodeVtkId(theObjID); +float* SMESH_Actor::GetNodeCoord(int theObjID){ + return myPickableActor->GetNodeCoord(theObjID); } @@ -960,15 +962,21 @@ int SMESH_Actor::GetElemObjId(int theVtkID){ return myPickableActor->GetElemObjId(theVtkID); } -SALOME_Actor::TVectorId SMESH_Actor::GetElemVtkId(int theObjID){ - return myPickableActor->GetElemVtkId(theObjID); +vtkCell* SMESH_Actor::GetElemCell(int theObjID){ + return myPickableActor->GetElemCell(theObjID); } void SMESH_Actor::SetVisibility(int theMode){ + SetVisibility(theMode,true); +} + + +void SMESH_Actor::SetVisibility(int theMode, bool theIsUpdateRepersentation){ SALOME_Actor::SetVisibility(theMode); if(GetVisibility()){ - SetRepresentation(GetRepresentation()); + if(theIsUpdateRepersentation) + SetRepresentation(GetRepresentation()); if(myColorMode != eNone){ if(my1DColorMode == e1DHighlited) @@ -1047,6 +1055,8 @@ void SMESH_Actor::SetRepresentation(int theMode){ switch(myRepresentation){ case ePoint: myPickableActor = myNodeActor; + myNodeActor->SetVisibility(true); + aProp = aBackProp = myNodeProp; aReperesent = SMESH_DeviceActor::ePoint; break; @@ -1084,58 +1094,71 @@ void SMESH_Actor::SetRepresentation(int theMode){ my1DActor->SetProperty(aProp); my1DActor->SetBackfaceProperty(aBackProp); my1DActor->SetRepresentation(aReperesent); + + my1DExtActor->SetRepresentation(aReperesent); - if ( GetPointRepresentation() || !GetUnstructuredGrid()->GetNumberOfCells() || myIsPointsLabeled ) - { + if(myIsPointsVisible) myPickableActor = myNodeActor; + + if(GetPointRepresentation()) myNodeActor->SetVisibility(true); - } SetMapper(myPickableActor->GetMapper()); + SetVisibility(GetVisibility(),false); + Modified(); } -void SMESH_Actor::SetPointRepresentation(int theIsPointsVisible){ +void SMESH_Actor::SetPointRepresentation(bool theIsPointsVisible){ myIsPointsVisible = theIsPointsVisible; SetRepresentation(GetRepresentation()); } +bool SMESH_Actor::GetPointRepresentation(){ + return myIsPointsVisible || myIsPointsLabeled; +} + void SMESH_Actor::UpdateHighlight(){ myHighlitableActor->SetVisibility(false); - myNodeActor->SetProperty(myNodeProp); - if(myPickableActor != myNodeActor) - myNodeActor->SetVisibility(false); + myHighlitableActor->SetHighlited(false); + + myNodeHighlitableActor->SetVisibility(false); + myNodeHighlitableActor->SetHighlited(false); - if(ishighlighted){ + if(myIsHighlighted){ myHighlitableActor->SetProperty(myHighlightProp); - }else if(ispreselected){ + }else if(myIsPreselected){ myHighlitableActor->SetProperty(myPreselectProp); } - if(ishighlighted || ispreselected){ - if(!GetUnstructuredGrid()->GetNumberOfCells()){ - myNodeActor->SetProperty(myHighlitableActor->GetProperty()); - myNodeActor->SetRepresentation(SMESH_DeviceActor::ePoint); - myNodeActor->SetVisibility(GetVisibility()); - }else{ + bool isVisible = GetVisibility(); + + if(myIsHighlighted || myIsPreselected){ + if(GetUnstructuredGrid()->GetNumberOfCells()){ myHighlitableActor->SetRepresentation(SMESH_DeviceActor::eWireframe); - myHighlitableActor->SetVisibility(GetVisibility()); + myHighlitableActor->SetVisibility(isVisible); + myHighlitableActor->SetHighlited(isVisible); + } + if(myRepresentation == ePoint || GetPointRepresentation()){ + myNodeHighlitableActor->SetProperty(myHighlitableActor->GetProperty()); + myNodeHighlitableActor->SetVisibility(isVisible); + myNodeHighlitableActor->SetHighlited(isVisible); } } } -void SMESH_Actor::highlight(Standard_Boolean highlight){ - ishighlighted = highlight; +void SMESH_Actor::highlight(bool theHighlight){ + myIsHighlighted = theHighlight; UpdateHighlight(); } -void SMESH_Actor::SetPreSelected(Standard_Boolean presel){ - ispreselected = presel; +void SMESH_Actor::SetPreSelected(bool thePreselect){ + myIsPreselected = thePreselect; UpdateHighlight(); } @@ -1165,7 +1188,39 @@ int SMESH_Actor::RenderTranslucentGeometry(vtkViewport *vp) } -void SMESH_Actor::Render(vtkRenderer *ren){} +void SMESH_Actor::Render(vtkRenderer *ren){ + unsigned long mTime = myTimeStamp->GetMTime(); + unsigned long anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime(); + if(anObjTime > mTime) + Update(); +} + + +void SMESH_Actor::Update(){ + SetVisibility(GetVisibility()); + unsigned long int anObjTime = myVisualObj->GetUnstructuredGrid()->GetMTime(); + unsigned long int aClippingTime = myImplicitBoolean->GetMTime(); + unsigned long int aTime = myTimeStamp->GetMTime(); + if(MYDEBUG) MESSAGE("SMESH_Actor::Update"); + + if(GetControlMode() != eNone) { + if(anObjTime > aTime || aClippingTime > aTime){ + SetControlMode(GetControlMode()); + SetVisibility(GetVisibility()); + } + } + if(myIsPointsLabeled){ + if(anObjTime > aTime || aClippingTime > aTime) + SetPointsLabeled(myIsPointsLabeled); + } + if(myIsCellsLabeled){ + if(anObjTime > aTime || aClippingTime > aTime) + SetCellsLabeled(myIsCellsLabeled); + } + + myTimeStamp->Modified(); + Modified(); +} void SMESH_Actor::ReleaseGraphicsResources(vtkWindow *renWin){ @@ -1262,17 +1317,21 @@ float SMESH_Actor::GetLineWidth(){ void SMESH_Actor::SetLineWidth(float theVal){ myEdgeProp->SetLineWidth(theVal); + + my1DProp->SetLineWidth(theVal + aLineWidthInc); + my1DExtProp->SetLineWidth(theVal + aLineWidthInc); + Modified(); } -void SMESH_Actor::SetNodeSize(float theSize){ - myNodeProp->SetPointSize(theSize); - myHighlightProp->SetPointSize(theSize); - myPreselectProp->SetPointSize(theSize); +void SMESH_Actor::SetNodeSize(float theVal){ + myNodeProp->SetPointSize(theVal); + myHighlightProp->SetPointSize(theVal); + myPreselectProp->SetPointSize(theVal); - my1DExtProp->SetPointSize(theSize); - my1DProp->SetPointSize(theSize); + my1DProp->SetPointSize(theVal + aPointSizeInc); + my1DExtProp->SetPointSize(theVal + aPointSizeInc); Modified(); } @@ -1285,3 +1344,95 @@ int SMESH_Actor::GetObjDimension( const int theObjId ) { return myVisualObj->GetElemDimension( theObjId ); } + + +vtkImplicitBoolean* SMESH_Actor::GetPlaneContainer(){ + return myImplicitBoolean; +} + + +static void ComputeBoundsParam(vtkDataSet* theDataSet, + float theDirection[3], float theMinPnt[3], + float& theMaxBoundPrj, float& theMinBoundPrj) +{ + float aBounds[6]; + theDataSet->GetBounds(aBounds); + + //Enlarge bounds in order to avoid conflicts of precision + for(int i = 0; i < 6; i += 2){ + static double EPS = 1.0E-3; + float aDelta = (aBounds[i+1] - aBounds[i])*EPS; + aBounds[i] -= aDelta; + aBounds[i+1] += aDelta; + } + + float aBoundPoints[8][3] = { {aBounds[0],aBounds[2],aBounds[4]}, + {aBounds[1],aBounds[2],aBounds[4]}, + {aBounds[0],aBounds[3],aBounds[4]}, + {aBounds[1],aBounds[3],aBounds[4]}, + {aBounds[0],aBounds[2],aBounds[5]}, + {aBounds[1],aBounds[2],aBounds[5]}, + {aBounds[0],aBounds[3],aBounds[5]}, + {aBounds[1],aBounds[3],aBounds[5]}}; + + int aMaxId = 0, aMinId = aMaxId; + theMaxBoundPrj = vtkMath::Dot(theDirection,aBoundPoints[aMaxId]); + theMinBoundPrj = theMaxBoundPrj; + for(int i = 1; i < 8; i++){ + float aTmp = vtkMath::Dot(theDirection,aBoundPoints[i]); + if(theMaxBoundPrj < aTmp){ + theMaxBoundPrj = aTmp; + aMaxId = i; + } + if(theMinBoundPrj > aTmp){ + theMinBoundPrj = aTmp; + aMinId = i; + } + } + float *aMinPnt = aBoundPoints[aMaxId]; + theMinPnt[0] = aMinPnt[0]; + theMinPnt[1] = aMinPnt[1]; + theMinPnt[2] = aMinPnt[2]; +} + + +static void DistanceToPosition(vtkDataSet* theDataSet, + float theDirection[3], float theDist, float thePos[3]) +{ + float aMaxBoundPrj, aMinBoundPrj, aMinPnt[3]; + ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj); + float aLength = (aMaxBoundPrj-aMinBoundPrj)*theDist; + thePos[0] = aMinPnt[0]-theDirection[0]*aLength; + thePos[1] = aMinPnt[1]-theDirection[1]*aLength; + thePos[2] = aMinPnt[2]-theDirection[2]*aLength; +} + + +static void PositionToDistance(vtkDataSet* theDataSet, + float theDirection[3], float thePos[3], float& theDist) +{ + float aMaxBoundPrj, aMinBoundPrj, aMinPnt[3]; + ComputeBoundsParam(theDataSet,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj); + float aPrj = vtkMath::Dot(theDirection,thePos); + theDist = (aPrj-aMinBoundPrj)/(aMaxBoundPrj-aMinBoundPrj); +} + + +void SMESH_Actor::SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane) +{ + thePlane->SetNormal(theDir); + float anOrigin[3]; + ::DistanceToPosition(GetUnstructuredGrid(),theDir,theDist,anOrigin); + thePlane->SetOrigin(anOrigin); + Update(); +} + + +void SMESH_Actor::GetPlaneParam(float theDir[3], float& theDist, vtkPlane* thePlane) +{ + thePlane->GetNormal(theDir); + + float anOrigin[3]; + thePlane->GetOrigin(anOrigin); + ::PositionToDistance(GetUnstructuredGrid(),theDir,anOrigin,theDist); +} diff --git a/src/OBJECT/SMESH_Actor.h b/src/OBJECT/SMESH_Actor.h index 2cb9628a8..b2f68c394 100644 --- a/src/OBJECT/SMESH_Actor.h +++ b/src/OBJECT/SMESH_Actor.h @@ -42,14 +42,19 @@ class vtkPolyData; class vtkMapper; class vtkActor2D; class vtkMaskPoints; +class vtkCellCenters; class vtkLabeledDataMapper; class vtkSelectVisiblePoints; class vtkScalarBarActor; class vtkLookupTable; +class vtkPlane; +class vtkImplicitBoolean; + +class vtkTimeStamp; + class SMESH_DeviceActor; -class SALOME_ExtractUnstructuredGrid; class SMESH_Actor : public SALOME_Actor{ @@ -58,7 +63,6 @@ class SMESH_Actor : public SALOME_Actor{ public: vtkTypeMacro(SMESH_Actor,SALOME_Actor); static SMESH_Actor* New(TVisualObjPtr theVisualObj, - SMESH::FilterManager_ptr theFilterMgr, const char* theEntry, const char* theName, int theIsClear); @@ -72,8 +76,8 @@ class SMESH_Actor : public SALOME_Actor{ virtual void RemoveFromRender(vtkRenderer* theRenderer); virtual bool hasHighlight() { return true; } - virtual void highlight(Standard_Boolean highlight); - virtual void SetPreSelected(Standard_Boolean presel = Standard_False); + virtual void highlight(bool theHighlight); + virtual void SetPreSelected(bool thePreselect = false); virtual bool IsInfinitive(); @@ -104,37 +108,36 @@ class SMESH_Actor : public SALOME_Actor{ void SetNodeSize(float size) ; float GetNodeSize() ; - virtual int GetObjId(int theVtkID); - virtual TVectorId GetVtkId(int theObjID); - virtual int GetNodeObjId(int theVtkID); - virtual TVectorId GetNodeVtkId(int theObjID); + virtual float* GetNodeCoord(int theObjID); virtual int GetElemObjId(int theVtkID); - virtual TVectorId GetElemVtkId(int theObjID); + virtual vtkCell* GetElemCell(int theObjID); virtual int GetObjDimension( const int theObjId ); virtual void SetVisibility(int theMode); + void SetVisibility(int theMode, bool theIsUpdateRepersentation); enum EReperesent { ePoint, eEdge, eSurface}; virtual void SetRepresentation(int theMode); - void SetPointRepresentation(int theIsPointsVisible); - bool GetPointRepresentation(){ return myIsPointsVisible;} + void SetPointRepresentation(bool theIsPointsVisible); + bool GetPointRepresentation(); - virtual vtkPolyData* GetPolyDataInput(); + virtual float* GetBounds(); virtual void SetTransform(SALOME_Transform* theTransform); vtkUnstructuredGrid* GetUnstructuredGrid(); + virtual vtkDataSet* GetInput(); virtual vtkMapper* GetMapper(); - float GetShrinkFactor(); - void SetShrinkFactor(float value ); + virtual float GetShrinkFactor(); + virtual void SetShrinkFactor(float value ); - bool IsShrunkable() { return myIsShrinkable;} - bool IsShrunk() { return myIsShrunk;} - void SetShrink(); - void UnShrink(); + virtual bool IsShrunkable() { return myIsShrinkable;} + virtual bool IsShrunk() { return myIsShrunk;} + virtual void SetShrink(); + virtual void UnShrink(); void SetPointsLabeled(bool theIsPointsLabeled); bool GetPointsLabeled(){ return myIsPointsLabeled;} @@ -142,7 +145,7 @@ class SMESH_Actor : public SALOME_Actor{ void SetCellsLabeled(bool theIsCellsLabeled); bool GetCellsLabeled(){ return myIsCellsLabeled;} - enum eControl{eNone, eLengthEdges, eFreeBorders, eMultiConnection, + enum eControl{eNone, eLengthEdges, eFreeBorders, eFreeEdges, eMultiConnection, eArea, eTaper, eAspectRatio, eMinimumAngle, eWarping, eSkew}; void SetControlMode(eControl theMode); eControl GetControlMode(){ return myColorMode;} @@ -152,12 +155,20 @@ class SMESH_Actor : public SALOME_Actor{ vtkScalarBarActor* GetScalarBarActor(){ return myScalarBarActor;} + void SetPlaneParam(float theDir[3], float theDist, vtkPlane* thePlane); + void GetPlaneParam(float theDir[3], float& theDist, vtkPlane* thePlane); + + vtkImplicitBoolean* GetPlaneContainer(); + TVisualObjPtr GetObject() { return myVisualObj;} + void SetControlsPrecision( const long p ) { myControlsPrecision = p; } + long GetControlsPrecision() const { return myControlsPrecision; } + protected: TVisualObjPtr myVisualObj; + vtkTimeStamp* myTimeStamp; - SMESH::FilterManager_var myFilterMgr; vtkScalarBarActor* myScalarBarActor; vtkLookupTable* myLookupTable; @@ -173,6 +184,7 @@ class SMESH_Actor : public SALOME_Actor{ vtkProperty* myHighlightProp; vtkProperty* myPreselectProp; SMESH_DeviceActor* myHighlitableActor; + SMESH_DeviceActor* myNodeHighlitableActor; eControl myColorMode; SMESH_DeviceActor* my2DActor; @@ -205,18 +217,21 @@ class SMESH_Actor : public SALOME_Actor{ vtkLabeledDataMapper* myClsLabeledDataMapper; vtkSelectVisiblePoints* myClsSelectVisiblePoints; + vtkImplicitBoolean* myImplicitBoolean; + + long myControlsPrecision; + SMESH_Actor(); ~SMESH_Actor(); - void Init(TVisualObjPtr theVisualObj, - SMESH::FilterManager_ptr theFilterMgr, + bool Init(TVisualObjPtr theVisualObj, const char* theEntry, const char* theName, int theIsClear); - void SetUnstructuredGrid(vtkUnstructuredGrid* theGrid); void SetIsShrunkable(bool theShrunkable); void UpdateHighlight(); + void Update(); private: // hide the two parameter Render() method from the user and the compiler. diff --git a/src/OBJECT/SMESH_ActorUtils.cxx b/src/OBJECT/SMESH_ActorUtils.cxx new file mode 100644 index 000000000..a5823c66f --- /dev/null +++ b/src/OBJECT/SMESH_ActorUtils.cxx @@ -0,0 +1,39 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + + +#include "SMESH_ActorUtils.h" + +#include "QAD_Config.h" +#include "utilities.h" + +#ifdef _DEBUG_ +static int MYDEBUG = 1; +#else +static int MYDEBUG = 0; +#endif + +namespace SMESH{ + float GetFloat(const QString& theValue, float theDefault){ + if(theValue.isEmpty()) return theDefault; + QString aValue = QAD_CONFIG->getSetting(theValue); + if(aValue.isEmpty()) return theDefault; + return aValue.toFloat(); + } +} diff --git a/src/Driver/Mesh_Writer.cxx b/src/OBJECT/SMESH_ActorUtils.h similarity index 84% rename from src/Driver/Mesh_Writer.cxx rename to src/OBJECT/SMESH_ActorUtils.h index e0c15f746..459549524 100644 --- a/src/Driver/Mesh_Writer.cxx +++ b/src/OBJECT/SMESH_ActorUtils.h @@ -1,5 +1,3 @@ -// SMESH Driver : implementaion of driver for reading and writing -// // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // @@ -18,11 +16,16 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : Mesh_Writer.cxx -// Module : SMESH -using namespace std; -#include "Mesh_Writer.h" +#ifndef SMESH_ACTORUTILS_H +#define SMESH_ACTORUTILS_H + +#include + + +namespace SMESH{ + float GetFloat(const QString& theValue, float theDefault = 0); +} + + +#endif diff --git a/src/OBJECT/SMESH_DeviceActor.cxx b/src/OBJECT/SMESH_DeviceActor.cxx index b838f4fe7..79d20d813 100644 --- a/src/OBJECT/SMESH_DeviceActor.cxx +++ b/src/OBJECT/SMESH_DeviceActor.cxx @@ -28,6 +28,7 @@ #include "SMESH_DeviceActor.h" +#include "SMESH_ExtractGeometry.h" #include "SALOME_Transform.h" #include "SALOME_TransformFilter.h" @@ -47,6 +48,19 @@ #include #include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + #ifdef _DEBUG_ static int MYDEBUG = 0; static int MYDEBUGWITHFILES = 0; @@ -72,14 +86,15 @@ SMESH_DeviceActor::SMESH_DeviceActor(){ vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor, myPolygonOffsetUnits); - //myMapper->SetResolveCoincidentTopologyToShiftZBuffer(); - //myMapper->SetResolveCoincidentTopologyZShift(0.02); - + myMapper->UseLookupTableScalarRangeOn(); myMapper->SetColorModeToMapScalars(); myShrinkFilter = vtkShrinkFilter::New(); + myExtractGeometry = SMESH_ExtractGeometry::New(); + myExtractGeometry->SetStoreMapping(true); + myExtractUnstructuredGrid = SALOME_ExtractUnstructuredGrid::New(); myExtractUnstructuredGrid->SetStoreMapping(true); @@ -114,6 +129,9 @@ SMESH_DeviceActor::~SMESH_DeviceActor(){ myGeomFilter->UnRegisterAllOutputs(); myGeomFilter->Delete(); + myExtractGeometry->UnRegisterAllOutputs(); + myExtractGeometry->Delete(); + myTransformFilter->UnRegisterAllOutputs(); myTransformFilter->Delete(); @@ -130,12 +148,23 @@ void SMESH_DeviceActor::SetStoreMapping(int theStoreMapping){ } +void SMESH_DeviceActor::Init(TVisualObjPtr theVisualObj, + vtkImplicitBoolean* theImplicitBoolean) +{ + myVisualObj = theVisualObj; + myExtractGeometry->SetImplicitFunction(theImplicitBoolean); + SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid()); +} + + void SMESH_DeviceActor::SetUnstructuredGrid(vtkUnstructuredGrid* theGrid){ if(theGrid){ //myIsShrinkable = theGrid->GetNumberOfCells() > 10; myIsShrinkable = true; - myExtractUnstructuredGrid->SetInput(theGrid); + myExtractGeometry->SetInput(theGrid); + + myExtractUnstructuredGrid->SetInput(myExtractGeometry->GetOutput()); myMergeFilter->SetGeometry(myExtractUnstructuredGrid->GetOutput()); theGrid = static_cast(myMergeFilter->GetOutput()); @@ -183,18 +212,132 @@ vtkUnstructuredGrid* SMESH_DeviceActor::GetUnstructuredGrid(){ } -vtkMergeFilter* SMESH_DeviceActor::GetMergeFilter(){ - return myMergeFilter; +void SMESH_DeviceActor::SetControlMode(SMESH::Controls::FunctorPtr theFunctor, + vtkScalarBarActor* theScalarBarActor, + vtkLookupTable* theLookupTable) +{ + bool anIsInitialized = theFunctor; + if(anIsInitialized){ + vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New(); + vtkUnstructuredGrid* aGrid = myExtractUnstructuredGrid->GetOutput(); + aDataSet->ShallowCopy(aGrid); + + vtkDoubleArray *aScalars = vtkDoubleArray::New(); + vtkIdType aNbCells = aGrid->GetNumberOfCells(); + aScalars->SetNumberOfComponents(1); + aScalars->SetNumberOfTuples(aNbCells); + + myVisualObj->UpdateFunctor(theFunctor); + + using namespace SMESH::Controls; + if(NumericalFunctor* aNumericalFunctor = dynamic_cast(theFunctor.get())){ + for(vtkIdType i = 0; i < aNbCells; i++){ + vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i); + vtkIdType anId2 = myExtractGeometry->GetElemObjId(anId); + vtkIdType anObjId = myVisualObj->GetElemObjId(anId2); + double aValue = aNumericalFunctor->GetValue(anObjId); + aScalars->SetValue(i,aValue); + } + }else if(Predicate* aPredicate = dynamic_cast(theFunctor.get())){ + for(vtkIdType i = 0; i < aNbCells; i++){ + vtkIdType anId = myExtractUnstructuredGrid->GetInputId(i); + vtkIdType anId2 = myExtractGeometry->GetElemObjId(anId); + vtkIdType anObjId = myVisualObj->GetElemObjId(anId2); + bool aValue = aPredicate->IsSatisfy(anObjId); + aScalars->SetValue(i,aValue); + } + } + + aDataSet->GetCellData()->SetScalars(aScalars); + aScalars->Delete(); + + theLookupTable->SetRange(aScalars->GetRange()); + theLookupTable->Build(); + + myMergeFilter->SetScalars(aDataSet); + aDataSet->Delete(); + } + GetMapper()->SetScalarVisibility(anIsInitialized); + theScalarBarActor->SetVisibility(anIsInitialized); } -vtkPolyData* SMESH_DeviceActor::GetPolyDataInput(){ - return myPassFilter.back()->GetPolyDataOutput(); +void SMESH_DeviceActor::SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor, + SMESH_DeviceActor* theDeviceActor) +{ + myExtractUnstructuredGrid->ClearRegisteredCells(); + myExtractUnstructuredGrid->ClearRegisteredCellsWithType(); + myExtractUnstructuredGrid->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::ePassAll); + myVisualObj->UpdateFunctor(theFunctor); + + using namespace SMESH::Controls; + if(FreeBorders* aFreeBorders = dynamic_cast(theFunctor.get())){ + myExtractUnstructuredGrid->SetModeOfChanging(SALOME_ExtractUnstructuredGrid::eAdding); + myExtractUnstructuredGrid->ClearRegisteredCells(); + vtkUnstructuredGrid* aGrid = theDeviceActor->GetUnstructuredGrid(); + vtkIdType aNbCells = aGrid->GetNumberOfCells(); + for( vtkIdType i = 0; i < aNbCells; i++ ){ + vtkIdType anObjId = theDeviceActor->GetElemObjId(i); + if(aFreeBorders->IsSatisfy(anObjId)) + myExtractUnstructuredGrid->RegisterCell(i); + } + if(!myExtractUnstructuredGrid->IsCellsRegistered()) + myExtractUnstructuredGrid->RegisterCell(-1); + SetUnstructuredGrid(myVisualObj->GetUnstructuredGrid()); + }else if(FreeEdges* aFreeEdges = dynamic_cast(theFunctor.get())){ + SMESH::Controls::FreeEdges::TBorders aBorders; + aFreeEdges->GetBoreders(aBorders); + vtkUnstructuredGrid* aDataSet = vtkUnstructuredGrid::New(); + vtkUnstructuredGrid* aGrid = myVisualObj->GetUnstructuredGrid(); + aDataSet->SetPoints(aGrid->GetPoints()); + + vtkIdType aNbCells = aBorders.size(); + vtkIdType aCellsSize = 3*aNbCells; + vtkCellArray* aConnectivity = vtkCellArray::New(); + aConnectivity->Allocate( aCellsSize, 0 ); + + vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New(); + aCellTypesArray->SetNumberOfComponents( 1 ); + aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() ); + + vtkIdList *anIdList = vtkIdList::New(); + anIdList->SetNumberOfIds(2); + + FreeEdges::TBorders::const_iterator anIter = aBorders.begin(); + for(vtkIdType aVtkId; anIter != aBorders.end(); anIter++){ + const FreeEdges::Border& aBorder = *anIter; + int aNode[2] = { + myVisualObj->GetNodeVTKId(aBorder.myPntId[0]), + myVisualObj->GetNodeVTKId(aBorder.myPntId[1]) + }; + //cout<<"aNode = "<= 0 && aNode[1] >= 0){ + anIdList->SetId( 0, aNode[0] ); + anIdList->SetId( 1, aNode[1] ); + aConnectivity->InsertNextCell( anIdList ); + aCellTypesArray->InsertNextValue( VTK_LINE ); + } + } + + vtkIntArray* aCellLocationsArray = vtkIntArray::New(); + aCellLocationsArray->SetNumberOfComponents( 1 ); + aCellLocationsArray->SetNumberOfTuples( aNbCells ); + + aConnectivity->InitTraversal(); + for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ ) + aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) ); + + aDataSet->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity ); + + SetUnstructuredGrid(aDataSet); + aDataSet->Delete(); + } } unsigned long int SMESH_DeviceActor::GetMTime(){ unsigned long mTime = this->Superclass::GetMTime(); + mTime = max(mTime,myExtractGeometry->GetMTime()); mTime = max(mTime,myExtractUnstructuredGrid->GetMTime()); mTime = max(mTime,myMergeFilter->GetMTime()); mTime = max(mTime,myGeomFilter->GetMTime()); @@ -208,8 +351,7 @@ void SMESH_DeviceActor::SetTransform(SALOME_Transform* theTransform){ } -void SMESH_DeviceActor::SetShrink() -{ +void SMESH_DeviceActor::SetShrink() { if ( !myIsShrinkable ) return; if ( vtkDataSet* aDataSet = myPassFilter[ 0 ]->GetOutput() ) { @@ -219,8 +361,7 @@ void SMESH_DeviceActor::SetShrink() } } -void SMESH_DeviceActor::UnShrink() -{ +void SMESH_DeviceActor::UnShrink() { if ( !myIsShrunk ) return; if ( vtkDataSet* aDataSet = myPassFilter[ 0 ]->GetOutput() ) { @@ -247,6 +388,7 @@ void SMESH_DeviceActor::SetRepresentation(EReperesent theMode){ myGeomFilter->SetInside(false); } myRepresentation = theMode; + GetProperty()->Modified(); myMapper->Modified(); Modified(); } @@ -269,62 +411,45 @@ int SMESH_DeviceActor::GetVisibility(){ } -int SMESH_DeviceActor::GetObjId(int theVtkID){ - if (GetRepresentation() == ePoint){ - return GetNodeObjId(theVtkID); - }else{ - return GetElemObjId(theVtkID); - } -} - - -SMESH_DeviceActor::TVectorId SMESH_DeviceActor::GetVtkId(int theObjID){ - if (GetRepresentation() == ePoint){ - return GetNodeVtkId(theObjID); - }else{ - return GetElemVtkId(theObjID); - } -} - - int SMESH_DeviceActor::GetNodeObjId(int theVtkID){ - vtkIdType aRetID = myVisualObj->GetNodeObjId(theVtkID); + vtkIdType anID = myExtractGeometry->GetNodeObjId(theVtkID); + vtkIdType aRetID = myVisualObj->GetNodeObjId(anID); if(MYDEBUG) MESSAGE("GetNodeObjId - theVtkID = "< +#include +class vtkCell; class vtkProperty; class vtkMergeFilter; class vtkShrinkFilter; class vtkPolyDataMapper; class vtkUnstructuredGrid; +class vtkScalarBarActor; +class vtkLookupTable; +class vtkImplicitBoolean; class SALOME_Transform; class SALOME_TransformFilter; class SALOME_PassThroughFilter; class SALOME_ExtractUnstructuredGrid; +class SMESH_ExtractGeometry; + class SMESH_DeviceActor: public vtkLODActor{ friend class SMESH_Actor; @@ -56,17 +64,11 @@ class SMESH_DeviceActor: public vtkLODActor{ void SetStoreMapping(int theStoreMapping); int GetStoreMapping(){ return myStoreMapping;} - typedef SALOME_GeometryFilter::TVectorId TVectorId; - int GetObjId(int theVtkID); - TVectorId GetVtkId(int theObjID); - - int GetNodeObjId(int theVtkID); - TVectorId GetNodeVtkId(int theObjID); + virtual int GetNodeObjId(int theVtkID); + virtual float* GetNodeCoord(int theObjID); - int GetElemObjId(int theVtkID); - TVectorId GetElemVtkId(int theObjID); - - vtkPolyData* GetPolyDataInput(); + virtual int GetElemObjId(int theVtkID); + virtual vtkCell* GetElemCell(int theObjID); virtual void SetTransform(SALOME_Transform* theTransform); virtual unsigned long int GetMTime(); @@ -88,11 +90,20 @@ class SMESH_DeviceActor: public vtkLODActor{ SALOME_ExtractUnstructuredGrid* GetExtractUnstructuredGrid(); vtkUnstructuredGrid* GetUnstructuredGrid(); - vtkMergeFilter* GetMergeFilter(); + + void SetControlMode(SMESH::Controls::FunctorPtr theFunctor, + vtkScalarBarActor* theScalarBarActor, + vtkLookupTable* theLookupTable); + void SetExtControlMode(SMESH::Controls::FunctorPtr theFunctor, + SMESH_DeviceActor* theDeviceActor); + + bool IsHighlited() { return myIsHighlited;} + void SetHighlited(bool theIsHighlited); virtual void Render(vtkRenderer *, vtkMapper *); protected: + void Init(TVisualObjPtr theVisualObj, vtkImplicitBoolean* theImplicitBoolean); void SetUnstructuredGrid(vtkUnstructuredGrid* theGrid); vtkPolyDataMapper *myMapper; @@ -101,6 +112,8 @@ class SMESH_DeviceActor: public vtkLODActor{ vtkProperty *myProperty; EReperesent myRepresentation; + SMESH_ExtractGeometry* myExtractGeometry; + vtkMergeFilter* myMergeFilter; SALOME_ExtractUnstructuredGrid* myExtractUnstructuredGrid; @@ -113,6 +126,8 @@ class SMESH_DeviceActor: public vtkLODActor{ bool myIsShrinkable; bool myIsShrunk; + bool myIsHighlited; + float myPolygonOffsetFactor; float myPolygonOffsetUnits; @@ -124,8 +139,8 @@ class SMESH_DeviceActor: public vtkLODActor{ SMESH_DeviceActor(); ~SMESH_DeviceActor(); - SMESH_DeviceActor(const SMESH_DeviceActor&) {}; - void operator=(const SMESH_DeviceActor&) {}; + SMESH_DeviceActor(const SMESH_DeviceActor&); + void operator=(const SMESH_DeviceActor&); }; diff --git a/src/OBJECT/SMESH_ExtractGeometry.cxx b/src/OBJECT/SMESH_ExtractGeometry.cxx new file mode 100644 index 000000000..84812a142 --- /dev/null +++ b/src/OBJECT/SMESH_ExtractGeometry.cxx @@ -0,0 +1,254 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + + +#include "SMESH_ExtractGeometry.h" + +#include "vtkCell.h" +#include "vtkCellData.h" +#include "vtkFloatArray.h" +#include "vtkIdList.h" +#include "vtkImplicitFunction.h" +#include "vtkObjectFactory.h" +#include "vtkPointData.h" +#include "vtkUnstructuredGrid.h" + +using namespace std; + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +#if defined __GNUC__ + #if __GNUC__ == 2 + #define __GNUC_2__ + #endif +#endif + + +vtkStandardNewMacro(SMESH_ExtractGeometry); + + +SMESH_ExtractGeometry::SMESH_ExtractGeometry() +{} + + +SMESH_ExtractGeometry::~SMESH_ExtractGeometry(){} + + +vtkIdType SMESH_ExtractGeometry::GetElemObjId(int theVtkID){ + if(myElemVTK2ObjIds.empty() || theVtkID > myElemVTK2ObjIds.size()) return -1; +#if defined __GNUC_2__ + return myElemVTK2ObjIds[theVtkID]; +#else + return myElemVTK2ObjIds.at(theVtkID); +#endif +} + + +vtkIdType SMESH_ExtractGeometry::GetNodeObjId(int theVtkID){ + if(myNodeVTK2ObjIds.empty() || theVtkID > myNodeVTK2ObjIds.size()) return -1; +#if defined __GNUC_2__ + return myNodeVTK2ObjIds[theVtkID]; +#else + return myNodeVTK2ObjIds.at(theVtkID); +#endif +} + + +void SMESH_ExtractGeometry::Execute() +{ + vtkIdType ptId, numPts, numCells, i, cellId, newCellId, newId, *pointMap; + vtkIdList *cellPts; + vtkCell *cell; + int numCellPts; + float *x; + float multiplier; + vtkPoints *newPts; + vtkIdList *newCellPts; + vtkDataSet *input = this->GetInput(); + vtkPointData *pd = input->GetPointData(); + vtkCellData *cd = input->GetCellData(); + vtkUnstructuredGrid *output = this->GetOutput(); + vtkPointData *outputPD = output->GetPointData(); + vtkCellData *outputCD = output->GetCellData(); + int npts; + numCells = input->GetNumberOfCells(); + numPts = input->GetNumberOfPoints(); + + vtkDebugMacro(<< "Extracting geometry"); + + if ( ! this->ImplicitFunction ) + { + vtkErrorMacro(<<"No implicit function specified"); + return; + } + + newCellPts = vtkIdList::New(); + newCellPts->Allocate(VTK_CELL_SIZE); + + if ( this->ExtractInside ) + { + multiplier = 1.0; + } + else + { + multiplier = -1.0; + } + + // Loop over all points determining whether they are inside the + // implicit function. Copy the points and point data if they are. + // + pointMap = new vtkIdType[numPts]; // maps old point ids into new + for (i=0; i < numPts; i++) + { + pointMap[i] = -1; + } + + output->Allocate(numCells/4); //allocate storage for geometry/topology + newPts = vtkPoints::New(); + newPts->Allocate(numPts/4,numPts); + outputPD->CopyAllocate(pd); + outputCD->CopyAllocate(cd); + vtkFloatArray *newScalars = NULL; + + if(myStoreMapping){ + myElemVTK2ObjIds.clear(); + myElemVTK2ObjIds.reserve(numCells); + myNodeVTK2ObjIds.clear(); + myNodeVTK2ObjIds.reserve(numPts); + } + + if ( ! this->ExtractBoundaryCells ) + { + for ( ptId=0; ptId < numPts; ptId++ ) + { + x = input->GetPoint(ptId); + if ( (this->ImplicitFunction->FunctionValue(x)*multiplier) < 0.0 ) + { + newId = newPts->InsertNextPoint(x); + pointMap[ptId] = newId; + myNodeVTK2ObjIds.push_back(ptId); + outputPD->CopyData(pd,ptId,newId); + } + } + } + else + { + // To extract boundary cells, we have to create supplemental information + if ( this->ExtractBoundaryCells ) + { + float val; + newScalars = vtkFloatArray::New(); + newScalars->SetNumberOfValues(numPts); + + for (ptId=0; ptId < numPts; ptId++ ) + { + x = input->GetPoint(ptId); + val = this->ImplicitFunction->FunctionValue(x) * multiplier; + newScalars->SetValue(ptId, val); + if ( val < 0.0 ) + { + newId = newPts->InsertNextPoint(x); + pointMap[ptId] = newId; + myNodeVTK2ObjIds.push_back(ptId); + outputPD->CopyData(pd,ptId,newId); + } + } + } + } + + // Now loop over all cells to see whether they are inside implicit + // function (or on boundary if ExtractBoundaryCells is on). + // + for (cellId=0; cellId < numCells; cellId++) + { + cell = input->GetCell(cellId); + cellPts = cell->GetPointIds(); + numCellPts = cell->GetNumberOfPoints(); + + newCellPts->Reset(); + if ( ! this->ExtractBoundaryCells ) //requires less work + { + for ( npts=0, i=0; i < numCellPts; i++, npts++) + { + ptId = cellPts->GetId(i); + if ( pointMap[ptId] < 0 ) + { + break; //this cell won't be inserted + } + else + { + newCellPts->InsertId(i,pointMap[ptId]); + } + } + } //if don't want to extract boundary cells + + else //want boundary cells + { + for ( npts=0, i=0; i < numCellPts; i++ ) + { + ptId = cellPts->GetId(i); + if ( newScalars->GetValue(ptId) <= 0.0 ) + { + npts++; + } + } + if ( npts > 0 ) + { + for ( i=0; i < numCellPts; i++ ) + { + ptId = cellPts->GetId(i); + if ( pointMap[ptId] < 0 ) + { + x = input->GetPoint(ptId); + newId = newPts->InsertNextPoint(x); + pointMap[ptId] = newId; + myNodeVTK2ObjIds.push_back(ptId); + outputPD->CopyData(pd,ptId,newId); + } + newCellPts->InsertId(i,pointMap[ptId]); + } + }//a boundary or interior cell + }//if mapping boundary cells + + if ( npts >= numCellPts || (this->ExtractBoundaryCells && npts > 0) ) + { + newCellId = output->InsertNextCell(cell->GetCellType(),newCellPts); + myElemVTK2ObjIds.push_back(cellId); + outputCD->CopyData(cd,cellId,newCellId); + } + }//for all cells + + // Update ourselves and release memory + // + delete [] pointMap; + newCellPts->Delete(); + output->SetPoints(newPts); + newPts->Delete(); + + if ( this->ExtractBoundaryCells ) + { + newScalars->Delete(); + } + + output->Squeeze(); +} diff --git a/src/SMDS/SMDS_HexahedronOfNodes.hxx b/src/OBJECT/SMESH_ExtractGeometry.h similarity index 51% rename from src/SMDS/SMDS_HexahedronOfNodes.hxx rename to src/OBJECT/SMESH_ExtractGeometry.h index 03cb242e2..794229516 100644 --- a/src/SMDS/SMDS_HexahedronOfNodes.hxx +++ b/src/OBJECT/SMESH_ExtractGeometry.h @@ -1,5 +1,3 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // @@ -18,41 +16,46 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMDS_MeshVolume.hxx -// Module : SMESH -#ifndef _SMDS_HexahedronOfNodes_HeaderFile -#define _SMDS_HexahedronOfNodes_HeaderFile +#ifndef SALOME_ExtractGeometry_HeaderFile +#define SALOME_ExtractGeometry_HeaderFile -#include "SMDS_MeshVolume.hxx" +#include #include -using namespace std; - -class SMDS_HexahedronOfNodes:public SMDS_MeshVolume -{ - - public: - SMDS_HexahedronOfNodes( - const SMDS_MeshNode * node1, - const SMDS_MeshNode * node2, - const SMDS_MeshNode * node3, - const SMDS_MeshNode * node4, - const SMDS_MeshNode * node5, - const SMDS_MeshNode * node6, - const SMDS_MeshNode * node7, - const SMDS_MeshNode * node8); - - void Print(ostream & OS) const; - int NbFaces() const; - int NbNodes() const; - int NbEdges() const; - SMDSAbs_ElementType GetType() const; - protected: - SMDS_ElemIteratorPtr - elementsIterator(SMDSAbs_ElementType type) const; - const SMDS_MeshNode * myNodes[8]; + + +class SMESH_ExtractGeometry : public vtkExtractGeometry{ +public: + vtkTypeMacro(SMESH_ExtractGeometry,vtkExtractGeometry); + + static SMESH_ExtractGeometry *New(); + + void SetStoreMapping(bool theStoreMapping){ + myStoreMapping = theStoreMapping; + Modified(); + } + bool GetStoreMapping(){ return myStoreMapping;} + + virtual vtkIdType GetNodeObjId(int theVtkID); + virtual vtkIdType GetElemObjId(int theVtkID); + +protected: + SMESH_ExtractGeometry(); + ~SMESH_ExtractGeometry(); + + void Execute(); + +private: + bool myStoreMapping; + typedef std::vector TVectorId; + TVectorId myElemVTK2ObjIds; + TVectorId myNodeVTK2ObjIds; + + SMESH_ExtractGeometry(const SMESH_ExtractGeometry&); // Not implemented. + void operator=(const SMESH_ExtractGeometry&); // Not implemented. }; + + #endif + + diff --git a/src/OBJECT/SMESH_Object.cxx b/src/OBJECT/SMESH_Object.cxx index eb39610cb..6621177cc 100644 --- a/src/OBJECT/SMESH_Object.cxx +++ b/src/OBJECT/SMESH_Object.cxx @@ -32,6 +32,12 @@ #include CORBA_SERVER_HEADER(SALOME_Exception) +#include +#include +#include +#include +#include + #include #include #include @@ -54,7 +60,7 @@ using namespace std; #endif #ifdef _DEBUG_ -static int MYDEBUG = 1; +static int MYDEBUG = 0; static int MYDEBUGWITHFILES = 0; #else static int MYDEBUG = 0; @@ -66,7 +72,9 @@ void WriteUnstructuredGrid(vtkUnstructuredGrid* theGrid, const char* theFileName vtkUnstructuredGridWriter* aWriter = vtkUnstructuredGridWriter::New(); aWriter->SetFileName(theFileName); aWriter->SetInput(theGrid); - aWriter->Write(); + if(theGrid->GetNumberOfCells()){ + aWriter->Write(); + } aWriter->Delete(); } @@ -405,8 +413,8 @@ void SMESH_VisualObj::buildNodePrs() myGrid->SetCells( 0, 0, 0 ); // Create cells - - /*vtkIdList *anIdList = vtkIdList::New(); + /* + vtkIdList *anIdList = vtkIdList::New(); anIdList->SetNumberOfIds( 1 ); vtkCellArray *aCells = vtkCellArray::New(); @@ -436,7 +444,8 @@ void SMESH_VisualObj::buildNodePrs() aCellLocationsArray->Delete(); aCellTypesArray->Delete(); aCells->Delete(); - anIdList->Delete(); */ + anIdList->Delete(); + */ } //================================================================================= @@ -547,6 +556,48 @@ void SMESH_VisualObj::buildElemPrs() anIdList->Delete(); } +//================================================================================= +// function : GetEdgeNodes +// purpose : Retrieve ids of nodes from edge of elements ( edge is numbered from 1 ) +//================================================================================= +bool SMESH_VisualObj::GetEdgeNodes( const int theElemId, + const int theEdgeNum, + int& theNodeId1, + int& theNodeId2 ) const +{ + const SMDS_Mesh* aMesh = GetMesh(); + if ( aMesh == 0 ) + return false; + + const SMDS_MeshElement* anElem = aMesh->FindElement( theElemId ); + if ( anElem == 0 ) + return false; + + int nbNodes = anElem->NbNodes(); + + if ( theEdgeNum < 1 || theEdgeNum > 4 || nbNodes != 3 && nbNodes != 4 || theEdgeNum > nbNodes ) + return false; + + int anIds[ nbNodes ]; + SMDS_ElemIteratorPtr anIter = anElem->nodesIterator(); + int i = 0; + while( anIter->more() ) + anIds[ i++ ] = anIter->next()->GetID(); + + if ( nbNodes != theEdgeNum ) + { + theNodeId1 = anIds[ theEdgeNum - 1 ]; + theNodeId2 = anIds[ theEdgeNum ]; + } + else + { + theNodeId1 = anIds[ nbNodes - 1 ]; + theNodeId2 = anIds[ 0 ]; + } + + return true; +} + /* Class : SMESH_MeshObj Description : Class for visualisation of mesh @@ -622,16 +673,51 @@ void SMESH_MeshObj::Update( int theIsClear ) for( ; anElemId < aNbElems; anElemId++ ) myMesh->RemoveElement( FindElement( myMesh, anIndexes[anElemId] ) ); break; + + case SMESH::MOVE_NODE: + for(CORBA::Long aCoordId=0; anElemId < aNbElems; anElemId++, aCoordId+=3) + { + SMDS_MeshNode* node = + const_cast( FindNode( myMesh, anIndexes[anElemId] )); + node->setXYZ( aCoords[aCoordId], aCoords[aCoordId+1], aCoords[aCoordId+2] ); + } + break; + + case SMESH::CHANGE_ELEMENT_NODES: + for ( CORBA::Long i = 0; anElemId < aNbElems; anElemId++ ) + { + // find element + const SMDS_MeshElement* elem = FindElement( myMesh, anIndexes[i++] ); + // nb nodes + int nbNodes = anIndexes[i++]; + // nodes + ASSERT( nbNodes < 9 ); + const SMDS_MeshNode* aNodes[ 8 ]; + for ( int iNode = 0; iNode < nbNodes; iNode++ ) + aNodes[ iNode ] = FindNode( myMesh, anIndexes[i++] ); + // change + myMesh->ChangeElementNodes( elem, aNodes, nbNodes ); + } + break; + + case SMESH::RENUMBER: + for(CORBA::Long i=0; anElemId < aNbElems; anElemId++, i+=3) + { + myMesh->Renumber( anIndexes[i], anIndexes[i+1], anIndexes[i+2] ); + } + break; + + default:; } } } catch ( SALOME::SALOME_Exception& exc ) { - INFOS("Follow exception was cought:\n\t"<SetMesh( myMeshServer ); + theFunctor->SetMesh( GetMesh() ); } //================================================================================= @@ -793,13 +879,13 @@ int SMESH_SubMeshObj::GetElemDimension( const int theObjId ) // function : UpdateFunctor // purpose : Update functor in accordance with current mesh //================================================================================= -void SMESH_SubMeshObj::UpdateFunctor( SMESH::Functor_ptr f ) +void SMESH_SubMeshObj::UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor ) { - f->SetMesh( myMeshObj->GetMeshServer() ); + theFunctor->SetMesh( myMeshObj->GetMesh() ); } //================================================================================= -// function : UpdateFunctor +// function : Update // purpose : Update mesh object and fill grid with new values //================================================================================= void SMESH_SubMeshObj::Update( int theIsClear ) @@ -818,10 +904,10 @@ void SMESH_SubMeshObj::Update( int theIsClear ) // function : SMESH_GroupObj // purpose : Constructor //================================================================================= -SMESH_GroupObj::SMESH_GroupObj( SMESH::SMESH_Group_ptr theGroup, - SMESH_MeshObj* theMeshObj ) +SMESH_GroupObj::SMESH_GroupObj( SMESH::SMESH_GroupBase_ptr theGroup, + SMESH_MeshObj* theMeshObj ) : SMESH_SubMeshObj( theMeshObj ), - myGroupServer( SMESH::SMESH_Group::_duplicate(theGroup) ) + myGroupServer( SMESH::SMESH_GroupBase::_duplicate(theGroup) ) { if ( MYDEBUG ) MESSAGE("SMESH_GroupObj - theGroup->_is_nil() = "<_is_nil()); myGroupServer->Register(); @@ -964,7 +1050,7 @@ int SMESH_subMeshObj::GetNbEntities( const SMESH::ElementType theType) const { case SMESH::NODE: { - return mySubMeshServer->GetNumberOfNodes(); + return mySubMeshServer->GetNumberOfNodes( false ); } break; case SMESH::EDGE: diff --git a/src/OBJECT/SMESH_Object.h b/src/OBJECT/SMESH_Object.h index 6ed30e2fa..b70ccae7c 100644 --- a/src/OBJECT/SMESH_Object.h +++ b/src/OBJECT/SMESH_Object.h @@ -30,16 +30,17 @@ #define SMESH_OBJECT_H // IDL Headers -#include +#include "SALOMEconfig.h" #include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_Group) -#include CORBA_SERVER_HEADER(SMESH_Filter) #include #include #include #include +#include "SMESH_Controls.hxx" + class vtkUnstructuredGrid; class vtkPoints; class SALOME_ExtractUnstructuredGrid; @@ -57,7 +58,6 @@ typedef boost::shared_ptr TVisualObjPtr; Class : SMESH_VisualObj Description : Base class for all mesh objects to be visuilised */ - class SMESH_VisualObj { protected: @@ -70,12 +70,18 @@ public: virtual ~SMESH_VisualObj(); virtual void Update( int theIsClear = true ) = 0; - virtual void UpdateFunctor( SMESH::Functor_ptr theFunctor ) = 0; + virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor ) = 0; virtual int GetElemDimension( const int theObjId ) = 0; virtual int GetNbEntities( const SMESH::ElementType) const = 0; virtual int GetEntities( const SMESH::ElementType, TEntityList& ) const = 0; virtual bool IsNodePrs() const = 0; + virtual SMDS_Mesh* GetMesh() const = 0; + + bool GetEdgeNodes( const int theElemId, + const int theEdgeNum, + int& theNodeId1, + int& theNodeId2 ) const; vtkUnstructuredGrid* GetUnstructuredGrid() { return myGrid; } @@ -91,7 +97,7 @@ protected: void buildNodePrs(); void buildElemPrs(); -private: +private: TMapOfIds mySMDS2VTKNodes; TMapOfIds myVTK2SMDSNodes; @@ -122,10 +128,10 @@ public: virtual int GetElemDimension( const int theObjId ); - virtual void UpdateFunctor( SMESH::Functor_ptr f ); + virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor ); SMESH::SMESH_Mesh_ptr GetMeshServer() { return myMeshServer.in(); } - SMDS_Mesh* GetMesh() { return myMesh; } + SMDS_Mesh* GetMesh() const { return myMesh; } protected: @@ -148,8 +154,9 @@ public: virtual void Update( int theIsClear = true ); - virtual void UpdateFunctor( SMESH::Functor_ptr ); + virtual void UpdateFunctor( const SMESH::Controls::FunctorPtr& theFunctor ); virtual int GetElemDimension( const int theObjId ); + virtual SMDS_Mesh* GetMesh() const { return myMeshObj->GetMesh(); } protected: @@ -165,7 +172,7 @@ protected: class SMESH_GroupObj: public SMESH_SubMeshObj { public: - SMESH_GroupObj( SMESH::SMESH_Group_ptr, SMESH_MeshObj* ); + SMESH_GroupObj( SMESH::SMESH_GroupBase_ptr, SMESH_MeshObj* ); virtual ~SMESH_GroupObj(); virtual int GetNbEntities( const SMESH::ElementType) const; @@ -174,7 +181,7 @@ public: private: - SMESH::SMESH_Group_var myGroupServer; + SMESH::SMESH_GroupBase_var myGroupServer; }; diff --git a/src/SMDS/Makefile.in b/src/SMDS/Makefile.in index 20bf98ce4..6ce749cf0 100644 --- a/src/SMDS/Makefile.in +++ b/src/SMDS/Makefile.in @@ -57,8 +57,9 @@ LIB_SRC = \ SMDS_VolumeOfNodes.cxx \ SMDS_FaceOfEdges.cxx \ SMDS_FaceOfNodes.cxx \ - SMDS_Tria3OfNodes.cxx \ - SMDS_HexahedronOfNodes.cxx + SMDS_VolumeTool.cxx +# SMDS_Tria3OfNodes.cxx \ +# SMDS_HexahedronOfNodes.cxx #SMDSControl_BoundaryEdges.cxx \ #SMDSControl_BoundaryFaces.cxx \ @@ -107,8 +108,9 @@ EXPORT_HEADERS= \ SMDS_VolumeOfNodes.hxx \ SMDS_FaceOfEdges.hxx \ SMDS_FaceOfNodes.hxx \ - SMDS_Tria3OfNodes.hxx \ - SMDS_HexahedronOfNodes.hxx + SMDS_VolumeTool.hxx +# SMDS_Tria3OfNodes.hxx \ +# SMDS_HexahedronOfNodes.hxx #SMDSControl_BoundaryEdges.hxx \ #SMDSControl_BoundaryFaces.hxx \ diff --git a/src/SMDS/SMDSAbs_ElementType.hxx b/src/SMDS/SMDSAbs_ElementType.hxx index 94319f90c..c474a4e55 100644 --- a/src/SMDS/SMDSAbs_ElementType.hxx +++ b/src/SMDS/SMDSAbs_ElementType.hxx @@ -30,7 +30,7 @@ /// Type (node, edge, face or volume) of elements /////////////////////////////////////////////////////////////////////////////// enum SMDSAbs_ElementType -{ +{ SMDSAbs_All, SMDSAbs_Node, SMDSAbs_Edge, diff --git a/src/SMDS/SMDSControl.cxx b/src/SMDS/SMDSControl.cxx deleted file mode 100644 index ceaff2848..000000000 --- a/src/SMDS/SMDSControl.cxx +++ /dev/null @@ -1,234 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// Copyright (C) 2003 OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org or email : webmaster@opencascade.org -// -// -// -// File : SMDSControl.cxx -// Author : Jean-Michel BOULCOURT -// Module : SMESH - -using namespace std; -#include "SMDSControl.ixx" -#include "SMDS_Mesh.hxx" -#include "SMDS_MeshElement.hxx" -#include "SMDS_ListOfMeshElement.hxx" -#include "SMDS_ListIteratorOfListOfMeshElement.hxx" - -//======================================================================= -//function : ComputeNeighborFaces -//purpose : -//======================================================================= - -Standard_Integer SMDSControl::ComputeNeighborFaces(const Handle(SMDS_Mesh)& M, - const Handle(SMDS_MeshElement)& ME, - const Standard_Integer idnode1, - const Standard_Integer idnode2) -{ - const Handle(SMDS_MeshElement)& node1 = M->FindNode(idnode1); - const Handle(SMDS_MeshElement)& node2 = M->FindNode(idnode2); - const SMDS_ListOfMeshElement& lstInvFaces1 = node1->InverseElements(); - const SMDS_ListOfMeshElement& lstInvFaces2 = node2->InverseElements(); - Standard_Integer neighbor=0; - - SMDS_ListIteratorOfListOfMeshElement it1(lstInvFaces1); - for (;it1.More();it1.Next()) { - const Handle(SMDS_MeshElement)& face = it1.Value(); - if (M->Contains(face) && !face->IsSame(ME)) { - if (face->IsNodeInElement(idnode1) && face->IsNodeInElement(idnode2)) { - neighbor++; - } - } - } - - if (neighbor > 0) { - return neighbor; - } - - SMDS_ListIteratorOfListOfMeshElement it2(lstInvFaces2); - for (;it2.More();it2.Next()) { - const Handle(SMDS_MeshElement)& face = it2.Value(); - if (M->Contains(face) && !face->IsSame(ME)) { - if (face->IsNodeInElement(idnode1) && face->IsNodeInElement(idnode2)) { - neighbor++; - } - } - } - - return neighbor; -} - -//======================================================================= -//function : ComputeNeighborVolumes -//purpose : -//======================================================================= - -Standard_Integer SMDSControl::ComputeNeighborVolumes(const Handle(SMDS_Mesh)& M, - const Handle(SMDS_MeshElement)& ME, - const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3) -{ - - const Handle(SMDS_MeshElement)& node1 = M->FindNode(idnode1); - const Handle(SMDS_MeshElement)& node2 = M->FindNode(idnode2); - const Handle(SMDS_MeshElement)& node3 = M->FindNode(idnode3); - const SMDS_ListOfMeshElement& lstInvVol1 = node1->InverseElements(); - const SMDS_ListOfMeshElement& lstInvVol2 = node2->InverseElements(); - const SMDS_ListOfMeshElement& lstInvVol3 = node3->InverseElements(); - - Standard_Integer neighbor=0; - - SMDS_ListIteratorOfListOfMeshElement it1(lstInvVol1); - for (;it1.More() && neighbor == 0;it1.Next()) { - const Handle(SMDS_MeshElement)& vol = it1.Value(); - if (M->Contains(vol) && !vol->IsSame(ME)) { - if (vol->IsNodeInElement(idnode1) - && vol->IsNodeInElement(idnode2) - && vol->IsNodeInElement(idnode3)) { - neighbor++; - } - } - } - - if (neighbor > 0) { - return neighbor; - } - - SMDS_ListIteratorOfListOfMeshElement it2(lstInvVol2); - for (;it2.More() && neighbor == 0;it2.Next()) { - const Handle(SMDS_MeshElement)& vol = it2.Value(); - if (M->Contains(vol) && !vol->IsSame(ME)) { - if (vol->IsNodeInElement(idnode1) - && vol->IsNodeInElement(idnode2) - && vol->IsNodeInElement(idnode3)) { - neighbor++; - } - } - } - - if (neighbor > 0) { - return neighbor; - } - - SMDS_ListIteratorOfListOfMeshElement it3(lstInvVol3); - for (;it3.More() && neighbor == 0;it3.Next()) { - const Handle(SMDS_MeshElement)& vol = it3.Value(); - if (M->Contains(vol) && !vol->IsSame(ME)) { - if (vol->IsNodeInElement(idnode1) - && vol->IsNodeInElement(idnode2) - && vol->IsNodeInElement(idnode3)) { - neighbor++; - } - } - } - - return neighbor; - -} - -//======================================================================= -//function : ComputeNeighborVolumes -//purpose : -//======================================================================= - -Standard_Integer SMDSControl::ComputeNeighborVolumes(const Handle(SMDS_Mesh)& M, - const Handle(SMDS_MeshElement)& ME, - const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4) -{ - - const Handle(SMDS_MeshElement)& node1 = M->FindNode(idnode1); - const Handle(SMDS_MeshElement)& node2 = M->FindNode(idnode2); - const Handle(SMDS_MeshElement)& node3 = M->FindNode(idnode3); - const Handle(SMDS_MeshElement)& node4 = M->FindNode(idnode4); - const SMDS_ListOfMeshElement& lstInvVol1 = node1->InverseElements(); - const SMDS_ListOfMeshElement& lstInvVol2 = node2->InverseElements(); - const SMDS_ListOfMeshElement& lstInvVol3 = node3->InverseElements(); - const SMDS_ListOfMeshElement& lstInvVol4 = node4->InverseElements(); - Standard_Integer neighbor=0; - - SMDS_ListIteratorOfListOfMeshElement it1(lstInvVol1); - for (;it1.More();it1.Next()) { - const Handle(SMDS_MeshElement)& vol = it1.Value(); - if (M->Contains(vol) && !vol->IsSame(ME)) { - if ( vol->IsNodeInElement(idnode1) - && vol->IsNodeInElement(idnode2) - && vol->IsNodeInElement(idnode3) - && vol->IsNodeInElement(idnode4)) { - neighbor++; - } - } - } - - if (neighbor >= 2) { - return neighbor; - } - - SMDS_ListIteratorOfListOfMeshElement it2(lstInvVol2); - for (;it2.More();it2.Next()) { - const Handle(SMDS_MeshElement)& vol = it2.Value(); - if (M->Contains(vol) && !vol->IsSame(ME)) { - if ( vol->IsNodeInElement(idnode1) - && vol->IsNodeInElement(idnode2) - && vol->IsNodeInElement(idnode3) - && vol->IsNodeInElement(idnode4)) { - neighbor++; - } - } - } - - if (neighbor >= 2) { - return neighbor; - } - - SMDS_ListIteratorOfListOfMeshElement it3(lstInvVol3); - for (;it3.More();it3.Next()) { - const Handle(SMDS_MeshElement)& vol = it3.Value(); - if (M->Contains(vol) && !vol->IsSame(ME)) { - if ( vol->IsNodeInElement(idnode1) - && vol->IsNodeInElement(idnode2) - && vol->IsNodeInElement(idnode3) - && vol->IsNodeInElement(idnode4)) { - neighbor++; - } - } - } - - if (neighbor >= 2) { - return neighbor; - } - - SMDS_ListIteratorOfListOfMeshElement it4(lstInvVol4); - for (;it4.More();it4.Next()) { - const Handle(SMDS_MeshElement)& vol = it4.Value(); - if (M->Contains(vol) && !vol->IsSame(ME)) { - if ( vol->IsNodeInElement(idnode1) - && vol->IsNodeInElement(idnode2) - && vol->IsNodeInElement(idnode3) - && vol->IsNodeInElement(idnode4)) { - neighbor++; - } - } - } - - return neighbor; -} diff --git a/src/SMDS/SMDSControl.hxx b/src/SMDS/SMDSControl.hxx deleted file mode 100644 index ce02a5698..000000000 --- a/src/SMDS/SMDSControl.hxx +++ /dev/null @@ -1,115 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// Copyright (C) 2003 OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org or email : webmaster@opencascade.org -// -// -// -// File : SMDSControl.hxx -// Module : SMESH - -#ifndef _SMDSControl_HeaderFile -#define _SMDSControl_HeaderFile - -#ifndef _Standard_Integer_HeaderFile -#include -#endif -#ifndef _Handle_SMDS_Mesh_HeaderFile -#include "Handle_SMDS_Mesh.hxx" -#endif -#ifndef _Handle_SMDS_MeshElement_HeaderFile -#include "Handle_SMDS_MeshElement.hxx" -#endif -class SMDS_Mesh; -class SMDS_MeshElement; -class SMDSControl_MeshBoundary; -class SMDSControl_BoundaryEdges; -class SMDSControl_BoundaryFaces; - - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -class SMDSControl { - -public: - - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT static Standard_Integer ComputeNeighborFaces(const Handle(SMDS_Mesh)& M,const Handle(SMDS_MeshElement)& ME,const Standard_Integer idnode1,const Standard_Integer idnode2) ; -Standard_EXPORT static Standard_Integer ComputeNeighborVolumes(const Handle(SMDS_Mesh)& M,const Handle(SMDS_MeshElement)& ME,const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3) ; -Standard_EXPORT static Standard_Integer ComputeNeighborVolumes(const Handle(SMDS_Mesh)& M,const Handle(SMDS_MeshElement)& ME,const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4) ; - - - - - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // - -friend class SMDSControl_MeshBoundary; -friend class SMDSControl_BoundaryEdges; -friend class SMDSControl_BoundaryFaces; - -}; - - - - - -// other inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/SMDS/SMDSControl_BoundaryEdges.cxx b/src/SMDS/SMDSControl_BoundaryEdges.cxx deleted file mode 100644 index b71ef13e5..000000000 --- a/src/SMDS/SMDSControl_BoundaryEdges.cxx +++ /dev/null @@ -1,79 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// Copyright (C) 2003 OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org or email : webmaster@opencascade.org -// -// -// -// File : SMDSControl_BoundaryEdges.cxx -// Author : Jean-Michel BOULCOURT -// Module : SMESH - -using namespace std; -#include "SMDSControl_BoundaryEdges.ixx" -#include "SMDSControl.hxx" - -#include "SMDS_MeshFacesIterator.hxx" -#include "SMDS_MeshElement.hxx" -#include "SMDS_MeshEdge.hxx" -#include "SMDS_MapIteratorOfExtendedMap.hxx" - -//======================================================================= -//function : SMDSControl_BoundaryEdges -//purpose : -//======================================================================= - -SMDSControl_BoundaryEdges::SMDSControl_BoundaryEdges(const Handle(SMDS_Mesh)& M) - :SMDSControl_MeshBoundary(M) -{ -} - -//======================================================================= -//function : Compute -//purpose : -//======================================================================= - -void SMDSControl_BoundaryEdges::Compute() -{ - Standard_Integer idnode1; - Standard_Integer idnode2; - Standard_Integer nbedg; - - myBoundaryMesh = myMesh->AddSubMesh(); - SMDS_MeshFacesIterator itface(myMesh); - - for (;itface.More();itface.Next()) { - Handle(SMDS_MeshElement) ME = itface.Value(); - - nbedg = ME->NbEdges(); - - for (Standard_Integer iedge=1; iedge<=nbedg; ++iedge) { - ME->GetEdgeDefinedByNodes(iedge,idnode1,idnode2); - Handle(SMDS_MeshElement) edge = new SMDS_MeshEdge(0,idnode1,idnode2); - if (!myBoundaryEdges.Add(edge)) - myBoundaryEdges.Remove(edge); - } - } - - SMDS_MapIteratorOfExtendedMap itbound(myBoundaryEdges); - - for (;itbound.More();itbound.Next()) { - const Handle(SMDS_MeshElement)& edge = itbound.Key(); - myBoundaryMesh->AddEdge(edge->GetConnection(1),edge->GetConnection(2)); - } -} diff --git a/src/SMDS/SMDSControl_BoundaryEdges.hxx b/src/SMDS/SMDSControl_BoundaryEdges.hxx deleted file mode 100644 index e54ba25e4..000000000 --- a/src/SMDS/SMDSControl_BoundaryEdges.hxx +++ /dev/null @@ -1,114 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// Copyright (C) 2003 OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org or email : webmaster@opencascade.org -// -// -// -// File : SMDSControl_BoundaryEdges.hxx -// Module : SMESH - -#ifndef _SMDSControl_BoundaryEdges_HeaderFile -#define _SMDSControl_BoundaryEdges_HeaderFile - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Handle_SMDSControl_BoundaryEdges_HeaderFile -#include "Handle_SMDSControl_BoundaryEdges.hxx" -#endif - -#ifndef _SMDS_MapOfMeshElement_HeaderFile -#include "SMDS_MapOfMeshElement.hxx" -#endif -#ifndef _SMDSControl_MeshBoundary_HeaderFile -#include "SMDSControl_MeshBoundary.hxx" -#endif -#ifndef _Handle_SMDS_Mesh_HeaderFile -#include "Handle_SMDS_Mesh.hxx" -#endif -class SMDS_Mesh; - - -class SMDSControl_BoundaryEdges : public SMDSControl_MeshBoundary { - -public: - - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT SMDSControl_BoundaryEdges(const Handle(SMDS_Mesh)& M); -Standard_EXPORT virtual void Compute() ; -Standard_EXPORT ~SMDSControl_BoundaryEdges(); - - - - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& SMDSControl_BoundaryEdges_Type_(); - Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // -SMDS_MapOfMeshElement myBoundaryEdges; - - -}; - - - - - -// other inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/SMDS/SMDSControl_BoundaryFaces.cxx b/src/SMDS/SMDSControl_BoundaryFaces.cxx deleted file mode 100644 index cb9d5060b..000000000 --- a/src/SMDS/SMDSControl_BoundaryFaces.cxx +++ /dev/null @@ -1,102 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// Copyright (C) 2003 OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org or email : webmaster@opencascade.org -// -// -// -// File : SMDSControl_BoundaryFaces.cxx -// Author : Jean-Michel BOULCOURT -// Module : SMESH - -using namespace std; -#include "SMDSControl_BoundaryFaces.ixx" -#include "SMDSControl.hxx" - -#include "SMDS_MeshVolumesIterator.hxx" -#include "SMDS_MeshElement.hxx" -#include "SMDS_MeshFace.hxx" -#include "SMDS_MeshTriangle.hxx" -#include "SMDS_MeshQuadrangle.hxx" -#include "SMDS_MapIteratorOfExtendedMap.hxx" - -//======================================================================= -//function : SMDSControl_BoundaryFaces -//purpose : -//======================================================================= - -SMDSControl_BoundaryFaces::SMDSControl_BoundaryFaces(const Handle(SMDS_Mesh)& M) - :SMDSControl_MeshBoundary(M) -{ -} - -//======================================================================= -//function : Compute -//purpose : -//======================================================================= - -void SMDSControl_BoundaryFaces::Compute() -{ - myBoundaryMesh = myMesh->AddSubMesh(); - SMDS_MeshVolumesIterator itvol(myMesh); - - Standard_Integer idnode[4]; // max number of nodes for a face - Standard_Integer nbnode; - - for (;itvol.More();itvol.Next()) { - Handle(SMDS_MeshElement) ME = itvol.Value(); - - - Standard_Integer nbfaces = ME->NbFaces(); - - for (Standard_Integer iface=1; iface<=nbfaces; ++iface) { - - ME->GetFaceDefinedByNodes(iface,idnode,nbnode); - // Triangle - if (nbnode == 3) { - Handle(SMDS_MeshElement) face = new SMDS_MeshTriangle(0,idnode[0],idnode[1],idnode[2]); - if (!myBoundaryFaces.Add(face)) - myBoundaryFaces.Remove(face); - - - } else { - // Quadrangle - - Handle(SMDS_MeshElement) face = new SMDS_MeshQuadrangle(0,idnode[0],idnode[1],idnode[2],idnode[3]); - if (!myBoundaryFaces.Add(face)) - myBoundaryFaces.Remove(face); - - } - } // end iface - - } // end itvol - - SMDS_MapIteratorOfExtendedMap itbound(myBoundaryFaces); - - for (;itbound.More();itbound.Next()) { - const Handle(SMDS_MeshElement)& face = itbound.Key(); - if (face->NbNodes() == 3) - myBoundaryMesh->AddFace(face->GetConnection(1),face->GetConnection(2),face->GetConnection(3)); - else - myBoundaryMesh->AddFace(face->GetConnection(1),face->GetConnection(2),face->GetConnection(3), - face->GetConnection(4)); - } - -} - - diff --git a/src/SMDS/SMDSControl_BoundaryFaces.hxx b/src/SMDS/SMDSControl_BoundaryFaces.hxx deleted file mode 100644 index 6307ce248..000000000 --- a/src/SMDS/SMDSControl_BoundaryFaces.hxx +++ /dev/null @@ -1,114 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// Copyright (C) 2003 OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org or email : webmaster@opencascade.org -// -// -// -// File : SMDSControl_BoundaryFaces.hxx -// Module : SMESH - -#ifndef _SMDSControl_BoundaryFaces_HeaderFile -#define _SMDSControl_BoundaryFaces_HeaderFile - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Handle_SMDSControl_BoundaryFaces_HeaderFile -#include -#endif - -#ifndef _SMDS_MapOfMeshElement_HeaderFile -#include "SMDS_MapOfMeshElement.hxx" -#endif -#ifndef _SMDSControl_MeshBoundary_HeaderFile -#include "SMDSControl_MeshBoundary.hxx" -#endif -#ifndef _Handle_SMDS_Mesh_HeaderFile -#include "Handle_SMDS_Mesh.hxx" -#endif -class SMDS_Mesh; - - -class SMDSControl_BoundaryFaces : public SMDSControl_MeshBoundary { - -public: - - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT SMDSControl_BoundaryFaces(const Handle(SMDS_Mesh)& M); -Standard_EXPORT virtual void Compute() ; -Standard_EXPORT ~SMDSControl_BoundaryFaces(); - - - - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& SMDSControl_BoundaryFaces_Type_(); - Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // -SMDS_MapOfMeshElement myBoundaryFaces; - - -}; - - - - - -// other inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/SMDS/SMDSControl_MeshBoundary.cxx b/src/SMDS/SMDSControl_MeshBoundary.cxx deleted file mode 100644 index f51092b7c..000000000 --- a/src/SMDS/SMDSControl_MeshBoundary.cxx +++ /dev/null @@ -1,60 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// Copyright (C) 2003 OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org or email : webmaster@opencascade.org -// -// -// -// File : SMDSControl_MeshBoundary.cxx -// Author : Jean-Michel BOULCOURT -// Module : SMESH - -using namespace std; -#include "SMDSControl_MeshBoundary.ixx" - -//======================================================================= -//function : SMDSControl_MeshBoundary -//purpose : -//======================================================================= - -SMDSControl_MeshBoundary::SMDSControl_MeshBoundary() -{ -} - -//======================================================================= -//function : SMDSControl_MeshBoundary -//purpose : -//======================================================================= - -SMDSControl_MeshBoundary::SMDSControl_MeshBoundary(const Handle(SMDS_Mesh)& M) - :myMesh(M) -{ -} - -//======================================================================= -//function : ResultMesh -//purpose : -//======================================================================= - -Handle(SMDS_Mesh) SMDSControl_MeshBoundary::ResultMesh() -{ - if (myBoundaryMesh.IsNull()) - Compute(); - return myBoundaryMesh; -} - diff --git a/src/SMDS/SMDSControl_MeshBoundary.hxx b/src/SMDS/SMDSControl_MeshBoundary.hxx deleted file mode 100644 index 0e77e5e9a..000000000 --- a/src/SMDS/SMDSControl_MeshBoundary.hxx +++ /dev/null @@ -1,114 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// Copyright (C) 2003 OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org or email : webmaster@opencascade.org -// -// -// -// File : SMDSControl_MeshBoundary.hxx -// Module : SMESH - -#ifndef _SMDSControl_MeshBoundary_HeaderFile -#define _SMDSControl_MeshBoundary_HeaderFile - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Handle_SMDSControl_MeshBoundary_HeaderFile -#include "Handle_SMDSControl_MeshBoundary.hxx" -#endif - -#ifndef _Handle_SMDS_Mesh_HeaderFile -#include "Handle_SMDS_Mesh.hxx" -#endif -#ifndef _MMgt_TShared_HeaderFile -#include -#endif -class SMDS_Mesh; - - -class SMDSControl_MeshBoundary : public MMgt_TShared { - -public: - - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT virtual void Compute() = 0; -Standard_EXPORT Handle_SMDS_Mesh ResultMesh() ; -Standard_EXPORT ~SMDSControl_MeshBoundary(); - - - - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& SMDSControl_MeshBoundary_Type_(); - Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; - -protected: - - // Methods PROTECTED - // -Standard_EXPORT SMDSControl_MeshBoundary(); -Standard_EXPORT SMDSControl_MeshBoundary(const Handle(SMDS_Mesh)& M); - - - // Fields PROTECTED - // -Handle_SMDS_Mesh myMesh; -Handle_SMDS_Mesh myBoundaryMesh; - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // - - -}; - - - - - -// other inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/SMDS/SMDSEdit_Transform.cxx b/src/SMDS/SMDSEdit_Transform.cxx deleted file mode 100644 index 4a9054ee1..000000000 --- a/src/SMDS/SMDSEdit_Transform.cxx +++ /dev/null @@ -1,120 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// Copyright (C) 2003 OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org or email : webmaster@opencascade.org -// -// -// -// File : SMDSEdit_Transform.cxx -// Author : Jean-Michel BOULCOURT -// Module : SMESH - -using namespace std; -#include "SMDSEdit_Transform.ixx" -#include "SMDS_MeshNode.hxx" -#include "SMDS_MeshElement.hxx" -#include "SMDS_MeshNodesIterator.hxx" -#include "SMDS_ListIteratorOfListOfMeshElement.hxx" -#include "TColStd_MapOfInteger.hxx" - - -//======================================================================= -//function : SMDSEdit_Transform -//purpose : -//======================================================================= - -SMDSEdit_Transform::SMDSEdit_Transform(const Handle(SMDS_Mesh)& aMesh,const gp_Trsf& aTrsf) - :myMesh(aMesh),myTrsf(aTrsf) -{ -} - -//======================================================================= -//function : SMDSEdit_Transform -//purpose : -//======================================================================= - -SMDSEdit_Transform::SMDSEdit_Transform(const Handle(SMDS_Mesh)& aMesh, - const SMDS_ListOfMeshElement& aListOfME, - const gp_Trsf& aTrsf) - :myMesh(aMesh),myTrsf(aTrsf) -{ - myListOfME = aListOfME; -} - -//======================================================================= -//function : SetTrsf -//purpose : -//======================================================================= - -void SMDSEdit_Transform::SetTrsf(const gp_Trsf& aTrsf) -{ - myTrsf = aTrsf; -} - -//======================================================================= -//function : GetTrsf -//purpose : -//======================================================================= - -gp_Trsf SMDSEdit_Transform::GetTrsf() const -{ - return myTrsf; -} - -//======================================================================= -//function : Perform -//purpose : -//======================================================================= - -void SMDSEdit_Transform::Perform() -{ - if (myListOfME.IsEmpty()) { - // transform the whole mesh - SMDS_MeshNodesIterator itNodes(myMesh); - - for (;itNodes.More();itNodes.Next()) { - const Handle(SMDS_MeshElement)& elem = itNodes.Value(); - Handle(SMDS_MeshNode) node = *((Handle(SMDS_MeshNode)*)&elem); - - gp_Pnt P = node->Pnt(); - P.Transform(myTrsf); - node->SetPnt(P); - } - - } else { - TColStd_MapOfInteger mapnode; - Standard_Integer nbnodes,inode; - - SMDS_ListIteratorOfListOfMeshElement itME(myListOfME); - for (;itME.More();itME.Next()) { - const Handle(SMDS_MeshElement)& elem = itME.Value(); - nbnodes = elem->NbNodes(); - - for (inode = 1; inode <= nbnodes; ++inode) { - const Handle(SMDS_MeshNode)& node = myMesh->GetNode(inode,elem); - if (mapnode.Add(node->GetID())) { - gp_Pnt P = node->Pnt(); - P.Transform(myTrsf); - node->SetPnt(P); - } - } - - } - } -} - diff --git a/src/SMDS/SMDSEdit_Transform.hxx b/src/SMDS/SMDSEdit_Transform.hxx deleted file mode 100644 index b28728f60..000000000 --- a/src/SMDS/SMDSEdit_Transform.hxx +++ /dev/null @@ -1,115 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// Copyright (C) 2003 OPEN CASCADE -// -// This library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Lesser General Public -// License as published by the Free Software Foundation; either -// version 2.1 of the License. -// -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public -// License along with this library; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -// -// See http://www.opencascade.org or email : webmaster@opencascade.org -// -// -// -// File : SMDSEdit_Transform.hxx -// Module : SMESH - -#ifndef _SMDSEdit_Transform_HeaderFile -#define _SMDSEdit_Transform_HeaderFile - -#ifndef _Handle_SMDS_Mesh_HeaderFile -#include "Handle_SMDS_Mesh.hxx" -#endif -#ifndef _gp_Trsf_HeaderFile -#include -#endif -#ifndef _SMDS_ListOfMeshElement_HeaderFile -#include "SMDS_ListOfMeshElement.hxx" -#endif -class SMDS_Mesh; -class gp_Trsf; -class SMDS_ListOfMeshElement; - - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Standard_Macro_HeaderFile -#include -#endif - -class SMDSEdit_Transform { - -public: - - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT SMDSEdit_Transform(const Handle(SMDS_Mesh)& aMesh,const gp_Trsf& aTrsf); -Standard_EXPORT SMDSEdit_Transform(const Handle(SMDS_Mesh)& aMesh,const SMDS_ListOfMeshElement& aListOfME,const gp_Trsf& aTrsf); -Standard_EXPORT void Perform() ; -Standard_EXPORT void SetTrsf(const gp_Trsf& aTrsf) ; -Standard_EXPORT gp_Trsf GetTrsf() const; - - - - - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // -Handle_SMDS_Mesh myMesh; -gp_Trsf myTrsf; -SMDS_ListOfMeshElement myListOfME; - - -}; - - - - - -// other inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/SMDS/SMDS_EdgePosition.cxx b/src/SMDS/SMDS_EdgePosition.cxx index e2f7d9755..82c92b398 100644 --- a/src/SMDS/SMDS_EdgePosition.cxx +++ b/src/SMDS/SMDS_EdgePosition.cxx @@ -26,8 +26,11 @@ // Module : SMESH #include "SMDS_EdgePosition.hxx" + #include "utilities.h" +using namespace std; + //======================================================================= //function : SMDS_EdgePosition //purpose : diff --git a/src/SMDS/SMDS_FaceOfEdges.cxx b/src/SMDS/SMDS_FaceOfEdges.cxx index 0a53bba6e..de9092f44 100644 --- a/src/SMDS/SMDS_FaceOfEdges.cxx +++ b/src/SMDS/SMDS_FaceOfEdges.cxx @@ -23,6 +23,8 @@ #include "SMDS_IteratorOfElements.hxx" #include "SMDS_MeshNode.hxx" +using namespace std; + //======================================================================= //function : NbEdges //purpose : diff --git a/src/SMDS/SMDS_FaceOfEdges.hxx b/src/SMDS/SMDS_FaceOfEdges.hxx index 414020755..6e8e7b8d6 100644 --- a/src/SMDS/SMDS_FaceOfEdges.hxx +++ b/src/SMDS/SMDS_FaceOfEdges.hxx @@ -22,15 +22,17 @@ #ifndef _SMDS_FaceOfEdges_HeaderFile #define _SMDS_FaceOfEdges_HeaderFile -#include #include "SMDS_MeshFace.hxx" #include "SMDS_MeshEdge.hxx" #include "SMDS_Iterator.hxx" +#include + + class SMDS_FaceOfEdges:public SMDS_MeshFace { public: - void Print(ostream & OS) const; + void Print(std::ostream & OS) const; SMDS_FaceOfEdges(const SMDS_MeshEdge* edge1, const SMDS_MeshEdge* edge2, const SMDS_MeshEdge* edge3); @@ -49,7 +51,7 @@ class SMDS_FaceOfEdges:public SMDS_MeshFace elementsIterator(SMDSAbs_ElementType type) const; private: - vector myEdges; + std::vector myEdges; }; diff --git a/src/SMDS/SMDS_FaceOfNodes.cxx b/src/SMDS/SMDS_FaceOfNodes.cxx index abc9c9d60..2ef48ca8a 100644 --- a/src/SMDS/SMDS_FaceOfNodes.cxx +++ b/src/SMDS/SMDS_FaceOfNodes.cxx @@ -24,6 +24,8 @@ #include "SMDS_MeshNode.hxx" #include "utilities.h" +using namespace std; + //======================================================================= //function : NbEdges //purpose : @@ -92,6 +94,7 @@ SMDS_ElemIteratorPtr SMDS_FaceOfNodes:: (new SMDS_IteratorOfElements (this,type,SMDS_ElemIteratorPtr(new SMDS_FaceOfNodes_MyIterator(myNodes)))); } + return SMDS_ElemIteratorPtr(); } SMDS_FaceOfNodes::SMDS_FaceOfNodes(const SMDS_MeshNode* node1, @@ -115,6 +118,27 @@ SMDS_FaceOfNodes::SMDS_FaceOfNodes(const SMDS_MeshNode* node1, myNodes[2]=node3; myNodes[3]=node4; } +bool SMDS_FaceOfNodes::ChangeNodes(const SMDS_MeshNode* nodes[], + const int nbNodes) +{ + if (nbNodes == 3) { + myNodes.resize(3); + myNodes[0]=nodes[0]; + myNodes[1]=nodes[1]; + myNodes[2]=nodes[2]; + } + else if ( nbNodes == 4) { + myNodes.resize(4); + myNodes[0]=nodes[0]; + myNodes[1]=nodes[1]; + myNodes[2]=nodes[2]; + myNodes[3]=nodes[3]; + } + else + return false; + + return true; +} /*bool operator<(const SMDS_FaceOfNodes& f1, const SMDS_FaceOfNodes& f2) { diff --git a/src/SMDS/SMDS_FaceOfNodes.hxx b/src/SMDS/SMDS_FaceOfNodes.hxx index 9a2adad0b..0203c1b10 100644 --- a/src/SMDS/SMDS_FaceOfNodes.hxx +++ b/src/SMDS/SMDS_FaceOfNodes.hxx @@ -22,15 +22,16 @@ #ifndef _SMDS_FaceOfNodes_HeaderFile #define _SMDS_FaceOfNodes_HeaderFile -#include #include "SMDS_MeshFace.hxx" #include "SMDS_MeshNode.hxx" #include "SMDS_Iterator.hxx" +#include + class SMDS_FaceOfNodes:public SMDS_MeshFace { public: - void Print(ostream & OS) const; + void Print(std::ostream & OS) const; SMDS_FaceOfNodes(const SMDS_MeshNode* node1, const SMDS_MeshNode* node2, const SMDS_MeshNode* node3); @@ -38,7 +39,8 @@ class SMDS_FaceOfNodes:public SMDS_MeshFace const SMDS_MeshNode* node2, const SMDS_MeshNode* node3, const SMDS_MeshNode* node4); - + bool ChangeNodes(const SMDS_MeshNode* nodes[], + const int nbNodes); int NbEdges() const; int NbFaces() const; int NbNodes() const; @@ -47,7 +49,7 @@ class SMDS_FaceOfNodes:public SMDS_MeshFace elementsIterator(SMDSAbs_ElementType type) const; private: - vector myNodes; + std::vector myNodes; }; diff --git a/src/SMDS/SMDS_FacePosition.cxx b/src/SMDS/SMDS_FacePosition.cxx index 57a98e7d4..c97e64f7a 100644 --- a/src/SMDS/SMDS_FacePosition.cxx +++ b/src/SMDS/SMDS_FacePosition.cxx @@ -26,8 +26,11 @@ // Module : SMESH #include "SMDS_FacePosition.hxx" + #include "utilities.h" +using namespace std; + //======================================================================= //function : SMDS_FacePosition //purpose : diff --git a/src/SMDS/SMDS_HexahedronOfNodes.cxx b/src/SMDS/SMDS_HexahedronOfNodes.cxx deleted file mode 100644 index 8682ad770..000000000 --- a/src/SMDS/SMDS_HexahedronOfNodes.cxx +++ /dev/null @@ -1,95 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org - -#include "utilities.h" -#include "SMDS_HexahedronOfNodes.hxx" -#include "SMDS_IteratorOfArray.hxx" -#include "SMDS_MeshNode.hxx" - -/////////////////////////////////////////////////////////////////////////////// -/// Create an hexahedron. node 1,2,3,4 and 5,6,7,8 are quadrangle and -/// 5,1 and 7,3 are an edges. -/////////////////////////////////////////////////////////////////////////////// -SMDS_HexahedronOfNodes::SMDS_HexahedronOfNodes( - const SMDS_MeshNode * node1, - const SMDS_MeshNode * node2, - const SMDS_MeshNode * node3, - const SMDS_MeshNode * node4, - const SMDS_MeshNode * node5, - const SMDS_MeshNode * node6, - const SMDS_MeshNode * node7, - const SMDS_MeshNode * node8) -{ - myNodes[0]=node1; - myNodes[1]=node2; - myNodes[2]=node3; - myNodes[3]=node4; - myNodes[4]=node5; - myNodes[5]=node6; - myNodes[6]=node7; - myNodes[7]=node8; -} -//======================================================================= -//function : Print -//purpose : -//======================================================================= - -void SMDS_HexahedronOfNodes::Print(ostream & OS) const -{ - OS << "volume <" << GetID() << "> : "; - int i; - for (i = 0; i < 7; ++i) OS << myNodes[i] << ","; - OS << myNodes[7]<< ") " << endl; -} - -int SMDS_HexahedronOfNodes::NbFaces() const -{ - return 6; -} - -int SMDS_HexahedronOfNodes::NbNodes() const -{ - return 8; -} - -int SMDS_HexahedronOfNodes::NbEdges() const -{ - return 12; -} - -SMDS_ElemIteratorPtr SMDS_HexahedronOfNodes:: - elementsIterator(SMDSAbs_ElementType type) const -{ - switch(type) - { - case SMDSAbs_Volume: - return SMDS_MeshElement::elementsIterator(SMDSAbs_Volume); - case SMDSAbs_Node: - return SMDS_ElemIteratorPtr (new SMDS_IteratorOfArray(myNodes)); - default: MESSAGE("ERROR : Iterator not implemented"); - } -} - -SMDSAbs_ElementType SMDS_HexahedronOfNodes::GetType() const -{ - return SMDSAbs_Volume; -} diff --git a/src/SMDS/SMDS_IteratorOfElements.hxx b/src/SMDS/SMDS_IteratorOfElements.hxx index bb4d94ebe..faf777de9 100644 --- a/src/SMDS/SMDS_IteratorOfElements.hxx +++ b/src/SMDS/SMDS_IteratorOfElements.hxx @@ -23,7 +23,6 @@ #include "SMDS_MeshElement.hxx" #include -using namespace std; class SMDS_IteratorOfElements:public SMDS_ElemIterator { @@ -46,8 +45,8 @@ class SMDS_IteratorOfElements:public SMDS_ElemIterator const SMDS_MeshElement * myElement; bool myReverseIteration; - set alreadyReturnedElements; - set::iterator itAlreadyReturned; + std::set alreadyReturnedElements; + std::set::iterator itAlreadyReturned; bool subMore(); const SMDS_MeshElement * subNext(); }; diff --git a/src/SMDS/SMDS_Mesh.cxx b/src/SMDS/SMDS_Mesh.cxx index 93c4cf568..c27244797 100644 --- a/src/SMDS/SMDS_Mesh.cxx +++ b/src/SMDS/SMDS_Mesh.cxx @@ -24,8 +24,6 @@ #include "SMDS_VolumeOfNodes.hxx" #include "SMDS_VolumeOfFaces.hxx" #include "SMDS_FaceOfNodes.hxx" -#include "SMDS_Tria3OfNodes.hxx" -#include "SMDS_HexahedronOfNodes.hxx" #include "SMDS_FaceOfEdges.hxx" #include @@ -647,7 +645,8 @@ SMDS_MeshVolume* SMDS_Mesh::AddVolumeWithID(const SMDS_MeshNode * n1, return NULL; } else { - volume=new SMDS_HexahedronOfNodes(n1,n2,n3,n4,n5,n6,n7,n8); +// volume=new SMDS_HexahedronOfNodes(n1,n2,n3,n4,n5,n6,n7,n8); + volume=new SMDS_VolumeOfNodes(n1,n2,n3,n4,n5,n6,n7,n8); myVolumes.insert(volume); } @@ -827,7 +826,7 @@ SMDS_MeshFace * SMDS_Mesh::createTriangle(const SMDS_MeshNode * node1, } else { - SMDS_MeshFace * face = new SMDS_Tria3OfNodes(node1,node2,node3); + SMDS_MeshFace * face = new SMDS_FaceOfNodes(node1,node2,node3); myFaces.insert(face); return face; } @@ -932,6 +931,75 @@ bool SMDS_Mesh::RemoveSubMesh(const SMDS_Mesh * aMesh) return found; } +//======================================================================= +//function : ChangeElementNodes +//purpose : +//======================================================================= + +bool SMDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem, + const SMDS_MeshNode * nodes[], + const int nbnodes) +{ + // keep current nodes of elem + set oldNodes; + SMDS_ElemIteratorPtr itn = elem->nodesIterator(); + while(itn->more()) + oldNodes.insert( itn->next() ); + + // change nodes + bool Ok = false; + switch ( elem->GetType() ) + { + case SMDSAbs_Edge: { + if ( nbnodes == 2 ) { + const SMDS_MeshEdge* edge = dynamic_cast( elem ); + if ( edge ) + Ok = const_cast( edge )->ChangeNodes( nodes[0], nodes[1] ); + } + break; + } + case SMDSAbs_Face: { + const SMDS_FaceOfNodes* face = dynamic_cast( elem ); + if ( face ) + Ok = const_cast( face )->ChangeNodes( nodes, nbnodes ); + break; + } + case SMDSAbs_Volume: { + const SMDS_VolumeOfNodes* vol = dynamic_cast( elem ); + if ( vol ) + Ok = const_cast( vol )->ChangeNodes( nodes, nbnodes ); + break; + } + default: + MESSAGE ( "WRONG ELEM TYPE"); + } + + if ( Ok ) { // update InverseElements + + // AddInverseElement to new nodes + for ( int i = 0; i < nbnodes; i++ ) + if ( oldNodes.find( nodes[i] ) == oldNodes.end() ) + // new node + const_cast( nodes[i] )->AddInverseElement( elem ); + else + // remove from oldNodes a node that remains in elem + oldNodes.erase( nodes[i] ); + + + // RemoveInverseElement from the nodes removed from elem + set::iterator it; + for ( it = oldNodes.begin(); it != oldNodes.end(); it++ ) + { + SMDS_MeshNode * n = static_cast + (const_cast( *it )); + n->RemoveInverseElement( elem ); + } + } + + //MESSAGE ( "::ChangeNodes() Ok = " << Ok); + + return Ok; +} //======================================================================= //function : FindEdge @@ -948,7 +1016,7 @@ const SMDS_MeshEdge* SMDS_Mesh::FindEdge(int idnode1, int idnode2) const //#include "Profiler.h" const SMDS_MeshEdge* SMDS_Mesh::FindEdge(const SMDS_MeshNode * node1, - const SMDS_MeshNode * node2) const + const SMDS_MeshNode * node2) { const SMDS_MeshEdge * toReturn=NULL; //PROFILER_Init(); @@ -1006,7 +1074,7 @@ const SMDS_MeshFace* SMDS_Mesh::FindFace(int idnode1, int idnode2, const SMDS_MeshFace* SMDS_Mesh::FindFace( const SMDS_MeshNode *node1, const SMDS_MeshNode *node2, - const SMDS_MeshNode *node3) const + const SMDS_MeshNode *node3) { const SMDS_MeshFace * face; const SMDS_MeshElement * node; @@ -1066,7 +1134,7 @@ const SMDS_MeshFace* SMDS_Mesh::FindFace( const SMDS_MeshNode *node1, const SMDS_MeshNode *node2, const SMDS_MeshNode *node3, - const SMDS_MeshNode *node4) const + const SMDS_MeshNode *node4) { const SMDS_MeshFace * face; const SMDS_MeshElement * node; @@ -1365,41 +1433,70 @@ void SMDS_Mesh::setInverseElements(bool b) } /////////////////////////////////////////////////////////////////////////////// -/// Return an iterator on nodes of the current mesh. Once used this iterator -/// must be free by the caller +/// Return an iterator on nodes of the current mesh /////////////////////////////////////////////////////////////////////////////// class SMDS_Mesh_MyNodeIterator:public SMDS_NodeIterator { - typedef SMDS_Mesh::SetOfNodes SetOfNodes; - const SetOfNodes& mySet; - SetOfNodes::iterator myIterator; + const SMDS_IdElementMap& myIdElemMap; + SMDS_IdElementMap::const_iterator myIterator; public: - SMDS_Mesh_MyNodeIterator(const SetOfNodes& s):mySet(s) + SMDS_Mesh_MyNodeIterator(const SMDS_IdElementMap& s):myIdElemMap(s) { - myIterator=mySet.begin(); + myIterator=myIdElemMap.begin(); } bool more() { - return myIterator!=mySet.end(); + return myIterator!=myIdElemMap.end(); } const SMDS_MeshNode* next() { - const SMDS_MeshNode* current=*myIterator; + const SMDS_MeshElement* current=(*myIterator).second; myIterator++; - return current; - } + return static_cast( current ); + } }; SMDS_NodeIteratorPtr SMDS_Mesh::nodesIterator() const { - return SMDS_NodeIteratorPtr(new SMDS_Mesh_MyNodeIterator(myNodes)); + return SMDS_NodeIteratorPtr + (new SMDS_Mesh_MyNodeIterator(myNodeIDFactory->GetIdElementMap())); +} +/////////////////////////////////////////////////////////////////////////////// +/// Return an iterator on nodes of the current mesh +/////////////////////////////////////////////////////////////////////////////// +class SMDS_Mesh_MyElemIterator:public SMDS_ElemIterator +{ + const SMDS_IdElementMap& myIdElemMap; + SMDS_IdElementMap::const_iterator myIterator; + public: + SMDS_Mesh_MyElemIterator(const SMDS_IdElementMap& s):myIdElemMap(s) + { + myIterator=myIdElemMap.begin(); + } + + bool more() + { + return myIterator!=myIdElemMap.end(); + } + + const SMDS_MeshElement* next() + { + const SMDS_MeshElement* current=(*myIterator).second; + myIterator++; + return current; + } +}; + +SMDS_ElemIteratorPtr SMDS_Mesh::elementsIterator() const +{ + return SMDS_ElemIteratorPtr + (new SMDS_Mesh_MyElemIterator(myElementIDFactory->GetIdElementMap())); } /////////////////////////////////////////////////////////////////////////////// -///Return an iterator on volumes of the current mesh. Once used this iterator -///must be free by the caller +///Return an iterator on volumes of the current mesh. /////////////////////////////////////////////////////////////////////////////// class SMDS_Mesh_MyEdgeIterator:public SMDS_EdgeIterator { @@ -1670,7 +1767,7 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem, void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem, list& removedElems, list& removedNodes, - const bool removenodes) + bool removenodes) { // get finite elements built on elem set * s1; @@ -1685,10 +1782,12 @@ void SMDS_Mesh::RemoveElement(const SMDS_MeshElement * elem, // get exclusive nodes (which would become free afterwards) set * s2; - if (s1->empty() && elem->GetType() == SMDSAbs_Node) + if (elem->GetType() == SMDSAbs_Node) // a node is removed { + // do not remove nodes except elem s2 = new set(); s2->insert(elem); + removenodes = true; } else s2 = getExclusiveNodes(*s1); @@ -1788,3 +1887,78 @@ bool SMDS_Mesh::Contains (const SMDS_MeshElement* elem) const return true; return false; } + +//======================================================================= +//function : MaxNodeID +//purpose : +//======================================================================= + +int SMDS_Mesh::MaxNodeID() const +{ + return myNodeIDFactory->GetMaxID(); +} + +//======================================================================= +//function : MinNodeID +//purpose : +//======================================================================= + +int SMDS_Mesh::MinNodeID() const +{ + return myNodeIDFactory->GetMinID(); +} + +//======================================================================= +//function : MaxElementID +//purpose : +//======================================================================= + +int SMDS_Mesh::MaxElementID() const +{ + return myElementIDFactory->GetMaxID(); +} + +//======================================================================= +//function : MinElementID +//purpose : +//======================================================================= + +int SMDS_Mesh::MinElementID() const +{ + return myElementIDFactory->GetMinID(); +} + +//======================================================================= +//function : Renumber +//purpose : Renumber all nodes or elements. +//======================================================================= + +void SMDS_Mesh::Renumber (const bool isNodes, const int startID, const int deltaID) +{ + if ( deltaID == 0 ) + return; + + SMDS_MeshElementIDFactory * idFactory = + isNodes ? myNodeIDFactory : myElementIDFactory; + + // get existing elements in the order of ID increasing and release their ids + list< SMDS_MeshElement * > elemList; + const SMDS_IdElementMap& idElemMap = idFactory->GetIdElementMap(); + SMDS_IdElementMap::const_iterator idElemIt = idElemMap.begin(); + while ( idElemIt != idElemMap.end() ) { + SMDS_MeshElement* elem = (*idElemIt).second; + int id = (*idElemIt).first; + idElemIt++; + elemList.push_back( elem ); + idFactory->ReleaseID( id ); + } + // set new IDs + int ID = startID; + list< SMDS_MeshElement * >::iterator elemIt = elemList.begin(); + for ( ; elemIt != elemList.end(); elemIt++ ) + { + idFactory->BindID( ID, *elemIt ); + ID += deltaID; + } +} + diff --git a/src/SMDS/SMDS_Mesh.hxx b/src/SMDS/SMDS_Mesh.hxx index 615071991..cdcc9166b 100644 --- a/src/SMDS/SMDS_Mesh.hxx +++ b/src/SMDS/SMDS_Mesh.hxx @@ -38,8 +38,6 @@ #include #include -class SMDSControl_BoundaryEdges; - typedef SMDS_Iterator SMDS_NodeIterator; typedef boost::shared_ptr > SMDS_NodeIteratorPtr; typedef SMDS_Iterator SMDS_EdgeIterator; @@ -58,7 +56,8 @@ public: SMDS_EdgeIteratorPtr edgesIterator() const; SMDS_FaceIteratorPtr facesIterator() const; SMDS_VolumeIteratorPtr volumesIterator() const; - + SMDS_ElemIteratorPtr elementsIterator() const; + SMDS_Mesh *AddSubMesh(); virtual SMDS_MeshNode* AddNodeWithID(double x, double y, double z, int ID); @@ -202,10 +201,10 @@ public: const SMDS_MeshFace * f6); virtual void RemoveElement(const SMDS_MeshElement * elem, - list& removedElems, - list& removedNodes, + std::list& removedElems, + std::list& removedNodes, const bool removenodes = false); - virtual void RemoveElement(const SMDS_MeshElement * elem, const bool removenodes = false); + virtual void RemoveElement(const SMDS_MeshElement * elem, bool removenodes = false); virtual void RemoveNode(const SMDS_MeshNode * node); virtual void RemoveEdge(const SMDS_MeshEdge * edge); virtual void RemoveFace(const SMDS_MeshFace * face); @@ -213,13 +212,34 @@ public: virtual bool RemoveFromParent(); virtual bool RemoveSubMesh(const SMDS_Mesh * aMesh); - + + static bool ChangeElementNodes(const SMDS_MeshElement * elem, + const SMDS_MeshNode * nodes[], + const int nbnodes); + + virtual void Renumber (const bool isNodes, const int startID = 1, const int deltaID = 1); + // Renumber all nodes or elements. + const SMDS_MeshNode *FindNode(int idnode) const; const SMDS_MeshEdge *FindEdge(int idnode1, int idnode2) const; const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3) const; const SMDS_MeshFace *FindFace(int idnode1, int idnode2, int idnode3, int idnode4) const; const SMDS_MeshElement *FindElement(int IDelem) const; - + static const SMDS_MeshEdge* FindEdge(const SMDS_MeshNode * n1, + const SMDS_MeshNode * n2); + static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1, + const SMDS_MeshNode *n2, + const SMDS_MeshNode *n3); + static const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1, + const SMDS_MeshNode *n2, + const SMDS_MeshNode *n3, + const SMDS_MeshNode *n4); + int MaxNodeID() const; + int MinNodeID() const; + int MaxElementID() const; + int MinElementID() const; + + int NbNodes() const; int NbEdges() const; int NbFaces() const; @@ -248,10 +268,10 @@ public: */ bool Contains (const SMDS_MeshElement* elem) const; - typedef set SetOfNodes; - typedef set SetOfEdges; - typedef set SetOfFaces; - typedef set SetOfVolumes; + typedef std::set SetOfNodes; + typedef std::set SetOfEdges; + typedef std::set SetOfFaces; + typedef std::set SetOfVolumes; private: SMDS_Mesh(SMDS_Mesh * parent); @@ -259,41 +279,25 @@ private: SMDS_MeshFace * createTriangle(const SMDS_MeshNode * node1, const SMDS_MeshNode * node2, const SMDS_MeshNode * node3); - SMDS_MeshFace * createQuadrangle(const SMDS_MeshNode * node1, const SMDS_MeshNode * node2, const SMDS_MeshNode * node3, const SMDS_MeshNode * node4); - - bool registerElement(int ID, SMDS_MeshElement * element); - - const SMDS_MeshEdge* FindEdge(const SMDS_MeshNode * n1, - const SMDS_MeshNode * n2) const; - SMDS_MeshEdge* FindEdgeOrCreate(const SMDS_MeshNode * n1, const SMDS_MeshNode * n2); - - const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1, - const SMDS_MeshNode *n2, - const SMDS_MeshNode *n3) const; - SMDS_MeshFace* FindFaceOrCreate(const SMDS_MeshNode *n1, const SMDS_MeshNode *n2, const SMDS_MeshNode *n3); - - const SMDS_MeshFace* FindFace(const SMDS_MeshNode *n1, - const SMDS_MeshNode *n2, - const SMDS_MeshNode *n3, - const SMDS_MeshNode *n4) const; - SMDS_MeshFace* FindFaceOrCreate(const SMDS_MeshNode *n1, const SMDS_MeshNode *n2, const SMDS_MeshNode *n3, const SMDS_MeshNode *n4); - void addChildrenWithNodes(set& setOfChildren, + bool registerElement(int ID, SMDS_MeshElement * element); + + void addChildrenWithNodes(std::set& setOfChildren, const SMDS_MeshElement * element, - set& nodes); + std::set& nodes); // Fields PRIVATE @@ -302,7 +306,7 @@ private: SetOfFaces myFaces; SetOfVolumes myVolumes; SMDS_Mesh *myParent; - list myChildren; + std::list myChildren; SMDS_MeshElementIDFactory *myNodeIDFactory; SMDS_MeshElementIDFactory *myElementIDFactory; @@ -311,4 +315,5 @@ private: bool myHasInverseElements; }; + #endif diff --git a/src/SMDS/SMDS_MeshEdge.cxx b/src/SMDS/SMDS_MeshEdge.cxx index 484207ba0..640723147 100644 --- a/src/SMDS/SMDS_MeshEdge.cxx +++ b/src/SMDS/SMDS_MeshEdge.cxx @@ -29,7 +29,8 @@ #include "SMDS_MeshEdge.hxx" #include "SMDS_IteratorOfElements.hxx" #include "SMDS_MeshNode.hxx" -#include + +using namespace std; //======================================================================= //function : SMDS_MeshEdge @@ -130,3 +131,17 @@ bool operator<(const SMDS_MeshEdge & e1, const SMDS_MeshEdge & e2) else if(id11==id21) return (id21 #include -using namespace std; class SMDS_MeshNode; class SMDS_MeshEdge; class SMDS_MeshFace; @@ -65,12 +64,12 @@ class SMDS_MeshElement:public SMDS_MeshObject ///Return the type of the current element virtual SMDSAbs_ElementType GetType() const = 0; - friend ostream & operator <<(ostream & OS, const SMDS_MeshElement *); + friend std::ostream & operator <<(std::ostream & OS, const SMDS_MeshElement *); friend bool SMDS_MeshElementIDFactory::BindID(int ID,SMDS_MeshElement*elem); protected: SMDS_MeshElement(int ID=-1); - virtual void Print(ostream & OS) const; + virtual void Print(std::ostream & OS) const; private: int myID; diff --git a/src/SMDS/SMDS_MeshElementIDFactory.cxx b/src/SMDS/SMDS_MeshElementIDFactory.cxx index 43f12c777..456d16a15 100644 --- a/src/SMDS/SMDS_MeshElementIDFactory.cxx +++ b/src/SMDS/SMDS_MeshElementIDFactory.cxx @@ -29,6 +29,8 @@ #include "SMDS_MeshElementIDFactory.hxx" #include "SMDS_MeshElement.hxx" +using namespace std; + //======================================================================= //function : SMDS_MeshElementIDFactory //purpose : @@ -82,3 +84,32 @@ void SMDS_MeshElementIDFactory::ReleaseID(const int ID) myIDElements.erase(ID); SMDS_MeshIDFactory::ReleaseID(ID); } + +//======================================================================= +//function : GetMaxID +//purpose : +//======================================================================= + +int SMDS_MeshElementIDFactory::GetMaxID() const +{ + map::const_reverse_iterator it = myIDElements.rbegin(); + if ( it != myIDElements.rend() ) + return (*it).first; + + return 0; +} + +//======================================================================= +//function : GetMinID +//purpose : +//======================================================================= + +int SMDS_MeshElementIDFactory::GetMinID() const +{ + map::const_iterator it = myIDElements.begin(); + if ( it != myIDElements.end() ) + return (*it).first; + + return 0; +} + diff --git a/src/SMDS/SMDS_MeshElementIDFactory.hxx b/src/SMDS/SMDS_MeshElementIDFactory.hxx index f987eaed2..932ad057c 100644 --- a/src/SMDS/SMDS_MeshElementIDFactory.hxx +++ b/src/SMDS/SMDS_MeshElementIDFactory.hxx @@ -30,10 +30,11 @@ #include "SMDS_MeshIDFactory.hxx" #include -using namespace std; class SMDS_MeshElement; +typedef std::map SMDS_IdElementMap; + class SMDS_MeshElementIDFactory:public SMDS_MeshIDFactory { public: @@ -42,8 +43,11 @@ class SMDS_MeshElementIDFactory:public SMDS_MeshIDFactory SMDS_MeshElement * MeshElement(int ID); virtual int GetFreeID(); virtual void ReleaseID(int ID); + int GetMaxID() const; + int GetMinID() const; + const SMDS_IdElementMap & GetIdElementMap() const { return myIDElements; } private: - map myIDElements; + SMDS_IdElementMap myIDElements; }; diff --git a/src/SMDS/SMDS_MeshGroup.cxx b/src/SMDS/SMDS_MeshGroup.cxx index 25ae25b73..6a255e152 100644 --- a/src/SMDS/SMDS_MeshGroup.cxx +++ b/src/SMDS/SMDS_MeshGroup.cxx @@ -24,9 +24,11 @@ // Author : Jean-Michel BOULCOURT // Module : SMESH -using namespace std; #include "SMDS_MeshGroup.hxx" #include "utilities.h" + +using namespace std; + //======================================================================= //function : SMDS_MeshGroup //purpose : diff --git a/src/SMDS/SMDS_MeshGroup.hxx b/src/SMDS/SMDS_MeshGroup.hxx index c5bfcb432..69084c5b9 100644 --- a/src/SMDS/SMDS_MeshGroup.hxx +++ b/src/SMDS/SMDS_MeshGroup.hxx @@ -28,7 +28,7 @@ #include "SMDS_Mesh.hxx" #include -using namespace std; + class SMDS_MeshGroup:public SMDS_MeshObject { @@ -54,23 +54,23 @@ class SMDS_MeshGroup:public SMDS_MeshObject bool Contains(const SMDS_MeshElement * theElem) const; void InitIterator() const - { const_cast(myIterator) = myElements.begin(); } + { const_cast(myIterator) = myElements.begin(); } bool More() const { return myIterator != myElements.end(); } const SMDS_MeshElement* Next() const - { return *(const_cast(myIterator))++; } + { return *(const_cast(myIterator))++; } private: SMDS_MeshGroup(SMDS_MeshGroup* theParent, const SMDSAbs_ElementType theType = SMDSAbs_All); - typedef set::iterator iterator; + typedef std::set::iterator TIterator; const SMDS_Mesh * myMesh; SMDSAbs_ElementType myType; - set myElements; + std::set myElements; SMDS_MeshGroup * myParent; - list myChildren; - iterator myIterator; + std::list myChildren; + TIterator myIterator; }; #endif diff --git a/src/SMDS/SMDS_MeshHexahedron.cxx b/src/SMDS/SMDS_MeshHexahedron.cxx deleted file mode 100644 index f72a3b211..000000000 --- a/src/SMDS/SMDS_MeshHexahedron.cxx +++ /dev/null @@ -1,217 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMDS_MeshHexahedron.cxx -// Author : Jean-Michel BOULCOURT -// Module : SMESH - -using namespace std; -#include "SMDS_MeshHexahedron.ixx" -#include - - -//======================================================================= -//function : SMDS_MeshHexahedron -//purpose : Hexaedra -//======================================================================= - -SMDS_MeshHexahedron::SMDS_MeshHexahedron(const Standard_Integer ID, - const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4, - const Standard_Integer idnode5, - const Standard_Integer idnode6, - const Standard_Integer idnode7, - const Standard_Integer idnode8):SMDS_MeshVolume(ID,8) -{ - SetConnections(idnode1,idnode2,idnode3,idnode4,idnode5,idnode6,idnode7,idnode8); - ComputeKey(); -} - - -//======================================================================= -//function : SetConnections -//purpose : Heaxahedron -//======================================================================= -void SMDS_MeshHexahedron::SetConnections(const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4, - const Standard_Integer idnode5, - const Standard_Integer idnode6, - const Standard_Integer idnode7, - const Standard_Integer idnode8) -{ - Standard_Integer idmin = (idnode1 < idnode2 ? idnode1 : idnode2); - idmin = (idmin < idnode3 ? idmin : idnode3); - idmin = (idmin < idnode4 ? idmin : idnode4); - idmin = (idmin < idnode5 ? idmin : idnode5); - idmin = (idmin < idnode6 ? idmin : idnode6); - idmin = (idmin < idnode7 ? idmin : idnode7); - idmin = (idmin < idnode8 ? idmin : idnode8); - - myNodes[0] = idmin; - if (idmin == idnode1) { // 1 2 3 4 5 6 7 8 - myNodes[1] = idnode2; - myNodes[2] = idnode3; - myNodes[3] = idnode4; - myNodes[4] = idnode5; - myNodes[5] = idnode6; - myNodes[6] = idnode7; - myNodes[7] = idnode8; - } else if (idmin == idnode2) { // 2 3 4 1 6 7 8 5 - myNodes[1] = idnode3; - myNodes[2] = idnode4; - myNodes[3] = idnode1; - myNodes[4] = idnode6; - myNodes[5] = idnode7; - myNodes[6] = idnode8; - myNodes[7] = idnode5; - } else if (idmin == idnode3) { // 3 4 1 2 7 8 5 6 - myNodes[1] = idnode4; - myNodes[2] = idnode1; - myNodes[3] = idnode2; - myNodes[4] = idnode7; - myNodes[5] = idnode8; - myNodes[6] = idnode5; - myNodes[7] = idnode6; - } else if (idmin == idnode4) { // 4 1 2 3 8 5 6 7 - myNodes[1] = idnode1; - myNodes[2] = idnode2; - myNodes[3] = idnode3; - myNodes[4] = idnode8; - myNodes[5] = idnode5; - myNodes[6] = idnode6; - myNodes[7] = idnode7; - } else if (idmin == idnode5) { // 5 6 7 8 1 2 3 4 - myNodes[1] = idnode6; - myNodes[2] = idnode7; - myNodes[3] = idnode8; - myNodes[4] = idnode1; - myNodes[5] = idnode2; - myNodes[6] = idnode3; - myNodes[7] = idnode4; - } else if (idmin == idnode6){ // 6 7 8 5 2 3 4 1 - myNodes[1] = idnode7; - myNodes[2] = idnode8; - myNodes[3] = idnode5; - myNodes[4] = idnode2; - myNodes[5] = idnode3; - myNodes[6] = idnode4; - myNodes[7] = idnode1; - } else if (idmin == idnode7) { // 7 8 5 6 3 4 1 2 - myNodes[1] = idnode8; - myNodes[2] = idnode5; - myNodes[3] = idnode6; - myNodes[4] = idnode3; - myNodes[5] = idnode4; - myNodes[6] = idnode1; - myNodes[7] = idnode2; - } else { // 8 5 6 7 4 1 2 3 - myNodes[1] = idnode5; - myNodes[2] = idnode6; - myNodes[3] = idnode7; - myNodes[4] = idnode4; - myNodes[5] = idnode1; - myNodes[6] = idnode2; - myNodes[7] = idnode3; - } - -} - -//======================================================================= -//function : NodesOfFace -//purpose : returns the rank node in mynodes. Useful to extract faces from volume -//======================================================================= -Standard_Integer SMDS_MeshHexahedron::NodesOfFace(const Standard_Integer rankface, - const Standard_Integer ranknode) -{ - static Standard_Integer facenode[6][4] = { - {0,1,2,3}, - {4,7,6,5}, - {0,4,5,1}, - {1,5,6,2}, - {2,6,7,3}, - {0,3,7,4} - }; - - return facenode[rankface-1][ranknode-1]; -} - -//======================================================================= -//function : NodesOfEdge -//purpose : returns the rank node in mynodes. Useful to extract edges from volume -//======================================================================= -Standard_Integer SMDS_MeshHexahedron::NodesOfEdge(const Standard_Integer rankedge, - const Standard_Integer ranknode) const -{ - static Standard_Integer faceedge[12][2] = { - {0,1}, - {1,2}, - {2,3}, - {0,3}, - {4,7}, - {6,7}, - {5,6}, - {4,5}, - {0,4}, - {1,5}, - {2,6}, - {3,7} - - }; - - return faceedge[rankedge-1][ranknode-1]; -} - -//======================================================================= -//function : GetFaceDefinedByNodes -//purpose : -//======================================================================= -void SMDS_MeshHexahedron::GetFaceDefinedByNodes(const Standard_Integer rank, - const Standard_Address idnode, - Standard_Integer& nb) const -{ - Standard_Integer *ptr; - nb = 4; - ptr = (Standard_Integer *)idnode; - ptr[0] = myNodes[NodesOfFace(rank,1)]; - ptr[1] = myNodes[NodesOfFace(rank,2)]; - ptr[2] = myNodes[NodesOfFace(rank,3)]; - ptr[3] = myNodes[NodesOfFace(rank,4)]; - -} - -//======================================================================= -//function : GetEdgeDefinedByNodes -//purpose : -//======================================================================= -void SMDS_MeshHexahedron::GetEdgeDefinedByNodes(const Standard_Integer rank, - Standard_Integer& idnode1, - Standard_Integer& idnode2) const -{ - idnode1 = myNodes[NodesOfEdge(rank,1)]; - idnode2 = myNodes[NodesOfEdge(rank,2)]; -} - diff --git a/src/SMDS/SMDS_MeshHexahedron.hxx b/src/SMDS/SMDS_MeshHexahedron.hxx deleted file mode 100644 index 994a1daa1..000000000 --- a/src/SMDS/SMDS_MeshHexahedron.hxx +++ /dev/null @@ -1,125 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMDS_MeshHexahedron.hxx -// Module : SMESH - -#ifndef _SMDS_MeshHexahedron_HeaderFile -#define _SMDS_MeshHexahedron_HeaderFile - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Handle_SMDS_MeshHexahedron_HeaderFile -#include "Handle_SMDS_MeshHexahedron.hxx" -#endif - -#ifndef _Standard_Integer_HeaderFile -#include -#endif -#ifndef _SMDS_MeshVolume_HeaderFile -#include "SMDS_MeshVolume.hxx" -#endif -#ifndef _Standard_Address_HeaderFile -#include -#endif -class Standard_ConstructionError; - - -class SMDS_MeshHexahedron : public SMDS_MeshVolume { - -public: - - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT SMDS_MeshHexahedron(const Standard_Integer ID,const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4,const Standard_Integer idnode5,const Standard_Integer idnode6,const Standard_Integer idnode7,const Standard_Integer idnode8); -Standard_EXPORT void GetEdgeDefinedByNodes(const Standard_Integer rank,Standard_Integer& idnode1,Standard_Integer& idnode2) const; -Standard_EXPORT void GetFaceDefinedByNodes(const Standard_Integer rank,const Standard_Address idnode,Standard_Integer& nb) const; -Standard_EXPORT inline void ComputeKey() ; -Standard_EXPORT inline Standard_Address GetConnections() const; -Standard_EXPORT inline Standard_Integer GetConnection(const Standard_Integer rank) const; -Standard_EXPORT inline Standard_Integer NbEdges() const; -Standard_EXPORT inline Standard_Integer NbFaces() const; -Standard_EXPORT static Standard_Integer NodesOfFace(const Standard_Integer rankface,const Standard_Integer ranknode) ; -Standard_EXPORT Standard_Integer NodesOfEdge(const Standard_Integer rankedge,const Standard_Integer ranknode) const; -Standard_EXPORT ~SMDS_MeshHexahedron(); - - - - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& SMDS_MeshHexahedron_Type_(); - Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // -Standard_EXPORT void SetConnections(const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4,const Standard_Integer idnode5,const Standard_Integer idnode6,const Standard_Integer idnode7,const Standard_Integer idnode8) ; - - - // Fields PRIVATE - // -Standard_Integer myNodes[8]; - - -}; - - -#include "SMDS_MeshHexahedron.lxx" - - - -// other inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/SMDS/SMDS_MeshIDFactory.cxx b/src/SMDS/SMDS_MeshIDFactory.cxx index db5df4222..96314592d 100644 --- a/src/SMDS/SMDS_MeshIDFactory.cxx +++ b/src/SMDS/SMDS_MeshIDFactory.cxx @@ -28,6 +28,8 @@ #include "SMDS_MeshIDFactory.hxx" +using namespace std; + //======================================================================= //function : SMDS_MeshIDFactory //purpose : diff --git a/src/SMDS/SMDS_MeshIDFactory.hxx b/src/SMDS/SMDS_MeshIDFactory.hxx index 76ac5ee91..62b2d4c00 100644 --- a/src/SMDS/SMDS_MeshIDFactory.hxx +++ b/src/SMDS/SMDS_MeshIDFactory.hxx @@ -29,7 +29,7 @@ #include "SMDS_MeshObject.hxx" #include -using namespace std; + class SMDS_MeshIDFactory:public SMDS_MeshObject { @@ -40,7 +40,7 @@ class SMDS_MeshIDFactory:public SMDS_MeshObject protected: SMDS_MeshIDFactory(); int myMaxID; - stack myPoolOfID; + std::stack myPoolOfID; }; #endif diff --git a/src/SMDS/SMDS_MeshNode.cxx b/src/SMDS/SMDS_MeshNode.cxx index cba7920fa..c672fe702 100644 --- a/src/SMDS/SMDS_MeshNode.cxx +++ b/src/SMDS/SMDS_MeshNode.cxx @@ -24,6 +24,8 @@ #include "SMDS_SpacePosition.hxx" #include "SMDS_IteratorOfElements.hxx" +using namespace std; + //======================================================================= //function : SMDS_MeshNode //purpose : diff --git a/src/SMDS/SMDS_MeshNode.hxx b/src/SMDS/SMDS_MeshNode.hxx index 01482f922..e4ecc1f5c 100644 --- a/src/SMDS/SMDS_MeshNode.hxx +++ b/src/SMDS/SMDS_MeshNode.hxx @@ -31,14 +31,14 @@ #include "SMDS_Position.hxx" #include -using namespace std; + class SMDS_MeshNode:public SMDS_MeshElement { public: SMDS_MeshNode(double x, double y, double z); - void Print(ostream & OS) const; + void Print(std::ostream & OS) const; double X() const; double Y() const; double Z() const; @@ -61,7 +61,7 @@ class SMDS_MeshNode:public SMDS_MeshElement private: double myX, myY, myZ; SMDS_PositionPtr myPosition; - set myInverseElements; + std::set myInverseElements; }; #endif diff --git a/src/SMDS/SMDS_MeshNodeIDFactory.hxx b/src/SMDS/SMDS_MeshNodeIDFactory.hxx deleted file mode 100644 index eafa45827..000000000 --- a/src/SMDS/SMDS_MeshNodeIDFactory.hxx +++ /dev/null @@ -1,112 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMDS_MeshNodeIDFactory.hxx -// Module : SMESH - -#ifndef _SMDS_MeshNodeIDFactory_HeaderFile -#define _SMDS_MeshNodeIDFactory_HeaderFile - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Handle_SMDS_MeshNodeIDFactory_HeaderFile -#include "Handle_SMDS_MeshNodeIDFactory.hxx" -#endif - -#ifndef _SMDS_MeshIDFactory_HeaderFile -#include "SMDS_MeshIDFactory.hxx" -#endif -#ifndef _Standard_Integer_HeaderFile -#include -#endif - - -class SMDS_MeshNodeIDFactory : public SMDS_MeshIDFactory { - -public: - - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT SMDS_MeshNodeIDFactory(); -Standard_EXPORT inline Standard_Integer GetFreeID() ; -Standard_EXPORT inline void ReleaseID(const Standard_Integer ID) ; -Standard_EXPORT ~SMDS_MeshNodeIDFactory(); - - - - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& SMDS_MeshNodeIDFactory_Type_(); - Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // - - -}; - - -#include "SMDS_MeshNodeIDFactory.lxx" - - - -// other inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/SMDS/SMDS_MeshPrism.cxx b/src/SMDS/SMDS_MeshPrism.cxx deleted file mode 100644 index fb384f668..000000000 --- a/src/SMDS/SMDS_MeshPrism.cxx +++ /dev/null @@ -1,182 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMDS_MeshPrism.cxx -// Author : Jean-Michel BOULCOURT -// Module : SMESH - -using namespace std; -#include "SMDS_MeshPrism.ixx" -#include "Standard_ConstructionError.hxx" - - -//======================================================================= -//function : SMDS_MeshPrism -//purpose : Prism -//======================================================================= - -SMDS_MeshPrism::SMDS_MeshPrism(const Standard_Integer ID, - const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4, - const Standard_Integer idnode5, - const Standard_Integer idnode6):SMDS_MeshVolume(ID,6) -{ - SetConnections(idnode1,idnode2,idnode3,idnode4,idnode5,idnode6); - ComputeKey(); -} - - -//======================================================================= -//function : SetConnections -//purpose : Prism -//======================================================================= -void SMDS_MeshPrism::SetConnections(const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4, - const Standard_Integer idnode5, - const Standard_Integer idnode6) -{ - Standard_Integer idmin = (idnode1 < idnode2 ? idnode1 : idnode2); - idmin = (idmin < idnode3 ? idmin : idnode3); - idmin = (idmin < idnode4 ? idmin : idnode4); - idmin = (idmin < idnode5 ? idmin : idnode5); - idmin = (idmin < idnode6 ? idmin : idnode6); - - myNodes[0] = idmin; - if (idmin == idnode1) { // 1 2 3 4 5 6 - myNodes[1] = idnode2; - myNodes[2] = idnode3; - myNodes[3] = idnode4; - myNodes[4] = idnode5; - myNodes[5] = idnode6; - } else if (idmin == idnode2) { // 2 3 1 5 6 4 - myNodes[1] = idnode3; - myNodes[2] = idnode1; - myNodes[3] = idnode5; - myNodes[4] = idnode6; - myNodes[5] = idnode4; - } else if (idmin == idnode3) { // 3 1 2 6 4 5 - myNodes[1] = idnode1; - myNodes[2] = idnode2; - myNodes[3] = idnode6; - myNodes[4] = idnode4; - myNodes[5] = idnode5; - } else if (idmin == idnode4) { // 4 5 6 1 2 3 - myNodes[1] = idnode5; - myNodes[2] = idnode6; - myNodes[3] = idnode1; - myNodes[4] = idnode2; - myNodes[5] = idnode3; - } else if (idmin == idnode5) { // 5 6 4 2 3 1 - myNodes[1] = idnode6; - myNodes[2] = idnode4; - myNodes[3] = idnode2; - myNodes[4] = idnode3; - myNodes[5] = idnode1; - } else { // 6 4 5 3 1 2 - myNodes[1] = idnode4; - myNodes[2] = idnode5; - myNodes[3] = idnode3; - myNodes[4] = idnode1; - myNodes[5] = idnode2; - } - -} - - -//======================================================================= -//function : NodesOfFace -//purpose : returns the rank node in mynodes. Useful to extract faces from volume -//======================================================================= -Standard_Integer SMDS_MeshPrism::NodesOfFace(const Standard_Integer rankface, - const Standard_Integer ranknode) -{ - static Standard_Integer facenode[5][4] = { - {0,1,2,-1}, - {3,5,4,-1}, - {0,3,4,1}, - {1,4,5,2}, - {2,5,3,0} - }; - - return facenode[rankface-1][ranknode-1]; -} - -//======================================================================= -//function : NodesOfEdge -//purpose : returns the rank node in mynodes. Useful to extract edges from volume -//======================================================================= -Standard_Integer SMDS_MeshPrism::NodesOfEdge(const Standard_Integer rankedge, - const Standard_Integer ranknode) const -{ - static Standard_Integer faceedge[9][2] = { - {0,1}, - {1,2}, - {0,2}, - {3,5}, - {4,5}, - {3,4}, - {0,3}, - {1,4}, - {2,5} - - }; - - return faceedge[rankedge-1][ranknode-1]; -} - -//======================================================================= -//function : GetFaceDefinedByNodes -//purpose : -//======================================================================= -void SMDS_MeshPrism::GetFaceDefinedByNodes(const Standard_Integer rank, - const Standard_Address idnode, - Standard_Integer& nb) const -{ - Standard_Integer *ptr; - ptr = (Standard_Integer *)idnode; - ptr[0] = myNodes[NodesOfFace(rank,1)]; - ptr[1] = myNodes[NodesOfFace(rank,2)]; - ptr[2] = myNodes[NodesOfFace(rank,3)]; - ptr[3] = myNodes[NodesOfFace(rank,4)]; - nb = (NodesOfFace(rank,4) == -1 ? 3 : 4); - if (nb == 4) - ptr[3] = myNodes[NodesOfFace(rank,4)]; - -} - -//======================================================================= -//function : GetEdgeDefinedByNodes -//purpose : -//======================================================================= -void SMDS_MeshPrism::GetEdgeDefinedByNodes(const Standard_Integer rank, - Standard_Integer& idnode1, - Standard_Integer& idnode2) const -{ - idnode1 = myNodes[NodesOfEdge(rank,1)]; - idnode2 = myNodes[NodesOfEdge(rank,2)]; -} - diff --git a/src/SMDS/SMDS_MeshPrism.hxx b/src/SMDS/SMDS_MeshPrism.hxx deleted file mode 100644 index e09f6c291..000000000 --- a/src/SMDS/SMDS_MeshPrism.hxx +++ /dev/null @@ -1,125 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMDS_MeshPrism.hxx -// Module : SMESH - -#ifndef _SMDS_MeshPrism_HeaderFile -#define _SMDS_MeshPrism_HeaderFile - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Handle_SMDS_MeshPrism_HeaderFile -#include "Handle_SMDS_MeshPrism.hxx" -#endif - -#ifndef _Standard_Integer_HeaderFile -#include "Standard_Integer.hxx" -#endif -#ifndef _SMDS_MeshVolume_HeaderFile -#include "SMDS_MeshVolume.hxx" -#endif -#ifndef _Standard_Address_HeaderFile -#include -#endif -class Standard_ConstructionError; - - -class SMDS_MeshPrism : public SMDS_MeshVolume { - -public: - - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT SMDS_MeshPrism(const Standard_Integer ID,const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4,const Standard_Integer idnode5,const Standard_Integer idnode6); -Standard_EXPORT void GetEdgeDefinedByNodes(const Standard_Integer rank,Standard_Integer& idnode1,Standard_Integer& idnode2) const; -Standard_EXPORT void GetFaceDefinedByNodes(const Standard_Integer rank,const Standard_Address idnode,Standard_Integer& nb) const; -Standard_EXPORT inline void ComputeKey() ; -Standard_EXPORT inline Standard_Address GetConnections() const; -Standard_EXPORT inline Standard_Integer GetConnection(const Standard_Integer rank) const; -Standard_EXPORT inline Standard_Integer NbEdges() const; -Standard_EXPORT inline Standard_Integer NbFaces() const; -Standard_EXPORT static Standard_Integer NodesOfFace(const Standard_Integer rankface,const Standard_Integer ranknode) ; -Standard_EXPORT Standard_Integer NodesOfEdge(const Standard_Integer rankedge,const Standard_Integer ranknode) const; -Standard_EXPORT ~SMDS_MeshPrism(); - - - - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& SMDS_MeshPrism_Type_(); - Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // -Standard_EXPORT void SetConnections(const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4,const Standard_Integer idnode5,const Standard_Integer idnode6) ; - - - // Fields PRIVATE - // -Standard_Integer myNodes[6]; - - -}; - - -#include "SMDS_MeshPrism.lxx" - - - -// other inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/SMDS/SMDS_MeshPyramid.cxx b/src/SMDS/SMDS_MeshPyramid.cxx deleted file mode 100644 index aa8462bb5..000000000 --- a/src/SMDS/SMDS_MeshPyramid.cxx +++ /dev/null @@ -1,168 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMDS_MeshPyramid.cxx -// Author : Jean-Michel BOULCOURT -// Module : SMESH - -using namespace std; -#include "SMDS_MeshPyramid.ixx" -#include - - -//======================================================================= -//function : SMDS_MeshPyramid -//purpose : Pyramid -//======================================================================= - -SMDS_MeshPyramid::SMDS_MeshPyramid(const Standard_Integer ID, - const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4, - const Standard_Integer idnode5):SMDS_MeshVolume(ID,5) -{ - SetConnections(idnode1,idnode2,idnode3,idnode4,idnode5); - ComputeKey(); -} - - - -//======================================================================= -//function : SetConnections -//purpose : Pyramid -//======================================================================= -void SMDS_MeshPyramid::SetConnections(const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4, - const Standard_Integer idnode5) -{ - - Standard_Integer idmin = (idnode1 < idnode2 ? idnode1 : idnode2); - idmin = (idmin < idnode3 ? idmin : idnode3); - idmin = (idmin < idnode4 ? idmin : idnode4); - idmin = (idmin < idnode5 ? idmin : idnode5); - - myNodes[0] = idmin; - if (idmin == idnode1) { // 1 2 3 4 5 - myNodes[1] = idnode2; - myNodes[2] = idnode3; - myNodes[3] = idnode4; - myNodes[4] = idnode5; - } else if (idmin == idnode2) { // 2 3 4 5 1 - myNodes[1] = idnode3; - myNodes[2] = idnode4; - myNodes[3] = idnode5; - myNodes[4] = idnode1; - } else if (idmin == idnode3) { // 3 4 5 1 2 - myNodes[1] = idnode4; - myNodes[2] = idnode5; - myNodes[3] = idnode1; - myNodes[4] = idnode2; - } else if (idmin == idnode4) { // 4 5 1 2 3 - myNodes[1] = idnode5; - myNodes[2] = idnode1; - myNodes[3] = idnode2; - myNodes[4] = idnode3; - } else { // 5 1 2 3 4 - myNodes[1] = idnode1; - myNodes[2] = idnode2; - myNodes[3] = idnode3; - myNodes[4] = idnode4; - } - -} - -//======================================================================= -//function : NodesOfFace -//purpose : returns the rank node in mynodes. Useful to extract faces from volume -//======================================================================= -Standard_Integer SMDS_MeshPyramid::NodesOfFace(const Standard_Integer rankface, - const Standard_Integer ranknode) -{ - static Standard_Integer facenode[5][4] = { - {0,1,2,3}, - {0,4,1,-1}, - {1,4,2,-1}, - {2,4,3,-1}, - {0,3,4,-1} - }; - - return facenode[rankface-1][ranknode-1]; -} - -//======================================================================= -//function : NodesOfEdge -//purpose : returns the rank node in mynodes. Useful to extract edges from volume -//======================================================================= -Standard_Integer SMDS_MeshPyramid::NodesOfEdge(const Standard_Integer rankedge, - const Standard_Integer ranknode) const -{ - static Standard_Integer faceedge[8][2] = { - {0,1}, - {1,2}, - {2,3}, - {0,3}, - {0,4}, - {1,4}, - {2,4}, - {3,4} - - }; - - return faceedge[rankedge-1][ranknode-1]; -} - - -//======================================================================= -//function : GetFaceDefinedByNodes -//purpose : -//======================================================================= -void SMDS_MeshPyramid::GetFaceDefinedByNodes(const Standard_Integer rank, - const Standard_Address idnode, - Standard_Integer& nb) const -{ - Standard_Integer *ptr; - ptr = (Standard_Integer *)idnode; - ptr[0] = myNodes[NodesOfFace(rank,1)]; - ptr[1] = myNodes[NodesOfFace(rank,2)]; - ptr[2] = myNodes[NodesOfFace(rank,3)]; - nb = (NodesOfFace(rank,4) == -1 ? 3 : 4); - if (nb == 4) - ptr[3] = myNodes[NodesOfFace(rank,4)]; - -} - -//======================================================================= -//function : GetEdgeDefinedByNodes -//purpose : -//======================================================================= -void SMDS_MeshPyramid::GetEdgeDefinedByNodes(const Standard_Integer rank, - Standard_Integer& idnode1, - Standard_Integer& idnode2) const -{ - idnode1 = myNodes[NodesOfEdge(rank,1)]; - idnode2 = myNodes[NodesOfEdge(rank,2)]; -} - diff --git a/src/SMDS/SMDS_MeshPyramid.hxx b/src/SMDS/SMDS_MeshPyramid.hxx deleted file mode 100644 index 79db781a0..000000000 --- a/src/SMDS/SMDS_MeshPyramid.hxx +++ /dev/null @@ -1,125 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMDS_MeshPyramid.hxx -// Module : SMESH - -#ifndef _SMDS_MeshPyramid_HeaderFile -#define _SMDS_MeshPyramid_HeaderFile - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Handle_SMDS_MeshPyramid_HeaderFile -#include "Handle_SMDS_MeshPyramid.hxx" -#endif - -#ifndef _Standard_Integer_HeaderFile -#include -#endif -#ifndef _SMDS_MeshVolume_HeaderFile -#include "SMDS_MeshVolume.hxx" -#endif -#ifndef _Standard_Address_HeaderFile -#include -#endif -class Standard_ConstructionError; - - -class SMDS_MeshPyramid : public SMDS_MeshVolume { - -public: - - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT SMDS_MeshPyramid(const Standard_Integer ID,const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4,const Standard_Integer idnode5); -Standard_EXPORT void GetFaceDefinedByNodes(const Standard_Integer rank,const Standard_Address idnode,Standard_Integer& nb) const; -Standard_EXPORT void GetEdgeDefinedByNodes(const Standard_Integer rank,Standard_Integer& idnode1,Standard_Integer& idnode2) const; -Standard_EXPORT inline void ComputeKey() ; -Standard_EXPORT inline Standard_Address GetConnections() const; -Standard_EXPORT inline Standard_Integer GetConnection(const Standard_Integer rank) const; -Standard_EXPORT inline Standard_Integer NbEdges() const; -Standard_EXPORT inline Standard_Integer NbFaces() const; -Standard_EXPORT static Standard_Integer NodesOfFace(const Standard_Integer rankface,const Standard_Integer ranknode) ; -Standard_EXPORT Standard_Integer NodesOfEdge(const Standard_Integer rankedge,const Standard_Integer ranknode) const; -Standard_EXPORT ~SMDS_MeshPyramid(); - - - - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& SMDS_MeshPyramid_Type_(); - Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // -Standard_EXPORT void SetConnections(const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4,const Standard_Integer idnode5) ; - - - // Fields PRIVATE - // -Standard_Integer myNodes[5]; - - -}; - - -#include "SMDS_MeshPyramid.lxx" - - - -// other inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/SMDS/SMDS_MeshQuadrangle.cxx b/src/SMDS/SMDS_MeshQuadrangle.cxx deleted file mode 100644 index 9a224ed79..000000000 --- a/src/SMDS/SMDS_MeshQuadrangle.cxx +++ /dev/null @@ -1,83 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMDS_MeshQuadrangle.cxx -// Author : Jean-Michel BOULCOURT -// Module : SMESH - -using namespace std; -#include "SMDS_MeshQuadrangle.ixx" - - - -//======================================================================= -//function : SMDS_MeshQuadrangle -//purpose : -//======================================================================= - -SMDS_MeshQuadrangle::SMDS_MeshQuadrangle(const Standard_Integer ID, - const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4):SMDS_MeshFace(ID,4) -{ - SetConnections(idnode1,idnode2,idnode3,idnode4); - ComputeKey(); -} - - - -//======================================================================= -//function : SetConnections -//purpose : -//======================================================================= -void SMDS_MeshQuadrangle::SetConnections(const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4) -{ - Standard_Integer idmin = (idnode1 < idnode2 ? idnode1 : idnode2); - idmin = (idmin < idnode3 ? idmin : idnode3); - idmin = (idmin < idnode4 ? idmin : idnode4); - - myNodes[0] = idmin; - if (idmin == idnode1) { - myNodes[1] = idnode2; - myNodes[2] = idnode3; - myNodes[3] = idnode4; - } else if (idmin == idnode2) { - myNodes[1] = idnode3; - myNodes[2] = idnode4; - myNodes[3] = idnode1; - } else if (idmin == idnode3) { - myNodes[1] = idnode4; - myNodes[2] = idnode1; - myNodes[3] = idnode2; - } else { - myNodes[1] = idnode1; - myNodes[2] = idnode2; - myNodes[3] = idnode3; - } - -} - diff --git a/src/SMDS/SMDS_MeshQuadrangle.hxx b/src/SMDS/SMDS_MeshQuadrangle.hxx deleted file mode 100644 index 39008c1c1..000000000 --- a/src/SMDS/SMDS_MeshQuadrangle.hxx +++ /dev/null @@ -1,119 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMDS_MeshQuadrangle.hxx -// Module : SMESH - -#ifndef _SMDS_MeshQuadrangle_HeaderFile -#define _SMDS_MeshQuadrangle_HeaderFile - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Handle_SMDS_MeshQuadrangle_HeaderFile -#include "Handle_SMDS_MeshQuadrangle.hxx" -#endif - -#ifndef _Standard_Integer_HeaderFile -#include -#endif -#ifndef _SMDS_MeshFace_HeaderFile -#include "SMDS_MeshFace.hxx" -#endif -#ifndef _Standard_Address_HeaderFile -#include -#endif - - -class SMDS_MeshQuadrangle : public SMDS_MeshFace { - -public: - - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT SMDS_MeshQuadrangle(const Standard_Integer ID,const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4); -Standard_EXPORT inline void ComputeKey() ; -Standard_EXPORT inline void GetEdgeDefinedByNodes(const Standard_Integer rank,Standard_Integer& idnode1,Standard_Integer& idnode2) const; -Standard_EXPORT inline Standard_Address GetConnections() const; -Standard_EXPORT inline Standard_Integer GetConnection(const Standard_Integer rank) const; -Standard_EXPORT ~SMDS_MeshQuadrangle(); - - - - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& SMDS_MeshQuadrangle_Type_(); - Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // -Standard_EXPORT void SetConnections(const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4) ; - - - // Fields PRIVATE - // -Standard_Integer myNodes[4]; - - -}; - - -#include "SMDS_MeshQuadrangle.lxx" - - - -// other inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/SMDS/SMDS_MeshTetrahedron.cxx b/src/SMDS/SMDS_MeshTetrahedron.cxx deleted file mode 100644 index 8c5cc52e4..000000000 --- a/src/SMDS/SMDS_MeshTetrahedron.cxx +++ /dev/null @@ -1,149 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMDS_MeshTetrahedron.cxx -// Author : Jean-Michel BOULCOURT -// Module : SMESH - -using namespace std; -#include "SMDS_MeshTetrahedron.ixx" -#include "Standard_ConstructionError.hxx" - -//======================================================================= -//function : SMDS_MeshTetrahedron -//purpose : Tetrahedra -//======================================================================= - -SMDS_MeshTetrahedron::SMDS_MeshTetrahedron(const Standard_Integer ID, - const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4):SMDS_MeshVolume(ID,4) -{ - SetConnections(idnode1,idnode2,idnode3,idnode4); - ComputeKey(); -} - - -//======================================================================= -//function : SetConnections -//purpose : Tetrahedra -//======================================================================= -void SMDS_MeshTetrahedron::SetConnections(const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3, - const Standard_Integer idnode4) -{ - Standard_Integer idmin = (idnode1 < idnode2 ? idnode1 : idnode2); - idmin = (idmin < idnode3 ? idmin : idnode3); - idmin = (idmin < idnode4 ? idmin : idnode4); - - myNodes[0] = idmin; - if (idmin == idnode1) { - myNodes[1] = idnode2; - myNodes[2] = idnode3; - myNodes[3] = idnode4; - } else if (idmin == idnode2) { - myNodes[1] = idnode3; - myNodes[2] = idnode4; - myNodes[3] = idnode1; - } else if (idmin == idnode3) { - myNodes[1] = idnode4; - myNodes[2] = idnode1; - myNodes[3] = idnode2; - } else { - myNodes[1] = idnode1; - myNodes[2] = idnode2; - myNodes[3] = idnode3; - } - -} - - -//======================================================================= -//function : NodesOfFace -//purpose : returns the rank node in mynodes. Useful to extract faces from volume -//======================================================================= -Standard_Integer SMDS_MeshTetrahedron::NodesOfFace(const Standard_Integer rankface, - const Standard_Integer ranknode) -{ - static Standard_Integer facenode[4][3] = { - {0,1,2}, - {0,3,1}, - {1,3,2}, - {0,2,3} - }; - - return facenode[rankface-1][ranknode-1]; -} - - -//======================================================================= -//function : NodesOfEdge -//purpose : returns the rank node in mynodes. Useful to extract edges from volume -//======================================================================= -Standard_Integer SMDS_MeshTetrahedron::NodesOfEdge(const Standard_Integer rankedge, - const Standard_Integer ranknode) const -{ - static Standard_Integer faceedge[6][2] = { - {0,1}, - {1,2}, - {0,2}, - {0,3}, - {1,3}, - {2,3} - }; - - return faceedge[rankedge-1][ranknode-1]; -} - - -//======================================================================= -//function : GetFaceDefinedByNodes -//purpose : -//======================================================================= -void SMDS_MeshTetrahedron::GetFaceDefinedByNodes(const Standard_Integer rank, - const Standard_Address idnode, - Standard_Integer& nb) const -{ - Standard_Integer *ptr; - nb = 3; - ptr = (Standard_Integer *)idnode; - ptr[0] = myNodes[NodesOfFace(rank,1)]; - ptr[1] = myNodes[NodesOfFace(rank,2)]; - ptr[2] = myNodes[NodesOfFace(rank,3)]; - -} - -//======================================================================= -//function : GetEdgeDefinedByNodes -//purpose : -//======================================================================= -void SMDS_MeshTetrahedron::GetEdgeDefinedByNodes(const Standard_Integer rank, - Standard_Integer& idnode1, - Standard_Integer& idnode2) const -{ - idnode1 = myNodes[NodesOfEdge(rank,1)]; - idnode2 = myNodes[NodesOfEdge(rank,2)]; -} - diff --git a/src/SMDS/SMDS_MeshTetrahedron.hxx b/src/SMDS/SMDS_MeshTetrahedron.hxx deleted file mode 100644 index c31c5eb5a..000000000 --- a/src/SMDS/SMDS_MeshTetrahedron.hxx +++ /dev/null @@ -1,125 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMDS_MeshTetrahedron.hxx -// Module : SMESH - -#ifndef _SMDS_MeshTetrahedron_HeaderFile -#define _SMDS_MeshTetrahedron_HeaderFile - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Handle_SMDS_MeshTetrahedron_HeaderFile -#include "Handle_SMDS_MeshTetrahedron.hxx" -#endif - -#ifndef _Standard_Integer_HeaderFile -#include -#endif -#ifndef _SMDS_MeshVolume_HeaderFile -#include "SMDS_MeshVolume.hxx" -#endif -#ifndef _Standard_Address_HeaderFile -#include -#endif -class Standard_ConstructionError; - - -class SMDS_MeshTetrahedron : public SMDS_MeshVolume { - -public: - - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT SMDS_MeshTetrahedron(const Standard_Integer ID,const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4); -Standard_EXPORT void GetFaceDefinedByNodes(const Standard_Integer rank,const Standard_Address idnode,Standard_Integer& nb) const; -Standard_EXPORT void GetEdgeDefinedByNodes(const Standard_Integer rank,Standard_Integer& idnode1,Standard_Integer& idnode2) const; -Standard_EXPORT inline void ComputeKey() ; -Standard_EXPORT inline Standard_Address GetConnections() const; -Standard_EXPORT inline Standard_Integer GetConnection(const Standard_Integer rank) const; -Standard_EXPORT inline Standard_Integer NbEdges() const; -Standard_EXPORT inline Standard_Integer NbFaces() const; -Standard_EXPORT static Standard_Integer NodesOfFace(const Standard_Integer rankface,const Standard_Integer ranknode) ; -Standard_EXPORT Standard_Integer NodesOfEdge(const Standard_Integer rankedge,const Standard_Integer ranknode) const; -Standard_EXPORT ~SMDS_MeshTetrahedron(); - - - - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& SMDS_MeshTetrahedron_Type_(); - Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // -Standard_EXPORT void SetConnections(const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3,const Standard_Integer idnode4) ; - - - // Fields PRIVATE - // -Standard_Integer myNodes[4]; - - -}; - - -#include "SMDS_MeshTetrahedron.lxx" - - - -// other inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/SMDS/SMDS_MeshTriangle.cxx b/src/SMDS/SMDS_MeshTriangle.cxx deleted file mode 100644 index 28b77ddc8..000000000 --- a/src/SMDS/SMDS_MeshTriangle.cxx +++ /dev/null @@ -1,71 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMDS_MeshTriangle.cxx -// Author : Jean-Michel BOULCOURT -// Module : SMESH - -using namespace std; -#include "SMDS_MeshTriangle.ixx" - - -//======================================================================= -//function : SMDS_MeshTriangle -//purpose : -//======================================================================= - -SMDS_MeshTriangle::SMDS_MeshTriangle(const Standard_Integer ID, - const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3):SMDS_MeshFace(ID,3) -{ - SetConnections(idnode1,idnode2,idnode3); - ComputeKey(); -} - - -//======================================================================= -//function : SetConnections -//purpose : -//======================================================================= -void SMDS_MeshTriangle::SetConnections(const Standard_Integer idnode1, - const Standard_Integer idnode2, - const Standard_Integer idnode3) -{ - Standard_Integer idmin = (idnode1 < idnode2 ? idnode1 : idnode2); - idmin = (idmin < idnode3 ? idmin : idnode3); - - myNodes[0] = idmin; - if (idmin == idnode1) { - myNodes[1] = idnode2; - myNodes[2] = idnode3; - } else if (idmin == idnode2) { - myNodes[1] = idnode3; - myNodes[2] = idnode1; - } else { - myNodes[1] = idnode1; - myNodes[2] = idnode2; - } - -} - diff --git a/src/SMDS/SMDS_MeshTriangle.hxx b/src/SMDS/SMDS_MeshTriangle.hxx deleted file mode 100644 index 586769fdd..000000000 --- a/src/SMDS/SMDS_MeshTriangle.hxx +++ /dev/null @@ -1,119 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMDS_MeshTriangle.hxx -// Module : SMESH - -#ifndef _SMDS_MeshTriangle_HeaderFile -#define _SMDS_MeshTriangle_HeaderFile - -#ifndef _Standard_HeaderFile -#include -#endif -#ifndef _Handle_SMDS_MeshTriangle_HeaderFile -#include "Handle_SMDS_MeshTriangle.hxx" -#endif - -#ifndef _Standard_Integer_HeaderFile -#include -#endif -#ifndef _SMDS_MeshFace_HeaderFile -#include "SMDS_MeshFace.hxx" -#endif -#ifndef _Standard_Address_HeaderFile -#include -#endif - - -class SMDS_MeshTriangle : public SMDS_MeshFace { - -public: - - inline void* operator new(size_t,void* anAddress) - { - return anAddress; - } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); - } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); - } -// inline void operator delete(void *anAddress, size_t size) -// { -// if (anAddress) Standard::Free((Standard_Address&)anAddress,size); -// } - // Methods PUBLIC - // -Standard_EXPORT SMDS_MeshTriangle(const Standard_Integer ID,const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3); -Standard_EXPORT inline void ComputeKey() ; -Standard_EXPORT inline void GetEdgeDefinedByNodes(const Standard_Integer rank,Standard_Integer& idnode1,Standard_Integer& idnode2) const; -Standard_EXPORT inline Standard_Address GetConnections() const; -Standard_EXPORT inline Standard_Integer GetConnection(const Standard_Integer rank) const; -Standard_EXPORT ~SMDS_MeshTriangle(); - - - - - // Type management - // - Standard_EXPORT friend Handle_Standard_Type& SMDS_MeshTriangle_Type_(); - Standard_EXPORT const Handle(Standard_Type)& DynamicType() const; - Standard_EXPORT Standard_Boolean IsKind(const Handle(Standard_Type)&) const; - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // -Standard_EXPORT void SetConnections(const Standard_Integer idnode1,const Standard_Integer idnode2,const Standard_Integer idnode3) ; - - - // Fields PRIVATE - // -Standard_Integer myNodes[3]; - - -}; - - -#include "SMDS_MeshTriangle.lxx" - - - -// other inline functions and methods (like "C++: function call" methods) -// - - -#endif diff --git a/src/SMDS/SMDS_Position.cxx b/src/SMDS/SMDS_Position.cxx index 0a634ceb2..926aa4bf9 100644 --- a/src/SMDS/SMDS_Position.cxx +++ b/src/SMDS/SMDS_Position.cxx @@ -55,3 +55,22 @@ int SMDS_Position::GetShapeId() const { return myShapeId; } + +//======================================================================= +//function : GetDim +//purpose : +//======================================================================= + +int SMDS_Position::GetDim() const +{ +// switch ( GetTypeOfPosition() ) { +// case SMDS_TOP_UNSPEC: return -1; +// case SMDS_TOP_VERTEX: return 0; +// case SMDS_TOP_EDGE: return 1; +// case SMDS_TOP_FACE: return 2; +// case SMDS_TOP_3DSPACE: return 3; +// } + return GetTypeOfPosition(); +} + + diff --git a/src/SMDS/SMDS_Position.hxx b/src/SMDS/SMDS_Position.hxx index 6047c30c3..a18ec9eb2 100644 --- a/src/SMDS/SMDS_Position.hxx +++ b/src/SMDS/SMDS_Position.hxx @@ -33,12 +33,14 @@ class SMDS_Position; typedef boost::shared_ptr SMDS_PositionPtr; + class SMDS_Position { public: const virtual double * Coords() const = 0; - virtual inline SMDS_TypeOfPosition GetTypeOfPosition() const = 0; + virtual SMDS_TypeOfPosition GetTypeOfPosition() const = 0; + virtual int GetDim() const; void SetShapeId(int aShapeId); int GetShapeId() const; virtual ~SMDS_Position() {} @@ -49,4 +51,6 @@ class SMDS_Position private: int myShapeId; }; + + #endif diff --git a/src/SMDS/SMDS_Tria3OfNodes.cxx b/src/SMDS/SMDS_Tria3OfNodes.cxx deleted file mode 100644 index 686e34e24..000000000 --- a/src/SMDS/SMDS_Tria3OfNodes.cxx +++ /dev/null @@ -1,107 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org - -#include "SMDS_Tria3OfNodes.hxx" -#include "SMDS_IteratorOfElements.hxx" -#include "SMDS_MeshNode.hxx" -#include "utilities.h" - -//======================================================================= -//function : NbEdges -//purpose : -//======================================================================= - -int SMDS_Tria3OfNodes::NbEdges() const -{ - return 3; -} - -int SMDS_Tria3OfNodes::NbFaces() const -{ - return 3; -} - -int SMDS_Tria3OfNodes::NbNodes() const -{ - return 3; -} -//======================================================================= -//function : Print -//purpose : -//======================================================================= - -void SMDS_Tria3OfNodes::Print(ostream & OS) const -{ - OS << "face <" << GetID() << " > : "; - int i; - for (i = 0; i < NbNodes() - 1; i++) OS << myNodes[i] << ","; - OS << myNodes[i] << ") " << endl; -} - -class SMDS_Tria3OfNodes_MyIterator:public SMDS_ElemIterator -{ - const SMDS_MeshNode * const* mySet; - int index; - public: - SMDS_Tria3OfNodes_MyIterator(const SMDS_MeshNode * const* s): - mySet(s),index(0) {} - - bool more() - { - return index<3; - } - - const SMDS_MeshElement* next() - { - index++; - return mySet[index-1]; - } -}; - -SMDS_ElemIteratorPtr SMDS_Tria3OfNodes:: - elementsIterator(SMDSAbs_ElementType type) const -{ - switch(type) - { - case SMDSAbs_Face: - return SMDS_MeshElement::elementsIterator(SMDSAbs_Face); - case SMDSAbs_Node: - return SMDS_ElemIteratorPtr(new SMDS_Tria3OfNodes_MyIterator(myNodes)); - case SMDSAbs_Edge: - MESSAGE("Error : edge iterator for SMDS_FaceOfNodes not implemented"); - break; - default: - return SMDS_ElemIteratorPtr - (new SMDS_IteratorOfElements - (this,type,SMDS_ElemIteratorPtr(new SMDS_Tria3OfNodes_MyIterator(myNodes)))); - } -} - -SMDS_Tria3OfNodes::SMDS_Tria3OfNodes(const SMDS_MeshNode* node1, - const SMDS_MeshNode* node2, - const SMDS_MeshNode* node3) -{ - myNodes[0]=node1; - myNodes[1]=node2; - myNodes[2]=node3; -} - - diff --git a/src/SMDS/SMDS_Tria3OfNodes.hxx b/src/SMDS/SMDS_Tria3OfNodes.hxx deleted file mode 100644 index 63552a03d..000000000 --- a/src/SMDS/SMDS_Tria3OfNodes.hxx +++ /dev/null @@ -1,50 +0,0 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org - -#ifndef _SMDS_Tria3OfNodes_HeaderFile -#define _SMDS_Tria3OfNodes_HeaderFile - -#include -#include "SMDS_MeshFace.hxx" -#include "SMDS_MeshNode.hxx" -#include "SMDS_Iterator.hxx" - -class SMDS_Tria3OfNodes:public SMDS_MeshFace -{ - public: - void Print(ostream & OS) const; - SMDS_Tria3OfNodes(const SMDS_MeshNode* node1, - const SMDS_MeshNode* node2, - const SMDS_MeshNode* node3); - - int NbEdges() const; - int NbFaces() const; - int NbNodes() const; - protected: - SMDS_ElemIteratorPtr - elementsIterator(SMDSAbs_ElementType type) const; - - private: - const SMDS_MeshNode* myNodes[3]; - -}; - -#endif diff --git a/src/SMDS/SMDS_TypeOfPosition.hxx b/src/SMDS/SMDS_TypeOfPosition.hxx index 9de8b7fb8..8c0631bfc 100644 --- a/src/SMDS/SMDS_TypeOfPosition.hxx +++ b/src/SMDS/SMDS_TypeOfPosition.hxx @@ -27,13 +27,13 @@ #ifndef _SMDS_TypeOfPosition_HeaderFile #define _SMDS_TypeOfPosition_HeaderFile -enum SMDS_TypeOfPosition +enum SMDS_TypeOfPosition // Value is equal to shape dimention { - SMDS_TOP_UNSPEC, - SMDS_TOP_3DSPACE, - SMDS_TOP_VERTEX, - SMDS_TOP_EDGE, - SMDS_TOP_FACE + SMDS_TOP_UNSPEC = -1, + SMDS_TOP_VERTEX = 0, + SMDS_TOP_EDGE = 1, + SMDS_TOP_FACE = 2, + SMDS_TOP_3DSPACE = 3 }; #endif diff --git a/src/SMDS/SMDS_VertexPosition.cxx b/src/SMDS/SMDS_VertexPosition.cxx index 8757ad4d3..94b12438c 100644 --- a/src/SMDS/SMDS_VertexPosition.cxx +++ b/src/SMDS/SMDS_VertexPosition.cxx @@ -26,8 +26,11 @@ // Module : SMESH #include "SMDS_VertexPosition.hxx" + #include "utilities.h" +using namespace std; + //======================================================================= //function : SMDS_VertexPosition //purpose : diff --git a/src/SMDS/SMDS_VolumeOfFaces.cxx b/src/SMDS/SMDS_VolumeOfFaces.cxx index 435107fe7..a710a8ffe 100644 --- a/src/SMDS/SMDS_VolumeOfFaces.cxx +++ b/src/SMDS/SMDS_VolumeOfFaces.cxx @@ -27,6 +27,9 @@ #include "SMDS_VolumeOfFaces.hxx" #include "SMDS_IteratorOfElements.hxx" + +using namespace std; + //======================================================================= //function : Print //purpose : diff --git a/src/SMDS/SMDS_VolumeOfFaces.hxx b/src/SMDS/SMDS_VolumeOfFaces.hxx index 7ea45b37c..4a78e366e 100644 --- a/src/SMDS/SMDS_VolumeOfFaces.hxx +++ b/src/SMDS/SMDS_VolumeOfFaces.hxx @@ -32,7 +32,7 @@ #include "SMDS_Iterator.hxx" #include #include -using namespace std; + class SMDS_VolumeOfFaces:public SMDS_MeshVolume { @@ -54,13 +54,13 @@ class SMDS_VolumeOfFaces:public SMDS_MeshVolume const SMDS_MeshFace * face5, const SMDS_MeshFace * face6); - void Print(ostream & OS) const; + void Print(std::ostream & OS) const; int NbFaces() const; protected: SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const; - vector myFaces; + std::vector myFaces; }; #endif diff --git a/src/SMDS/SMDS_VolumeOfNodes.cxx b/src/SMDS/SMDS_VolumeOfNodes.cxx index 3f4d6a245..25c0bf567 100644 --- a/src/SMDS/SMDS_VolumeOfNodes.cxx +++ b/src/SMDS/SMDS_VolumeOfNodes.cxx @@ -19,9 +19,11 @@ // // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -#include "utilities.h" #include "SMDS_VolumeOfNodes.hxx" #include "SMDS_MeshNode.hxx" +#include "utilities.h" + +using namespace std; /////////////////////////////////////////////////////////////////////////////// /// Create an hexahedron. node 1,2,3,4 and 5,6,7,8 are quadrangle and @@ -92,6 +94,18 @@ SMDS_VolumeOfNodes::SMDS_VolumeOfNodes( myNodes[4]=node5; myNodes[5]=node6; } +bool SMDS_VolumeOfNodes::ChangeNodes(const SMDS_MeshNode* nodes[], + const int nbNodes) +{ + if (nbNodes < 4 || nbNodes > 8 || nbNodes == 7) + return false; + + myNodes.resize( nbNodes ); + for ( int i = 0; i < nbNodes; i++ ) + myNodes[ i ] = nodes [ i ]; + + return true; +} //======================================================================= //function : Print //purpose : @@ -115,6 +129,7 @@ int SMDS_VolumeOfNodes::NbFaces() const case 8: return 6; default: MESSAGE("invalid number of nodes"); } + return 0; } int SMDS_VolumeOfNodes::NbNodes() const @@ -132,6 +147,7 @@ int SMDS_VolumeOfNodes::NbEdges() const case 8: return 12; default: MESSAGE("invalid number of nodes"); } + return 0; } class SMDS_VolumeOfNodes_MyIterator:public SMDS_ElemIterator diff --git a/src/SMDS/SMDS_VolumeOfNodes.hxx b/src/SMDS/SMDS_VolumeOfNodes.hxx index 7d4aa27de..b2a6c038e 100644 --- a/src/SMDS/SMDS_VolumeOfNodes.hxx +++ b/src/SMDS/SMDS_VolumeOfNodes.hxx @@ -29,7 +29,7 @@ #include "SMDS_MeshVolume.hxx" #include -using namespace std; + class SMDS_VolumeOfNodes:public SMDS_MeshVolume { @@ -62,8 +62,10 @@ class SMDS_VolumeOfNodes:public SMDS_MeshVolume const SMDS_MeshNode * node6, const SMDS_MeshNode * node7, const SMDS_MeshNode * node8); + bool ChangeNodes(const SMDS_MeshNode* nodes[], + const int nbNodes); - void Print(ostream & OS) const; + void Print(std::ostream & OS) const; int NbFaces() const; int NbNodes() const; int NbEdges() const; @@ -71,6 +73,6 @@ class SMDS_VolumeOfNodes:public SMDS_MeshVolume protected: SMDS_ElemIteratorPtr elementsIterator(SMDSAbs_ElementType type) const; - vector myNodes; + std::vector myNodes; }; #endif diff --git a/src/SMDS/SMDS_VolumeTool.cxx b/src/SMDS/SMDS_VolumeTool.cxx new file mode 100644 index 000000000..7acb3f054 --- /dev/null +++ b/src/SMDS/SMDS_VolumeTool.cxx @@ -0,0 +1,771 @@ +// File : SMDS_VolumeTool.cxx +// Created : Tue Jul 13 12:22:13 2004 +// Author : Edward AGAPOV (eap) +// Copyright : Open CASCADE + + +#include "SMDS_VolumeTool.hxx" + +#include "SMDS_MeshElement.hxx" +#include "SMDS_MeshNode.hxx" +#include +#include + +using namespace std; + +/* +// N3 +// + +// /|\ +// / | \ +// / | \ +// N0 +---|---+ N2 TETRAHEDRON +// \ | / +// \ | / +// \ | / +// \|/ +// + +// N1 +*/ +static int Tetra_F [4][4] = { // FORWARD == REVERSED EXTERNAL + { 0, 1, 2, 0 }, // Bottom face has an internal normal, other - external + { 0, 1, 3, 0 }, + { 1, 2, 3, 1 }, + { 0, 3, 2, 0 }}; +static int Tetra_R [4][4] = { // REVERSED == FORWARD EXTERNAL + { 0, 2, 1, 0 }, // All faces have external normals + { 0, 1, 3, 0 }, + { 1, 2, 3, 1 }, + { 0, 3, 2, 0 }}; +static int Tetra_nbN [] = { 3, 3, 3, 3 }; + +/* +// + N4 +// /|\ +// / | \ +// / | \ +// / | \ +// N3 +---------+ N5 +// | | | +// | + N1 | +// | / \ | PENTAHEDRON +// | / \ | +// | / \ | +// |/ \| +// N0 +---------+ N2 +*/ +static int Penta_F [5][5] = { // FORWARD + { 0, 1, 2, 0, 0 }, // Top face has an internal normal, other - external + { 3, 4, 5, 3, 3 }, // 0 is bottom, 1 is top face + { 0, 2, 5, 3, 0 }, + { 1, 2, 5, 4, 1 }, + { 1, 0, 3, 4, 1 }}; +static int Penta_R [5][5] = { // REVERSED + { 0, 2, 1, 0, 0 }, // Bottom face has an internal normal, other - external + { 3, 5, 4, 3, 3 }, // 0 is bottom, 1 is top face + { 0, 2, 5, 3, 0 }, + { 1, 2, 5, 4, 1 }, + { 1, 0, 3, 4, 1 }}; +static int Penta_FE [5][5] = { // EXTERNAL + { 0, 1, 2, 0, 0 }, + { 3, 5, 4, 3, 3 }, + { 0, 2, 5, 3, 0 }, + { 1, 2, 5, 4, 1 }, + { 1, 0, 3, 4, 1 }}; +static int Penta_RE [5][5] = { // REVERSED EXTERNAL + { 0, 0, 2, 1, 0 }, + { 3, 3, 4, 5, 3 }, + { 0, 2, 5, 3, 0 }, + { 1, 2, 5, 4, 1 }, + { 1, 0, 3, 4, 1 }}; +static int Penta_nbN [] = { 3, 3, 4, 4, 4 }; + +/* +// N7+----------+N6 +// /| /| +// / | / | +// / | / | +// N4+----------+N5 | +// | | | | HEXAHEDRON +// | | | | +// | | | | +// | N3+------|---+N2 +// | / | / +// | / | / +// |/ |/ +// N0+----------+N1 +*/ +static int Hexa_F [6][5] = { // FORWARD + { 0, 1, 2, 3, 0 }, // opposite faces are neighbouring, + { 4, 5, 6, 7, 4 }, // even face normal is internal, odd - external + { 1, 0, 4, 5, 1 }, // same index nodes nodes of opposite faces are linked + { 2, 3, 7, 6, 2 }, + { 0, 3, 7, 4, 0 }, + { 1, 2, 6, 5, 1 }}; +static int Hexa_R [6][5] = { // REVERSED + { 0, 3, 2, 1, 0 }, // opposite faces are neighbouring, + { 4, 7, 6, 5, 4 }, // even face normal is external, odd - internal + { 1, 5, 4, 0, 1 }, // same index nodes nodes of opposite faces are linked + { 2, 6, 7, 3, 2 }, + { 0, 4, 7, 3, 0 }, + { 1, 5, 6, 2, 1 }}; +static int Hexa_FE [6][5] = { // EXTERNAL + { 0, 3, 2, 1, 0 }, // opposite faces are neighbouring, + { 4, 5, 6, 7, 4 }, // all face normals are external, + { 0, 1, 5, 4, 0 }, // links in opposite faces: 0-0, 1-3, 2-2, 3-1 + { 3, 7, 6, 2, 3 }, + { 1, 2, 6, 5, 1 }, + { 0, 4, 7, 3, 0 }}; +static int Hexa_RE [6][5] = { // REVERSED EXTERNAL + { 0, 1, 2, 3, 0 }, // opposite faces are neighbouring, + { 4, 7, 6, 5, 4 }, // all face normals are external, + { 0, 1, 5, 4, 0 }, // links in opposite faces: 0-0, 1-3, 2-2, 3-1 + { 3, 7, 6, 2, 3 }, + { 1, 2, 6, 5, 1 }, + { 0, 4, 7, 3, 0 }}; +static int Hexa_nbN [] = { 4, 4, 4, 4, 4, 4 }; + +// ======================================================== +// to perform some calculations without linkage to CASCADE +// ======================================================== +struct XYZ { + double x; + double y; + double z; + XYZ() { x = 0; y = 0; z = 0; } + XYZ( double X, double Y, double Z ) { x = X; y = Y; z = Z; } + XYZ( const XYZ& other ) { x = other.x; y = other.y; z = other.z; } + XYZ( const SMDS_MeshNode* n ) { x = n->X(); y = n->Y(); z = n->Z(); } + XYZ operator-( const XYZ& other ); + XYZ Crossed( const XYZ& other ); + double Dot( const XYZ& other ); + double Magnitude(); +}; +XYZ XYZ::operator-( const XYZ& Right ) { + return XYZ(x - Right.x, y - Right.y, z - Right.z); +} +XYZ XYZ::Crossed( const XYZ& Right ) { + return XYZ (y * Right.z - z * Right.y, + z * Right.x - x * Right.z, + x * Right.y - y * Right.x); +} +double XYZ::Dot( const XYZ& Other ) { + return(x * Other.x + y * Other.y + z * Other.z); +} +double XYZ::Magnitude() { + return sqrt (x * x + y * y + z * z); +} + +//======================================================================= +//function : SMDS_VolumeTool +//purpose : +//======================================================================= + +SMDS_VolumeTool::SMDS_VolumeTool () + : myVolume( 0 ), + myVolForward( true ), + myNbFaces( 0 ), + myVolumeNbNodes( 0 ), + myForwardFaces( false ), + myExternalFaces( false ) +{ +} +//======================================================================= +//function : SMDS_VolumeTool +//purpose : +//======================================================================= + +SMDS_VolumeTool::SMDS_VolumeTool (const SMDS_MeshElement* theVolume) + : myForwardFaces( false ), + myExternalFaces( false ) +{ + Set( theVolume ); +} + +//======================================================================= +//function : SMDS_VolumeTool +//purpose : +//======================================================================= + +SMDS_VolumeTool::~SMDS_VolumeTool() +{ +} + +//======================================================================= +//function : SetVolume +//purpose : Set volume to iterate on +//======================================================================= + +bool SMDS_VolumeTool::Set (const SMDS_MeshElement* theVolume) +{ + myVolume = 0; + myVolForward = true; + myCurFace = -1; + myVolumeNbNodes = 0; + myNbFaces = 0; + if ( theVolume && theVolume->GetType() == SMDSAbs_Volume ) + { + myVolumeNbNodes = theVolume->NbNodes(); + switch ( myVolumeNbNodes ) { + case 4: + case 6: + case 8: + { + myVolume = theVolume; + myNbFaces = theVolume->NbFaces(); + + // set volume nodes + int iNode = 0; + SMDS_ElemIteratorPtr nodeIt = myVolume->nodesIterator(); + while ( nodeIt->more() ) + myVolumeNodes[ iNode++ ] = static_cast( nodeIt->next() ); + + // nb nodes in each face + if ( myVolumeNbNodes == 4 ) + myFaceNbNodes = Tetra_nbN; + else if ( myVolumeNbNodes == 6 ) + myFaceNbNodes = Penta_nbN; + else + myFaceNbNodes = Hexa_nbN; + break; + // define volume orientation + XYZ botNormal; + GetFaceNormal( 0, botNormal.x, botNormal.y, botNormal.z ); + const SMDS_MeshNode* topNode = myVolumeNodes[ myVolumeNbNodes - 1 ]; + const SMDS_MeshNode* botNode = myVolumeNodes[ 0 ]; + XYZ upDir (topNode->X() - botNode->X(), + topNode->Y() - botNode->Y(), + topNode->Z() - botNode->Z() ); + bool diffDir = ( botNormal.Dot( upDir ) < 0 ); + myVolForward = ( myVolumeNbNodes == 6 ? diffDir : !diffDir ); + + } + default: myVolume = 0; + } + } + return ( myVolume != 0 ); +} + +//======================================================================= +//function : GetInverseNodes +//purpose : Return nodes vector of an inverse volume +//======================================================================= + +#define SWAP_NODES(nodes,i1,i2) \ +{ \ + const SMDS_MeshNode* tmp = nodes[ i1 ]; \ + nodes[ i1 ] = nodes[ i2 ]; \ + nodes[ i2 ] = tmp; \ +} +void SMDS_VolumeTool::Inverse () +{ + if ( !myVolume ) return; + + myVolForward = !myVolForward; + myCurFace = -1; + + // inverse top and bottom faces + switch ( myVolumeNbNodes ) { + case 4: + SWAP_NODES( myVolumeNodes, 1, 2 ); + break; + case 6: + SWAP_NODES( myVolumeNodes, 1, 2 ); + SWAP_NODES( myVolumeNodes, 4, 5 ); + break; + case 8: + SWAP_NODES( myVolumeNodes, 1, 3 ); + SWAP_NODES( myVolumeNodes, 5, 7 ); + break; + default:; + } +} + +//======================================================================= +//function : GetSize +//purpose : Return element volume +//======================================================================= + +double SMDS_VolumeTool::GetSize() const +{ + return 0; +} + +//======================================================================= +//function : GetBaryCenter +//purpose : +//======================================================================= + +bool SMDS_VolumeTool::GetBaryCenter(double & X, double & Y, double & Z) const +{ + X = Y = Z = 0.; + if ( !myVolume ) + return false; + + for ( int i = 0; i < myVolumeNbNodes; i++ ) { + X += myVolumeNodes[ i ]->X(); + Y += myVolumeNodes[ i ]->Y(); + Z += myVolumeNodes[ i ]->Z(); + } + X /= myVolumeNbNodes; + Y /= myVolumeNbNodes; + Z /= myVolumeNbNodes; + + return true; +} + +//======================================================================= +//function : SetForwardOrientation +//purpose : Node order will be as for forward orientation +//======================================================================= + +void SMDS_VolumeTool::SetForwardOrientation () +{ + myForwardFaces = true; +} + +//======================================================================= +//function : SetExternalNormal +//purpose : Node order will be so that faces normals are external +//======================================================================= + +void SMDS_VolumeTool::SetExternalNormal () +{ + myExternalFaces = true; +} + +//======================================================================= +//function : NbFaceNodes +//purpose : Return number of nodes in the array of face nodes +//======================================================================= + +int SMDS_VolumeTool::NbFaceNodes( int faceIndex ) +{ + if ( !setFace( faceIndex )) + return 0; + return myFaceNbNodes[ faceIndex ]; +} + +//======================================================================= +//function : GetFaceNodes +//purpose : Return pointer to the array of face nodes. +// To comfort link iteration, the array +// length == NbFaceNodes( faceIndex ) + 1 and +// the last node == the first one. +//======================================================================= + +const SMDS_MeshNode** SMDS_VolumeTool::GetFaceNodes( int faceIndex ) +{ + if ( !setFace( faceIndex )) + return 0; + return myFaceNodes; +} + +//======================================================================= +//function : GetFaceNodesIndices +//purpose : Return pointer to the array of face nodes indices +// To comfort link iteration, the array +// length == NbFaceNodes( faceIndex ) + 1 and +// the last node index == the first one. +//======================================================================= + +const int* SMDS_VolumeTool::GetFaceNodesIndices( int faceIndex ) +{ + if ( !setFace( faceIndex )) + return 0; + return myFaceNodeIndices; +} + +//======================================================================= +//function : GetFaceNodes +//purpose : Return a set of face nodes. +//======================================================================= + +bool SMDS_VolumeTool::GetFaceNodes (int faceIndex, + std::set& theFaceNodes ) +{ + if ( !setFace( faceIndex )) + return false; + + theFaceNodes.clear(); + int iNode, nbNode = myFaceNbNodes[ faceIndex ]; + for ( int iNode = 0; iNode < nbNode; iNode++ ) + theFaceNodes.insert( myFaceNodes[ iNode ]); + + return true; +} + +//======================================================================= +//function : IsFaceExternal +//purpose : Check normal orientation of a returned face +//======================================================================= + +bool SMDS_VolumeTool::IsFaceExternal( int faceIndex ) +{ + if ( myExternalFaces || !myVolume ) + return true; + + bool reversed = ( !myForwardFaces && !myVolForward ); + switch ( myVolumeNbNodes ) { + case 4: + // only the bottom of a forward tetrahedron can be internal + return ( reversed || faceIndex != 0 ); + case 6: + // in a forward pentahedron, the top is internal, in a reversed one - bottom + return ( reversed ? faceIndex != 0 : faceIndex != 1 ); + case 8: { + // in a forward hexahedron, odd face normal is external, else vice versa + bool odd = faceIndex % 2; + return ( reversed ? !odd : odd ); + } + default:; + } + return false; +} + +//======================================================================= +//function : GetFaceNormal +//purpose : Return a normal to a face +//======================================================================= + +bool SMDS_VolumeTool::GetFaceNormal (int faceIndex, double & X, double & Y, double & Z) +{ + if ( !setFace( faceIndex )) + return false; + + XYZ p1 ( myFaceNodes[0] ); + XYZ p2 ( myFaceNodes[1] ); + XYZ p3 ( myFaceNodes[2] ); + XYZ aVec12( p2 - p1 ); + XYZ aVec13( p3 - p1 ); + XYZ cross = aVec12.Crossed( aVec13 ); + + double size = cross.Magnitude(); + if ( size <= DBL_MIN ) + return false; + + X = cross.x / size; + Y = cross.y / size; + Z = cross.z / size; + + return true; +} + + +//======================================================================= +//function : GetFaceArea +//purpose : Return face area +//======================================================================= + +double SMDS_VolumeTool::GetFaceArea( int faceIndex ) +{ + if ( !setFace( faceIndex )) + return 0; + + XYZ p1 ( myFaceNodes[0] ); + XYZ p2 ( myFaceNodes[1] ); + XYZ p3 ( myFaceNodes[2] ); + XYZ aVec12( p2 - p1 ); + XYZ aVec13( p3 - p1 ); + double area = aVec12.Crossed( aVec13 ).Magnitude() * 0.5; + + if ( myFaceNbNodes[ faceIndex ] == 4 ) { + XYZ p4 ( myFaceNodes[3] ); + XYZ aVec14( p4 - p1 ); + area += aVec14.Crossed( aVec13 ).Magnitude() * 0.5; + } + return area; +} + +//======================================================================= +//function : GetOppFaceIndex +//purpose : Return index of the opposite face if it exists, else -1. +//======================================================================= + +int SMDS_VolumeTool::GetOppFaceIndex( int faceIndex ) const +{ + int ind = -1; + if ( faceIndex >= 0 && faceIndex < NbFaces() ) { + switch ( myVolumeNbNodes ) { + case 6: + if ( faceIndex == 0 || faceIndex == 1 ) + ind = 1 - faceIndex; + break; + case 8: + ind = faceIndex + ( faceIndex % 2 ? -1 : 1 ); + break; + default:; + } + } + return ind; +} + +//======================================================================= +//function : IsLinked +//purpose : return true if theNode1 is linked with theNode2 +//======================================================================= + +bool SMDS_VolumeTool::IsLinked (const SMDS_MeshNode* theNode1, + const SMDS_MeshNode* theNode2) const +{ + if ( !myVolume ) + return false; + + // find nodes indices + int i1 = -1, i2 = -1; + for ( int i = 0; i < myVolumeNbNodes; i++ ) { + if ( myVolumeNodes[ i ] == theNode1 ) + i1 = i; + else if ( myVolumeNodes[ i ] == theNode2 ) + i2 = i; + } + return IsLinked( i1, i2 ); +} + +//======================================================================= +//function : IsLinked +//purpose : return true if the node with theNode1Index is linked +// with the node with theNode2Index +//======================================================================= + +bool SMDS_VolumeTool::IsLinked (const int theNode1Index, + const int theNode2Index) const +{ + int minInd = theNode1Index < theNode2Index ? theNode1Index : theNode2Index; + int maxInd = theNode1Index < theNode2Index ? theNode2Index : theNode1Index; + + if ( minInd < 0 || maxInd > myVolumeNbNodes - 1 || maxInd == minInd ) + return false; + + switch ( myVolumeNbNodes ) { + case 4: + return true; + case 6: + switch ( maxInd - minInd ) { + case 1: return minInd != 2; + case 2: return minInd == 0 || minInd == 3; + case 3: return true; + default:; + } + break; + case 8: + switch ( maxInd - minInd ) { + case 1: return minInd != 3; + case 3: return minInd == 0 || minInd == 4; + case 4: return true; + default:; + } + break; + default:; + } + return false; +} + +//======================================================================= +//function : GetNodeIndex +//purpose : Return an index of theNode +//======================================================================= + +int SMDS_VolumeTool::GetNodeIndex(const SMDS_MeshNode* theNode) const +{ + if ( myVolume ) { + for ( int i = 0; i < myVolumeNbNodes; i++ ) { + if ( myVolumeNodes[ i ] == theNode ) + return i; + } + } + return -1; +} + + +//======================================================================= +//function : IsFreeFace +//purpose : check that only one volume is build on the face nodes +//======================================================================= + +bool SMDS_VolumeTool::IsFreeFace( int faceIndex ) +{ + const int free = true; + if ( !setFace( faceIndex )) + return !free; + + const SMDS_MeshNode** nodes = GetFaceNodes( faceIndex ); + int nbFaceNodes = NbFaceNodes( faceIndex ); + + // evaluate nb of face nodes shared by other volume + int maxNbShared = -1; + typedef map< const SMDS_MeshElement*, int > TElemIntMap; + TElemIntMap volNbShared; + TElemIntMap::iterator vNbIt; + for ( int iNode = 0; iNode < nbFaceNodes; iNode++ ) + { + const SMDS_MeshNode* n = nodes[ iNode ]; + SMDS_ElemIteratorPtr eIt = n->GetInverseElementIterator(); + while ( eIt->more() ) { + const SMDS_MeshElement* elem = eIt->next(); + if ( elem != myVolume && elem->GetType() == SMDSAbs_Volume ) { + int nbShared = 1; + vNbIt = volNbShared.find( elem ); + if ( vNbIt == volNbShared.end() ) + volNbShared.insert ( TElemIntMap::value_type( elem, nbShared )); + else + nbShared = ++(*vNbIt).second; + if ( nbShared > maxNbShared ) + maxNbShared = nbShared; + } + } + } + if ( maxNbShared < 3 ) + return free; // is free + + // find volumes laying on the opposite side of the face + // and sharing all nodes + XYZ intNormal; // internal normal + GetFaceNormal( faceIndex, intNormal.x, intNormal.y, intNormal.z ); + if ( IsFaceExternal( faceIndex )) + intNormal = XYZ( -intNormal.x, -intNormal.y, -intNormal.z ); + XYZ p0 ( nodes[0] ), baryCenter; + for ( vNbIt = volNbShared.begin(); vNbIt != volNbShared.end(); vNbIt++ ) + { + int nbShared = (*vNbIt).second; + if ( nbShared >= 3 ) { + SMDS_VolumeTool volume( (*vNbIt).first ); + volume.GetBaryCenter( baryCenter.x, baryCenter.y, baryCenter.z ); + XYZ intNormal2( baryCenter - p0 ); + if ( intNormal.Dot( intNormal2 ) < 0 ) + continue; // opposite side + } + // remove a volume from volNbShared map + volNbShared.erase( vNbIt ); + } + // here volNbShared contains only volumes laying on the + // opposite side of the face + if ( volNbShared.empty() ) + return free; // is free + + // check if the whole area of a face is shared + bool isShared[] = { false, false, false, false }; // 4 triangle parts of a quadrangle + for ( vNbIt = volNbShared.begin(); vNbIt != volNbShared.end(); vNbIt++ ) + { + SMDS_VolumeTool volume( (*vNbIt).first ); + bool prevLinkShared = false; + int nbSharedLinks = 0; + for ( int iNode = 0; iNode < nbFaceNodes; iNode++ ) + { + bool linkShared = volume.IsLinked( nodes[ iNode ], nodes[ iNode + 1] ); + if ( linkShared ) + nbSharedLinks++; + if ( linkShared && prevLinkShared && + volume.IsLinked( nodes[ iNode - 1 ], nodes[ iNode + 1] )) + isShared[ iNode ] = true; + prevLinkShared = linkShared; + } + if ( nbSharedLinks == nbFaceNodes ) + return !free; // is not free + if ( nbFaceNodes == 4 ) { + // check traingle parts 1 & 3 + if ( isShared[1] && isShared[3] ) + return !free; // is not free + // check traingle parts 0 & 2; + // 0 part could not be checked in the loop; check it here + if ( isShared[2] && prevLinkShared && + volume.IsLinked( nodes[ 0 ], nodes[ 1 ] ) && + volume.IsLinked( nodes[ 1 ], nodes[ 3 ] ) ) + return !free; // is not free + } + } + return free; +} + +//======================================================================= +//function : GetFaceIndex +//purpose : Return index of a face formed by theFaceNodes +//======================================================================= + +int SMDS_VolumeTool::GetFaceIndex( const set& theFaceNodes ) +{ + for ( int iFace = 0; iFace < myNbFaces; iFace++ ) { + const SMDS_MeshNode** nodes = GetFaceNodes( iFace ); + int nbFaceNodes = NbFaceNodes( iFace ); + set nodeSet; + for ( int iNode = 0; iNode < nbFaceNodes; iNode++ ) + nodeSet.insert( nodes[ iNode ] ); + if ( theFaceNodes == nodeSet ) + return iFace; + } + return -1; +} + +//======================================================================= +//function : GetFaceIndex +//purpose : Return index of a face formed by theFaceNodes +//======================================================================= + +int SMDS_VolumeTool::GetFaceIndex( const set& theFaceNodesIndices ) +{ + for ( int iFace = 0; iFace < myNbFaces; iFace++ ) { + const int* nodes = GetFaceNodesIndices( iFace ); + int nbFaceNodes = NbFaceNodes( iFace ); + set nodeSet; + for ( int iNode = 0; iNode < nbFaceNodes; iNode++ ) + nodeSet.insert( nodes[ iNode ] ); + if ( theFaceNodesIndices == nodeSet ) + return iFace; + } + return -1; +} + +//======================================================================= +//function : setFace +//purpose : +//======================================================================= + +bool SMDS_VolumeTool::setFace( int faceIndex ) +{ + if ( !myVolume ) + return false; + + if ( myCurFace == faceIndex ) + return true; + + if ( faceIndex < 0 || faceIndex >= NbFaces() ) + return false; + + // choose face node indices + switch ( myVolumeNbNodes ) { + case 4: + if ( myExternalFaces ) + myFaceNodeIndices = myVolForward ? Tetra_R[ faceIndex ] : Tetra_F[ faceIndex ]; + else if ( myForwardFaces ) + myFaceNodeIndices = myVolForward ? Tetra_F[ faceIndex ] : Tetra_R[ faceIndex ]; + else + myFaceNodeIndices = Tetra_F[ faceIndex ]; + break; + case 6: + if ( myExternalFaces ) + myFaceNodeIndices = myVolForward ? Penta_FE[ faceIndex ] : Penta_RE[ faceIndex ]; + else if ( myForwardFaces ) + myFaceNodeIndices = myVolForward ? Penta_F[ faceIndex ] : Penta_R[ faceIndex ]; + else + myFaceNodeIndices = Penta_F[ faceIndex ]; + break; + case 8: + if ( myExternalFaces ) + myFaceNodeIndices = myVolForward ? Hexa_FE[ faceIndex ] : Hexa_RE[ faceIndex ]; + else if ( myForwardFaces ) + myFaceNodeIndices = myVolForward ? Hexa_F[ faceIndex ] : Hexa_R[ faceIndex ]; + else + myFaceNodeIndices = Hexa_F[ faceIndex ]; + break; + default: return false; + } + + // set face nodes + int iNode, nbNode = myFaceNbNodes[ faceIndex ]; + for ( iNode = 0; iNode <= nbNode; iNode++ ) + myFaceNodes[ iNode ] = myVolumeNodes[ myFaceNodeIndices[ iNode ]]; + + myCurFace = faceIndex; + + return true; +} diff --git a/src/SMDS/SMDS_VolumeTool.hxx b/src/SMDS/SMDS_VolumeTool.hxx new file mode 100644 index 000000000..0c840a512 --- /dev/null +++ b/src/SMDS/SMDS_VolumeTool.hxx @@ -0,0 +1,230 @@ +// SMESH SMDS : implementaion of Salome mesh data structure +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMDS_VolumeTool.hxx +// Module : SMESH +// Created : Tue Jul 13 11:27:17 2004 +// Author : Edward AGAPOV (eap) + + +#ifndef SMDS_VolumeTool_HeaderFile +#define SMDS_VolumeTool_HeaderFile + +class SMDS_MeshElement; +class SMDS_MeshNode; + +#include +#include + +// ========================================================================= +// +// Class providing topological and other information about SMDS_MeshVolume: +// allows iteration on faces or, to be precise, on nodes of volume sides; +// provides info on nodes connection etc. +// +// ========================================================================= + +class SMDS_VolumeTool +{ + public: + + SMDS_VolumeTool (); + ~SMDS_VolumeTool (); + SMDS_VolumeTool (const SMDS_MeshElement* theVolume); + + bool Set (const SMDS_MeshElement* theVolume); + // Set volume. + // Return false if theVolume is not of type SMDSAbs_Volume + + // ----------------------- + // general info + // ----------------------- + + bool IsForward() const { return myVolForward; } + // Check volume orientation. can be changed by Inverse(). + // See node order of forward volumes at file bottom + + void Inverse(); + // Change nodes order as if the volume changes its orientation: + // top and bottom faces are reversed. + // Result of IsForward() and methods returning nodes change + + const SMDS_MeshNode** GetNodes() { return myVolumeNodes; } + // Return array of volume nodes + + int NbNodes() { return myVolumeNbNodes; } + // Return array of volume nodes + + double GetSize() const; + // Return element volume + + bool GetBaryCenter (double & X, double & Y, double & Z) const; + + + // ----------------------- + // info on node connection + // ----------------------- + + bool IsLinked (const SMDS_MeshNode* theNode1, + const SMDS_MeshNode* theNode2) const; + // Return true if theNode1 is linked with theNode2. + + bool IsLinked (const int theNode1Index, + const int theNode2Index) const; + // Return true if the node with theNode1Index is linked + // with the node with theNode2Index + + int GetNodeIndex(const SMDS_MeshNode* theNode) const; + // Return an index of theNode + + // ------------- + // info on faces + // ------------- + + void SetForwardOrientation (); + // Node order in faces will be as for forward orientation + + void SetExternalNormal (); + // Node order in faces will be so that faces normals are external. + // It overrides SetForwardOrientation() + + int NbFaces() const { return myNbFaces; } + // Return number of faces of the volume. In the following + // methods 0 <= faceIndex < NbFaces() + + int NbFaceNodes( int faceIndex ); + // Return number of nodes in the array of face nodes + + const int* GetFaceNodesIndices( int faceIndex ); + // Return the array of face nodes indices + // To comfort link iteration, the array + // length == NbFaceNodes( faceIndex ) + 1 and + // the last node index == the first one. + + const SMDS_MeshNode** GetFaceNodes( int faceIndex ); + // Return the array of face nodes. + // To comfort link iteration, the array + // length == NbFaceNodes( faceIndex ) + 1 and + // the last node == the first one. + // WARNING: do not modify the array, some methods + // work basing on its contents + + bool GetFaceNodes (int faceIndex, + std::set& theFaceNodes ); + // Return a set of face nodes. + + bool IsFaceExternal( int faceIndex ); + // Check normal orientation of a face. + // SetForwardOrientation() and SetForwardOrientation() are taken + // into account. + + bool IsFreeFace( int faceIndex ); + // Check that all volumes built on the face nodes lays on one side + + bool GetFaceNormal (int faceIndex, double & X, double & Y, double & Z); + // Return a normal to a face + + double GetFaceArea( int faceIndex ); + // Return face area + + int GetOppFaceIndex( int faceIndex ) const; + // Return index of the opposite face if it exists, else -1. + + int GetFaceIndex( const std::set& theFaceNodes ); + // Return index of a face formed by theFaceNodes. + // Return -1 if a face not found + + int GetFaceIndex( const std::set& theFaceNodesIndices ); + // Return index of a face formed by theFaceNodesIndices + // Return -1 if a face not found + + + private: + + bool setFace( int faceIndex ); + + const SMDS_MeshElement* myVolume; + bool myVolForward; + int myNbFaces; + int myVolumeNbNodes; + const SMDS_MeshNode* myVolumeNodes[ 8 ]; + + bool myForwardFaces; + bool myExternalFaces; + int* myFaceNodeIndices; + int* myFaceNbNodes; + const SMDS_MeshNode* myFaceNodes[ 5 ]; + int myCurFace; + +}; +#endif + + +/////////////////////////////////////////////////////////////////////////// +// +// ORDER OF NODES OF FORWARD ELEMENT +// +/////////////////////////////////////////////////////////////////////////// +/* +// N3 +// + +// /|\ +// / | \ +// / | \ +// N0 +---|---+ N2 TETRAHEDRON +// \ | / +// \ | / +// \ | / +// \|/ +// + +// N1 + +// + N4 +// /|\ +// / | \ +// / | \ +// / | \ +// N3 +---------+ N5 +// | | | +// | + N1 | +// | / \ | PENTAHEDRON +// | / \ | +// | / \ | +// |/ \| +// N0 +---------+ N2 + +// N7+----------+N6 +// /| /| +// / | / | +// / | / | +// N4+----------+N5 | +// | | | | HEXAHEDRON +// | | | | +// | | | | +// | N3+------|---+N2 +// | / | / +// | / | / +// |/ |/ +// N0+----------+N1 +// +*/ diff --git a/src/SMESH/Makefile.in b/src/SMESH/Makefile.in index f8fe6b7fa..9d31f6282 100644 --- a/src/SMESH/Makefile.in +++ b/src/SMESH/Makefile.in @@ -25,7 +25,6 @@ # Author : Paul RASCLE, EDF # Module : SMESH # $Header$ - top_srcdir=@top_srcdir@ top_builddir=../.. srcdir=@srcdir@ @@ -44,7 +43,9 @@ EXPORT_HEADERS= \ SMESH_1D_Algo.hxx \ SMESH_2D_Algo.hxx \ SMESH_3D_Algo.hxx \ - SMESH_Group.hxx + SMESH_Group.hxx \ + SMESH_MeshEditor.hxx \ + SMESH_Pattern.hxx EXPORT_PYSCRIPTS = @@ -58,7 +59,9 @@ LIB_SRC = SMESH_Gen.cxx SMESH_Mesh.cxx SMESH_subMesh.cxx \ SMESH_1D_Algo.cxx \ SMESH_2D_Algo.cxx \ SMESH_3D_Algo.cxx \ - SMESH_Group.cxx + SMESH_Group.cxx \ + SMESH_MeshEditor.cxx \ + SMESH_Pattern.cxx LIB_SERVER_IDL = @@ -68,14 +71,12 @@ LIB_CLIENT_IDL = BIN = BIN_SRC = -# additionnal information to compil and link file +# additionnal information to compile and link file CPPFLAGS+= $(OCC_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome \ $(BOOST_CPPFLAGS) CXXFLAGS+= $(OCC_CXXFLAGS) $(MED2_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -#IDLCXXFLAGS+= -Wbtp - -LDFLAGS+= $(HDF5_LIBS) $(MED2_LIBS) -lOpUtil -lSMESHDS -lSMDS -lMeshDriverDAT -lMeshDriverMED -lMeshDriverUNV -L${KERNEL_ROOT_DIR}/lib/salome +LDFLAGS+= -L${KERNEL_ROOT_DIR}/lib/salome -lSMESHDS -lMeshDriverDAT -lMeshDriverSTL -lMeshDriverMED -lMeshDriverUNV @CONCLUDE@ diff --git a/src/SMESH/SMESH_Algo.hxx b/src/SMESH/SMESH_Algo.hxx index d19bd94f3..029dc6711 100644 --- a/src/SMESH/SMESH_Algo.hxx +++ b/src/SMESH/SMESH_Algo.hxx @@ -37,7 +37,6 @@ #include #include #include -using namespace std; class SMESH_Gen; class SMESH_Mesh; @@ -48,14 +47,14 @@ class SMESH_Algo:public SMESH_Hypothesis SMESH_Algo(int hypId, int studyId, SMESH_Gen * gen); virtual ~ SMESH_Algo(); - const vector < string > &GetCompatibleHypothesis(); + const std::vector < std::string > &GetCompatibleHypothesis(); virtual bool CheckHypothesis(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape, SMESH_Hypothesis::Hypothesis_Status& aStatus) = 0; virtual bool Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) = 0; - virtual const list & + virtual const std::list & GetUsedHypothesis(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape); const list & @@ -83,9 +82,9 @@ class SMESH_Algo:public SMESH_Hypothesis protected: bool _onlyUnaryInput; bool _requireDescretBoundary; - vector _compatibleHypothesis; - list _appliedHypList; - list _usedHypList; + std::vector _compatibleHypothesis; + std::list _appliedHypList; + std::list _usedHypList; }; #endif diff --git a/src/SMESH/SMESH_Gen.cxx b/src/SMESH/SMESH_Gen.cxx index 44000dfac..3a202a347 100644 --- a/src/SMESH/SMESH_Gen.cxx +++ b/src/SMESH/SMESH_Gen.cxx @@ -1,23 +1,23 @@ // 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -33,13 +33,14 @@ #include "utilities.h" #include "OpUtil.hxx" +#include "Utils_ExceptHandlers.hxx" #include #include #include #include -#include "Utils_ExceptHandlers.hxx" +using namespace std; //============================================================================= /*! @@ -56,7 +57,7 @@ SMESH_Gen::SMESH_Gen() //============================================================================= /*! - * + * */ //============================================================================= @@ -67,7 +68,7 @@ SMESH_Gen::~SMESH_Gen() //============================================================================= /*! - * + * */ //============================================================================= @@ -96,7 +97,7 @@ SMESH_Gen::~SMESH_Gen() //============================================================================= /*! - * + * */ //============================================================================= @@ -115,7 +116,7 @@ throw(SALOME_Exception) StudyContextStruct *myStudyContext = GetStudyContext(studyId); - // create a new SMESH_mesh object + // create a new SMESH_mesh object SMESH_Mesh *mesh = new SMESH_Mesh(_localId++, studyId, @@ -131,7 +132,7 @@ throw(SALOME_Exception) //============================================================================= /*! - * + * */ //============================================================================= @@ -139,7 +140,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) { MESSAGE("SMESH_Gen::Compute"); // bool isDone = false; - /* + /* Algo : s'appuie ou non sur une geometrie Si geometrie: Vertex : rien à faire (range le point) @@ -157,11 +158,11 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) bool ret = true; - if ( !CheckAlgoState( aMesh, aShape )) - { - INFOS( "ABORT MESHING: some algos or hypothesis are missing"); - return false; - } +// if ( !CheckAlgoState( aMesh, aShape )) +// { +// INFOS( "ABORT MESHING: some algos or hypothesis are missing"); +// return false; +// } SMESH_subMesh *sm = aMesh.GetSubMesh(aShape); @@ -169,7 +170,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) // apply algos that do not require descretized boundaries, starting // from the most complex shapes // ----------------------------------------------------------------- - + // map containing all subshapes in the order: vertices, edges, faces... const map& smMap = sm->DependsOn(); map::const_reverse_iterator revItSub = smMap.rbegin(); @@ -181,11 +182,14 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) if ( GetShapeDim( aSubShape ) < 1 ) break; SMESH_Algo* algo = GetAlgo( aMesh, aSubShape ); - if (algo && - !algo->NeedDescretBoundary() && - smToCompute->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE ) - { - ret = smToCompute->ComputeStateEngine( SMESH_subMesh::COMPUTE ); + if (algo && !algo->NeedDescretBoundary()) { + if (smToCompute->GetComputeState() == SMESH_subMesh::READY_TO_COMPUTE) { + ret = smToCompute->ComputeStateEngine( SMESH_subMesh::COMPUTE ); + } else if (smToCompute->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE) { + // JFA for PAL6524 + ret = false; + } else { + } } if (!ret) return false; @@ -199,11 +203,11 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) else smToCompute = 0; } - + // ----------------------------------------------- // mesh the rest subshapes starting from vertices // ----------------------------------------------- - + smToCompute = sm->GetFirstToCompute(); while (smToCompute) { @@ -211,38 +215,42 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) int dim = GetShapeDim(subShape); if (dim > 0) { - //MESSAGE ( "MESH shape id=" << smToCompute->GetId() << - // " type=" << smToCompute->GetSubShape().ShapeType()); - bool ret1 = smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE); - ret = ret && ret1; + if ( !smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE) ) + ret = false; } else { - ASSERT(dim == 0); - ASSERT(smToCompute->_vertexSet == false); TopoDS_Vertex V1 = TopoDS::Vertex(subShape); gp_Pnt P1 = BRep_Tool::Pnt(V1); SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); - //MESSAGE("point "<AddNode(P1.X(), P1.Y(), P1.Z()); if ( node ) { // san - increase robustness meshDS->SetNodeOnVertex(node, V1); - smToCompute->GetSubMeshDS(); - smToCompute->_vertexSet = true; smToCompute->ComputeStateEngine(SMESH_subMesh::COMPUTE); } } smToCompute = sm->GetFirstToCompute(); } + if (!ret) return false; + + // JFA for PAL6524: if there are failed sub-meshes, return Standard_False + const map < int, SMESH_subMesh * >&subMeshes = sm->DependsOn(); + map < int, SMESH_subMesh * >::const_iterator itsub; + for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++) { + SMESH_subMesh *smi = (*itsub).second; + if (smi->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE) return false; + } + if (sm->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE) return false; + MESSAGE( "VSR - SMESH_Gen::Compute() finished" ); - return ret; + return true; } //======================================================================= //function : checkConformIgnoredAlgos -//purpose : +//purpose : //======================================================================= static bool checkConformIgnoredAlgos(SMESH_Mesh& aMesh, @@ -270,7 +278,7 @@ static bool checkConformIgnoredAlgos(SMESH_Mesh& aMesh, const SMESH_Algo* algo = dynamic_cast (aHyp); ASSERT ( algo ); - + if ( aLocIgnoAlgo ) // algo is hidden by a local algo of upper dim { INFOS( "Local <" << algo->GetName() << "> is hidden by local <" @@ -285,7 +293,7 @@ static bool checkConformIgnoredAlgos(SMESH_Mesh& aMesh, if ( dim < aMaxGlobIgnoDim ) { // algo is hidden by a global algo - INFOS( ( isGlobal ? "Global" : "Local" ) + INFOS( ( isGlobal ? "Global" : "Local" ) << " <" << algo->GetName() << "> is hidden by global <" << aGlobIgnoAlgo->GetName() << ">"); } @@ -319,7 +327,7 @@ static bool checkConformIgnoredAlgos(SMESH_Mesh& aMesh, } } } - + return ret; } @@ -339,7 +347,7 @@ static bool checkMissing(SMESH_Gen* aGen, { if ( aSubMesh->GetSubShape().ShapeType() == TopAbs_VERTEX) return true; - + //MESSAGE("=====checkMissing"); int ret = true; @@ -433,11 +441,11 @@ bool SMESH_Gen::CheckAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) SMESH_subMesh* sm = aMesh.GetSubMesh(aShape); const SMESHDS_Mesh* meshDS = aMesh.GetMeshDS(); TopoDS_Shape mainShape = meshDS->ShapeToMesh(); - + // ----------------- // get global algos // ----------------- - + const SMESH_Algo* aGlobAlgoArr[] = {0,0,0,0}; const list& listHyp = meshDS->GetHypothesis( mainShape ); @@ -450,13 +458,13 @@ bool SMESH_Gen::CheckAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) const SMESH_Algo* algo = dynamic_cast (aHyp); ASSERT ( algo ); - + int dim = algo->GetDim(); aGlobAlgoArr[ dim ] = algo; hasAlgo = true; } - + // -------------------------------------------------------- // info on algos that will be ignored because of ones that // don't NeedDescretBoundary() attached to super-shapes, @@ -518,7 +526,7 @@ bool SMESH_Gen::CheckAlgoState(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape) // ---------------------------------------------------------------- //MESSAGE( "---info on missing hypothesis and find out if all needed algos are"); - + // find max dim of global algo int aTopAlgoDim = 0; for (dim = 3; dim > 0; dim--) @@ -596,10 +604,10 @@ static int getAlgo(const list& theHypList, const int theAlgoShapeType) { list::const_iterator it = theHypList.begin(); - + int nb_algo = 0; int algo_id = -1; - + while (it!=theHypList.end()) { const SMESH_Hypothesis *anHyp = static_cast< const SMESH_Hypothesis *>( *it ); @@ -611,7 +619,7 @@ static int getAlgo(const list& theHypList, algo_id = anHyp->GetID(); break; } - + //if (nb_algo > 1) return -1; // more than one algo it++; } @@ -621,7 +629,7 @@ static int getAlgo(const list& theHypList, //============================================================================= /*! - * + * */ //============================================================================= @@ -653,7 +661,7 @@ SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) ASSERT(_mapAlgo.find(algo_id) != _mapAlgo.end()); return _mapAlgo[algo_id]; - + // const SMESHDS_Hypothesis *theHyp = NULL; // SMESH_Algo *algo = NULL; // const SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); @@ -673,7 +681,7 @@ SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) // const list& listHyp = // meshDS->GetHypothesis(tryShape); // list::const_iterator it=listHyp.begin(); - + // int nb_algo = 0; // int shapeDim = GetShapeDim(aShape); // int typeOfShape = aShape.ShapeType(); @@ -738,7 +746,7 @@ SMESH_Algo *SMESH_Gen::GetAlgo(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) //============================================================================= /*! - * + * */ //============================================================================= @@ -758,7 +766,7 @@ StudyContextStruct *SMESH_Gen::GetStudyContext(int studyId) //============================================================================= /*! - * + * */ //============================================================================= @@ -768,7 +776,7 @@ void SMESH_Gen::Save(int studyId, const char *aUrlOfFile) //============================================================================= /*! - * + * */ //============================================================================= @@ -778,7 +786,7 @@ void SMESH_Gen::Load(int studyId, const char *aUrlOfFile) //============================================================================= /*! - * + * */ //============================================================================= @@ -788,38 +796,7 @@ void SMESH_Gen::Close(int studyId) //============================================================================= /*! - * - */ -//============================================================================= - -const char *SMESH_Gen::ComponentDataType() -{ -} - -//============================================================================= -/*! - * - */ -//============================================================================= - -const char *SMESH_Gen::IORToLocalPersistentID(const char *IORString, - bool & IsAFile) -{ -} - -//============================================================================= -/*! - * - */ -//============================================================================= - -const char *SMESH_Gen::LocalPersistentIDToIOR(const char *aLocalPersistentID) -{ -} - -//============================================================================= -/*! - * + * */ //============================================================================= diff --git a/src/SMESH/SMESH_Gen.hxx b/src/SMESH/SMESH_Gen.hxx index 3a01de04c..77b3cfc23 100644 --- a/src/SMESH/SMESH_Gen.hxx +++ b/src/SMESH/SMESH_Gen.hxx @@ -43,12 +43,12 @@ #include #include -using namespace std; + typedef struct studyContextStruct { - map < int, SMESH_Hypothesis * >mapHypothesis; - map < int, SMESH_Mesh * >mapMesh; + std::map < int, SMESH_Hypothesis * >mapHypothesis; + std::map < int, SMESH_Mesh * >mapMesh; SMESHDS_Document * myDocument; } StudyContextStruct; @@ -89,15 +89,15 @@ class SMESH_Gen int GetANewId(); - map < int, SMESH_Algo * >_mapAlgo; - map < int, SMESH_1D_Algo * >_map1D_Algo; - map < int, SMESH_2D_Algo * >_map2D_Algo; - map < int, SMESH_3D_Algo * >_map3D_Algo; + std::map < int, SMESH_Algo * >_mapAlgo; + std::map < int, SMESH_1D_Algo * >_map1D_Algo; + std::map < int, SMESH_2D_Algo * >_map2D_Algo; + std::map < int, SMESH_3D_Algo * >_map3D_Algo; private: int _localId; // unique Id of created objects, within SMESH_Gen entity - map < int, StudyContextStruct * >_mapStudyContext; + std::map < int, StudyContextStruct * >_mapStudyContext; // hypotheses managing int _hypId; diff --git a/src/SMESH/SMESH_Group.cxx b/src/SMESH/SMESH_Group.cxx index da29a2989..49cade122 100644 --- a/src/SMESH/SMESH_Group.cxx +++ b/src/SMESH/SMESH_Group.cxx @@ -25,9 +25,10 @@ // Module : SMESH // $Header$ -#include -#include -#include +#include "SMESH_Group.hxx" +#include "SMESH_Mesh.hxx" +#include "SMESHDS_Group.hxx" +#include "SMESHDS_GroupOnGeom.hxx" //============================================================================= /*! @@ -35,12 +36,22 @@ */ //============================================================================= -SMESH_Group::SMESH_Group (const SMESH_Mesh* theMesh, +SMESH_Group::SMESH_Group (int theID, + const SMESH_Mesh* theMesh, const SMDSAbs_ElementType theType, - const char* theName) + const char* theName, + const TopoDS_Shape& theShape) : myName(theName) { - myGroupDS = new SMESHDS_Group (const_cast(theMesh)->GetMeshDS(), theType); + if ( theShape.IsNull() ) + myGroupDS = new SMESHDS_Group (theID, + const_cast(theMesh)->GetMeshDS(), + theType); + else + myGroupDS = new SMESHDS_GroupOnGeom (theID, + const_cast(theMesh)->GetMeshDS(), + theType, + theShape); } //============================================================================= diff --git a/src/SMESH/SMESH_Group.hxx b/src/SMESH/SMESH_Group.hxx index 5147a44d7..26493e4e0 100644 --- a/src/SMESH/SMESH_Group.hxx +++ b/src/SMESH/SMESH_Group.hxx @@ -30,25 +30,28 @@ #include #include -using namespace std; +#include -class SMESHDS_Group; + +class SMESHDS_GroupBase; class SMESH_Mesh; class SMESH_Group { public: - SMESH_Group (const SMESH_Mesh* theMesh, + SMESH_Group (int theID, + const SMESH_Mesh* theMesh, const SMDSAbs_ElementType theType, - const char* theName); + const char* theName, + const TopoDS_Shape& theShape = TopoDS_Shape()); ~SMESH_Group (); void SetName (const char* theName) { myName = theName; } const char* GetName () const { return myName.c_str(); } - SMESHDS_Group * GetGroupDS () { return myGroupDS; } + SMESHDS_GroupBase * GetGroupDS () { return myGroupDS; } private: SMESH_Group (const SMESH_Group& theOther); @@ -56,8 +59,8 @@ class SMESH_Group SMESH_Group& operator = (const SMESH_Group& theOther); // prohibited assign operator - SMESHDS_Group * myGroupDS; - string myName; + SMESHDS_GroupBase * myGroupDS; + std::string myName; }; diff --git a/src/SMESH/SMESH_Hypothesis.hxx b/src/SMESH/SMESH_Hypothesis.hxx index 9fcea7b25..1d881a680 100644 --- a/src/SMESH/SMESH_Hypothesis.hxx +++ b/src/SMESH/SMESH_Hypothesis.hxx @@ -68,7 +68,7 @@ protected: int _param_algo_dim; private: - string _libName; + std::string _libName; }; #endif diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index 6d03700c7..50c793296 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -37,12 +37,14 @@ #include "utilities.h" -#include "Mesh_Writer.h" #include "DriverMED_W_SMESHDS_Mesh.h" -#include "DriverDAT_W_SMESHDS_Mesh.h" -#include "DriverUNV_W_SMESHDS_Mesh.h" +#include "DriverDAT_W_SMDS_Mesh.h" +#include "DriverUNV_W_SMDS_Mesh.h" +#include "DriverSTL_W_SMDS_Mesh.h" #include "DriverMED_R_SMESHDS_Mesh.h" +#include "DriverUNV_R_SMDS_Mesh.h" +#include "DriverSTL_R_SMDS_Mesh.h" #include #include @@ -51,19 +53,12 @@ #include #include "Utils_ExceptHandlers.hxx" +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif -//============================================================================= -/*! - * - */ -//============================================================================= - -SMESH_Mesh::SMESH_Mesh() -{ - MESSAGE("SMESH_Mesh::SMESH_Mesh"); - _id = -1; - ASSERT(0); -} //============================================================================= /*! @@ -74,7 +69,7 @@ SMESH_Mesh::SMESH_Mesh() SMESH_Mesh::SMESH_Mesh(int localId, int studyId, SMESH_Gen * gen, SMESHDS_Document * myDocument) : _groupId( 0 ) { - MESSAGE("SMESH_Mesh::SMESH_Mesh(int localId)"); + INFOS("SMESH_Mesh::SMESH_Mesh(int localId)"); _id = localId; _studyId = studyId; _gen = gen; @@ -92,7 +87,7 @@ SMESH_Mesh::SMESH_Mesh(int localId, int studyId, SMESH_Gen * gen, SMESHDS_Docume SMESH_Mesh::~SMESH_Mesh() { - MESSAGE("SMESH_Mesh::~SMESH_Mesh"); + INFOS("SMESH_Mesh::~SMESH_Mesh"); // delete groups map < int, SMESH_Group * >::iterator itg; @@ -109,16 +104,41 @@ SMESH_Mesh::~SMESH_Mesh() //============================================================================= void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape){ - MESSAGE("SMESH_Mesh::ShapeToMesh"); - if (_isShapeToMesh) - throw - SALOME_Exception(LOCALIZED - ("a shape to mesh as already been defined")); - _isShapeToMesh = true; - _myMeshDS->ShapeToMesh(aShape); + if(MYDEBUG) MESSAGE("SMESH_Mesh::ShapeToMesh"); + if (_isShapeToMesh) + throw + SALOME_Exception(LOCALIZED + ("a shape to mesh as already been defined")); + _isShapeToMesh = true; + _myMeshDS->ShapeToMesh(aShape); + + // NRI : 24/02/03 + //EAP: 1/9/04 TopExp::MapShapes(aShape, _subShapes); USE the same map of _myMeshDS +} - // NRI : 24/02/03 - TopExp::MapShapes(aShape, _subShapes); +//======================================================================= +//function : UNVToMesh +//purpose : +//======================================================================= + +int SMESH_Mesh::UNVToMesh(const char* theFileName) +{ + if(MYDEBUG) MESSAGE("UNVToMesh - theFileName = "<NbNodes() = "<<_myMeshDS->NbNodes()); + MESSAGE("MEDToMesh - _myMeshDS->NbEdges() = "<<_myMeshDS->NbEdges()); + MESSAGE("MEDToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces()); + MESSAGE("MEDToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes()); + } + return 1; } //======================================================================= @@ -128,37 +148,66 @@ void SMESH_Mesh::ShapeToMesh(const TopoDS_Shape & aShape){ int SMESH_Mesh::MEDToMesh(const char* theFileName, const char* theMeshName) { - MESSAGE("MEDToMesh - theFileName = "< myReader(new DriverMED_R_SMESHDS_Mesh); - myReader->SetMesh(_myMeshDS); - myReader->SetMeshId(-1); - myReader->SetFile(theFileName); - myReader->SetMeshName(theMeshName); - DriverMED_R_SMESHDS_Mesh::ReadStatus status = myReader->ReadMySelf(); - MESSAGE("MEDToMesh - _myMeshDS->NbNodes() = "<<_myMeshDS->NbNodes()); - MESSAGE("MEDToMesh - _myMeshDS->NbEdges() = "<<_myMeshDS->NbEdges()); - MESSAGE("MEDToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces()); - MESSAGE("MEDToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes()); + DriverMED_R_SMESHDS_Mesh myReader; + myReader.SetMesh(_myMeshDS); + myReader.SetMeshId(-1); + myReader.SetFile(theFileName); + myReader.SetMeshName(theMeshName); + Driver_Mesh::Status status = myReader.Perform(); + if(MYDEBUG){ + MESSAGE("MEDToMesh - _myMeshDS->NbNodes() = "<<_myMeshDS->NbNodes()); + MESSAGE("MEDToMesh - _myMeshDS->NbEdges() = "<<_myMeshDS->NbEdges()); + MESSAGE("MEDToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces()); + MESSAGE("MEDToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes()); + } // Reading groups (sub-meshes are out of scope of MED import functionality) - list aGroupNames = myReader->GetGroupNames(); - MESSAGE("MEDToMesh - Nb groups = "< aGroupNames = myReader.GetGroupNames(); + if(MYDEBUG) MESSAGE("MEDToMesh - Nb groups = "<::iterator it = aGroupNames.begin(); it != aGroupNames.end(); it++ ) { SMESH_Group* aGroup = AddGroup( SMDSAbs_All, it->c_str(), anId ); if ( aGroup ) { - MESSAGE("MEDToMesh - group added: "<c_str()); - SMESHDS_Group* aGroupDS = aGroup->GetGroupDS(); - aGroupDS->SetStoreName( it->c_str() ); - myReader->GetGroup( aGroupDS ); + if(MYDEBUG) MESSAGE("MEDToMesh - group added: "<c_str()); + SMESHDS_Group* aGroupDS = dynamic_cast( aGroup->GetGroupDS() ); + if ( aGroupDS ) { + aGroupDS->SetStoreName( it->c_str() ); + myReader.GetGroup( aGroupDS ); + } } } return (int) status; } +//======================================================================= +//function : STLToMesh +//purpose : +//======================================================================= + +int SMESH_Mesh::STLToMesh(const char* theFileName) +{ + if(MYDEBUG) MESSAGE("UNVToMesh - theFileName = "<NbNodes() = "<<_myMeshDS->NbNodes()); + MESSAGE("MEDToMesh - _myMeshDS->NbEdges() = "<<_myMeshDS->NbEdges()); + MESSAGE("MEDToMesh - _myMeshDS->NbFaces() = "<<_myMeshDS->NbFaces()); + MESSAGE("MEDToMesh - _myMeshDS->NbVolumes() = "<<_myMeshDS->NbVolumes()); + } + return 1; +} + //============================================================================= /*! * @@ -167,23 +216,45 @@ int SMESH_Mesh::MEDToMesh(const char* theFileName, const char* theMeshName) SMESH_Hypothesis::Hypothesis_Status SMESH_Mesh::AddHypothesis(const TopoDS_Shape & aSubShape, - int anHypId) throw(SALOME_Exception) + int anHypId ) throw(SALOME_Exception) { Unexpect aCatch(SalomeException); - MESSAGE("SMESH_Mesh::AddHypothesis"); + if(MYDEBUG) MESSAGE("SMESH_Mesh::AddHypothesis"); + + SMESH_subMesh *subMesh = GetSubMesh(aSubShape); + SMESHDS_SubMesh *subMeshDS = subMesh->GetSubMeshDS(); + if ( subMeshDS && subMeshDS->IsComplexSubmesh() ) + { + // return the worst but not fatal state of all group memebers + SMESH_Hypothesis::Hypothesis_Status aBestRet, aWorstNotFatal, ret; + aBestRet = SMESH_Hypothesis::HYP_BAD_DIM; + aWorstNotFatal = SMESH_Hypothesis::HYP_OK; + for ( TopoDS_Iterator itS ( aSubShape ); itS.More(); itS.Next()) + { + ret = AddHypothesis( itS.Value(), anHypId ); + if ( !SMESH_Hypothesis::IsStatusFatal( ret ) && ret > aWorstNotFatal ) + aWorstNotFatal = ret; + if ( ret < aBestRet ) + aBestRet = ret; + } + if ( SMESH_Hypothesis::IsStatusFatal( aBestRet )) + return aBestRet; + return aWorstNotFatal; + } StudyContextStruct *sc = _gen->GetStudyContext(_studyId); if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end()) { - MESSAGE("Hypothesis ID does not give an hypothesis"); - SCRUTE(_studyId); - SCRUTE(anHypId); + if(MYDEBUG) MESSAGE("Hypothesis ID does not give an hypothesis"); + if(MYDEBUG) { + SCRUTE(_studyId); + SCRUTE(anHypId); + } throw SALOME_Exception(LOCALIZED("hypothesis does not exist")); } - SMESH_subMesh *subMesh = GetSubMesh(aSubShape); SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId]; - SCRUTE( anHyp->GetName() ); + if(MYDEBUG) SCRUTE( anHyp->GetName() ); int event; bool isGlobalHyp = IsMainShape( aSubShape ); @@ -194,7 +265,7 @@ SMESH_Hypothesis::Hypothesis_Status string hypName = anHyp->GetName(); if ( hypName == "NotConformAllowed" ) { - MESSAGE( "Hypotesis can be only global" ); + if(MYDEBUG) MESSAGE( "Hypotesis can be only global" ); return SMESH_Hypothesis::HYP_INCOMPATIBLE; } } @@ -222,7 +293,7 @@ SMESH_Hypothesis::Hypothesis_Status } subMesh->DumpAlgoState(true); - SCRUTE(ret); + if(MYDEBUG) SCRUTE(ret); return ret; } @@ -237,43 +308,63 @@ SMESH_Hypothesis::Hypothesis_Status int anHypId)throw(SALOME_Exception) { Unexpect aCatch(SalomeException); - MESSAGE("SMESH_Mesh::RemoveHypothesis"); - - StudyContextStruct *sc = _gen->GetStudyContext(_studyId); - if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end()) - throw SALOME_Exception(LOCALIZED("hypothesis does not exist")); - - SMESH_subMesh *subMesh = GetSubMesh(aSubShape); - SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId]; - int hypType = anHyp->GetType(); - SCRUTE(hypType); - int event; - - // shape - - if (anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO) - event = SMESH_subMesh::REMOVE_HYP; - else - event = SMESH_subMesh::REMOVE_ALGO; - SMESH_Hypothesis::Hypothesis_Status ret = subMesh->AlgoStateEngine(event, anHyp); - - // subShapes - if (!SMESH_Hypothesis::IsStatusFatal(ret) && - !subMesh->IsApplicableHypotesis( anHyp )) // is removed from father - { - if (anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO) - event = SMESH_subMesh::REMOVE_FATHER_HYP; - else - event = SMESH_subMesh::REMOVE_FATHER_ALGO; - SMESH_Hypothesis::Hypothesis_Status ret2 = - subMesh->SubMeshesAlgoStateEngine(event, anHyp); - if (ret2 > ret) // more severe - ret = ret2; - } + if(MYDEBUG) MESSAGE("SMESH_Mesh::RemoveHypothesis"); + + SMESH_subMesh *subMesh = GetSubMesh(aSubShape); + SMESHDS_SubMesh *subMeshDS = subMesh->GetSubMeshDS(); + if ( subMeshDS && subMeshDS->IsComplexSubmesh() ) + { + // return the worst but not fatal state of all group memebers + SMESH_Hypothesis::Hypothesis_Status aBestRet, aWorstNotFatal, ret; + aBestRet = SMESH_Hypothesis::HYP_BAD_DIM; + aWorstNotFatal = SMESH_Hypothesis::HYP_OK; + for ( TopoDS_Iterator itS ( aSubShape ); itS.More(); itS.Next()) + { + ret = RemoveHypothesis( itS.Value(), anHypId ); + if ( !SMESH_Hypothesis::IsStatusFatal( ret ) && ret > aWorstNotFatal ) + aWorstNotFatal = ret; + if ( ret < aBestRet ) + aBestRet = ret; + } + if ( SMESH_Hypothesis::IsStatusFatal( aBestRet )) + return aBestRet; + return aWorstNotFatal; + } - subMesh->DumpAlgoState(true); - SCRUTE(ret); - return ret; + StudyContextStruct *sc = _gen->GetStudyContext(_studyId); + if (sc->mapHypothesis.find(anHypId) == sc->mapHypothesis.end()) + throw SALOME_Exception(LOCALIZED("hypothesis does not exist")); + + SMESH_Hypothesis *anHyp = sc->mapHypothesis[anHypId]; + int hypType = anHyp->GetType(); + if(MYDEBUG) SCRUTE(hypType); + int event; + + // shape + + if (anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO) + event = SMESH_subMesh::REMOVE_HYP; + else + event = SMESH_subMesh::REMOVE_ALGO; + SMESH_Hypothesis::Hypothesis_Status ret = subMesh->AlgoStateEngine(event, anHyp); + + // subShapes + if (!SMESH_Hypothesis::IsStatusFatal(ret) && + !subMesh->IsApplicableHypotesis( anHyp )) // is removed from father + { + if (anHyp->GetType() == SMESHDS_Hypothesis::PARAM_ALGO) + event = SMESH_subMesh::REMOVE_FATHER_HYP; + else + event = SMESH_subMesh::REMOVE_FATHER_ALGO; + SMESH_Hypothesis::Hypothesis_Status ret2 = + subMesh->SubMeshesAlgoStateEngine(event, anHyp); + if (ret2 > ret) // more severe + ret = ret2; + } + + subMesh->DumpAlgoState(true); + if(MYDEBUG) SCRUTE(ret); + return ret; } //============================================================================= @@ -284,7 +375,7 @@ SMESH_Hypothesis::Hypothesis_Status SMESHDS_Mesh * SMESH_Mesh::GetMeshDS() { - return _myMeshDS; + return _myMeshDS; } //============================================================================= @@ -294,23 +385,10 @@ SMESHDS_Mesh * SMESH_Mesh::GetMeshDS() //============================================================================= const list& - SMESH_Mesh::GetHypothesisList(const TopoDS_Shape & aSubShape) const - throw(SALOME_Exception) +SMESH_Mesh::GetHypothesisList(const TopoDS_Shape & aSubShape) const + throw(SALOME_Exception) { Unexpect aCatch(SalomeException); -// MESSAGE("SMESH_Mesh::GetHypothesisList"); -// _subShapeHypothesisList.clear(); -// const list& listHyp = -// _myMeshDS->GetHypothesis(aSubShape); - -// list::const_iterator it=listHyp.begin(); -// while (it!=listHyp.end()) -// { -// const SMESHDS_Hypothesis *anHyp = *it; -// _subShapeHypothesisList.push_back(anHyp); -// it++; -// } -// return _subShapeHypothesisList; return _myMeshDS->GetHypothesis(aSubShape); } @@ -323,8 +401,8 @@ const list& const list & SMESH_Mesh::GetLog() throw(SALOME_Exception) { Unexpect aCatch(SalomeException); - MESSAGE("SMESH_Mesh::GetLog"); - return _myMeshDS->GetScript()->GetCommands(); + if(MYDEBUG) MESSAGE("SMESH_Mesh::GetLog"); + return _myMeshDS->GetScript()->GetCommands(); } //============================================================================= @@ -335,8 +413,8 @@ const list & SMESH_Mesh::GetLog() throw(SALOME_Exception) void SMESH_Mesh::ClearLog() throw(SALOME_Exception) { Unexpect aCatch(SalomeException); - MESSAGE("SMESH_Mesh::ClearLog"); - _myMeshDS->GetScript()->Clear(); + if(MYDEBUG) MESSAGE("SMESH_Mesh::ClearLog"); + _myMeshDS->GetScript()->Clear(); } //============================================================================= @@ -347,8 +425,8 @@ void SMESH_Mesh::ClearLog() throw(SALOME_Exception) int SMESH_Mesh::GetId() { - MESSAGE("SMESH_Mesh::GetId"); - return _id; + if(MYDEBUG) MESSAGE("SMESH_Mesh::GetId"); + return _id; } //============================================================================= @@ -359,7 +437,7 @@ int SMESH_Mesh::GetId() SMESH_Gen *SMESH_Mesh::GetGen() { - return _gen; + return _gen; } //============================================================================= @@ -372,38 +450,26 @@ SMESH_subMesh *SMESH_Mesh::GetSubMesh(const TopoDS_Shape & aSubShape) throw(SALOME_Exception) { Unexpect aCatch(SalomeException); - //MESSAGE("SMESH_Mesh::GetSubMesh"); - SMESH_subMesh *aSubMesh; - int index = _subShapes.FindIndex(aSubShape); - - if (_mapSubMesh.find(index) != _mapSubMesh.end()) - { - aSubMesh = _mapSubMesh[index]; - } - else - { - aSubMesh = new SMESH_subMesh(index, this, _myMeshDS, aSubShape); - _mapSubMesh[index] = aSubMesh; - } + SMESH_subMesh *aSubMesh; + int index = _myMeshDS->ShapeToIndex(aSubShape); + + // for submeshes on GEOM Group + if ( !index && aSubShape.ShapeType() == TopAbs_COMPOUND ) { + TopoDS_Iterator it( aSubShape ); + if ( it.More() ) + index = _myMeshDS->AddCompoundSubmesh( aSubShape, it.Value().ShapeType() ); + } - /* NRI 24/02/2003 - * int index = -1; - * if (_subShapes.Contains(aSubShape)) - * { - * index = _subShapes.FindIndex(aSubShape); - * ASSERT(_mapSubMesh.find(index) != _mapSubMesh.end()); - * aSubMesh = _mapSubMesh[index]; - * //MESSAGE("found submesh " << index); - * } - * else - * { - * index = _subShapes.Add(aSubShape); - * aSubMesh = new SMESH_subMesh(index, this, _myMeshDS, aSubShape); - * _mapSubMesh[index] = aSubMesh; - * //MESSAGE("created submesh " << index); - * } - */ - return aSubMesh; + if (_mapSubMesh.find(index) != _mapSubMesh.end()) + { + aSubMesh = _mapSubMesh[index]; + } + else + { + aSubMesh = new SMESH_subMesh(index, this, _myMeshDS, aSubShape); + _mapSubMesh[index] = aSubMesh; + } + return aSubMesh; } //============================================================================= @@ -412,54 +478,23 @@ throw(SALOME_Exception) * if it does not exist. */ //============================================================================= -// -// * Given a subShape, find if there is a subMesh associated to this subShape -// * or to a collection of shapes containing this subShape. Collection = -// * compsolid, shell, wire. -// * -// * WARNING : with arg = compsolid, shell or wire returns always NULL. -// * with a face inside a shell, and submesh created for both, if arg is face, -// * returns first created submesh of the two. -// * subMesh is not created, return may be NULL. SMESH_subMesh *SMESH_Mesh::GetSubMeshContaining(const TopoDS_Shape & aSubShape) throw(SALOME_Exception) { Unexpect aCatch(SalomeException); - //MESSAGE("SMESH_Mesh::GetSubMeshContaining"); - bool isFound = false; - SMESH_subMesh *aSubMesh = NULL; - - int index = _subShapes.FindIndex(aSubShape); - if (_mapSubMesh.find(index) != _mapSubMesh.end()) - { - aSubMesh = _mapSubMesh[index]; - isFound = true; - } - - /* NRI 24/02/2003 - * int index = -1; - * if (_subShapes.Contains(aSubShape)) - * { - * index = _subShapes.FindIndex(aSubShape); - * ASSERT(_mapSubMesh.find(index) != _mapSubMesh.end()); - * aSubMesh = _mapSubMesh[index]; - * isFound = true; - * //MESSAGE("found submesh " << index); - * } - */ - -// map::iterator itsm; -// for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++) -// { -// aSubMesh = (*itsm).second; -// isFound = aSubMesh->Contains(aSubShape); -// if (isFound) break; -// } - - if (!isFound) - aSubMesh = NULL; - return aSubMesh; + bool isFound = false; + SMESH_subMesh *aSubMesh = NULL; + + int index = _myMeshDS->ShapeToIndex(aSubShape); + if (_mapSubMesh.find(index) != _mapSubMesh.end()) + { + aSubMesh = _mapSubMesh[index]; + isFound = true; + } + if (!isFound) + aSubMesh = NULL; + return aSubMesh; } //======================================================================= @@ -470,8 +505,6 @@ throw(SALOME_Exception) bool SMESH_Mesh::IsUsedHypothesis(SMESHDS_Hypothesis * anHyp, const TopoDS_Shape & aSubShape) { - //MESSAGE( "SMESH_Mesh::IsUsedHypothesis" ); - // check if anHyp is applicable to aSubShape SMESH_subMesh * subMesh = GetSubMeshContaining( aSubShape ); if (!subMesh || @@ -535,7 +568,7 @@ const list < SMESH_subMesh * >& throw(SALOME_Exception) { Unexpect aCatch(SalomeException); - MESSAGE("SMESH_Mesh::GetSubMeshUsingHypothesis"); + if(MYDEBUG) MESSAGE("SMESH_Mesh::GetSubMeshUsingHypothesis"); map < int, SMESH_subMesh * >::iterator itsm; _subMeshesUsingHypothesisList.clear(); for (itsm = _mapSubMesh.begin(); itsm != _mapSubMesh.end(); itsm++) @@ -556,51 +589,64 @@ throw(SALOME_Exception) void SMESH_Mesh::ExportMED(const char *file, const char* theMeshName, bool theAutoGroups) throw(SALOME_Exception) { Unexpect aCatch(SalomeException); - std::auto_ptr myWriter(new DriverMED_W_SMESHDS_Mesh); - myWriter ->SetFile ( file ); - myWriter ->SetMesh ( _myMeshDS ); + DriverMED_W_SMESHDS_Mesh myWriter; + myWriter.SetFile ( file ); + myWriter.SetMesh ( _myMeshDS ); if ( !theMeshName ) - myWriter->SetMeshId ( _idDoc ); + myWriter.SetMeshId ( _idDoc ); else { - myWriter->SetMeshId ( -1 ); - myWriter->SetMeshName( theMeshName ); + myWriter.SetMeshId ( -1 ); + myWriter.SetMeshName( theMeshName ); } if ( theAutoGroups ) { - myWriter->AddGroupOfNodes(); - myWriter->AddGroupOfEdges(); - myWriter->AddGroupOfFaces(); - myWriter->AddGroupOfVolumes(); + myWriter.AddGroupOfNodes(); + myWriter.AddGroupOfEdges(); + myWriter.AddGroupOfFaces(); + myWriter.AddGroupOfVolumes(); } for ( map::iterator it = _mapGroup.begin(); it != _mapGroup.end(); it++ ) { - SMESH_Group* aGroup = it->second; - SMESHDS_Group* aGroupDS = aGroup->GetGroupDS(); - aGroupDS->SetStoreName( aGroup->GetName() ); - myWriter->AddGroup( aGroupDS ); + SMESH_Group* aGroup = it->second; + SMESHDS_GroupBase* aGroupDS = aGroup->GetGroupDS(); + if ( aGroupDS ) { + aGroupDS->SetStoreName( aGroup->GetName() ); + myWriter.AddGroup( aGroupDS ); + } } - myWriter->Add(); + myWriter.Perform(); } void SMESH_Mesh::ExportDAT(const char *file) throw(SALOME_Exception) { Unexpect aCatch(SalomeException); - Mesh_Writer *myWriter = new DriverDAT_W_SMESHDS_Mesh; - myWriter->SetFile(string(file)); - myWriter->SetMesh(_myMeshDS); - myWriter->SetMeshId(_idDoc); - myWriter->Add(); + DriverDAT_W_SMDS_Mesh myWriter; + myWriter.SetFile(string(file)); + myWriter.SetMesh(_myMeshDS); + myWriter.SetMeshId(_idDoc); + myWriter.Perform(); } void SMESH_Mesh::ExportUNV(const char *file) throw(SALOME_Exception) { Unexpect aCatch(SalomeException); - Mesh_Writer *myWriter = new DriverUNV_W_SMESHDS_Mesh; - myWriter->SetFile(string(file)); - myWriter->SetMesh(_myMeshDS); - myWriter->SetMeshId(_idDoc); - myWriter->Add(); + DriverUNV_W_SMDS_Mesh myWriter; + myWriter.SetFile(string(file)); + myWriter.SetMesh(_myMeshDS); + myWriter.SetMeshId(_idDoc); + myWriter.Perform(); +} + +void SMESH_Mesh::ExportSTL(const char *file, const bool isascii) throw(SALOME_Exception) +{ + Unexpect aCatch(SalomeException); + DriverSTL_W_SMDS_Mesh myWriter; + myWriter.SetFile(string(file)); + myWriter.SetIsAscii( isascii ); + myWriter.SetMesh(_myMeshDS); + myWriter.SetMeshId(_idDoc); + myWriter.Perform(); } //============================================================================= @@ -611,7 +657,7 @@ void SMESH_Mesh::ExportUNV(const char *file) throw(SALOME_Exception) int SMESH_Mesh::NbNodes() throw(SALOME_Exception) { Unexpect aCatch(SalomeException); - return _myMeshDS->NbNodes(); + return _myMeshDS->NbNodes(); } //============================================================================= @@ -622,7 +668,7 @@ int SMESH_Mesh::NbNodes() throw(SALOME_Exception) int SMESH_Mesh::NbEdges() throw(SALOME_Exception) { Unexpect aCatch(SalomeException); - return _myMeshDS->NbEdges(); + return _myMeshDS->NbEdges(); } //============================================================================= @@ -633,7 +679,7 @@ int SMESH_Mesh::NbEdges() throw(SALOME_Exception) int SMESH_Mesh::NbFaces() throw(SALOME_Exception) { Unexpect aCatch(SalomeException); - return _myMeshDS->NbFaces(); + return _myMeshDS->NbFaces(); } /////////////////////////////////////////////////////////////////////////////// @@ -642,11 +688,11 @@ int SMESH_Mesh::NbFaces() throw(SALOME_Exception) int SMESH_Mesh::NbTriangles() throw(SALOME_Exception) { Unexpect aCatch(SalomeException); - int Nb = 0; - - SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator(); - while(itFaces->more()) if(itFaces->next()->NbNodes()==3) Nb++; - return Nb; + int Nb = 0; + + SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator(); + while(itFaces->more()) if(itFaces->next()->NbNodes()==3) Nb++; + return Nb; } /////////////////////////////////////////////////////////////////////////////// @@ -655,11 +701,11 @@ int SMESH_Mesh::NbTriangles() throw(SALOME_Exception) int SMESH_Mesh::NbQuadrangles() throw(SALOME_Exception) { Unexpect aCatch(SalomeException); - int Nb = 0; - - SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator(); - while(itFaces->more()) if(itFaces->next()->NbNodes()==4) Nb++; - return Nb; + int Nb = 0; + + SMDS_FaceIteratorPtr itFaces=_myMeshDS->facesIterator(); + while(itFaces->more()) if(itFaces->next()->NbNodes()==4) Nb++; + return Nb; } //============================================================================= @@ -670,43 +716,43 @@ int SMESH_Mesh::NbQuadrangles() throw(SALOME_Exception) int SMESH_Mesh::NbVolumes() throw(SALOME_Exception) { Unexpect aCatch(SalomeException); - return _myMeshDS->NbVolumes(); + return _myMeshDS->NbVolumes(); } int SMESH_Mesh::NbTetras() throw(SALOME_Exception) { Unexpect aCatch(SalomeException); - int Nb = 0; - SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator(); - while(itVolumes->more()) if(itVolumes->next()->NbNodes()==4) Nb++; - return Nb; + int Nb = 0; + SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator(); + while(itVolumes->more()) if(itVolumes->next()->NbNodes()==4) Nb++; + return Nb; } int SMESH_Mesh::NbHexas() throw(SALOME_Exception) { Unexpect aCatch(SalomeException); - int Nb = 0; - SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator(); - while(itVolumes->more()) if(itVolumes->next()->NbNodes()==8) Nb++; - return Nb; + int Nb = 0; + SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator(); + while(itVolumes->more()) if(itVolumes->next()->NbNodes()==8) Nb++; + return Nb; } int SMESH_Mesh::NbPyramids() throw(SALOME_Exception) { Unexpect aCatch(SalomeException); - int Nb = 0; - SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator(); - while(itVolumes->more()) if(itVolumes->next()->NbNodes()==5) Nb++; - return Nb; + int Nb = 0; + SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator(); + while(itVolumes->more()) if(itVolumes->next()->NbNodes()==5) Nb++; + return Nb; } int SMESH_Mesh::NbPrisms() throw(SALOME_Exception) { Unexpect aCatch(SalomeException); - int Nb = 0; - SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator(); - while(itVolumes->more()) if(itVolumes->next()->NbNodes()==6) Nb++; - return Nb; + int Nb = 0; + SMDS_VolumeIteratorPtr itVolumes=_myMeshDS->volumesIterator(); + while(itVolumes->more()) if(itVolumes->next()->NbNodes()==6) Nb++; + return Nb; } //============================================================================= @@ -717,7 +763,7 @@ int SMESH_Mesh::NbPrisms() throw(SALOME_Exception) int SMESH_Mesh::NbSubMesh() throw(SALOME_Exception) { Unexpect aCatch(SalomeException); - return _myMeshDS->NbSubMesh(); + return _myMeshDS->NbSubMesh(); } //======================================================================= @@ -727,7 +773,7 @@ int SMESH_Mesh::NbSubMesh() throw(SALOME_Exception) bool SMESH_Mesh::IsNotConformAllowed() const { - MESSAGE("SMESH_Mesh::IsNotConformAllowed"); + if(MYDEBUG) MESSAGE("SMESH_Mesh::IsNotConformAllowed"); const list& listHyp = _myMeshDS->GetHypothesis( _myMeshDS->ShapeToMesh() ); @@ -761,12 +807,14 @@ bool SMESH_Mesh::IsMainShape(const TopoDS_Shape& theShape) const SMESH_Group* SMESH_Mesh::AddGroup (const SMDSAbs_ElementType theType, const char* theName, - int& theId) + int& theId, + const TopoDS_Shape& theShape) { if (_mapGroup.find(_groupId) != _mapGroup.end()) return NULL; - SMESH_Group* aGroup = new SMESH_Group (this, theType, theName); theId = _groupId; + SMESH_Group* aGroup = new SMESH_Group (theId, this, theType, theName, theShape); + GetMeshDS()->AddGroup( aGroup->GetGroupDS() ); _mapGroup[_groupId++] = aGroup; return aGroup; } @@ -811,8 +859,9 @@ void SMESH_Mesh::RemoveGroup (const int theGroupID) { if (_mapGroup.find(theGroupID) == _mapGroup.end()) return; - delete _mapGroup[theGroupID]; + GetMeshDS()->RemoveGroup( _mapGroup[theGroupID]->GetGroupDS() ); _mapGroup.erase (theGroupID); + delete _mapGroup[theGroupID]; } //======================================================================= diff --git a/src/SMESH/SMESH_Mesh.hxx b/src/SMESH/SMESH_Mesh.hxx index 2f77fa2e5..d594b7115 100644 --- a/src/SMESH/SMESH_Mesh.hxx +++ b/src/SMESH/SMESH_Mesh.hxx @@ -34,8 +34,7 @@ #include "SMESHDS_Command.hxx" #include "SMESH_Hypothesis.hxx" #include "SMESH_subMesh.hxx" -#include -#include "Utils_SALOME_Exception.hxx" +#include "SMDSAbs_ElementType.hxx" #include #include @@ -57,15 +56,8 @@ #include #include -#if (__GNUC__>2) #include -#include -#include -#else -#include -#include -#include -#endif +#include class SMESH_Gen; class SMESH_Group; @@ -73,124 +65,127 @@ class TopTools_ListOfShape; class SMESH_Mesh { - public: - SMESH_Mesh(); - SMESH_Mesh(int localId, int studyId, SMESH_Gen * gen, - SMESHDS_Document * myDocument); - - virtual ~SMESH_Mesh(); - - void ShapeToMesh(const TopoDS_Shape & aShape); - /*! - * consult DriverMED_R_SMESHDS_Mesh::ReadStatus for returned value - */ - int MEDToMesh(const char* theFileName, const char* theMeshName); - - SMESH_Hypothesis::Hypothesis_Status - AddHypothesis(const TopoDS_Shape & aSubShape, int anHypId) - throw(SALOME_Exception); - - SMESH_Hypothesis::Hypothesis_Status - RemoveHypothesis(const TopoDS_Shape & aSubShape, int anHypId) - throw(SALOME_Exception); - - const list & - GetHypothesisList(const TopoDS_Shape & aSubShape) const - throw(SALOME_Exception); - - const list & GetLog() throw(SALOME_Exception); - -// const SMESHDS_ListOfAsciiString& GetLog() -// throw (SALOME_Exception); - - void ClearLog() throw(SALOME_Exception); - - int GetId(); - - SMESHDS_Mesh * GetMeshDS(); - - SMESH_Gen *GetGen(); - - SMESH_subMesh *GetSubMesh(const TopoDS_Shape & aSubShape) - throw(SALOME_Exception); - - SMESH_subMesh *GetSubMeshContaining(const TopoDS_Shape & aSubShape) - throw(SALOME_Exception); - - const list < SMESH_subMesh * >& - GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp) - throw(SALOME_Exception); - - bool IsUsedHypothesis(SMESHDS_Hypothesis * anHyp, - const TopoDS_Shape & aSubShape); - // Return True if anHyp is used to mesh aSubShape - - bool IsNotConformAllowed() const; - // check if a hypothesis alowing notconform mesh is present - - bool IsMainShape(const TopoDS_Shape& theShape) const; - - const TopTools_ListOfShape& GetAncestors(const TopoDS_Shape& theSubShape); - // return list of ancestors of theSubShape in the order - // that lower dimention shapes come first. - - void ExportDAT(const char *file) throw(SALOME_Exception); - void ExportMED(const char *file, const char* theMeshName = NULL, bool theAutoGroups = true) throw(SALOME_Exception); - void ExportUNV(const char *file) throw(SALOME_Exception); - - int NbNodes() throw(SALOME_Exception); - - int NbEdges() throw(SALOME_Exception); - - int NbFaces() throw(SALOME_Exception); - - int NbTriangles() throw(SALOME_Exception); - - int NbQuadrangles() throw(SALOME_Exception); - - int NbVolumes() throw(SALOME_Exception); - - int NbTetras() throw(SALOME_Exception); - - int NbHexas() throw(SALOME_Exception); - - int NbPyramids() throw(SALOME_Exception); - - int NbPrisms() throw(SALOME_Exception); - - int NbSubMesh() throw(SALOME_Exception); - - int NbGroup() const { return _mapGroup.size(); } + SMESH_Mesh(); + SMESH_Mesh(const SMESH_Mesh&); +public: + SMESH_Mesh(int localId, int studyId, SMESH_Gen * gen, + SMESHDS_Document * myDocument); - SMESH_Group* AddGroup (const SMDSAbs_ElementType theType, - const char* theName, - int& theId); + virtual ~SMESH_Mesh(); - SMESH_Group* GetGroup (const int theGroupID); - - list GetGroupIds(); + void ShapeToMesh(const TopoDS_Shape & aShape); - void RemoveGroup (const int theGroupID); - - ostream& Dump(ostream & save); - - private: + int UNVToMesh(const char* theFileName); + /*! + * consult DriverMED_R_SMESHDS_Mesh::ReadStatus for returned value + */ + int MEDToMesh(const char* theFileName, const char* theMeshName); + + int STLToMesh(const char* theFileName); - int _id; // id given by creator (unique within the creator instance) - int _studyId; - int _idDoc; // id given by SMESHDS_Document - int _groupId; // id generator for group objects - bool _isShapeToMesh; // set to true when a shape is given (only once) - list _subShapeHypothesisList; - list _subMeshesUsingHypothesisList; - SMESHDS_Document * _myDocument; - SMESHDS_Mesh * _myMeshDS; - TopTools_IndexedMapOfShape _subShapes; - map _mapSubMesh; - map _mapGroup; - SMESH_Gen *_gen; + SMESH_Hypothesis::Hypothesis_Status + AddHypothesis(const TopoDS_Shape & aSubShape, int anHypId) + throw(SALOME_Exception); + + SMESH_Hypothesis::Hypothesis_Status + RemoveHypothesis(const TopoDS_Shape & aSubShape, int anHypId) + throw(SALOME_Exception); + + const list & + GetHypothesisList(const TopoDS_Shape & aSubShape) const + throw(SALOME_Exception); + + const list & GetLog() throw(SALOME_Exception); + + void ClearLog() throw(SALOME_Exception); + + int GetId(); + + SMESHDS_Mesh * GetMeshDS(); + + SMESH_Gen *GetGen(); + + SMESH_subMesh *GetSubMesh(const TopoDS_Shape & aSubShape) + throw(SALOME_Exception); + + SMESH_subMesh *GetSubMeshContaining(const TopoDS_Shape & aSubShape) + throw(SALOME_Exception); + + const list < SMESH_subMesh * >& + GetSubMeshUsingHypothesis(SMESHDS_Hypothesis * anHyp) + throw(SALOME_Exception); + + bool IsUsedHypothesis(SMESHDS_Hypothesis * anHyp, + const TopoDS_Shape & aSubShape); + // Return True if anHyp is used to mesh aSubShape + + bool IsNotConformAllowed() const; + // check if a hypothesis alowing notconform mesh is present + + bool IsMainShape(const TopoDS_Shape& theShape) const; - TopTools_IndexedDataMapOfShapeListOfShape _mapAncestors; + const TopTools_ListOfShape& GetAncestors(const TopoDS_Shape& theSubShape); + // return list of ancestors of theSubShape in the order + // that lower dimention shapes come first. + + void ExportDAT(const char *file) throw(SALOME_Exception); + void ExportMED(const char *file, const char* theMeshName = NULL, bool theAutoGroups = true) throw(SALOME_Exception); + void ExportUNV(const char *file) throw(SALOME_Exception); + void ExportSTL(const char *file, const bool isascii) throw(SALOME_Exception); + + int NbNodes() throw(SALOME_Exception); + + int NbEdges() throw(SALOME_Exception); + + int NbFaces() throw(SALOME_Exception); + + int NbTriangles() throw(SALOME_Exception); + + int NbQuadrangles() throw(SALOME_Exception); + + int NbVolumes() throw(SALOME_Exception); + + int NbTetras() throw(SALOME_Exception); + + int NbHexas() throw(SALOME_Exception); + + int NbPyramids() throw(SALOME_Exception); + + int NbPrisms() throw(SALOME_Exception); + + int NbSubMesh() throw(SALOME_Exception); + + int NbGroup() const { return _mapGroup.size(); } + + SMESH_Group* AddGroup (const SMDSAbs_ElementType theType, + const char* theName, + int& theId, + const TopoDS_Shape& theShape=TopoDS_Shape()); + + SMESH_Group* GetGroup (const int theGroupID); + + list GetGroupIds(); + + void RemoveGroup (const int theGroupID); + + ostream& Dump(ostream & save); + +private: + int _id; // id given by creator (unique within the creator instance) + int _studyId; + int _idDoc; // id given by SMESHDS_Document + int _groupId; // id generator for group objects + bool _isShapeToMesh; // set to true when a shape is given (only once) + list _subShapeHypothesisList; + list _subMeshesUsingHypothesisList; + SMESHDS_Document * _myDocument; + SMESHDS_Mesh * _myMeshDS; + //TopTools_IndexedMapOfShape _subShapes; USE the same map of _myMeshDS + map _mapSubMesh; + map _mapGroup; + SMESH_Gen *_gen; + + TopTools_IndexedDataMapOfShapeListOfShape _mapAncestors; }; #endif diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx new file mode 100644 index 000000000..71a4d3c11 --- /dev/null +++ b/src/SMESH/SMESH_MeshEditor.cxx @@ -0,0 +1,3556 @@ +// SMESH SMESH : idl implementation based on 'SMESH' unit's classes +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESH_MeshEditor.cxx +// Created : Mon Apr 12 16:10:22 2004 +// Author : Edward AGAPOV (eap) + + +#include "SMESH_MeshEditor.hxx" + +#include "SMDS_FaceOfNodes.hxx" +#include "SMDS_VolumeTool.hxx" +#include "SMESHDS_Group.hxx" +#include "SMESHDS_Mesh.hxx" +#include "SMESH_subMesh.hxx" + +#include "utilities.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace std; + +typedef map TNodeNodeMap; +typedef map > TNodeOfNodeListMap; +typedef map > TElemOfNodeListMap; + +//======================================================================= +//function : SMESH_MeshEditor +//purpose : +//======================================================================= + +SMESH_MeshEditor::SMESH_MeshEditor( SMESH_Mesh* theMesh ): +myMesh( theMesh ) +{ +} + +//======================================================================= +//function : Remove +//purpose : Remove a node or an element. +// Modify a compute state of sub-meshes which become empty +//======================================================================= + +bool SMESH_MeshEditor::Remove (const list< int >& theIDs, + const bool isNodes ) +{ + + SMESHDS_Mesh* aMesh = GetMeshDS(); + set< SMESH_subMesh *> smmap; + + list::const_iterator it = theIDs.begin(); + for ( ; it != theIDs.end(); it++ ) + { + const SMDS_MeshElement * elem; + if ( isNodes ) + elem = aMesh->FindNode( *it ); + else + elem = aMesh->FindElement( *it ); + if ( !elem ) + continue; + + // Find sub-meshes to notify about modification + SMDS_ElemIteratorPtr nodeIt = elem->nodesIterator(); + while ( nodeIt->more() ) + { + const SMDS_MeshNode* node = static_cast( nodeIt->next() ); + const SMDS_PositionPtr& aPosition = node->GetPosition(); + if ( aPosition.get() ) { + int aShapeID = aPosition->GetShapeId(); + if ( aShapeID ) { + TopoDS_Shape aShape = aMesh->IndexToShape( aShapeID ); + SMESH_subMesh * sm = GetMesh()->GetSubMeshContaining( aShape ); + if ( sm ) + smmap.insert( sm ); + } + } + } + + // Do remove + if ( isNodes ) + aMesh->RemoveNode( static_cast< const SMDS_MeshNode* >( elem )); + else + aMesh->RemoveElement( elem ); + } + + // Notify sub-meshes about modification + if ( !smmap.empty() ) { + set< SMESH_subMesh *>::iterator smIt; + for ( smIt = smmap.begin(); smIt != smmap.end(); smIt++ ) + (*smIt)->ComputeStateEngine( SMESH_subMesh::MESH_ENTITY_REMOVED ); + } + return true; +} + +//======================================================================= +//function : FindShape +//purpose : Return an index of the shape theElem is on +// or zero if a shape not found +//======================================================================= + +int SMESH_MeshEditor::FindShape (const SMDS_MeshElement * theElem) +{ + SMESHDS_Mesh * aMesh = GetMeshDS(); + if ( aMesh->ShapeToMesh().IsNull() ) + return 0; + + if ( theElem->GetType() == SMDSAbs_Node ) + { + const SMDS_PositionPtr& aPosition = + static_cast( theElem )->GetPosition(); + if ( aPosition.get() ) + return aPosition->GetShapeId(); + else + return 0; + } + + TopoDS_Shape aShape; // the shape a node is on + SMDS_ElemIteratorPtr nodeIt = theElem->nodesIterator(); + while ( nodeIt->more() ) + { + const SMDS_MeshNode* node = static_cast( nodeIt->next() ); + const SMDS_PositionPtr& aPosition = node->GetPosition(); + if ( aPosition.get() ) { + int aShapeID = aPosition->GetShapeId(); + SMESHDS_SubMesh * sm = aMesh->MeshElements( aShapeID ); + if ( sm ) + { + if ( sm->Contains( theElem )) + return aShapeID; + if ( aShape.IsNull() ) + aShape = aMesh->IndexToShape( aShapeID ); + } + else + { + //MESSAGE ( "::FindShape() No SubShape for aShapeID " << aShapeID ); + } + } + } + + // None of nodes is on a proper shape, + // find the shape among ancestors of aShape on which a node is + if ( aShape.IsNull() ) { + //MESSAGE ("::FindShape() - NONE node is on shape") + return 0; + } + TopTools_ListIteratorOfListOfShape ancIt( GetMesh()->GetAncestors( aShape )); + for ( ; ancIt.More(); ancIt.Next() ) + { + SMESHDS_SubMesh * sm = aMesh->MeshElements( ancIt.Value() ); + if ( sm && sm->Contains( theElem )) + return aMesh->ShapeToIndex( ancIt.Value() ); + } + + //MESSAGE ("::FindShape() - SHAPE NOT FOUND") + return 0; +} + +//======================================================================= +//function : InverseDiag +//purpose : Replace two neighbour triangles with ones built on the same 4 nodes +// but having other common link. +// Return False if args are improper +//======================================================================= + +bool SMESH_MeshEditor::InverseDiag (const SMDS_MeshElement * theTria1, + const SMDS_MeshElement * theTria2 ) +{ + if (!theTria1 || !theTria2) + return false; + const SMDS_FaceOfNodes* F1 = dynamic_cast( theTria1 ); + if (!F1) return false; + const SMDS_FaceOfNodes* F2 = dynamic_cast( theTria2 ); + if (!F2) return false; + + // 1 +--+ A theTria1: ( 1 A B ) A->2 ( 1 2 B ) 1 +--+ A + // | /| theTria2: ( B A 2 ) B->1 ( 1 A 2 ) |\ | + // |/ | | \| + // B +--+ 2 B +--+ 2 + + // put nodes in array and find out indices of the same ones + const SMDS_MeshNode* aNodes [6]; + int sameInd [] = { 0, 0, 0, 0, 0, 0 }; + int i = 0; + SMDS_ElemIteratorPtr it = theTria1->nodesIterator(); + while ( it->more() ) + { + aNodes[ i ] = static_cast( it->next() ); + + if ( i > 2 ) // theTria2 + // find same node of theTria1 + for ( int j = 0; j < 3; j++ ) + if ( aNodes[ i ] == aNodes[ j ]) { + sameInd[ j ] = i; + sameInd[ i ] = j; + break; + } + // next + i++; + if ( i == 3 ) { + if ( it->more() ) + return false; // theTria1 is not a triangle + it = theTria2->nodesIterator(); + } + if ( i == 6 && it->more() ) + return false; // theTria2 is not a triangle + } + + // find indices of 1,2 and of A,B in theTria1 + int iA = 0, iB = 0, i1 = 0, i2 = 0; + for ( i = 0; i < 6; i++ ) + { + if ( sameInd [ i ] == 0 ) + if ( i < 3 ) i1 = i; + else i2 = i; + else if (i < 3) + if ( iA ) iB = i; + else iA = i; + } + // nodes 1 and 2 should not be the same + if ( aNodes[ i1 ] == aNodes[ i2 ] ) + return false; + + + // theTria1: A->2 + aNodes[ iA ] = aNodes[ i2 ]; + // theTria2: B->1 + aNodes[ sameInd[ iB ]] = aNodes[ i1 ]; + + //MESSAGE( theTria1 << theTria2 ); + + GetMeshDS()->ChangeElementNodes( theTria1, aNodes, 3 ); + GetMeshDS()->ChangeElementNodes( theTria2, &aNodes[ 3 ], 3 ); + + //MESSAGE( theTria1 << theTria2 ); + + return true; +} + +//======================================================================= +//function : findTriangles +//purpose : find triangles sharing theNode1-theNode2 link +//======================================================================= + +static bool findTriangles(const SMDS_MeshNode * theNode1, + const SMDS_MeshNode * theNode2, + const SMDS_MeshElement*& theTria1, + const SMDS_MeshElement*& theTria2) +{ + if ( !theNode1 || !theNode2 ) return false; + + theTria1 = theTria2 = 0; + + set< const SMDS_MeshElement* > emap; + SMDS_ElemIteratorPtr it = theNode1->GetInverseElementIterator(); + while (it->more()) { + const SMDS_MeshElement* elem = it->next(); + if ( elem->GetType() == SMDSAbs_Face && elem->NbNodes() == 3 ) + emap.insert( elem ); + } + it = theNode2->GetInverseElementIterator(); + while (it->more()) { + const SMDS_MeshElement* elem = it->next(); + if ( elem->GetType() == SMDSAbs_Face && + emap.find( elem ) != emap.end() ) + if ( theTria1 ) { + theTria2 = elem; + break; + } else { + theTria1 = elem; + } + } + return ( theTria1 && theTria2 ); +} + +//======================================================================= +//function : InverseDiag +//purpose : Replace two neighbour triangles sharing theNode1-theNode2 link +// with ones built on the same 4 nodes but having other common link. +// Return false if proper faces not found +//======================================================================= + +bool SMESH_MeshEditor::InverseDiag (const SMDS_MeshNode * theNode1, + const SMDS_MeshNode * theNode2) +{ + MESSAGE( "::InverseDiag()" ); + + const SMDS_MeshElement *tr1, *tr2; + if ( !findTriangles( theNode1, theNode2, tr1, tr2 )) + return false; + + const SMDS_FaceOfNodes* F1 = dynamic_cast( tr1 ); + if (!F1) return false; + const SMDS_FaceOfNodes* F2 = dynamic_cast( tr2 ); + if (!F2) return false; + + // 1 +--+ A tr1: ( 1 A B ) A->2 ( 1 2 B ) 1 +--+ A + // | /| tr2: ( B A 2 ) B->1 ( 1 A 2 ) |\ | + // |/ | | \| + // B +--+ 2 B +--+ 2 + + // put nodes in array + // and find indices of 1,2 and of A in tr1 and of B in tr2 + int i, iA1 = 0, i1 = 0; + const SMDS_MeshNode* aNodes1 [3]; + SMDS_ElemIteratorPtr it; + for (i = 0, it = tr1->nodesIterator(); it->more(); i++ ) { + aNodes1[ i ] = static_cast( it->next() ); + if ( aNodes1[ i ] == theNode1 ) + iA1 = i; // node A in tr1 + else if ( aNodes1[ i ] != theNode2 ) + i1 = i; // node 1 + } + int iB2 = 0, i2 = 0; + const SMDS_MeshNode* aNodes2 [3]; + for (i = 0, it = tr2->nodesIterator(); it->more(); i++ ) { + aNodes2[ i ] = static_cast( it->next() ); + if ( aNodes2[ i ] == theNode2 ) + iB2 = i; // node B in tr2 + else if ( aNodes2[ i ] != theNode1 ) + i2 = i; // node 2 + } + + // nodes 1 and 2 should not be the same + if ( aNodes1[ i1 ] == aNodes2[ i2 ] ) + return false; + + // tr1: A->2 + aNodes1[ iA1 ] = aNodes2[ i2 ]; + // tr2: B->1 + aNodes2[ iB2 ] = aNodes1[ i1 ]; + + //MESSAGE( tr1 << tr2 ); + + GetMeshDS()->ChangeElementNodes( tr1, aNodes1, 3 ); + GetMeshDS()->ChangeElementNodes( tr2, aNodes2, 3 ); + + //MESSAGE( tr1 << tr2 ); + + return true; + +} + +//======================================================================= +//function : getQuadrangleNodes +//purpose : fill theQuadNodes - nodes of a quadrangle resulting from +// fusion of triangles tr1 and tr2 having shared link on +// theNode1 and theNode2 +//======================================================================= + +bool getQuadrangleNodes(const SMDS_MeshNode * theQuadNodes [], + const SMDS_MeshNode * theNode1, + const SMDS_MeshNode * theNode2, + const SMDS_MeshElement * tr1, + const SMDS_MeshElement * tr2 ) +{ + // find the 4-th node to insert into tr1 + const SMDS_MeshNode* n4 = 0; + SMDS_ElemIteratorPtr it = tr2->nodesIterator(); + while ( !n4 && it->more() ) + { + const SMDS_MeshNode * n = static_cast( it->next() ); + bool isDiag = ( n == theNode1 || n == theNode2 ); + if ( !isDiag ) + n4 = n; + } + // Make an array of nodes to be in a quadrangle + int iNode = 0, iFirstDiag = -1; + it = tr1->nodesIterator(); + while ( it->more() ) + { + const SMDS_MeshNode * n = static_cast( it->next() ); + bool isDiag = ( n == theNode1 || n == theNode2 ); + if ( isDiag ) + { + if ( iFirstDiag < 0 ) + iFirstDiag = iNode; + else if ( iNode - iFirstDiag == 1 ) + theQuadNodes[ iNode++ ] = n4; // insert the 4-th node between diagonal nodes + } + else if ( n == n4 ) + { + return false; // tr1 and tr2 should not have all the same nodes + } + theQuadNodes[ iNode++ ] = n; + } + if ( iNode == 3 ) // diagonal nodes have 0 and 2 indices + theQuadNodes[ iNode ] = n4; + + return true; +} + +//======================================================================= +//function : DeleteDiag +//purpose : Replace two neighbour triangles sharing theNode1-theNode2 link +// with a quadrangle built on the same 4 nodes. +// Return false if proper faces not found +//======================================================================= + +bool SMESH_MeshEditor::DeleteDiag (const SMDS_MeshNode * theNode1, + const SMDS_MeshNode * theNode2) +{ + MESSAGE( "::DeleteDiag()" ); + + const SMDS_MeshElement *tr1, *tr2; + if ( !findTriangles( theNode1, theNode2, tr1, tr2 )) + return false; + + const SMDS_FaceOfNodes* F1 = dynamic_cast( tr1 ); + if (!F1) return false; + const SMDS_FaceOfNodes* F2 = dynamic_cast( tr2 ); + if (!F2) return false; + + const SMDS_MeshNode* aNodes [ 4 ]; + if ( ! getQuadrangleNodes( aNodes, theNode1, theNode2, tr1, tr2 )) + return false; + + //MESSAGE( endl << tr1 << tr2 ); + + GetMeshDS()->ChangeElementNodes( tr1, aNodes, 4 ); + GetMeshDS()->RemoveElement( tr2 ); + + //MESSAGE( endl << tr1 ); + + return true; +} + +//======================================================================= +//function : Reorient +//purpose : Reverse the normal of theFace +// Return false if theFace is null +//======================================================================= + +bool SMESH_MeshEditor::Reorient (const SMDS_MeshElement * theFace) +{ + if (!theFace) return false; + const SMDS_FaceOfNodes* F = dynamic_cast( theFace ); + if (!F) return false; + + const SMDS_MeshNode* aNodes [4], *tmpNode; + int i = 0; + SMDS_ElemIteratorPtr it = theFace->nodesIterator(); + while ( it->more() ) + aNodes[ i++ ] = static_cast( it->next() ); + + // exchange nodes with indeces 0 and 2 + tmpNode = aNodes[ 0 ]; + aNodes[ 0 ] = aNodes[ 2 ]; + aNodes[ 2 ] = tmpNode; + + //MESSAGE( theFace ); + + GetMeshDS()->ChangeElementNodes( theFace, aNodes, theFace->NbNodes() ); + + //MESSAGE( theFace ); + + return true; +} + +//======================================================================= +//function : getBadRate +//purpose : +//======================================================================= + +static double getBadRate (const SMDS_MeshElement* theElem, + SMESH::Controls::NumericalFunctorPtr& theCrit) +{ + TColgp_SequenceOfXYZ P; + if ( !theElem || !theCrit->GetPoints( theElem, P )) + return 1e100; + return theCrit->GetBadRate( theCrit->GetValue( P ), theElem->NbNodes() ); +} + +//======================================================================= +//function : QuadToTri +//purpose : Cut quadrangles into triangles. +// theCrit is used to select a diagonal to cut +//======================================================================= + +bool SMESH_MeshEditor::QuadToTri (set & theElems, + SMESH::Controls::NumericalFunctorPtr theCrit) +{ + MESSAGE( "::QuadToTri()" ); + + if ( !theCrit.get() ) + return false; + + SMESHDS_Mesh * aMesh = GetMeshDS(); + + set< const SMDS_MeshElement * >::iterator itElem; + for ( itElem = theElems.begin(); itElem != theElems.end(); itElem++ ) + { + const SMDS_MeshElement* elem = (*itElem); + if ( !elem || elem->GetType() != SMDSAbs_Face || elem->NbNodes() != 4 ) + continue; + + // retrieve element nodes + const SMDS_MeshNode* aNodes [4]; + SMDS_ElemIteratorPtr itN = elem->nodesIterator(); + int i = 0; + while ( itN->more() ) + aNodes[ i++ ] = static_cast( itN->next() ); + + // compare two sets of possible triangles + double aBadRate1, aBadRate2; // to what extent a set is bad + SMDS_FaceOfNodes tr1 ( aNodes[0], aNodes[1], aNodes[2] ); + SMDS_FaceOfNodes tr2 ( aNodes[2], aNodes[3], aNodes[0] ); + aBadRate1 = getBadRate( &tr1, theCrit ) + getBadRate( &tr2, theCrit ); + + SMDS_FaceOfNodes tr3 ( aNodes[1], aNodes[2], aNodes[3] ); + SMDS_FaceOfNodes tr4 ( aNodes[3], aNodes[0], aNodes[1] ); + aBadRate2 = getBadRate( &tr3, theCrit ) + getBadRate( &tr4, theCrit ); + + int aShapeId = FindShape( elem ); + //MESSAGE( "aBadRate1 = " << aBadRate1 << "; aBadRate2 = " << aBadRate2 + // << " ShapeID = " << aShapeId << endl << elem ); + + if ( aBadRate1 <= aBadRate2 ) { + // tr1 + tr2 is better + aMesh->ChangeElementNodes( elem, aNodes, 3 ); + //MESSAGE( endl << elem ); + + elem = aMesh->AddFace( aNodes[2], aNodes[3], aNodes[0] ); + } + else { + // tr3 + tr4 is better + aMesh->ChangeElementNodes( elem, &aNodes[1], 3 ); + //MESSAGE( endl << elem ); + + elem = aMesh->AddFace( aNodes[3], aNodes[0], aNodes[1] ); + } + //MESSAGE( endl << elem ); + + // put a new triangle on the same shape + if ( aShapeId ) + aMesh->SetMeshElementOnShape( elem, aShapeId ); + } + + return true; +} + +//======================================================================= +//function : addToSameGroups +//purpose : add elemToAdd to the groups the elemInGroups belongs to +//======================================================================= + +static void addToSameGroups (const SMDS_MeshElement* elemToAdd, + const SMDS_MeshElement* elemInGroups, + SMESHDS_Mesh * aMesh) +{ + const set& groups = aMesh->GetGroups(); + set::const_iterator grIt = groups.begin(); + for ( ; grIt != groups.end(); grIt++ ) { + SMESHDS_Group* group = dynamic_cast( *grIt ); + if ( group && group->SMDSGroup().Contains( elemInGroups )) + group->SMDSGroup().Add( elemToAdd ); + } +} + +//======================================================================= +//function : QuadToTri +//purpose : Cut quadrangles into triangles. +// theCrit is used to select a diagonal to cut +//======================================================================= + +bool SMESH_MeshEditor::QuadToTri (std::set & theElems, + const bool the13Diag) +{ + MESSAGE( "::QuadToTri()" ); + + SMESHDS_Mesh * aMesh = GetMeshDS(); + + set< const SMDS_MeshElement * >::iterator itElem; + for ( itElem = theElems.begin(); itElem != theElems.end(); itElem++ ) + { + const SMDS_MeshElement* elem = (*itElem); + if ( !elem || elem->GetType() != SMDSAbs_Face || elem->NbNodes() != 4 ) + continue; + + // retrieve element nodes + const SMDS_MeshNode* aNodes [4]; + SMDS_ElemIteratorPtr itN = elem->nodesIterator(); + int i = 0; + while ( itN->more() ) + aNodes[ i++ ] = static_cast( itN->next() ); + + int aShapeId = FindShape( elem ); + const SMDS_MeshElement* newElem = 0; + if ( the13Diag ) + { + aMesh->ChangeElementNodes( elem, aNodes, 3 ); + newElem = aMesh->AddFace( aNodes[2], aNodes[3], aNodes[0] ); + } + else + { + aMesh->ChangeElementNodes( elem, &aNodes[1], 3 ); + newElem = aMesh->AddFace( aNodes[3], aNodes[0], aNodes[1] ); + } + + // put a new triangle on the same shape and add to the same groups + + if ( aShapeId ) + aMesh->SetMeshElementOnShape( newElem, aShapeId ); + + addToSameGroups( newElem, elem, aMesh ); + } + + return true; +} + +//======================================================================= +//function : getAngle +//purpose : +//======================================================================= + +double getAngle(const SMDS_MeshElement * tr1, + const SMDS_MeshElement * tr2, + const SMDS_MeshNode * n1, + const SMDS_MeshNode * n2) +{ + double angle = 2*PI; // bad angle + + // get normals + TColgp_SequenceOfXYZ P1, P2; + if ( !SMESH::Controls::NumericalFunctor::GetPoints( tr1, P1 ) || + !SMESH::Controls::NumericalFunctor::GetPoints( tr2, P2 )) + return angle; + gp_Vec N1 = gp_Vec( P1(2) - P1(1) ) ^ gp_Vec( P1(3) - P1(1) ); + if ( N1.SquareMagnitude() <= gp::Resolution() ) + return angle; + gp_Vec N2 = gp_Vec( P2(2) - P2(1) ) ^ gp_Vec( P2(3) - P2(1) ); + if ( N2.SquareMagnitude() <= gp::Resolution() ) + return angle; + + // find the first diagonal node n1 in the triangles: + // take in account a diagonal link orientation + const SMDS_MeshElement *nFirst[2], *tr[] = { tr1, tr2 }; + for ( int t = 0; t < 2; t++ ) + { + SMDS_ElemIteratorPtr it = tr[ t ]->nodesIterator(); + int i = 0, iDiag = -1; + while ( it->more()) { + const SMDS_MeshElement *n = it->next(); + if ( n == n1 || n == n2 ) + if ( iDiag < 0) + iDiag = i; + else { + if ( i - iDiag == 1 ) + nFirst[ t ] = ( n == n1 ? n2 : n1 ); + else + nFirst[ t ] = n; + break; + } + i++; + } + } + if ( nFirst[ 0 ] == nFirst[ 1 ] ) + N2.Reverse(); + + angle = N1.Angle( N2 ); + //SCRUTE( angle ); + return angle; +} + +// ================================================= +// class generating a unique ID for a pair of nodes +// and able to return nodes by that ID +// ================================================= + +class LinkID_Gen { + public: + + LinkID_Gen( const SMESHDS_Mesh* theMesh ) + :myMesh( theMesh ), myMaxID( theMesh->MaxNodeID() + 1) + {} + + long GetLinkID (const SMDS_MeshNode * n1, + const SMDS_MeshNode * n2) const + { + return ( Min(n1->GetID(),n2->GetID()) * myMaxID + Max(n1->GetID(),n2->GetID())); + } + + bool GetNodes (const long theLinkID, + const SMDS_MeshNode* & theNode1, + const SMDS_MeshNode* & theNode2) const + { + theNode1 = myMesh->FindNode( theLinkID / myMaxID ); + if ( !theNode1 ) return false; + theNode2 = myMesh->FindNode( theLinkID % myMaxID ); + if ( !theNode2 ) return false; + return true; + } + + private: + LinkID_Gen(); + const SMESHDS_Mesh* myMesh; + long myMaxID; +}; + +//======================================================================= +//function : TriToQuad +//purpose : Fuse neighbour triangles into quadrangles. +// theCrit is used to select a neighbour to fuse with. +// theMaxAngle is a max angle between element normals at which +// fusion is still performed. +//======================================================================= + +bool SMESH_MeshEditor::TriToQuad (set & theElems, + SMESH::Controls::NumericalFunctorPtr theCrit, + const double theMaxAngle) +{ + MESSAGE( "::TriToQuad()" ); + + if ( !theCrit.get() ) + return false; + + SMESHDS_Mesh * aMesh = GetMeshDS(); + LinkID_Gen aLinkID_Gen( aMesh ); + + + // Prepare data for algo: build + // 1. map of elements with their linkIDs + // 2. map of linkIDs with their elements + + map< long, list< const SMDS_MeshElement* > > mapLi_listEl; + map< long, list< const SMDS_MeshElement* > >::iterator itLE; + map< const SMDS_MeshElement*, set< long > > mapEl_setLi; + map< const SMDS_MeshElement*, set< long > >::iterator itEL; + + set::iterator itElem; + for ( itElem = theElems.begin(); itElem != theElems.end(); itElem++ ) + { + const SMDS_MeshElement* elem = (*itElem); + if ( !elem || elem->NbNodes() != 3 ) + continue; + + // retrieve element nodes + const SMDS_MeshNode* aNodes [4]; + SMDS_ElemIteratorPtr itN = elem->nodesIterator(); + int i = 0; + while ( itN->more() ) + aNodes[ i++ ] = static_cast( itN->next() ); + ASSERT( i == 3 ); + aNodes[ 3 ] = aNodes[ 0 ]; + + // fill maps + for ( i = 0; i < 3; i++ ) + { + long linkID = aLinkID_Gen.GetLinkID( aNodes[ i ], aNodes[ i+1 ] ); + // check if elements sharing a link can be fused + itLE = mapLi_listEl.find( linkID ); + if ( itLE != mapLi_listEl.end() ) + { + if ((*itLE).second.size() > 1 ) // consider only 2 elems adjacent by a link + continue; + const SMDS_MeshElement* elem2 = (*itLE).second.front(); +// if ( FindShape( elem ) != FindShape( elem2 )) +// continue; // do not fuse triangles laying on different shapes + if ( getAngle( elem, elem2, aNodes[i], aNodes[i+1] ) > theMaxAngle ) + continue; // avoid making badly shaped quads + (*itLE).second.push_back( elem ); + } + else + mapLi_listEl[ linkID ].push_back( elem ); + mapEl_setLi [ elem ].insert( linkID ); + } + } + // Clean the maps from the links shared by a sole element, ie + // links to which only one element is bound in mapLi_listEl + + for ( itLE = mapLi_listEl.begin(); itLE != mapLi_listEl.end(); itLE++ ) + { + int nbElems = (*itLE).second.size(); + if ( nbElems < 2 ) { + const SMDS_MeshElement* elem = (*itLE).second.front(); + long link = (*itLE).first; + mapEl_setLi[ elem ].erase( link ); + if ( mapEl_setLi[ elem ].empty() ) + mapEl_setLi.erase( elem ); + } + } + + // Algo: fuse triangles into quadrangles + + while ( ! mapEl_setLi.empty() ) + { + // Look for the start element: + // the element having the least nb of shared links + + const SMDS_MeshElement* startElem = 0; + int minNbLinks = 4; + for ( itEL = mapEl_setLi.begin(); itEL != mapEl_setLi.end(); itEL++ ) + { + int nbLinks = (*itEL).second.size(); + if ( nbLinks < minNbLinks ) + { + startElem = (*itEL).first; + minNbLinks = nbLinks; + if ( minNbLinks == 1 ) + break; + } + } + + // search elements to fuse starting from startElem or links of elements + // fused earlyer - startLinks + list< long > startLinks; + while ( startElem || !startLinks.empty() ) + { + while ( !startElem && !startLinks.empty() ) + { + // Get an element to start, by a link + long linkId = startLinks.front(); + startLinks.pop_front(); + itLE = mapLi_listEl.find( linkId ); + if ( itLE != mapLi_listEl.end() ) + { + list< const SMDS_MeshElement* > & listElem = (*itLE).second; + list< const SMDS_MeshElement* >::iterator itE = listElem.begin(); + for ( ; itE != listElem.end() ; itE++ ) + if ( mapEl_setLi.find( (*itE) ) != mapEl_setLi.end() ) + startElem = (*itE); + mapLi_listEl.erase( itLE ); + } + } + + if ( startElem ) + { + // Get candidates to be fused + + const SMDS_MeshElement *tr1 = startElem, *tr2 = 0, *tr3 = 0; + long link12, link13; + startElem = 0; + ASSERT( mapEl_setLi.find( tr1 ) != mapEl_setLi.end() ); + set< long >& setLi = mapEl_setLi[ tr1 ]; + ASSERT( !setLi.empty() ); + set< long >::iterator itLi; + for ( itLi = setLi.begin(); itLi != setLi.end(); itLi++ ) + { + long linkID = (*itLi); + itLE = mapLi_listEl.find( linkID ); + if ( itLE == mapLi_listEl.end() ) + continue; + const SMDS_MeshElement* elem = (*itLE).second.front(); + if ( elem == tr1 ) + elem = (*itLE).second.back(); + mapLi_listEl.erase( itLE ); + if ( mapEl_setLi.find( elem ) == mapEl_setLi.end()) + continue; + if ( tr2 ) + { + tr3 = elem; + link13 = linkID; + } + else + { + tr2 = elem; + link12 = linkID; + } + + // add other links of elem to list of links to re-start from + set< long >& links = mapEl_setLi[ elem ]; + set< long >::iterator it; + for ( it = links.begin(); it != links.end(); it++ ) + { + long linkID2 = (*it); + if ( linkID2 != linkID ) + startLinks.push_back( linkID2 ); + } + } + + // Get nodes of possible quadrangles + + const SMDS_MeshNode *n12 [4], *n13 [4]; + bool Ok12 = false, Ok13 = false; + const SMDS_MeshNode *linkNode1, *linkNode2; + if ( tr2 && + aLinkID_Gen.GetNodes( link12, linkNode1, linkNode2 ) && + getQuadrangleNodes( n12, linkNode1, linkNode2, tr1, tr2 )) + Ok12 = true; + if ( tr3 && + aLinkID_Gen.GetNodes( link13, linkNode1, linkNode2 ) && + getQuadrangleNodes( n13, linkNode1, linkNode2, tr1, tr3 )) + Ok13 = true; + + // Choose a pair to fuse + + if ( Ok12 && Ok13 ) + { + SMDS_FaceOfNodes quad12 ( n12[ 0 ], n12[ 1 ], n12[ 2 ], n12[ 3 ] ); + SMDS_FaceOfNodes quad13 ( n13[ 0 ], n13[ 1 ], n13[ 2 ], n13[ 3 ] ); + double aBadRate12 = getBadRate( &quad12, theCrit ); + double aBadRate13 = getBadRate( &quad13, theCrit ); + if ( aBadRate13 < aBadRate12 ) + Ok12 = false; + else + Ok13 = false; + } + + + // Make quadrangles + // and remove fused elems and removed links from the maps + + mapEl_setLi.erase( tr1 ); + if ( Ok12 ) + { + mapEl_setLi.erase( tr2 ); + mapLi_listEl.erase( link12 ); + aMesh->ChangeElementNodes( tr1, n12, 4 ); + aMesh->RemoveElement( tr2 ); + } + else if ( Ok13 ) + { + mapEl_setLi.erase( tr3 ); + mapLi_listEl.erase( link13 ); + aMesh->ChangeElementNodes( tr1, n13, 4 ); + aMesh->RemoveElement( tr3 ); + } + + // Next element to fuse: the rejected one + if ( tr3 ) + startElem = Ok12 ? tr3 : tr2; + + } // if ( startElem ) + } // while ( startElem || !startLinks.empty() ) + } // while ( ! mapEl_setLi.empty() ) + + return true; +} + + +#define DUMPSO(txt) \ +// cout << txt << endl; +//============================================================================= +/*! + * + */ +//============================================================================= +static void swap( int i1, int i2, int idNodes[], gp_Pnt P[] ) +{ + if ( i1 == i2 ) + return; + int tmp = idNodes[ i1 ]; + idNodes[ i1 ] = idNodes[ i2 ]; + idNodes[ i2 ] = tmp; + gp_Pnt Ptmp = P[ i1 ]; + P[ i1 ] = P[ i2 ]; + P[ i2 ] = Ptmp; + DUMPSO( i1 << "(" << idNodes[ i2 ] << ") <-> " << i2 << "(" << idNodes[ i1 ] << ")"); +} + +//======================================================================= +//function : SortQuadNodes +//purpose : Set 4 nodes of a quadrangle face in a good order. +// Swap 1<->2 or 2<->3 nodes and correspondingly return +// 1 or 2 else 0. +//======================================================================= + +int SMESH_MeshEditor::SortQuadNodes (const SMDS_Mesh * theMesh, + int idNodes[] ) +{ + gp_Pnt P[4]; + int i; + for ( i = 0; i < 4; i++ ) { + const SMDS_MeshNode *n = theMesh->FindNode( idNodes[i] ); + if ( !n ) return 0; + P[ i ].SetCoord( n->X(), n->Y(), n->Z() ); + } + + gp_Vec V1(P[0], P[1]); + gp_Vec V2(P[0], P[2]); + gp_Vec V3(P[0], P[3]); + + gp_Vec Cross1 = V1 ^ V2; + gp_Vec Cross2 = V2 ^ V3; + + i = 0; + if (Cross1.Dot(Cross2) < 0) + { + Cross1 = V2 ^ V1; + Cross2 = V1 ^ V3; + + if (Cross1.Dot(Cross2) < 0) + i = 2; + else + i = 1; + swap ( i, i + 1, idNodes, P ); + +// for ( int ii = 0; ii < 4; ii++ ) { +// const SMDS_MeshNode *n = theMesh->FindNode( idNodes[ii] ); +// DUMPSO( ii << "(" << idNodes[ii] <<") : "<X()<<" "<Y()<<" "<Z()); +// } + } + return i; +} + +//======================================================================= +//function : SortHexaNodes +//purpose : Set 8 nodes of a hexahedron in a good order. +// Return success status +//======================================================================= + +bool SMESH_MeshEditor::SortHexaNodes (const SMDS_Mesh * theMesh, + int idNodes[] ) +{ + gp_Pnt P[8]; + int i; + DUMPSO( "INPUT: ========================================"); + for ( i = 0; i < 8; i++ ) { + const SMDS_MeshNode *n = theMesh->FindNode( idNodes[i] ); + if ( !n ) return false; + P[ i ].SetCoord( n->X(), n->Y(), n->Z() ); + DUMPSO( i << "(" << idNodes[i] <<") : "<X()<<" "<Y()<<" "<Z()); + } + DUMPSO( "========================================"); + + + set faceNodes; // ids of bottom face nodes, to be found + set checkedId1; // ids of tried 2-nd nodes + Standard_Real leastDist = DBL_MAX; // dist of the 4-th node from 123 plane + const Standard_Real tol = 1.e-6; // tolerance to find nodes in plane + int iMin, iLoop1 = 0; + + // Loop to try the 2-nd nodes + + while ( leastDist > DBL_MIN && ++iLoop1 < 8 ) + { + // Find not checked 2-nd node + for ( i = 1; i < 8; i++ ) + if ( checkedId1.find( idNodes[i] ) == checkedId1.end() ) { + int id1 = idNodes[i]; + swap ( 1, i, idNodes, P ); + checkedId1.insert ( id1 ); + break; + } + + // Find the 3-d node so that 1-2-3 triangle to be on a hexa face, + // ie that all but meybe one (id3 which is on the same face) nodes + // lay on the same side from the triangle plane. + + bool manyInPlane = false; // more than 4 nodes lay in plane + int iLoop2 = 0; + while ( ++iLoop2 < 6 ) { + + // get 1-2-3 plane coeffs + Standard_Real A, B, C, D; + gp_Vec N = gp_Vec (P[0], P[1]).Crossed( gp_Vec (P[0], P[2]) ); + if ( N.SquareMagnitude() > gp::Resolution() ) + { + gp_Pln pln ( P[0], N ); + pln.Coefficients( A, B, C, D ); + + // find the node (iMin) closest to pln + Standard_Real dist[ 8 ], minDist = DBL_MAX; + set idInPln; + for ( i = 3; i < 8; i++ ) { + dist[i] = A * P[i].X() + B * P[i].Y() + C * P[i].Z() + D; + if ( fabs( dist[i] ) < minDist ) { + minDist = fabs( dist[i] ); + iMin = i; + } + if ( fabs( dist[i] ) <= tol ) + idInPln.insert( idNodes[i] ); + } + + // there should not be more than 4 nodes in bottom plane + if ( idInPln.size() > 1 ) + { + DUMPSO( "### idInPln.size() = " << idInPln.size()); + // idInPlane does not contain the first 3 nodes + if ( manyInPlane || idInPln.size() == 5) + return false; // all nodes in one plane + manyInPlane = true; + + // set the 1-st node to be not in plane + for ( i = 3; i < 8; i++ ) { + if ( idInPln.find( idNodes[ i ] ) == idInPln.end() ) { + DUMPSO( "### Reset 0-th node"); + swap( 0, i, idNodes, P ); + break; + } + } + + // reset to re-check second nodes + leastDist = DBL_MAX; + faceNodes.clear(); + checkedId1.clear(); + iLoop1 = 0; + break; // from iLoop2; + } + + // check that the other 4 nodes are on the same side + bool sameSide = true; + bool isNeg = dist[ iMin == 3 ? 4 : 3 ] <= 0.; + for ( i = 3; sameSide && i < 8; i++ ) { + if ( i != iMin ) + sameSide = ( isNeg == dist[i] <= 0.); + } + + // keep best solution + if ( sameSide && minDist < leastDist ) { + leastDist = minDist; + faceNodes.clear(); + faceNodes.insert( idNodes[ 1 ] ); + faceNodes.insert( idNodes[ 2 ] ); + faceNodes.insert( idNodes[ iMin ] ); + DUMPSO( "loop " << iLoop2 << " id2 " << idNodes[ 1 ] << " id3 " << idNodes[ 2 ] + << " leastDist = " << leastDist); + if ( leastDist <= DBL_MIN ) + break; + } + } + + // set next 3-d node to check + int iNext = 2 + iLoop2; + if ( iNext < 8 ) { + DUMPSO( "Try 2-nd"); + swap ( 2, iNext, idNodes, P ); + } + } // while ( iLoop2 < 6 ) + } // iLoop1 + + if ( faceNodes.empty() ) return false; + + // Put the faceNodes in proper places + for ( i = 4; i < 8; i++ ) { + if ( faceNodes.find( idNodes[ i ] ) != faceNodes.end() ) { + // find a place to put + int iTo = 1; + while ( faceNodes.find( idNodes[ iTo ] ) != faceNodes.end() ) + iTo++; + DUMPSO( "Set faceNodes"); + swap ( iTo, i, idNodes, P ); + } + } + + + // Set nodes of the found bottom face in good order + DUMPSO( " Found bottom face: "); + i = SortQuadNodes( theMesh, idNodes ); + if ( i ) { + gp_Pnt Ptmp = P[ i ]; + P[ i ] = P[ i+1 ]; + P[ i+1 ] = Ptmp; + } +// else +// for ( int ii = 0; ii < 4; ii++ ) { +// const SMDS_MeshNode *n = theMesh->FindNode( idNodes[ii] ); +// DUMPSO( ii << "(" << idNodes[ii] <<") : "<X()<<" "<Y()<<" "<Z()); +// } + + // Gravity center of the top and bottom faces + gp_Pnt aGCb = ( P[0].XYZ() + P[1].XYZ() + P[2].XYZ() + P[3].XYZ() ) / 4.; + gp_Pnt aGCt = ( P[4].XYZ() + P[5].XYZ() + P[6].XYZ() + P[7].XYZ() ) / 4.; + + // Get direction from the bottom to the top face + gp_Vec upDir ( aGCb, aGCt ); + Standard_Real upDirSize = upDir.Magnitude(); + if ( upDirSize <= gp::Resolution() ) return false; + upDir / upDirSize; + + // Assure that the bottom face normal points up + gp_Vec Nb = gp_Vec (P[0], P[1]).Crossed( gp_Vec (P[0], P[2]) ); + Nb += gp_Vec (P[0], P[2]).Crossed( gp_Vec (P[0], P[3]) ); + if ( Nb.Dot( upDir ) < 0 ) { + DUMPSO( "Reverse bottom face"); + swap( 1, 3, idNodes, P ); + } + + // Find 5-th node - the one closest to the 1-st among the last 4 nodes. + Standard_Real minDist = DBL_MAX; + for ( i = 4; i < 8; i++ ) { + // projection of P[i] to the plane defined by P[0] and upDir + gp_Pnt Pp = P[i].Translated( upDir * ( upDir.Dot( gp_Vec( P[i], P[0] )))); + Standard_Real sqDist = P[0].SquareDistance( Pp ); + if ( sqDist < minDist ) { + minDist = sqDist; + iMin = i; + } + } + DUMPSO( "Set 4-th"); + swap ( 4, iMin, idNodes, P ); + + // Set nodes of the top face in good order + DUMPSO( "Sort top face"); + i = SortQuadNodes( theMesh, &idNodes[4] ); + if ( i ) { + i += 4; + gp_Pnt Ptmp = P[ i ]; + P[ i ] = P[ i+1 ]; + P[ i+1 ] = Ptmp; + } + + // Assure that direction of the top face normal is from the bottom face + gp_Vec Nt = gp_Vec (P[4], P[5]).Crossed( gp_Vec (P[4], P[6]) ); + Nt += gp_Vec (P[4], P[6]).Crossed( gp_Vec (P[4], P[7]) ); + if ( Nt.Dot( upDir ) < 0 ) { + DUMPSO( "Reverse top face"); + swap( 5, 7, idNodes, P ); + } + +// DUMPSO( "OUTPUT: ========================================"); +// for ( i = 0; i < 8; i++ ) { +// float *p = ugrid->GetPoint(idNodes[i]); +// DUMPSO( i << "(" << idNodes[i] << ") : " << p[0] << " " << p[1] << " " << p[2]); +// } + + return true; +} + +//======================================================================= +//function : laplacianSmooth +//purpose : pulls theNode toward the center of surrounding nodes directly +// connected to that node along an element edge +//======================================================================= + +void laplacianSmooth(SMESHDS_Mesh * theMesh, + const SMDS_MeshNode* theNode, + const set & theElems, + const set & theFixedNodes) +{ + // find surrounding nodes + set< const SMDS_MeshNode* > nodeSet; + SMDS_ElemIteratorPtr elemIt = theNode->GetInverseElementIterator(); + while ( elemIt->more() ) + { + const SMDS_MeshElement* elem = elemIt->next(); + if ( theElems.find( elem ) == theElems.end() ) + continue; + + int i = 0, iNode = 0; + const SMDS_MeshNode* aNodes [4]; + SMDS_ElemIteratorPtr itN = elem->nodesIterator(); + while ( itN->more() ) + { + aNodes[ i ] = static_cast( itN->next() ); + if ( aNodes[ i ] == theNode ) + iNode = i; + else + nodeSet.insert( aNodes[ i ] ); + i++; + } + if ( elem->NbNodes() == 4 ) { // remove an opposite node + iNode += ( iNode < 2 ) ? 2 : -2; + nodeSet.erase( aNodes[ iNode ]); + } + } + + // compute new coodrs + double coord[] = { 0., 0., 0. }; + set< const SMDS_MeshNode* >::iterator nodeSetIt = nodeSet.begin(); + for ( ; nodeSetIt != nodeSet.end(); nodeSetIt++ ) { + const SMDS_MeshNode* node = (*nodeSetIt); + coord[0] += node->X(); + coord[1] += node->Y(); + coord[2] += node->Z(); + } + double nbNodes = nodeSet.size(); + theMesh->MoveNode (theNode, + coord[0]/nbNodes, + coord[1]/nbNodes, + coord[2]/nbNodes); +} + +//======================================================================= +//function : centroidalSmooth +//purpose : pulls theNode toward the element-area-weighted centroid of the +// surrounding elements +//======================================================================= + +void centroidalSmooth(SMESHDS_Mesh * theMesh, + const SMDS_MeshNode* theNode, + const set & theElems, + const set & theFixedNodes) +{ + gp_XYZ aNewXYZ(0.,0.,0.); + SMESH::Controls::Area anAreaFunc; + double totalArea = 0.; + int nbElems = 0; + + SMDS_ElemIteratorPtr elemIt = theNode->GetInverseElementIterator(); + while ( elemIt->more() ) + { + const SMDS_MeshElement* elem = elemIt->next(); + if ( theElems.find( elem ) == theElems.end() ) + continue; + + nbElems++; + + gp_XYZ elemCenter(0.,0.,0.); + TColgp_SequenceOfXYZ aNodePoints; + SMDS_ElemIteratorPtr itN = elem->nodesIterator(); + while ( itN->more() ) + { + const SMDS_MeshNode* aNode = static_cast( itN->next() ); + gp_XYZ aP( aNode->X(), aNode->Y(), aNode->Z() ); + aNodePoints.Append( aP ); + elemCenter += aP; + } + double elemArea = anAreaFunc.GetValue( aNodePoints ); + totalArea += elemArea; + elemCenter /= elem->NbNodes(); + aNewXYZ += elemCenter * elemArea; + } + aNewXYZ /= totalArea; + theMesh->MoveNode (theNode, + aNewXYZ.X(), + aNewXYZ.Y(), + aNewXYZ.Z()); +} + +//======================================================================= +//function : Smooth +//purpose : Smooth theElements during theNbIterations or until a worst +// element has aspect ratio <= theTgtAspectRatio. +// Aspect Ratio varies in range [1.0, inf]. +// If theElements is empty, the whole mesh is smoothed. +// theFixedNodes contains additionally fixed nodes. Nodes built +// on edges and boundary nodes are always fixed. +//======================================================================= + +void SMESH_MeshEditor::Smooth (set & theElems, + set & theFixedNodes, + const SmoothMethod theSmoothMethod, + const int theNbIterations, + double theTgtAspectRatio) +{ + MESSAGE((theSmoothMethod==LAPLACIAN ? "LAPLACIAN" : "CENTROIDAL") << "--::Smooth()"); + + SMESHDS_Mesh* aMesh = GetMeshDS(); + if ( theElems.empty() ) { + // add all faces + SMDS_FaceIteratorPtr fIt = aMesh->facesIterator(); + while ( fIt->more() ) + theElems.insert( fIt->next() ); + } + + set setMovableNodes; + + // Fill setMovableNodes + + map< const SMDS_MeshNode*, int > mapNodeNbFaces; + set< const SMDS_MeshElement* >::iterator itElem; + for ( itElem = theElems.begin(); itElem != theElems.end(); itElem++ ) + { + const SMDS_MeshElement* elem = (*itElem); + if ( !elem || elem->GetType() != SMDSAbs_Face ) + continue; + + SMDS_ElemIteratorPtr itN = elem->nodesIterator(); + while ( itN->more() ) { + const SMDS_MeshNode* node = + static_cast( itN->next() ); + + if ( theFixedNodes.find( node ) != theFixedNodes.end() ) + continue; + + // if node is on edge => it is fixed + SMDS_PositionPtr aPositionPtr = node->GetPosition(); + if ( aPositionPtr.get() && + (aPositionPtr->GetTypeOfPosition() == SMDS_TOP_EDGE || + aPositionPtr->GetTypeOfPosition() == SMDS_TOP_VERTEX)) { + theFixedNodes.insert( node ); + continue; + } + // fill mapNodeNbFaces in order to detect fixed boundary nodes + map::iterator nodeNbFacesIt = + mapNodeNbFaces.find ( node ); + if ( nodeNbFacesIt == mapNodeNbFaces.end() ) + mapNodeNbFaces.insert( map::value_type( node, 1 )); + else + (*nodeNbFacesIt).second++; + } + } + // put not fixed nodes in setMovableNodes + map::iterator nodeNbFacesIt = + mapNodeNbFaces.begin(); + for ( ; nodeNbFacesIt != mapNodeNbFaces.end(); nodeNbFacesIt++ ) { + const SMDS_MeshNode* node = (*nodeNbFacesIt).first; + // a node is on free boundary if it is shared by 1-2 faces + if ( (*nodeNbFacesIt).second > 2 ) + setMovableNodes.insert( node ); + else + theFixedNodes.insert( node ); + } + + // SMOOTHING // + + if ( theTgtAspectRatio < 1.0 ) + theTgtAspectRatio = 1.0; + + SMESH::Controls::AspectRatio aQualityFunc; + + for ( int it = 0; it < theNbIterations; it++ ) + { + Standard_Real maxDisplacement = 0.; + set::iterator movableNodesIt + = setMovableNodes.begin(); + for ( ; movableNodesIt != setMovableNodes.end(); movableNodesIt++ ) + { + const SMDS_MeshNode* node = (*movableNodesIt); + gp_XYZ aPrevPos ( node->X(), node->Y(), node->Z() ); + + // smooth + if ( theSmoothMethod == LAPLACIAN ) + laplacianSmooth( aMesh, node, theElems, theFixedNodes ); + else + centroidalSmooth( aMesh, node, theElems, theFixedNodes ); + + // displacement + gp_XYZ aNewPos ( node->X(), node->Y(), node->Z() ); + Standard_Real aDispl = (aPrevPos - aNewPos).SquareModulus(); + if ( aDispl > maxDisplacement ) + maxDisplacement = aDispl; + } + // no node movement => exit + if ( maxDisplacement < 1.e-16 ) { + MESSAGE("-- no node movement -- maxDisplacement: " << maxDisplacement << " it "<< it); + break; + } + + // check elements quality + double maxRatio = 0; + for ( itElem = theElems.begin(); itElem != theElems.end(); itElem++ ) + { + const SMDS_MeshElement* elem = (*itElem); + if ( !elem || elem->GetType() != SMDSAbs_Face ) + continue; + TColgp_SequenceOfXYZ aPoints; + if ( aQualityFunc.GetPoints( elem, aPoints )) { + double aValue = aQualityFunc.GetValue( aPoints ); + if ( aValue > maxRatio ) + maxRatio = aValue; + } + } + if ( maxRatio <= theTgtAspectRatio ) { + MESSAGE("-- quality achived -- maxRatio " << maxRatio << " it "<< it); + break; + } + if (it+1 == theNbIterations) { + MESSAGE("-- Iteration limit exceeded --"); + } + } +} + +//======================================================================= +//function : isReverse +//purpose : +//======================================================================= + +static bool isReverse(const SMDS_MeshNode* prevNodes[], + const SMDS_MeshNode* nextNodes[], + const int nbNodes, + const int iNotSame) +{ + int iBeforeNotSame = ( iNotSame == 0 ? nbNodes - 1 : iNotSame - 1 ); + int iAfterNotSame = ( iNotSame + 1 == nbNodes ? 0 : iNotSame + 1 ); + + const SMDS_MeshNode* nB = prevNodes[ iBeforeNotSame ]; + const SMDS_MeshNode* nA = prevNodes[ iAfterNotSame ]; + const SMDS_MeshNode* nP = prevNodes[ iNotSame ]; + const SMDS_MeshNode* nN = nextNodes[ iNotSame ]; + + gp_Pnt pB ( nB->X(), nB->Y(), nB->Z() ); + gp_Pnt pA ( nA->X(), nA->Y(), nA->Z() ); + gp_Pnt pP ( nP->X(), nP->Y(), nP->Z() ); + gp_Pnt pN ( nN->X(), nN->Y(), nN->Z() ); + + gp_Vec vB ( pP, pB ), vA ( pP, pA ), vN ( pP, pN ); + + return (vA ^ vB) * vN < 0.0; +} + +//======================================================================= +//function : sweepElement +//purpose : +//======================================================================= + +static void sweepElement(SMESHDS_Mesh* aMesh, + const SMDS_MeshElement* elem, + const TNodeOfNodeListMap& mapNewNodes ) +{ + // Loop on elem nodes: + // find new nodes and detect same nodes indices + list::const_iterator itNN[ 4 ]; + const SMDS_MeshNode* prevNod[ 4 ], *nextNod[ 4 ]; + int nbSame = 0, iNotSameNode = 0, iSameNode = 0; + + TNodeOfNodeListMap::const_iterator mapIt; + int iNode = 0; + SMDS_ElemIteratorPtr itN = elem->nodesIterator(); + while ( itN->more() ) + { + const SMDS_MeshNode* node = + static_cast( itN->next() ); + mapIt = mapNewNodes.find( node ); + if ( mapIt == mapNewNodes.end() ) + return; // not duplicated node + + itNN[ iNode ] = (*mapIt).second.begin(); + prevNod[ iNode ] = node; + nextNod[ iNode ] = (*mapIt).second.front(); + if ( prevNod[ iNode ] != nextNod [ iNode ]) + iNotSameNode = iNode; + else { + iSameNode = iNode; + nbSame++; + } + iNode++; + } + int nbNodes = iNode; + if ( nbSame == nbNodes || nbSame > 2) { + MESSAGE( " Too many same nodes of element " << elem->GetID() ); + return; + } + + int iBeforeSame = 0, iAfterSame = 0, iOpposSame = 0; + if ( nbSame > 0 ) { + iBeforeSame = ( iSameNode == 0 ? nbNodes - 1 : iSameNode - 1 ); + iAfterSame = ( iSameNode + 1 == nbNodes ? 0 : iSameNode + 1 ); + iOpposSame = ( iSameNode - 2 < 0 ? iSameNode + 2 : iSameNode - 2 ); + } + + // check element orientation + int i0 = 0, i2 = 2; + if ( nbNodes > 2 && isReverse( prevNod, nextNod, nbNodes, iNotSameNode )) { +// MESSAGE("Reversed elem " << elem->GetID() ); + i0 = 2; + i2 = 0; + if ( nbSame > 0 ) { + int iAB = iAfterSame + iBeforeSame; + iBeforeSame = iAB - iBeforeSame; + iAfterSame = iAB - iAfterSame; + } + } + + // make new elements + int iStep, nbSteps = (*mapIt).second.size(); + for (iStep = 0; iStep < nbSteps; iStep++ ) + { + // get next nodes + for ( iNode = 0; iNode < nbNodes; iNode++ ) { + nextNod[ iNode ] = *itNN[ iNode ]; + itNN[ iNode ]++; + } + switch ( nbNodes ) + { + case 2: { // EDGE + + if ( nbSame == 0 ) + aMesh->AddFace( prevNod[ 0 ], prevNod[ 1 ], nextNod[ 1 ], nextNod[ 0 ] ); + else + aMesh->AddFace( prevNod[ 0 ], prevNod[ 1 ], nextNod[ iNotSameNode ] ); + break; + } + case 3: { // TRIANGLE + + if ( nbSame == 0 ) // --- 1 pentahedron + { + aMesh->AddVolume (prevNod[ i2 ], prevNod[ 1 ], prevNod[ i0 ], + nextNod[ i2 ], nextNod[ 1 ], nextNod[ i0 ] ); + } + else if ( nbSame == 1 ) // --- 2 tetrahedrons + { + aMesh->AddVolume (prevNod[ i0 ], prevNod[ 1 ], prevNod[ i2 ], + nextNod[ iBeforeSame ]); + aMesh->AddVolume (nextNod[ i2 ], nextNod[ 1 ], nextNod[ i0 ], + prevNod[ iAfterSame ]); + } + else // 2 same nodes: --- 1 tetrahedron + { + aMesh->AddVolume (prevNod[ i0 ], prevNod[ 1 ], prevNod[ i2 ], + nextNod[ iNotSameNode ]); + } + break; + } + case 4: { // QUADRANGLE + + if ( nbSame == 0 ) // --- 1 hexahedron + { + aMesh->AddVolume (prevNod[ i0 ], prevNod[ 1 ], prevNod[ i2 ], prevNod[ 3 ], + nextNod[ i0 ], nextNod[ 1 ], nextNod[ i2 ], nextNod[ 3 ]); + } + else if ( nbSame == 1 ) // --- 2 tetrahedrons + 1 pentahedron + { + aMesh->AddVolume (prevNod[ iBeforeSame ], prevNod[ iSameNode ], + prevNod[ iAfterSame ], nextNod[ iBeforeSame ]); + aMesh->AddVolume (nextNod[ iAfterSame ], nextNod[ iSameNode ], + nextNod[ iBeforeSame ], prevNod[ iAfterSame ]); + aMesh->AddVolume (prevNod[ iBeforeSame ], prevNod[ iOpposSame ], prevNod[ iAfterSame ], + nextNod[ iBeforeSame ], nextNod[ iOpposSame ], nextNod[ iAfterSame ] ); + } + else if ( nbSame == 2 ) // 1 pentahedron + { + if ( prevNod[ iBeforeSame ] == nextNod[ iBeforeSame ] ) + // iBeforeSame is same too + aMesh->AddVolume (prevNod[ iOpposSame ], prevNod[ iBeforeSame ], nextNod[ iOpposSame ], + prevNod[ iAfterSame ], prevNod[ iSameNode ], nextNod[ iAfterSame ]); + else + // iAfterSame is same too + aMesh->AddVolume (prevNod[ iBeforeSame ], prevNod[ iSameNode ], nextNod[ iBeforeSame ], + prevNod[ iOpposSame ], prevNod[ iAfterSame ], nextNod[ iOpposSame ]); + } + break; + } + default: + return; + } + + // set new prev nodes + for ( iNode = 0; iNode < nbNodes; iNode++ ) + prevNod[ iNode ] = nextNod[ iNode ]; + + } // for steps +} + +//======================================================================= +//function : RotationSweep +//purpose : +//======================================================================= + +void SMESH_MeshEditor::RotationSweep(set & theElems, + const gp_Ax1& theAxis, + const double theAngle, + const int theNbSteps, + const double theTol) +{ + gp_Trsf aTrsf; + aTrsf.SetRotation( theAxis, theAngle ); + + gp_Lin aLine( theAxis ); + double aSqTol = theTol * theTol; + + SMESHDS_Mesh* aMesh = GetMeshDS(); + + TNodeOfNodeListMap mapNewNodes; + + // loop on theElems + set< const SMDS_MeshElement* >::iterator itElem; + for ( itElem = theElems.begin(); itElem != theElems.end(); itElem++ ) + { + // check element type + const SMDS_MeshElement* elem = (*itElem); + if ( !elem || + (elem->GetType() != SMDSAbs_Face && + elem->GetType() != SMDSAbs_Edge )) + continue; + + // loop on elem nodes + SMDS_ElemIteratorPtr itN = elem->nodesIterator(); + while ( itN->more() ) { + + // check if a node has been already sweeped + const SMDS_MeshNode* node = + static_cast( itN->next() ); + if (mapNewNodes.find( node ) != mapNewNodes.end() ) + continue; + + list& listNewNodes = mapNewNodes[ node ]; + + // make new nodes + gp_XYZ aXYZ( node->X(), node->Y(), node->Z() ); + double coord[3]; + aXYZ.Coord( coord[0], coord[1], coord[2] ); + bool isOnAxis = ( aLine.SquareDistance( aXYZ ) <= aSqTol ); + const SMDS_MeshNode * newNode = node; + for ( int i = 0; i < theNbSteps; i++ ) { + if ( !isOnAxis ) { + aTrsf.Transforms( coord[0], coord[1], coord[2] ); + newNode = aMesh->AddNode( coord[0], coord[1], coord[2] ); + } + listNewNodes.push_back( newNode ); + } + } + // make new elements + sweepElement( aMesh, elem, mapNewNodes ); + } +} +//======================================================================= +//function : ExtrusionSweep +//purpose : +//======================================================================= + +void SMESH_MeshEditor::ExtrusionSweep(set & theElems, + const gp_Vec& theStep, + const int theNbSteps) +{ + gp_Trsf aTrsf; + aTrsf.SetTranslation( theStep ); + + SMESHDS_Mesh* aMesh = GetMeshDS(); + + TNodeOfNodeListMap mapNewNodes; + + // loop on theElems + set< const SMDS_MeshElement* >::iterator itElem; + for ( itElem = theElems.begin(); itElem != theElems.end(); itElem++ ) + { + // check element type + const SMDS_MeshElement* elem = (*itElem); + if ( !elem || + (elem->GetType() != SMDSAbs_Face && + elem->GetType() != SMDSAbs_Edge)) + continue; + + // loop on elem nodes + SMDS_ElemIteratorPtr itN = elem->nodesIterator(); + while ( itN->more() ) { + + // check if a node has been already sweeped + const SMDS_MeshNode* node = + static_cast( itN->next() ); + if (mapNewNodes.find( node ) != mapNewNodes.end() ) + continue; + + list& listNewNodes = mapNewNodes[ node ]; + + // make new nodes + double coord[3]; + coord[0] = node->X(); + coord[1] = node->Y(); + coord[2] = node->Z(); + for ( int i = 0; i < theNbSteps; i++ ) { + aTrsf.Transforms( coord[0], coord[1], coord[2] ); + const SMDS_MeshNode * newNode = aMesh->AddNode( coord[0], coord[1], coord[2] ); + listNewNodes.push_back( newNode ); + } + } + // make new elements + sweepElement( aMesh, elem, mapNewNodes ); + } +} + +//======================================================================= +//function : Transform +//purpose : +//======================================================================= + +void SMESH_MeshEditor::Transform (set & theElems, + const gp_Trsf& theTrsf, + const bool theCopy) +{ + bool needReverse; + switch ( theTrsf.Form() ) { + case gp_PntMirror: + case gp_Ax2Mirror: + needReverse = true; + break; + default: + needReverse = false; + } + + SMESHDS_Mesh* aMesh = GetMeshDS(); + + // map old node to new one + TNodeNodeMap nodeMap; + + // elements sharing moved nodes; those of them which have all + // nodes mirrored but are not in theElems are to be reversed + set inverseElemSet; + + // loop on theElems + set< const SMDS_MeshElement* >::iterator itElem; + for ( itElem = theElems.begin(); itElem != theElems.end(); itElem++ ) + { + const SMDS_MeshElement* elem = (*itElem); + if ( !elem ) + continue; + + // loop on elem nodes + SMDS_ElemIteratorPtr itN = elem->nodesIterator(); + while ( itN->more() ) { + + // check if a node has been already transormed + const SMDS_MeshNode* node = + static_cast( itN->next() ); + if (nodeMap.find( node ) != nodeMap.end() ) + continue; + + double coord[3]; + coord[0] = node->X(); + coord[1] = node->Y(); + coord[2] = node->Z(); + theTrsf.Transforms( coord[0], coord[1], coord[2] ); + const SMDS_MeshNode * newNode = node; + if ( theCopy ) + newNode = aMesh->AddNode( coord[0], coord[1], coord[2] ); + else + aMesh->MoveNode( node, coord[0], coord[1], coord[2] ); + nodeMap.insert( TNodeNodeMap::value_type( node, newNode )); + + // keep inverse elements + if ( !theCopy && needReverse ) { + SMDS_ElemIteratorPtr invElemIt = node->GetInverseElementIterator(); + while ( invElemIt->more() ) + inverseElemSet.insert( invElemIt->next() ); + } + } + } + + // either new elements are to be created + // or a mirrored element are to be reversed + if ( !theCopy && !needReverse) + return; + + if ( !inverseElemSet.empty()) { + set::iterator invElemIt = inverseElemSet.begin(); + for ( ; invElemIt != inverseElemSet.end(); invElemIt++ ) + theElems.insert( *invElemIt ); + } + + // replicate or reverse elements + + enum { + REV_TETRA = 0, // = nbNodes - 4 + REV_PYRAMID = 1, // = nbNodes - 4 + REV_PENTA = 2, // = nbNodes - 4 + REV_FACE = 3, + REV_HEXA = 4, // = nbNodes - 4 + FORWARD = 5 + }; + int index[][8] = { + { 2, 1, 0, 3, 4, 0, 0, 0 }, // REV_TETRA + { 2, 1, 0, 3, 4, 0, 0, 0 }, // REV_PYRAMID + { 2, 1, 0, 5, 4, 3, 0, 0 }, // REV_PENTA + { 2, 1, 0, 3, 0, 0, 0, 0 }, // REV_FACE + { 2, 1, 0, 3, 6, 5, 4, 7 }, // REV_HEXA + { 0, 1, 2, 3, 4, 5, 6, 7 } // FORWARD + }; + + for ( itElem = theElems.begin(); itElem != theElems.end(); itElem++ ) + { + const SMDS_MeshElement* elem = (*itElem); + if ( !elem || elem->GetType() == SMDSAbs_Node ) + continue; + + int nbNodes = elem->NbNodes(); + int elemType = elem->GetType(); + + int* i = index[ FORWARD ]; + if ( needReverse && nbNodes > 2) // reverse mirrored faces and volumes + if ( elemType == SMDSAbs_Face ) + i = index[ REV_FACE ]; + else + i = index[ nbNodes - 4 ]; + + // find transformed nodes + const SMDS_MeshNode* nodes[8]; + int iNode = 0; + SMDS_ElemIteratorPtr itN = elem->nodesIterator(); + while ( itN->more() ) + { + const SMDS_MeshNode* node = + static_cast( itN->next() ); + TNodeNodeMap::iterator nodeMapIt = nodeMap.find( node ); + if ( nodeMapIt == nodeMap.end() ) + break; // not all nodes transformed + nodes[ i [ iNode++ ]] = (*nodeMapIt).second; + } + if ( iNode != nbNodes ) + continue; // not all nodes transformed + + if ( theCopy ) + { + // add a new element + switch ( elemType ) { + case SMDSAbs_Edge: + aMesh->AddEdge( nodes[ 0 ], nodes[ 1 ] ); + break; + case SMDSAbs_Face: + if ( nbNodes == 3 ) + aMesh->AddFace( nodes[ 0 ], nodes[ 1 ], nodes[ 2 ] ); + else + aMesh->AddFace( nodes[ 0 ], nodes[ 1 ], nodes[ 2 ] , nodes[ 3 ]); + break; + case SMDSAbs_Volume: + if ( nbNodes == 4 ) + aMesh->AddVolume( nodes[ 0 ], nodes[ 1 ], nodes[ 2 ] , nodes[ 3 ] ); + else if ( nbNodes == 8 ) + aMesh->AddVolume( nodes[ 0 ], nodes[ 1 ], nodes[ 2 ] , nodes[ 3 ], + nodes[ 4 ], nodes[ 5 ], nodes[ 6 ] , nodes[ 7 ]); + else if ( nbNodes == 6 ) + aMesh->AddVolume( nodes[ 0 ], nodes[ 1 ], nodes[ 2 ] , nodes[ 3 ], + nodes[ 4 ], nodes[ 5 ]); + else if ( nbNodes == 5 ) + aMesh->AddVolume( nodes[ 0 ], nodes[ 1 ], nodes[ 2 ] , nodes[ 3 ], + nodes[ 4 ]); + break; + default:; + } + } + else + { + // reverse element as it was reversed by transformation + if ( nbNodes > 2 ) + aMesh->ChangeElementNodes( elem, nodes, nbNodes ); + } + } +} + +//======================================================================= +//function : FindCoincidentNodes +//purpose : Return list of group of nodes close to each other within theTolerance +//======================================================================= + +void SMESH_MeshEditor::FindCoincidentNodes (const double theTolerance, + TListOfListOfNodes & theGroupsOfNodes) +{ + double tol2 = theTolerance * theTolerance; + + list nodes; + SMDS_NodeIteratorPtr nIt = GetMeshDS()->nodesIterator(); + while ( nIt->more() ) + nodes.push_back( nIt->next() ); + + list::iterator it2, it1 = nodes.begin(); + for ( ; it1 != nodes.end(); it1++ ) + { + const SMDS_MeshNode* n1 = *it1; + gp_Pnt p1( n1->X(), n1->Y(), n1->Z() ); + + list * groupPtr = 0; + it2 = it1; + for ( it2++; it2 != nodes.end(); it2++ ) + { + const SMDS_MeshNode* n2 = *it2; + gp_Pnt p2( n2->X(), n2->Y(), n2->Z() ); + if ( p1.SquareDistance( p2 ) <= tol2 ) + { + if ( !groupPtr ) { + theGroupsOfNodes.push_back( list() ); + groupPtr = & theGroupsOfNodes.back(); + groupPtr->push_back( n1 ); + } + groupPtr->push_back( n2 ); + it2 = nodes.erase( it2 ); + it2--; + } + } + } +} + +//======================================================================= +//function : MergeNodes +//purpose : In each group, the cdr of nodes are substituted by the first one +// in all elements. +//======================================================================= + +void SMESH_MeshEditor::MergeNodes (TListOfListOfNodes & theGroupsOfNodes) +{ + SMESHDS_Mesh* aMesh = GetMeshDS(); + + TNodeNodeMap nodeNodeMap; // node to replace - new node + set elems; // all elements with changed nodes + list< int > rmElemIds, rmNodeIds; + + // Fill nodeNodeMap and elems + + TListOfListOfNodes::iterator grIt = theGroupsOfNodes.begin(); + for ( ; grIt != theGroupsOfNodes.end(); grIt++ ) + { + list& nodes = *grIt; + list::iterator nIt = nodes.begin(); + const SMDS_MeshNode* nToKeep = *nIt; + for ( ; nIt != nodes.end(); nIt++ ) + { + const SMDS_MeshNode* nToRemove = *nIt; + nodeNodeMap.insert( TNodeNodeMap::value_type( nToRemove, nToKeep )); + if ( nToRemove != nToKeep ) { + rmNodeIds.push_back( nToRemove->GetID() ); + addToSameGroups( nToKeep, nToRemove, aMesh ); + } + + SMDS_ElemIteratorPtr invElemIt = nToRemove->GetInverseElementIterator(); + while ( invElemIt->more() ) + elems.insert( invElemIt->next() ); + } + } + // Change element nodes or remove an element + + set::iterator eIt = elems.begin(); + for ( ; eIt != elems.end(); eIt++ ) + { + const SMDS_MeshElement* elem = *eIt; + int nbNodes = elem->NbNodes(); + int aShapeId = FindShape( elem ); + + set nodeSet; + const SMDS_MeshNode* curNodes[ nbNodes ], *uniqueNodes[ nbNodes ]; + int iUnique = 0, iCur = 0, nbRepl = 0, iRepl [ nbNodes ]; + + // get new seq of nodes + SMDS_ElemIteratorPtr itN = elem->nodesIterator(); + while ( itN->more() ) + { + const SMDS_MeshNode* n = + static_cast( itN->next() ); + + TNodeNodeMap::iterator nnIt = nodeNodeMap.find( n ); + if ( nnIt != nodeNodeMap.end() ) { // n sticks + n = (*nnIt).second; + iRepl[ nbRepl++ ] = iCur; + } + curNodes[ iCur ] = n; + bool isUnique = nodeSet.insert( n ).second; + if ( isUnique ) + uniqueNodes[ iUnique++ ] = n; + iCur++; + } + + // Analyse element topology after replacement + + bool isOk = true; + int nbUniqueNodes = nodeSet.size(); + if ( nbNodes != nbUniqueNodes ) // some nodes stick + { + switch ( nbNodes ) { + case 2: ///////////////////////////////////// EDGE + isOk = false; break; + case 3: ///////////////////////////////////// TRIANGLE + isOk = false; break; + case 4: + if ( elem->GetType() == SMDSAbs_Volume ) // TETRAHEDRON + isOk = false; + else { //////////////////////////////////// QUADRANGLE + if ( nbUniqueNodes < 3 ) + isOk = false; + else if ( nbRepl == 2 && iRepl[ 1 ] - iRepl[ 0 ] == 2 ) + isOk = false; // opposite nodes stick + } + break; + case 6: ///////////////////////////////////// PENTAHEDRON + if ( nbUniqueNodes == 4 ) { + // ---------------------------------> tetrahedron + if (nbRepl == 3 && + iRepl[ 0 ] > 2 && iRepl[ 1 ] > 2 && iRepl[ 2 ] > 2 ) { + // all top nodes stick: reverse a bottom + uniqueNodes[ 0 ] = curNodes [ 1 ]; + uniqueNodes[ 1 ] = curNodes [ 0 ]; + } + else if (nbRepl == 3 && + iRepl[ 0 ] < 3 && iRepl[ 1 ] < 3 && iRepl[ 2 ] < 3 ) { + // all bottom nodes stick: set a top before + uniqueNodes[ 3 ] = uniqueNodes [ 0 ]; + uniqueNodes[ 0 ] = curNodes [ 3 ]; + uniqueNodes[ 1 ] = curNodes [ 4 ]; + uniqueNodes[ 2 ] = curNodes [ 5 ]; + } + else if (nbRepl == 4 && + iRepl[ 2 ] - iRepl [ 0 ] == 3 && iRepl[ 3 ] - iRepl [ 1 ] == 3 ) { + // a lateral face turns into a line: reverse a bottom + uniqueNodes[ 0 ] = curNodes [ 1 ]; + uniqueNodes[ 1 ] = curNodes [ 0 ]; + } + else + isOk = false; + } + else if ( nbUniqueNodes == 5 ) { + // PENTAHEDRON --------------------> 2 tetrahedrons + if ( nbRepl == 2 && iRepl[ 1 ] - iRepl [ 0 ] == 3 ) { + // a bottom node sticks with a linked top one + // 1. + SMDS_MeshElement* newElem = + aMesh->AddVolume(curNodes[ 3 ], + curNodes[ 4 ], + curNodes[ 5 ], + curNodes[ iRepl[ 0 ] == 2 ? 1 : 2 ]); + if ( aShapeId ) + aMesh->SetMeshElementOnShape( newElem, aShapeId ); + // 2. : reverse a bottom + uniqueNodes[ 0 ] = curNodes [ 1 ]; + uniqueNodes[ 1 ] = curNodes [ 0 ]; + nbUniqueNodes = 4; + } + else + isOk = false; + } + else + isOk = false; + break; + case 8: { //////////////////////////////////// HEXAHEDRON + isOk = false; + SMDS_VolumeTool hexa (elem); + hexa.SetExternalNormal(); + if ( nbUniqueNodes == 4 && nbRepl == 6 ) { + //////////////////////// ---> tetrahedron + for ( int iFace = 0; iFace < 6; iFace++ ) { + const int *ind = hexa.GetFaceNodesIndices( iFace ); // indices of face nodes + if (curNodes[ind[ 0 ]] == curNodes[ind[ 1 ]] && + curNodes[ind[ 0 ]] == curNodes[ind[ 2 ]] && + curNodes[ind[ 0 ]] == curNodes[ind[ 3 ]] ) { + // one face turns into a point ... + int iOppFace = hexa.GetOppFaceIndex( iFace ); + ind = hexa.GetFaceNodesIndices( iOppFace ); + int nbStick = 0; + iUnique = 2; // reverse a tetrahedron bottom + for ( iCur = 0; iCur < 4 && nbStick < 2; iCur++ ) { + if ( curNodes[ind[ iCur ]] == curNodes[ind[ iCur + 1 ]] ) + nbStick++; + else if ( iUnique >= 0 ) + uniqueNodes[ iUnique-- ] = curNodes[ind[ iCur ]]; + } + if ( nbStick == 1 ) { + // ... and the opposite one - into a triangle. + // set a top node + ind = hexa.GetFaceNodesIndices( iFace ); + uniqueNodes[ 3 ] = curNodes[ind[ 0 ]]; + isOk = true; + } + break; + } + } + } + else if (nbUniqueNodes == 5 && nbRepl == 4 ) { + //////////////////// HEXAHEDRON ---> 2 tetrahedrons + for ( int iFace = 0; iFace < 6; iFace++ ) { + const int *ind = hexa.GetFaceNodesIndices( iFace ); // indices of face nodes + if (curNodes[ind[ 0 ]] == curNodes[ind[ 1 ]] && + curNodes[ind[ 0 ]] == curNodes[ind[ 2 ]] && + curNodes[ind[ 0 ]] == curNodes[ind[ 3 ]] ) { + // one face turns into a point ... + int iOppFace = hexa.GetOppFaceIndex( iFace ); + ind = hexa.GetFaceNodesIndices( iOppFace ); + int nbStick = 0; + iUnique = 2; // reverse a tetrahedron 1 bottom + for ( iCur = 0; iCur < 4 && nbStick == 0; iCur++ ) { + if ( curNodes[ind[ iCur ]] == curNodes[ind[ iCur + 1 ]] ) + nbStick++; + else if ( iUnique >= 0 ) + uniqueNodes[ iUnique-- ] = curNodes[ind[ iCur ]]; + } + if ( nbStick == 0 ) { + // ... and the opposite one is a quadrangle + // set a top node + const int* indTop = hexa.GetFaceNodesIndices( iFace ); + uniqueNodes[ 3 ] = curNodes[indTop[ 0 ]]; + nbUniqueNodes = 4; + // tetrahedron 2 + SMDS_MeshElement* newElem = + aMesh->AddVolume(curNodes[ind[ 0 ]], + curNodes[ind[ 3 ]], + curNodes[ind[ 2 ]], + curNodes[indTop[ 0 ]]); + if ( aShapeId ) + aMesh->SetMeshElementOnShape( newElem, aShapeId ); + isOk = true; + } + break; + } + } + } + else if ( nbUniqueNodes == 6 && nbRepl == 4 ) { + ////////////////// HEXAHEDRON ---> 2 tetrahedrons or 1 prism + // find indices of quad and tri faces + int iQuadFace[ 6 ], iTriFace[ 6 ], nbQuad = 0, nbTri = 0, iFace; + for ( iFace = 0; iFace < 6; iFace++ ) { + const int *ind = hexa.GetFaceNodesIndices( iFace ); // indices of face nodes + nodeSet.clear(); + for ( iCur = 0; iCur < 4; iCur++ ) + nodeSet.insert( curNodes[ind[ iCur ]] ); + nbUniqueNodes = nodeSet.size(); + if ( nbUniqueNodes == 3 ) + iTriFace[ nbTri++ ] = iFace; + else if ( nbUniqueNodes == 4 ) + iQuadFace[ nbQuad++ ] = iFace; + } + if (nbQuad == 2 && nbTri == 4 && + hexa.GetOppFaceIndex( iQuadFace[ 0 ] ) == iQuadFace[ 1 ]) { + // 2 opposite quadrangles stuck with a diagonal; + // sample groups of merged indices: (0-4)(2-6) + // --------------------------------------------> 2 tetrahedrons + const int *ind1 = hexa.GetFaceNodesIndices( iQuadFace[ 0 ]); // indices of quad1 nodes + const int *ind2 = hexa.GetFaceNodesIndices( iQuadFace[ 1 ]); + int i0, i1d, i2, i3d, i0t, i2t; // d-daigonal, t-top + if (curNodes[ind1[ 0 ]] == curNodes[ind2[ 0 ]] && + curNodes[ind1[ 2 ]] == curNodes[ind2[ 2 ]]) { + // stuck with 0-2 diagonal + i0 = ind1[ 3 ]; + i1d = ind1[ 0 ]; + i2 = ind1[ 1 ]; + i3d = ind1[ 2 ]; + i0t = ind2[ 1 ]; + i2t = ind2[ 3 ]; + } + else if (curNodes[ind1[ 1 ]] == curNodes[ind2[ 3 ]] && + curNodes[ind1[ 3 ]] == curNodes[ind2[ 1 ]]) { + // stuck with 1-3 diagonal + i0 = ind1[ 0 ]; + i1d = ind1[ 1 ]; + i2 = ind1[ 2 ]; + i3d = ind1[ 3 ]; + i0t = ind2[ 0 ]; + i2t = ind2[ 1 ]; + } + else { + ASSERT(0); + } + // tetrahedron 1 + uniqueNodes[ 0 ] = curNodes [ i0 ]; + uniqueNodes[ 1 ] = curNodes [ i1d ]; + uniqueNodes[ 2 ] = curNodes [ i3d ]; + uniqueNodes[ 3 ] = curNodes [ i0t ]; + nbUniqueNodes = 4; + // tetrahedron 2 + SMDS_MeshElement* newElem = aMesh->AddVolume(curNodes[ i1d ], + curNodes[ i2 ], + curNodes[ i3d ], + curNodes[ i2t ]); + if ( aShapeId ) + aMesh->SetMeshElementOnShape( newElem, aShapeId ); + isOk = true; + } + else if (( nbTri == 2 && nbQuad == 3 ) || // merged (0-4)(1-5) + ( nbTri == 4 && nbQuad == 2 )) { // merged (7-4)(1-5) + // --------------------------------------------> prism + // find 2 opposite triangles + nbUniqueNodes = 6; + for ( iFace = 0; iFace + 1 < nbTri; iFace++ ) { + if ( hexa.GetOppFaceIndex( iTriFace[ iFace ] ) == iTriFace[ iFace + 1 ]) { + // find indices of kept and replaced nodes + // and fill unique nodes of 2 opposite triangles + const int *ind1 = hexa.GetFaceNodesIndices( iTriFace[ iFace ]); + const int *ind2 = hexa.GetFaceNodesIndices( iTriFace[ iFace + 1 ]); + const SMDS_MeshNode** hexanodes = hexa.GetNodes(); + // fill unique nodes + iUnique = 0; + isOk = true; + for ( iCur = 0; iCur < 4 && isOk; iCur++ ) { + const SMDS_MeshNode* n = curNodes[ind1[ iCur ]]; + const SMDS_MeshNode* nInit = hexanodes[ind1[ iCur ]]; + if ( n == nInit ) { + // iCur of a linked node of the opposite face (make normals co-directed): + int iCurOpp = ( iCur == 1 || iCur == 3 ) ? 4 - iCur : iCur; + // check that correspondent corners of triangles are linked + if ( !hexa.IsLinked( ind1[ iCur ], ind2[ iCurOpp ] )) + isOk = false; + else { + uniqueNodes[ iUnique ] = n; + uniqueNodes[ iUnique + 3 ] = curNodes[ind2[ iCurOpp ]]; + iUnique++; + } + } + } + break; + } + } + } + } // if ( nbUniqueNodes == 6 && nbRepl == 4 ) + break; + } // HEXAHEDRON + + default: + isOk = false; + } // switch ( nbNodes ) + + } // if ( nbNodes != nbUniqueNodes ) // some nodes stick + + if ( isOk ) + aMesh->ChangeElementNodes( elem, uniqueNodes, nbUniqueNodes ); + else + rmElemIds.push_back( elem->GetID() ); + + } // loop on elements + + // Remove equal nodes and bad elements + + Remove( rmNodeIds, true ); + Remove( rmElemIds, false ); + +} + +//======================================================================= +//function : MergeEqualElements +//purpose : Remove all but one of elements built on the same nodes. +//======================================================================= + +void SMESH_MeshEditor::MergeEqualElements() +{ + SMESHDS_Mesh* aMesh = GetMeshDS(); + + SMDS_EdgeIteratorPtr eIt = aMesh->edgesIterator(); + SMDS_FaceIteratorPtr fIt = aMesh->facesIterator(); + SMDS_VolumeIteratorPtr vIt = aMesh->volumesIterator(); + + list< int > rmElemIds; // IDs of elems to remove + + for ( int iDim = 1; iDim <= 3; iDim++ ) { + + set< set > setOfNodeSet; + + while ( 1 ) { + // get next element + const SMDS_MeshElement* elem = 0; + if ( iDim == 1 ) { + if ( eIt->more() ) elem = eIt->next(); + } else if ( iDim == 2 ) { + if ( fIt->more() ) elem = fIt->next(); + } else { + if ( vIt->more() ) elem = vIt->next(); + } + if ( !elem ) break; + + // get elem nodes + set nodeSet; + SMDS_ElemIteratorPtr nodeIt = elem->nodesIterator(); + while ( nodeIt->more() ) + nodeSet.insert( nodeIt->next() ); + + // check uniqueness + bool isUnique = setOfNodeSet.insert( nodeSet ).second; + if ( !isUnique ) + rmElemIds.push_back( elem->GetID() ); + } + } + + Remove( rmElemIds, false ); +} + +//======================================================================= +//function : findAdjacentFace +//purpose : +//======================================================================= +#define CHECKIND(max,val) {if ( (val) >= (max) ) \ + +static const SMDS_MeshElement* findAdjacentFace(const SMDS_MeshNode* n1, + const SMDS_MeshNode* n2, + const SMDS_MeshElement* elem) +{ + SMDS_ElemIteratorPtr invElemIt = n1->facesIterator(); + while ( invElemIt->more() ) { // loop on inverse elements of n1 + const SMDS_MeshElement* adjElem = invElemIt->next(); + if ( elem != adjElem ) { + // get face nodes and find index of n1 + int i1, nbN = adjElem->NbNodes(), iNode = 0; + const SMDS_MeshNode* faceNodes[ nbN ], *n; + SMDS_ElemIteratorPtr nIt = adjElem->nodesIterator(); + while ( nIt->more() ) { + faceNodes[ iNode ] = static_cast( nIt->next() ); + if ( faceNodes[ iNode++ ] == n1 ) + i1 = iNode - 1; + } + // find a n2 linked to n1 + for ( iNode = 0; iNode < 2; iNode++ ) { + if ( iNode ) // node before n1 + n = faceNodes[ i1 == 0 ? nbN - 1 : i1 - 1 ]; + else // node after n1 + n = faceNodes[ i1 + 1 == nbN ? 0 : i1 + 1 ]; + if ( n == n2 ) + return adjElem; + } + } + } + return 0; +} + +//======================================================================= +//function : findFreeBorder +//purpose : +//======================================================================= + +#define ControlFreeBorder SMESH::Controls::FreeEdges::IsFreeEdge + +static bool findFreeBorder (const SMDS_MeshNode* theFirstNode, + const SMDS_MeshNode* theSecondNode, + const SMDS_MeshNode* theLastNode, + list< const SMDS_MeshNode* > & theNodes, + list< const SMDS_MeshElement* > & theFaces) +{ + if ( !theFirstNode || !theSecondNode ) + return false; + // find border face between theFirstNode and theSecondNode + const SMDS_MeshElement* curElem = findAdjacentFace( theFirstNode, theSecondNode, 0 ); + if ( !curElem ) + return false; + + theFaces.push_back( curElem ); + theNodes.push_back( theFirstNode ); + theNodes.push_back( theSecondNode ); + + const SMDS_MeshNode* nodes [5], *nIgnore = theFirstNode, * nStart = theSecondNode; + set < const SMDS_MeshElement* > foundElems; + bool needTheLast = ( theLastNode != 0 ); + + while ( nStart != theLastNode ) + { + if ( nStart == theFirstNode ) + return !needTheLast; + + // find all free border faces sharing form nStart + + list< const SMDS_MeshElement* > curElemList; + list< const SMDS_MeshNode* > nStartList; + SMDS_ElemIteratorPtr invElemIt = nStart->facesIterator(); + while ( invElemIt->more() ) { + const SMDS_MeshElement* e = invElemIt->next(); + if ( e == curElem || foundElems.insert( e ).second ) + { + // get nodes + SMDS_ElemIteratorPtr nIt = e->nodesIterator(); + int iNode = 0, nbNodes = e->NbNodes(); + while ( nIt->more() ) + nodes[ iNode++ ] = static_cast( nIt->next() ); + nodes[ iNode ] = nodes[ 0 ]; + // check 2 links + for ( iNode = 0; iNode < nbNodes; iNode++ ) + if (((nodes[ iNode ] == nStart && nodes[ iNode + 1] != nIgnore ) || + (nodes[ iNode + 1] == nStart && nodes[ iNode ] != nIgnore )) && + ControlFreeBorder( &nodes[ iNode ], e->GetID() )) + { + nStartList.push_back( nodes[ iNode + ( nodes[ iNode ] == nStart ? 1 : 0 )]); + curElemList.push_back( e ); + } + } + } + // analyse the found + + int nbNewBorders = curElemList.size(); + if ( nbNewBorders == 0 ) { + // no free border furthermore + return !needTheLast; + } + else if ( nbNewBorders == 1 ) { + // one more element found + nIgnore = nStart; + nStart = nStartList.front(); + curElem = curElemList.front(); + theFaces.push_back( curElem ); + theNodes.push_back( nStart ); + } + else { + // several continuations found + list< const SMDS_MeshElement* >::iterator curElemIt; + list< const SMDS_MeshNode* >::iterator nStartIt; + // check if one of them reached the last node + if ( needTheLast ) { + for (curElemIt = curElemList.begin(), nStartIt = nStartList.begin(); + curElemIt!= curElemList.end(); + curElemIt++, nStartIt++ ) + if ( *nStartIt == theLastNode ) { + theFaces.push_back( *curElemIt ); + theNodes.push_back( *nStartIt ); + return true; + } + } + // find the best free border by the continuations + list contNodes[ 2 ], *cNL; + list contFaces[ 2 ], *cFL; + for (curElemIt = curElemList.begin(), nStartIt = nStartList.begin(); + curElemIt!= curElemList.end(); + curElemIt++, nStartIt++ ) + { + cNL = & contNodes[ contNodes[0].empty() ? 0 : 1 ]; + cFL = & contFaces[ contFaces[0].empty() ? 0 : 1 ]; + // find one more free border + if ( ! findFreeBorder( nIgnore, nStart, theLastNode, *cNL, *cFL )) { + cNL->clear(); + cFL->clear(); + } + else if ( !contNodes[0].empty() && !contNodes[1].empty() ) { + // choice: clear a worse one + int iLongest = ( contNodes[0].size() < contNodes[1].size() ? 1 : 0 ); + int iWorse = ( needTheLast ? 1 - iLongest : iLongest ); + contNodes[ iWorse ].clear(); + contFaces[ iWorse ].clear(); + } + } + if ( contNodes[0].empty() && contNodes[1].empty() ) + return false; + + // append the best free border + cNL = & contNodes[ contNodes[0].empty() ? 1 : 0 ]; + cFL = & contFaces[ contFaces[0].empty() ? 1 : 0 ]; + theNodes.pop_back(); // remove nIgnore + theNodes.pop_back(); // remove nStart + theFaces.pop_back(); // remove curElem + list< const SMDS_MeshNode* >::iterator nIt = cNL->begin(); + list< const SMDS_MeshElement* >::iterator fIt = cFL->begin(); + for ( ; nIt != cNL->end(); nIt++ ) theNodes.push_back( *nIt ); + for ( ; fIt != cFL->end(); fIt++ ) theFaces.push_back( *fIt ); + return true; + + } // several continuations found + } // while ( nStart != theLastNode ) + + return true; +} + +//======================================================================= +//function : CheckFreeBorderNodes +//purpose : Return true if the tree nodes are on a free border +//======================================================================= + +bool SMESH_MeshEditor::CheckFreeBorderNodes(const SMDS_MeshNode* theNode1, + const SMDS_MeshNode* theNode2, + const SMDS_MeshNode* theNode3) +{ + list< const SMDS_MeshNode* > nodes; + list< const SMDS_MeshElement* > faces; + return findFreeBorder( theNode1, theNode2, theNode3, nodes, faces); +} + +//======================================================================= +//function : SewFreeBorder +//purpose : +//======================================================================= + +SMESH_MeshEditor::Sew_Error + SMESH_MeshEditor::SewFreeBorder (const SMDS_MeshNode* theBordFirstNode, + const SMDS_MeshNode* theBordSecondNode, + const SMDS_MeshNode* theBordLastNode, + const SMDS_MeshNode* theSideFirstNode, + const SMDS_MeshNode* theSideSecondNode, + const SMDS_MeshNode* theSideThirdNode, + bool theSideIsFreeBorder) +{ + MESSAGE("::SewFreeBorder()"); + Sew_Error aResult = SEW_OK; + + // ==================================== + // find side nodes and elements + // ==================================== + + list< const SMDS_MeshNode* > nSide[ 2 ]; + list< const SMDS_MeshElement* > eSide[ 2 ]; + list< const SMDS_MeshNode* >::iterator nIt[ 2 ]; + list< const SMDS_MeshElement* >::iterator eIt[ 2 ]; + + // Free border 1 + // -------------- + if (!findFreeBorder(theBordFirstNode,theBordSecondNode,theBordLastNode, + nSide[0], eSide[0])) { + MESSAGE(" Free Border 1 not found " ); + aResult = SEW_BORDER1_NOT_FOUND; + } + if (theSideIsFreeBorder) + { + // Free border 2 + // -------------- + if (!findFreeBorder(theSideFirstNode, theSideSecondNode, theSideThirdNode, + nSide[1], eSide[1])) { + MESSAGE(" Free Border 2 not found " ); + aResult = ( aResult != SEW_OK ? SEW_BOTH_BORDERS_NOT_FOUND : SEW_BORDER2_NOT_FOUND ); + } + } + if ( aResult != SEW_OK ) + return aResult; + + if (!theSideIsFreeBorder) + { + // Side 2 + // -------------- + + // ------------------------------------------------------------------------- + // Algo: + // 1. If nodes to merge are not coincident, move nodes of the free border + // from the coord sys defined by the direction from the first to last + // nodes of the border to the correspondent sys of the side 2 + // 2. On the side 2, find the links most co-directed with the correspondent + // links of the free border + // ------------------------------------------------------------------------- + + // 1. Since sewing may brake if there are volumes to split on the side 2, + // we wont move nodes but just compute new coordinates for them + typedef map TNodeXYZMap; + TNodeXYZMap nBordXYZ; + list< const SMDS_MeshNode* >& bordNodes = nSide[ 0 ]; + list< const SMDS_MeshNode* >::iterator nBordIt; + + gp_XYZ Pb1( theBordFirstNode->X(), theBordFirstNode->Y(), theBordFirstNode->Z() ); + gp_XYZ Pb2( theBordLastNode->X(), theBordLastNode->Y(), theBordLastNode->Z() ); + gp_XYZ Ps1( theSideFirstNode->X(), theSideFirstNode->Y(), theSideFirstNode->Z() ); + gp_XYZ Ps2( theSideSecondNode->X(), theSideSecondNode->Y(), theSideSecondNode->Z() ); + double tol2 = 1.e-8; + gp_Vec Vbs1( Pb1 - Ps1 ),Vbs2( Pb2 - Ps2 ); + if ( Vbs1.SquareMagnitude() > tol2 || Vbs2.SquareMagnitude() > tol2 ) + { + // Need node movement. + + // find X and Z axes to create trsf + gp_Vec Zb( Pb1 - Pb2 ), Zs( Ps1 - Ps2 ); + gp_Vec X = Zs ^ Zb; + if ( X.SquareMagnitude() <= gp::Resolution() * gp::Resolution() ) + // Zb || Zs + X = gp_Ax2( gp::Origin(), Zb ).XDirection(); + + // coord systems + gp_Ax3 toBordAx( Pb1, Zb, X ); + gp_Ax3 fromSideAx( Ps1, Zs, X ); + gp_Ax3 toGlobalAx( gp::Origin(), gp::DZ(), gp::DX() ); + // set trsf + gp_Trsf toBordSys, fromSide2Sys; + toBordSys.SetTransformation( toBordAx ); + fromSide2Sys.SetTransformation( fromSideAx, toGlobalAx ); + fromSide2Sys.SetScaleFactor( Zs.Magnitude() / Zb.Magnitude() ); + + // move + for ( nBordIt = bordNodes.begin(); nBordIt != bordNodes.end(); nBordIt++ ) { + const SMDS_MeshNode* n = *nBordIt; + gp_XYZ xyz( n->X(),n->Y(),n->Z() ); + toBordSys.Transforms( xyz ); + fromSide2Sys.Transforms( xyz ); + nBordXYZ.insert( TNodeXYZMap::value_type( n, xyz )); + } + } + else + { + // just insert nodes XYZ in the nBordXYZ map + for ( nBordIt = bordNodes.begin(); nBordIt != bordNodes.end(); nBordIt++ ) { + const SMDS_MeshNode* n = *nBordIt; + nBordXYZ.insert( TNodeXYZMap::value_type( n, gp_XYZ( n->X(),n->Y(),n->Z() ))); + } + } + + // 2. On the side 2, find the links most co-directed with the correspondent + // links of the free border + + list< const SMDS_MeshElement* >& sideElems = eSide[ 1 ]; + list< const SMDS_MeshNode* >& sideNodes = nSide[ 1 ]; + sideNodes.push_back( theSideFirstNode ); + + bool hasVolumes = false; + LinkID_Gen aLinkID_Gen( GetMeshDS() ); + set foundSideLinkIDs, checkedLinkIDs; + SMDS_VolumeTool volume; + const SMDS_MeshNode* faceNodes[ 4 ]; + + const SMDS_MeshNode* sideNode; + const SMDS_MeshElement* sideElem; + const SMDS_MeshNode* prevSideNode = theSideFirstNode; + const SMDS_MeshNode* prevBordNode = theBordFirstNode; + nBordIt = bordNodes.begin(); + nBordIt++; + // border node position and border link direction to compare with + gp_XYZ bordPos = nBordXYZ[ *nBordIt ]; + gp_XYZ bordDir = bordPos - nBordXYZ[ prevBordNode ]; + // choose next side node by link direction or by closeness to + // the current border node: + bool searchByDir = ( *nBordIt != theBordLastNode ); + do { + // find the next node on the Side 2 + sideNode = 0; + double maxDot = -DBL_MAX, minDist = DBL_MAX; + long linkID; + checkedLinkIDs.clear(); + gp_XYZ prevXYZ( prevSideNode->X(), prevSideNode->Y(), prevSideNode->Z() ); + + SMDS_ElemIteratorPtr invElemIt + = prevSideNode->GetInverseElementIterator(); + while ( invElemIt->more() ) { // loop on inverse elements on the Side 2 + const SMDS_MeshElement* elem = invElemIt->next(); + // prepare data for a loop on links, of a face or a volume + int iPrevNode, iNode = 0, nbNodes = elem->NbNodes(); + bool isVolume = volume.Set( elem ); + const SMDS_MeshNode** nodes = isVolume ? volume.GetNodes() : faceNodes; + if ( isVolume ) // --volume + hasVolumes = true; + else if ( nbNodes > 2 ) { // --face + // retrieve all face nodes and find iPrevNode - an index of the prevSideNode + SMDS_ElemIteratorPtr nIt = elem->nodesIterator(); + while ( nIt->more() ) { + nodes[ iNode ] = static_cast( nIt->next() ); + if ( nodes[ iNode++ ] == prevSideNode ) + iPrevNode = iNode - 1; + } + // there are 2 links to check + nbNodes = 2; + } + else // --edge + continue; + // loop on links, to be precise, on the second node of links + for ( iNode = 0; iNode < nbNodes; iNode++ ) { + const SMDS_MeshNode* n = nodes[ iNode ]; + if ( isVolume ) { + if ( !volume.IsLinked( n, prevSideNode )) + continue; + } else { + if ( iNode ) // a node before prevSideNode + n = nodes[ iPrevNode == 0 ? elem->NbNodes() - 1 : iPrevNode - 1 ]; + else // a node after prevSideNode + n = nodes[ iPrevNode + 1 == elem->NbNodes() ? 0 : iPrevNode + 1 ]; + } + // check if this link was already used + long iLink = aLinkID_Gen.GetLinkID( prevSideNode, n ); + bool isJustChecked = !checkedLinkIDs.insert( iLink ).second; + if (!isJustChecked && + foundSideLinkIDs.find( iLink ) == foundSideLinkIDs.end() ) { + // test a link geometrically + gp_XYZ nextXYZ ( n->X(), n->Y(), n->Z() ); + bool linkIsBetter = false; + double dot, dist; + if ( searchByDir ) { // choose most co-directed link + dot = bordDir * ( nextXYZ - prevXYZ ).Normalized(); + linkIsBetter = ( dot > maxDot ); + } + else { // choose link with the node closest to bordPos + dist = ( nextXYZ - bordPos ).SquareModulus(); + linkIsBetter = ( dist < minDist ); + } + if ( linkIsBetter ) { + maxDot = dot; + minDist = dist; + linkID = iLink; + sideNode = n; + sideElem = elem; + } + } + } + } // loop on inverse elements of prevSideNode + + if ( !sideNode ) { + MESSAGE(" Cant find path by links of the Side 2 "); + return SEW_BAD_SIDE_NODES; + } + sideNodes.push_back( sideNode ); + sideElems.push_back( sideElem ); + foundSideLinkIDs.insert ( linkID ); + prevSideNode = sideNode; + + if ( *nBordIt == theBordLastNode ) + searchByDir = false; + else { + // find the next border link to compare with + gp_XYZ sidePos( sideNode->X(), sideNode->Y(), sideNode->Z() ); + searchByDir = ( bordDir * ( sidePos - bordPos ) <= 0 ); + while ( *nBordIt != theBordLastNode && !searchByDir ) { + prevBordNode = *nBordIt; + nBordIt++; + bordPos = nBordXYZ[ *nBordIt ]; + bordDir = bordPos - nBordXYZ[ prevBordNode ]; + searchByDir = ( bordDir * ( sidePos - bordPos ) <= 0 ); + } + } + } + while ( sideNode != theSideSecondNode ); + + if ( hasVolumes && sideNodes.size () != bordNodes.size() ) { + MESSAGE("VOLUME SPLITTING IS FORBIDDEN"); + return SEW_VOLUMES_TO_SPLIT; // volume splitting is forbidden + } + } // end nodes search on the side 2 + + // ============================ + // sew the border to the side 2 + // ============================ + + int nbNodes[] = { nSide[0].size(), nSide[1].size() }; + int maxNbNodes = Max( nbNodes[0], nbNodes[1] ); + + TListOfListOfNodes nodeGroupsToMerge; + if ( nbNodes[0] == nbNodes[1] || + ( theSideIsFreeBorder && !theSideThirdNode)) { + + // all nodes are to be merged + + for (nIt[0] = nSide[0].begin(), nIt[1] = nSide[1].begin(); + nIt[0] != nSide[0].end() && nIt[1] != nSide[1].end(); + nIt[0]++, nIt[1]++ ) + { + nodeGroupsToMerge.push_back( list() ); + nodeGroupsToMerge.back().push_back( *nIt[1] ); // to keep + nodeGroupsToMerge.back().push_back( *nIt[0] ); // tp remove + } + } + else { + + // insert new nodes into the border and the side to get equal nb of segments + + // get normalized parameters of nodes on the borders + double param[ 2 ][ maxNbNodes ]; + int iNode, iBord; + for ( iBord = 0; iBord < 2; iBord++ ) { // loop on 2 borders + list< const SMDS_MeshNode* >& nodes = nSide[ iBord ]; + list< const SMDS_MeshNode* >::iterator nIt = nodes.begin(); + const SMDS_MeshNode* nPrev = *nIt; + double bordLength = 0; + for ( iNode = 0; nIt != nodes.end(); nIt++, iNode++ ) { // loop on border nodes + const SMDS_MeshNode* nCur = *nIt; + gp_XYZ segment (nCur->X() - nPrev->X(), + nCur->Y() - nPrev->Y(), + nCur->Z() - nPrev->Z()); + double segmentLen = segment.Modulus(); + bordLength += segmentLen; + param[ iBord ][ iNode ] = bordLength; + nPrev = nCur; + } + // normalize within [0,1] + for ( iNode = 0; iNode < nbNodes[ iBord ]; iNode++ ) { + param[ iBord ][ iNode ] /= bordLength; + } + } + + // loop on border segments + const SMDS_MeshNode *nPrev[ 2 ] = { 0, 0 }; + int i[ 2 ] = { 0, 0 }; + nIt[0] = nSide[0].begin(); eIt[0] = eSide[0].begin(); + nIt[1] = nSide[1].begin(); eIt[1] = eSide[1].begin(); + + TElemOfNodeListMap insertMap; + TElemOfNodeListMap::iterator insertMapIt; + // insertMap is + // key: elem to insert nodes into + // value: 2 nodes to insert between + nodes to be inserted + do { + bool next[ 2 ] = { false, false }; + + // find min adjacent segment length after sewing + double nextParam = 10., prevParam = 0; + for ( iBord = 0; iBord < 2; iBord++ ) { // loop on 2 borders + if ( i[ iBord ] + 1 < nbNodes[ iBord ]) + nextParam = Min( nextParam, param[iBord][ i[iBord] + 1 ]); + if ( i[ iBord ] > 0 ) + prevParam = Max( prevParam, param[iBord][ i[iBord] - 1 ]); + } + double minParam = Min( param[ 0 ][ i[0] ], param[ 1 ][ i[1] ]); + double maxParam = Max( param[ 0 ][ i[0] ], param[ 1 ][ i[1] ]); + double minSegLen = Min( nextParam - minParam, maxParam - prevParam ); + + // choose to insert or to merge nodes + double du = param[ 1 ][ i[1] ] - param[ 0 ][ i[0] ]; + if ( Abs( du ) <= minSegLen * 0.2 ) { + // merge + // ------ + nodeGroupsToMerge.push_back( list() ); + const SMDS_MeshNode* n0 = *nIt[0]; + const SMDS_MeshNode* n1 = *nIt[1]; + nodeGroupsToMerge.back().push_back( n1 ); + nodeGroupsToMerge.back().push_back( n0 ); + // position of node of the border changes due to merge + param[ 0 ][ i[0] ] += du; + // move n1 for the sake of elem shape evaluation during insertion. + // n1 will be removed by MergeNodes() anyway + const_cast( n0 )->setXYZ( n1->X(), n1->Y(), n1->Z() ); + next[0] = next[1] = true; + } + else { + // insert + // ------ + int intoBord = ( du < 0 ) ? 0 : 1; + const SMDS_MeshElement* elem = *eIt[ intoBord ]; + const SMDS_MeshNode* n1 = nPrev[ intoBord ]; + const SMDS_MeshNode* n2 = *nIt[ intoBord ]; + const SMDS_MeshNode* nIns = *nIt[ 1 - intoBord ]; + if ( intoBord == 1 ) { + // move node of the border to be on a link of elem of the side + gp_XYZ p1 (n1->X(), n1->Y(), n1->Z()); + gp_XYZ p2 (n2->X(), n2->Y(), n2->Z()); + double ratio = du / ( param[ 1 ][ i[1] ] - param[ 1 ][ i[1]-1 ]); + gp_XYZ p = p2 * ( 1 - ratio ) + p1 * ratio; + GetMeshDS()->MoveNode( nIns, p.X(), p.Y(), p.Z() ); + } + insertMapIt = insertMap.find( elem ); + bool notFound = ( insertMapIt == insertMap.end() ); + bool otherLink = ( !notFound && (*insertMapIt).second.front() != n1 ); + if ( otherLink ) { + // insert into another link of the same element: + // 1. perform insertion into the other link of the elem + list & nodeList = (*insertMapIt).second; + const SMDS_MeshNode* n12 = nodeList.front(); nodeList.pop_front(); + const SMDS_MeshNode* n22 = nodeList.front(); nodeList.pop_front(); + InsertNodesIntoLink( elem, n12, n22, nodeList ); + // 2. perform insertion into the link of adjacent faces + while (true) { + const SMDS_MeshElement* adjElem = findAdjacentFace( n12, n22, elem ); + if ( adjElem ) + InsertNodesIntoLink( adjElem, n12, n22, nodeList ); + else + break; + } + // 3. find an element appeared on n1 and n2 after the insertion + insertMap.erase( elem ); + elem = findAdjacentFace( n1, n2, 0 ); + } + if ( notFound || otherLink ) { + // add element and nodes of the side into the insertMap + insertMapIt = insertMap.insert + ( TElemOfNodeListMap::value_type( elem, list() )).first; + (*insertMapIt).second.push_back( n1 ); + (*insertMapIt).second.push_back( n2 ); + } + // add node to be inserted into elem + (*insertMapIt).second.push_back( nIns ); + next[ 1 - intoBord ] = true; + } + + // go to the next segment + for ( iBord = 0; iBord < 2; iBord++ ) { // loop on 2 borders + if ( next[ iBord ] ) { + if ( i[ iBord ] != 0 && eIt[ iBord ] != eSide[ iBord ].end()) + eIt[ iBord ]++; + nPrev[ iBord ] = *nIt[ iBord ]; + nIt[ iBord ]++; i[ iBord ]++; + } + } + } + while ( nIt[0] != nSide[0].end() && nIt[1] != nSide[1].end()); + + // perform insertion of nodes into elements + + for (insertMapIt = insertMap.begin(); + insertMapIt != insertMap.end(); + insertMapIt++ ) + { + const SMDS_MeshElement* elem = (*insertMapIt).first; + list & nodeList = (*insertMapIt).second; + const SMDS_MeshNode* n1 = nodeList.front(); nodeList.pop_front(); + const SMDS_MeshNode* n2 = nodeList.front(); nodeList.pop_front(); + + InsertNodesIntoLink( elem, n1, n2, nodeList ); + + if ( !theSideIsFreeBorder ) { + // look for and insert nodes into the faces adjacent to elem + while (true) { + const SMDS_MeshElement* adjElem = findAdjacentFace( n1, n2, elem ); + if ( adjElem ) + InsertNodesIntoLink( adjElem, n1, n2, nodeList ); + else + break; + } + } + } + + } // end: insert new nodes + + MergeNodes ( nodeGroupsToMerge ); + + return aResult; +} + +//======================================================================= +//function : InsertNodesIntoLink +//purpose : insert theNodesToInsert into theFace between theBetweenNode1 +// and theBetweenNode2 and split theElement +//======================================================================= + +void SMESH_MeshEditor::InsertNodesIntoLink(const SMDS_MeshElement* theFace, + const SMDS_MeshNode* theBetweenNode1, + const SMDS_MeshNode* theBetweenNode2, + list& theNodesToInsert) +{ + if ( theFace->GetType() != SMDSAbs_Face ) return; + + // find indices of 2 link nodes and of the rest nodes + int iNode = 0, il1, il2, i3, i4; + il1 = il2 = i3 = i4 = -1; + const SMDS_MeshNode* nodes[ 8 ]; + SMDS_ElemIteratorPtr nodeIt = theFace->nodesIterator(); + while ( nodeIt->more() ) { + const SMDS_MeshNode* n = static_cast( nodeIt->next() ); + if ( n == theBetweenNode1 ) + il1 = iNode; + else if ( n == theBetweenNode2 ) + il2 = iNode; + else if ( i3 < 0 ) + i3 = iNode; + else + i4 = iNode; + nodes[ iNode++ ] = n; + } + if ( il1 < 0 || il2 < 0 || i3 < 0 ) + return ; + + // arrange link nodes to go one after another regarding the face orientation + bool reverse = ( Abs( il2 - il1 ) == 1 ? il2 < il1 : il1 < il2 ); + if ( reverse ) { + iNode = il1; + il1 = il2; + il2 = iNode; + theNodesToInsert.reverse(); + } + // check that not link nodes of a quadrangles are in good order + int nbFaceNodes = theFace->NbNodes(); + if ( nbFaceNodes == 4 && i4 - i3 != 1 ) { + iNode = i3; + i3 = i4; + i4 = iNode; + } + + // put theNodesToInsert between theBetweenNode1 and theBetweenNode2 + int nbLinkNodes = 2 + theNodesToInsert.size(); + const SMDS_MeshNode* linkNodes[ nbLinkNodes ]; + linkNodes[ 0 ] = nodes[ il1 ]; + linkNodes[ nbLinkNodes - 1 ] = nodes[ il2 ]; + list::iterator nIt = theNodesToInsert.begin(); + for ( iNode = 1; nIt != theNodesToInsert.end(); nIt++ ) { + linkNodes[ iNode++ ] = *nIt; + } + // decide how to split a quadrangle: compare possible variants + // and choose which of splits to be a quadrangle + int i1, i2, iSplit, nbSplits = nbLinkNodes - 1, iBestQuad; + if ( nbFaceNodes == 3 ) + { + iBestQuad = nbSplits; + i4 = i3; + } + else if ( nbFaceNodes == 4 ) + { + SMESH::Controls::NumericalFunctorPtr aCrit( new SMESH::Controls::AspectRatio); + double aBestRate = DBL_MAX; + for ( int iQuad = 0; iQuad < nbSplits; iQuad++ ) { + i1 = 0; i2 = 1; + double aBadRate = 0; + // evaluate elements quality + for ( iSplit = 0; iSplit < nbSplits; iSplit++ ) { + if ( iSplit == iQuad ) { + SMDS_FaceOfNodes quad (linkNodes[ i1++ ], + linkNodes[ i2++ ], + nodes[ i3 ], + nodes[ i4 ]); + aBadRate += getBadRate( &quad, aCrit ); + } + else { + SMDS_FaceOfNodes tria (linkNodes[ i1++ ], + linkNodes[ i2++ ], + nodes[ iSplit < iQuad ? i4 : i3 ]); + aBadRate += getBadRate( &tria, aCrit ); + } + } + // choice + if ( aBadRate < aBestRate ) { + iBestQuad = iQuad; + aBestRate = aBadRate; + } + } + } + + // create new elements + SMESHDS_Mesh *aMesh = GetMeshDS(); + int aShapeId = FindShape( theFace ); + + i1 = 0; i2 = 1; + for ( iSplit = 0; iSplit < nbSplits - 1; iSplit++ ) { + SMDS_MeshElement* newElem = 0; + if ( iSplit == iBestQuad ) + newElem = aMesh->AddFace (linkNodes[ i1++ ], + linkNodes[ i2++ ], + nodes[ i3 ], + nodes[ i4 ]); + else + newElem = aMesh->AddFace (linkNodes[ i1++ ], + linkNodes[ i2++ ], + nodes[ iSplit < iBestQuad ? i4 : i3 ]); + if ( aShapeId && newElem ) + aMesh->SetMeshElementOnShape( newElem, aShapeId ); + } + + // change nodes of theFace + const SMDS_MeshNode* newNodes[ 4 ]; + newNodes[ 0 ] = linkNodes[ i1 ]; + newNodes[ 1 ] = linkNodes[ i2 ]; + newNodes[ 2 ] = nodes[ iSplit >= iBestQuad ? i3 : i4 ]; + newNodes[ 3 ] = nodes[ i4 ]; + aMesh->ChangeElementNodes( theFace, newNodes, iSplit == iBestQuad ? 4 : 3 ); +} + +//======================================================================= +//function : SewSideElements +//purpose : +//======================================================================= + +SMESH_MeshEditor::Sew_Error + SMESH_MeshEditor::SewSideElements (set& theSide1, + set& theSide2, + const SMDS_MeshNode* theFirstNode1, + const SMDS_MeshNode* theFirstNode2, + const SMDS_MeshNode* theSecondNode1, + const SMDS_MeshNode* theSecondNode2) +{ + MESSAGE ("::::SewSideElements()"); + if ( theSide1.size() != theSide2.size() ) + return SEW_DIFF_NB_OF_ELEMENTS; + + Sew_Error aResult = SEW_OK; + // Algo: + // 1. Build set of faces representing each side + // 2. Find which nodes of the side 1 to merge with ones on the side 2 + // 3. Replace nodes in elements of the side 1 and remove replaced nodes + + // ======================================================================= + // 1. Build set of faces representing each side: + // ======================================================================= + // a. build set of nodes belonging to faces + // b. complete set of faces: find missing fices whose nodes are in set of nodes + // c. create temporary faces representing side of volumes if correspondent + // face does not exist + + SMESHDS_Mesh* aMesh = GetMeshDS(); + SMDS_Mesh aTmpFacesMesh; + set faceSet1, faceSet2; + set volSet1, volSet2; + set nodeSet1, nodeSet2; + set * faceSetPtr[] = { &faceSet1, &faceSet2 }; + set * volSetPtr[] = { &volSet1, &volSet2 }; + set * nodeSetPtr[] = { &nodeSet1, &nodeSet2 }; + set * elemSetPtr[] = { &theSide1, &theSide2 }; + int iSide, iFace, iNode; + + for ( iSide = 0; iSide < 2; iSide++ ) { + set * nodeSet = nodeSetPtr[ iSide ]; + set * elemSet = elemSetPtr[ iSide ]; + set * faceSet = faceSetPtr[ iSide ]; + set * volSet = volSetPtr [ iSide ]; + set::iterator vIt, eIt; + set::iterator nIt; + + // ----------------------------------------------------------- + // 1a. Collect nodes of existing faces + // and build set of face nodes in order to detect missing + // faces corresponing to sides of volumes + // ----------------------------------------------------------- + + set< set > setOfFaceNodeSet; + + // loop on the given element of a side + for (eIt = elemSet->begin(); eIt != elemSet->end(); eIt++ ) { + const SMDS_MeshElement* elem = *eIt; + if ( elem->GetType() == SMDSAbs_Face ) { + faceSet->insert( elem ); + set faceNodeSet; + SMDS_ElemIteratorPtr nodeIt = elem->nodesIterator(); + while ( nodeIt->more() ) { + const SMDS_MeshNode* n = static_cast( nodeIt->next() ); + nodeSet->insert( n ); + faceNodeSet.insert( n ); + } + setOfFaceNodeSet.insert( faceNodeSet ); + } + else if ( elem->GetType() == SMDSAbs_Volume ) + volSet->insert( elem ); + } + // ------------------------------------------------------------------------------ + // 1b. Complete set of faces: find missing fices whose nodes are in set of nodes + // ------------------------------------------------------------------------------ + + for ( nIt = nodeSet->begin(); nIt != nodeSet->end(); nIt++ ) { // loop on nodes of iSide + SMDS_ElemIteratorPtr fIt = (*nIt)->facesIterator(); + while ( fIt->more() ) { // loop on faces sharing a node + const SMDS_MeshElement* f = fIt->next(); + if ( faceSet->find( f ) == faceSet->end() ) { + // check if all nodes are in nodeSet and + // complete setOfFaceNodeSet if they are + set faceNodeSet; + SMDS_ElemIteratorPtr nodeIt = f->nodesIterator(); + bool allInSet = true; + while ( nodeIt->more() && allInSet ) { // loop on nodes of a face + const SMDS_MeshNode* n = static_cast( nodeIt->next() ); + if ( nodeSet->find( n ) == nodeSet->end() ) + allInSet = false; + else + faceNodeSet.insert( n ); + } + if ( allInSet ) { + faceSet->insert( f ); + setOfFaceNodeSet.insert( faceNodeSet ); + } + } + } + } + + // ------------------------------------------------------------------------- + // 1c. Create temporary faces representing sides of volumes if correspondent + // face does not exist + // ------------------------------------------------------------------------- + + if ( !volSet->empty() ) + { + //int nodeSetSize = nodeSet->size(); + + // loop on given volumes + for ( vIt = volSet->begin(); vIt != volSet->end(); vIt++ ) { + SMDS_VolumeTool vol (*vIt); + // loop on volume faces: find free faces + // -------------------------------------- + list freeFaceList; + for ( iFace = 0; iFace < vol.NbFaces(); iFace++ ) { + if ( !vol.IsFreeFace( iFace )) + continue; + // check if there is already a face with same nodes in a face set + const SMDS_MeshElement* aFreeFace = 0; + const SMDS_MeshNode** fNodes = vol.GetFaceNodes( iFace ); + int nbNodes = vol.NbFaceNodes( iFace ); + set faceNodeSet; + vol.GetFaceNodes( iFace, faceNodeSet ); + bool isNewFace = setOfFaceNodeSet.insert( faceNodeSet ).second; + if ( isNewFace ) { + // no such a face is given but it still can exist, check it + if ( nbNodes == 3 ) + aFreeFace = aMesh->FindFace( fNodes[0],fNodes[1],fNodes[2] ); + else + aFreeFace = aMesh->FindFace( fNodes[0],fNodes[1],fNodes[2],fNodes[3] ); + } + if ( !aFreeFace ) { + // create a temporary face + if ( nbNodes == 3 ) + aFreeFace = aTmpFacesMesh.AddFace( fNodes[0],fNodes[1],fNodes[2] ); + else + aFreeFace = aTmpFacesMesh.AddFace( fNodes[0],fNodes[1],fNodes[2],fNodes[3] ); + } + if ( aFreeFace ) + freeFaceList.push_back( aFreeFace ); + + } // loop on faces of a volume + + // choose one of several free faces + // -------------------------------------- + if ( freeFaceList.size() > 1 ) { + // choose a face having max nb of nodes shared by other elems of a side + int maxNbNodes = -1/*, nbExcludedFaces = 0*/; + list::iterator fIt = freeFaceList.begin(); + while ( fIt != freeFaceList.end() ) { // loop on free faces + int nbSharedNodes = 0; + SMDS_ElemIteratorPtr nodeIt = (*fIt)->nodesIterator(); + while ( nodeIt->more() ) { // loop on free face nodes + const SMDS_MeshNode* n = + static_cast( nodeIt->next() ); + SMDS_ElemIteratorPtr invElemIt = n->GetInverseElementIterator(); + while ( invElemIt->more() ) { + const SMDS_MeshElement* e = invElemIt->next(); + if ( faceSet->find( e ) != faceSet->end() ) + nbSharedNodes++; + if ( elemSet->find( e ) != elemSet->end() ) + nbSharedNodes++; + } + } + if ( nbSharedNodes >= maxNbNodes ) { + maxNbNodes = nbSharedNodes; + fIt++; + } + else + freeFaceList.erase( fIt++ ); // here fIt++ occures before erase + } + if ( freeFaceList.size() > 1 ) + { + // could not choose one face, use another way + // choose a face most close to the bary center of the opposite side + gp_XYZ aBC( 0., 0., 0. ); + set addedNodes; + set * elemSet2 = elemSetPtr[ 1 - iSide ]; + eIt = elemSet2->begin(); + for ( eIt = elemSet2->begin(); eIt != elemSet2->end(); eIt++ ) { + SMDS_ElemIteratorPtr nodeIt = (*eIt)->nodesIterator(); + while ( nodeIt->more() ) { // loop on free face nodes + const SMDS_MeshNode* n = + static_cast( nodeIt->next() ); + if ( addedNodes.insert( n ).second ) + aBC += gp_XYZ( n->X(),n->Y(),n->Z() ); + } + } + aBC /= addedNodes.size(); + double minDist = DBL_MAX; + fIt = freeFaceList.begin(); + while ( fIt != freeFaceList.end() ) { // loop on free faces + double dist = 0; + SMDS_ElemIteratorPtr nodeIt = (*fIt)->nodesIterator(); + while ( nodeIt->more() ) { // loop on free face nodes + const SMDS_MeshNode* n = + static_cast( nodeIt->next() ); + gp_XYZ p( n->X(),n->Y(),n->Z() ); + dist += ( aBC - p ).SquareModulus(); + } + if ( dist < minDist ) { + minDist = dist; + freeFaceList.erase( freeFaceList.begin(), fIt++ ); + } + else + fIt = freeFaceList.erase( fIt++ ); + } + } + } // choose one of several free faces of a volume + + if ( freeFaceList.size() == 1 ) { + const SMDS_MeshElement* aFreeFace = freeFaceList.front(); + faceSet->insert( aFreeFace ); + // complete a node set with nodes of a found free face +// for ( iNode = 0; iNode < ; iNode++ ) +// nodeSet->insert( fNodes[ iNode ] ); + } + + } // loop on volumes of a side + +// // complete a set of faces if new nodes in a nodeSet appeared +// // ---------------------------------------------------------- +// if ( nodeSetSize != nodeSet->size() ) { +// for ( ; nIt != nodeSet->end(); nIt++ ) { // loop on nodes of iSide +// SMDS_ElemIteratorPtr fIt = (*nIt)->facesIterator(); +// while ( fIt->more() ) { // loop on faces sharing a node +// const SMDS_MeshElement* f = fIt->next(); +// if ( faceSet->find( f ) == faceSet->end() ) { +// // check if all nodes are in nodeSet and +// // complete setOfFaceNodeSet if they are +// set faceNodeSet; +// SMDS_ElemIteratorPtr nodeIt = f->nodesIterator(); +// bool allInSet = true; +// while ( nodeIt->more() && allInSet ) { // loop on nodes of a face +// const SMDS_MeshNode* n = static_cast( nodeIt->next() ); +// if ( nodeSet->find( n ) == nodeSet->end() ) +// allInSet = false; +// else +// faceNodeSet.insert( n ); +// } +// if ( allInSet ) { +// faceSet->insert( f ); +// setOfFaceNodeSet.insert( faceNodeSet ); +// } +// } +// } +// } +// } + } // Create temporary faces, if there are volumes given + } // loop on sides + + if ( faceSet1.size() != faceSet2.size() ) { + // delete temporary faces: they are in reverseElements of actual nodes + SMDS_FaceIteratorPtr tmpFaceIt = aTmpFacesMesh.facesIterator(); + while ( tmpFaceIt->more() ) + aTmpFacesMesh.RemoveElement( tmpFaceIt->next() ); + MESSAGE("Diff nb of faces"); + return SEW_TOPO_DIFF_SETS_OF_ELEMENTS; + } + + // ============================================================ + // 2. Find nodes to merge: + // bind a node to remove to a node to put instead + // ============================================================ + + TNodeNodeMap nReplaceMap; // bind a node to remove to a node to put instead + if ( theFirstNode1 != theFirstNode2 ) + nReplaceMap.insert( TNodeNodeMap::value_type( theFirstNode1, theFirstNode2 )); + if ( theSecondNode1 != theSecondNode2 ) + nReplaceMap.insert( TNodeNodeMap::value_type( theSecondNode1, theSecondNode2 )); + + LinkID_Gen aLinkID_Gen( GetMeshDS() ); + set< long > linkIdSet; // links to process + linkIdSet.insert( aLinkID_Gen.GetLinkID( theFirstNode1, theSecondNode1 )); + + typedef pair< const SMDS_MeshNode*, const SMDS_MeshNode* > TPairOfNodes; + list< TPairOfNodes > linkList[2]; + linkList[0].push_back( TPairOfNodes( theFirstNode1, theSecondNode1 )); + linkList[1].push_back( TPairOfNodes( theFirstNode2, theSecondNode2 )); + // loop on links in linkList; find faces by links and append links + // of the found faces to linkList + list< TPairOfNodes >::iterator linkIt[] = { linkList[0].begin(), linkList[1].begin() } ; + for ( ; linkIt[0] != linkList[0].end(); linkIt[0]++, linkIt[1]++ ) + { + TPairOfNodes link[] = { *linkIt[0], *linkIt[1] }; + long linkID = aLinkID_Gen.GetLinkID( link[0].first, link[0].second ); + if ( linkIdSet.find( linkID ) == linkIdSet.end() ) + continue; + + // by links, find faces in the face sets, + // and find indices of link nodes in the found faces; + // in a face set, there is only one or no face sharing a link + // --------------------------------------------------------------- + + const SMDS_MeshElement* face[] = { 0, 0 }; + const SMDS_MeshNode* faceNodes[ 2 ][ 5 ]; + const SMDS_MeshNode* notLinkNodes[ 2 ][ 2 ] = {{ 0, 0 },{ 0, 0 }} ; + int iLinkNode[2][2]; + for ( iSide = 0; iSide < 2; iSide++ ) { // loop on 2 sides + const SMDS_MeshNode* n1 = link[iSide].first; + const SMDS_MeshNode* n2 = link[iSide].second; + set * faceSet = faceSetPtr[ iSide ]; + set< const SMDS_MeshElement* > fMap; + for ( int i = 0; i < 2; i++ ) { // loop on 2 nodes of a link + const SMDS_MeshNode* n = i ? n1 : n2; // a node of a link + SMDS_ElemIteratorPtr fIt = n->facesIterator(); + while ( fIt->more() ) { // loop on faces sharing a node + const SMDS_MeshElement* f = fIt->next(); + if (faceSet->find( f ) != faceSet->end() && // f is in face set + ! fMap.insert( f ).second ) // f encounters twice + { + if ( face[ iSide ] ) { + MESSAGE( "2 faces per link " ); + aResult = iSide ? SEW_BAD_SIDE2_NODES : SEW_BAD_SIDE1_NODES; + break; + } + face[ iSide ] = f; + faceSet->erase( f ); + // get face nodes and find ones of a link + iNode = 0; + SMDS_ElemIteratorPtr nIt = f->nodesIterator(); + while ( nIt->more() ) { + const SMDS_MeshNode* n = + static_cast( nIt->next() ); + if ( n == n1 ) + iLinkNode[ iSide ][ 0 ] = iNode; + else if ( n == n2 ) + iLinkNode[ iSide ][ 1 ] = iNode; + else if ( notLinkNodes[ iSide ][ 0 ] ) + notLinkNodes[ iSide ][ 1 ] = n; + else + notLinkNodes[ iSide ][ 0 ] = n; + faceNodes[ iSide ][ iNode++ ] = n; + } + faceNodes[ iSide ][ iNode ] = faceNodes[ iSide ][ 0 ]; + } + } + } + } + // check similarity of elements of the sides + if (aResult == SEW_OK && ( face[0] && !face[1] ) || ( !face[0] && face[1] )) { + MESSAGE("Correspondent face not found on side " << ( face[0] ? 1 : 0 )); + if ( nReplaceMap.size() == 2 ) // faces on input nodes not found + aResult = ( face[0] ? SEW_BAD_SIDE2_NODES : SEW_BAD_SIDE1_NODES ); + else + aResult = SEW_TOPO_DIFF_SETS_OF_ELEMENTS; + break; // do not return because it s necessary to remove tmp faces + } + + // set nodes to merge + // ------------------- + + if ( face[0] && face[1] ) + { + int nbNodes = face[0]->NbNodes(); + if ( nbNodes != face[1]->NbNodes() ) { + MESSAGE("Diff nb of face nodes"); + aResult = SEW_TOPO_DIFF_SETS_OF_ELEMENTS; + break; // do not return because it s necessary to remove tmp faces + } + bool reverse[] = { false, false }; // order of notLinkNodes of quadrangle + if ( nbNodes == 3 ) + nReplaceMap.insert( TNodeNodeMap::value_type + ( notLinkNodes[0][0], notLinkNodes[1][0] )); + else { + for ( iSide = 0; iSide < 2; iSide++ ) { // loop on 2 sides + // analyse link orientation in faces + int i1 = iLinkNode[ iSide ][ 0 ]; + int i2 = iLinkNode[ iSide ][ 1 ]; + reverse[ iSide ] = Abs( i1 - i2 ) == 1 ? i1 > i2 : i2 > i1; + // if notLinkNodes are the first and the last ones, then + // their order does not correspond to the link orientation + if (( i1 == 1 && i2 == 2 ) || + ( i1 == 2 && i2 == 1 )) + reverse[ iSide ] = !reverse[ iSide ]; + } + if ( reverse[0] == reverse[1] ) { + nReplaceMap.insert( TNodeNodeMap::value_type + ( notLinkNodes[0][0], notLinkNodes[1][0] )); + nReplaceMap.insert( TNodeNodeMap::value_type + ( notLinkNodes[0][1], notLinkNodes[1][1] )); + } + else { + nReplaceMap.insert( TNodeNodeMap::value_type + ( notLinkNodes[0][0], notLinkNodes[1][1] )); + nReplaceMap.insert( TNodeNodeMap::value_type + ( notLinkNodes[0][1], notLinkNodes[1][0] )); + } + } + + // add other links of the faces to linkList + // ----------------------------------------- + + const SMDS_MeshNode** nodes = faceNodes[ 0 ]; + for ( iNode = 0; iNode < nbNodes; iNode++ ) + { + linkID = aLinkID_Gen.GetLinkID( nodes[iNode], nodes[iNode+1] ); + pair< set::iterator, bool > iter_isnew = linkIdSet.insert( linkID ); + if ( !iter_isnew.second ) { // already in a set: no need to process + linkIdSet.erase( iter_isnew.first ); + } + else // new in set == encountered for the first time: add + { + const SMDS_MeshNode* n1 = nodes[ iNode ]; + const SMDS_MeshNode* n2 = nodes[ iNode + 1]; + linkList[0].push_back ( TPairOfNodes( n1, n2 )); + linkList[1].push_back ( TPairOfNodes( nReplaceMap[n1], nReplaceMap[n2] )); + } + } + } // 2 faces found + } // loop on link lists + + if ( aResult == SEW_OK && + ( linkIt[0] != linkList[0].end() || + !faceSetPtr[0]->empty() || !faceSetPtr[1]->empty() )) { + MESSAGE( (linkIt[0] != linkList[0].end()) <<" "<< (faceSetPtr[0]->empty()) << + " " << (faceSetPtr[1]->empty())); + aResult = SEW_TOPO_DIFF_SETS_OF_ELEMENTS; + } + + // ==================================================================== + // 3. Replace nodes in elements of the side 1 and remove replaced nodes + // ==================================================================== + + // delete temporary faces: they are in reverseElements of actual nodes + SMDS_FaceIteratorPtr tmpFaceIt = aTmpFacesMesh.facesIterator(); + while ( tmpFaceIt->more() ) + aTmpFacesMesh.RemoveElement( tmpFaceIt->next() ); + + if ( aResult != SEW_OK) + return aResult; + + list< int > nodeIDsToRemove/*, elemIDsToRemove*/; + // loop on nodes replacement map + TNodeNodeMap::iterator nReplaceMapIt = nReplaceMap.begin(), nnIt; + for ( ; nReplaceMapIt != nReplaceMap.end(); nReplaceMapIt++ ) + if ( (*nReplaceMapIt).first != (*nReplaceMapIt).second ) + { + const SMDS_MeshNode* nToRemove = (*nReplaceMapIt).first; + nodeIDsToRemove.push_back( nToRemove->GetID() ); + // loop on elements sharing nToRemove + SMDS_ElemIteratorPtr invElemIt = nToRemove->GetInverseElementIterator(); + while ( invElemIt->more() ) { + const SMDS_MeshElement* e = invElemIt->next(); + // get a new suite of nodes: make replacement + int nbReplaced = 0, i = 0, nbNodes = e->NbNodes(); + const SMDS_MeshNode* nodes[ 8 ]; + SMDS_ElemIteratorPtr nIt = e->nodesIterator(); + while ( nIt->more() ) { + const SMDS_MeshNode* n = + static_cast( nIt->next() ); + nnIt = nReplaceMap.find( n ); + if ( nnIt != nReplaceMap.end() ) { + nbReplaced++; + n = (*nnIt).second; + } + nodes[ i++ ] = n; + } + // if ( nbReplaced == nbNodes && e->GetType() == SMDSAbs_Face ) + // elemIDsToRemove.push_back( e->GetID() ); + // else + if ( nbReplaced ) + aMesh->ChangeElementNodes( e, nodes, nbNodes ); + } + } + + Remove( nodeIDsToRemove, true ); + + return aResult; +} diff --git a/src/SMESH/SMESH_MeshEditor.hxx b/src/SMESH/SMESH_MeshEditor.hxx new file mode 100644 index 000000000..10b7f9fa9 --- /dev/null +++ b/src/SMESH/SMESH_MeshEditor.hxx @@ -0,0 +1,241 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESH_MeshEditor.hxx +// Created : Mon Apr 12 14:56:19 2004 +// Author : Edward AGAPOV (eap) +// Module : SMESH + + +#ifndef SMESH_MeshEditor_HeaderFile +#define SMESH_MeshEditor_HeaderFile + +#include "SMESH_Mesh.hxx" +#include "SMESH_Controls.hxx" + +#include +#include + +class SMDS_MeshElement; +class SMDS_MeshFace; +class SMDS_MeshNode; +class gp_Ax1; +class gp_Vec; + +class SMESH_MeshEditor { + public: + + SMESH_MeshEditor( SMESH_Mesh* theMesh ); + + bool Remove (const std::list< int >& theElemIDs, const bool isNodes); + // Remove a node or an element. + // Modify a compute state of sub-meshes which become empty + + bool InverseDiag (const SMDS_MeshElement * theTria1, + const SMDS_MeshElement * theTria2 ); + // Replace two neighbour triangles with ones built on the same 4 nodes + // but having other common link. + // Return False if args are improper + + bool InverseDiag (const SMDS_MeshNode * theNode1, + const SMDS_MeshNode * theNode2 ); + // Replace two neighbour triangles sharing theNode1-theNode2 link + // with ones built on the same 4 nodes but having other common link. + // Return false if proper faces not found + + bool DeleteDiag (const SMDS_MeshNode * theNode1, + const SMDS_MeshNode * theNode2 ); + // Replace two neighbour triangles sharing theNode1-theNode2 link + // with a quadrangle built on the same 4 nodes. + // Return false if proper faces not found + + bool Reorient (const SMDS_MeshElement * theFace); + // Reverse the normal of theFace + // Return false if theFace is null + + + bool TriToQuad (std::set & theElems, + SMESH::Controls::NumericalFunctorPtr theCriterion, + const double theMaxAngle); + // Fuse neighbour triangles into quadrangles. + // theCriterion is used to choose a neighbour to fuse with. + // theMaxAngle is a max angle between element normals at which + // fusion is still performed; theMaxAngle is mesured in radians. + + bool QuadToTri (std::set & theElems, + SMESH::Controls::NumericalFunctorPtr theCriterion); + // Cut quadrangles into triangles. + // theCriterion is used to choose a diagonal to cut + + bool QuadToTri (std::set & theElems, + const bool the13Diag); + // Cut quadrangles into triangles + + + enum SmoothMethod { LAPLACIAN = 0, CENTROIDAL }; + + void Smooth (std::set & theElements, + std::set & theFixedNodes, + const SmoothMethod theSmoothMethod, + const int theNbIterations, + double theTgtAspectRatio = 1.0); + // Smooth theElements using theSmoothMethod during theNbIterations + // or until a worst element has aspect ratio <= theTgtAspectRatio. + // Aspect Ratio varies in range [1.0, inf]. + // If theElements is empty, the whole mesh is smoothed. + // theFixedNodes contains additionally fixed nodes. Nodes built + // on edges and boundary nodes are always fixed. + + + void RotationSweep (std::set & theElements, + const gp_Ax1& theAxis, + const double theAngle, + const int theNbSteps, + const double theToler); + // Generate new elements by rotation of theElements around theAxis + // by theAngle by theNbSteps + + void ExtrusionSweep (std::set & theElements, + const gp_Vec& theStep, + const int theNbSteps); + // Generate new elements by extrusion of theElements + // by theStep by theNbSteps + + + void Transform (std::set & theElements, + const gp_Trsf& theTrsf, + const bool theCopy); + // Move or copy theElements applying theTrsf to their nodes + + + typedef std::list< std::list< const SMDS_MeshNode* > > TListOfListOfNodes; + + void FindCoincidentNodes (const double theTolerance, + TListOfListOfNodes & theGroupsOfNodes); + // Return list of group of nodes close to each other within theTolerance + + void MergeNodes (TListOfListOfNodes & theNodeGroups); + // In each group, the cdr of nodes are substituted by the first one + // in all elements. + + void MergeEqualElements(); + // Remove all but one of elements built on the same nodes. + // Return nb of successfully merged groups. + + static bool CheckFreeBorderNodes(const SMDS_MeshNode* theNode1, + const SMDS_MeshNode* theNode2, + const SMDS_MeshNode* theNode3 = 0); + // Return true if the three nodes are on a free border + + enum Sew_Error { + SEW_OK, + // for SewFreeBorder() + SEW_BORDER1_NOT_FOUND, + SEW_BORDER2_NOT_FOUND, + SEW_BOTH_BORDERS_NOT_FOUND, + SEW_BAD_SIDE_NODES, + SEW_VOLUMES_TO_SPLIT, + // for SewSideElements() + SEW_DIFF_NB_OF_ELEMENTS, + SEW_TOPO_DIFF_SETS_OF_ELEMENTS, + SEW_BAD_SIDE1_NODES, + SEW_BAD_SIDE2_NODES + }; + + + Sew_Error SewFreeBorder (const SMDS_MeshNode* theBorderFirstNode, + const SMDS_MeshNode* theBorderSecondNode, + const SMDS_MeshNode* theBorderLastNode, + const SMDS_MeshNode* theSide2FirstNode, + const SMDS_MeshNode* theSide2SecondNode, + const SMDS_MeshNode* theSide2ThirdNode = 0, + bool theSide2IsFreeBorder = true); + // Sew the free border to the side2 by replacing nodes in + // elements on the free border with nodes of the elements + // of the side 2. If nb of links in the free border and + // between theSide2FirstNode and theSide2LastNode are different, + // additional nodes are inserted on a link provided that no + // volume elements share the splitted link. + // The side 2 is a free border if theSide2IsFreeBorder == true. + // Sewing is peformed between the given first, second and last + // nodes on the sides. + // theBorderFirstNode is merged with theSide2FirstNode. + // if (!theSide2IsFreeBorder) then theSide2SecondNode gives + // the last node on the side 2, which will be merged with + // theBorderLastNode. + // if (theSide2IsFreeBorder) then theSide2SecondNode will + // be merged with theBorderSecondNode. + // if (theSide2IsFreeBorder && theSide2ThirdNode == 0) then + // the 2 free borders are sewn link by link and no additional + // nodes are inserted. + // Return false, if sewing failed. + + Sew_Error SewSideElements (std::set& theSide1, + std::set& theSide2, + const SMDS_MeshNode* theFirstNode1ToMerge, + const SMDS_MeshNode* theFirstNode2ToMerge, + const SMDS_MeshNode* theSecondNode1ToMerge, + const SMDS_MeshNode* theSecondNode2ToMerge); + // Sew two sides of a mesh. Nodes belonging to theSide1 are + // merged with nodes of elements of theSide2. + // Number of elements in theSide1 and in theSide2 must be + // equal and they should have similar node connectivity. + // The nodes to merge should belong to side s borders and + // the first node should be linked to the second. + + void InsertNodesIntoLink(const SMDS_MeshElement* theFace, + const SMDS_MeshNode* theBetweenNode1, + const SMDS_MeshNode* theBetweenNode2, + std::list& theNodesToInsert); + // insert theNodesToInsert into theFace between theBetweenNode1 + // and theBetweenNode2 and split theElement. + + static int SortQuadNodes (const SMDS_Mesh * theMesh, + int theNodeIds[] ); + // Set 4 nodes of a quadrangle face in a good order. + // Swap 1<->2 or 2<->3 nodes and correspondingly return + // 1 or 2 else 0. + + static bool SortHexaNodes (const SMDS_Mesh * theMesh, + int theNodeIds[] ); + // Set 8 nodes of a hexahedron in a good order. + // Return success status + + + int FindShape (const SMDS_MeshElement * theElem); + // Return an index of the shape theElem is on + // or zero if a shape not found + + + SMESH_Mesh * GetMesh() { return myMesh; } + + SMESHDS_Mesh * GetMeshDS() { return myMesh->GetMeshDS(); } + + + private: + + SMESH_Mesh * myMesh; + +}; + +#endif diff --git a/src/SMESH/SMESH_Pattern.cxx b/src/SMESH/SMESH_Pattern.cxx new file mode 100644 index 000000000..7f20a5cad --- /dev/null +++ b/src/SMESH/SMESH_Pattern.cxx @@ -0,0 +1,4310 @@ +// File : SMESH_Pattern.cxx +// Created : Thu Aug 5 11:09:29 2004 +// Author : Edward AGAPOV (eap) +// Copyright : Open CASCADE + + +#include "SMESH_Pattern.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "SMDS_EdgePosition.hxx" +#include "SMDS_FacePosition.hxx" +#include "SMDS_MeshElement.hxx" +#include "SMDS_MeshNode.hxx" +#include "SMESHDS_Mesh.hxx" +#include "SMESHDS_SubMesh.hxx" +#include "SMESH_Mesh.hxx" + +#include "utilities.h" + +using namespace std; + +typedef map< const SMDS_MeshElement*, int > TNodePointIDMap; + +#define SQRT_FUNC 1 + +//======================================================================= +//function : SMESH_Pattern +//purpose : +//======================================================================= + +SMESH_Pattern::SMESH_Pattern () +{ +} +//======================================================================= +//function : getInt +//purpose : +//======================================================================= + +static inline int getInt( const char * theSring ) +{ + if ( *theSring < '0' || *theSring > '9' ) + return -1; + + char *ptr; + int val = strtol( theSring, &ptr, 10 ); + if ( ptr == theSring || + // there must not be neither '.' nor ',' nor 'E' ... + (*ptr != ' ' && *ptr != '\n' && *ptr != '\0')) + return -1; + + return val; +} + +//======================================================================= +//function : getDouble +//purpose : +//======================================================================= + +static inline double getDouble( const char * theSring ) +{ + char *ptr; + return strtod( theSring, &ptr ); +} + +//======================================================================= +//function : readLine +//purpose : Put token starting positions in theFields until '\n' or '\0' +// Return the number of the found tokens +//======================================================================= + +static int readLine (list & theFields, + const char* & theLineBeg, + const bool theClearFields ) +{ + if ( theClearFields ) + theFields.clear(); + + // algo: + /* loop */ + /* switch ( symbol ) { */ + /* case white-space: */ + /* look for a non-space symbol; */ + /* case string-end: */ + /* case line-end: */ + /* exit; */ + /* case comment beginning: */ + /* skip all till a line-end; */ + /* case a number */ + /* put its position in theFields, skip till a white-space;*/ + /* default: */ + /* abort; */ + /* till line-end */ + + int nbRead = 0; + bool stopReading = false; + do { + bool goOn = true; + bool isNumber = false; + switch ( *theLineBeg ) + { + case ' ': // white space + case '\t': // tab + case 13: // ^M + break; + + case '\n': // a line ends + stopReading = ( nbRead > 0 ); + break; + + case '!': // comment + do theLineBeg++; + while ( *theLineBeg != '\n' && *theLineBeg != '\0' ); + goOn = false; + break; + + case '\0': // file ends + return nbRead; + + case '-': // real number + case '+': + case '.': + isNumber = true; + default: // data + isNumber = isNumber || ( *theLineBeg >= '0' && *theLineBeg <= '9' ); + if ( isNumber ) { + theFields.push_back( theLineBeg ); + nbRead++; + do theLineBeg++; + while (*theLineBeg != ' ' && + *theLineBeg != '\n' && + *theLineBeg != '\0'); + goOn = false; + } + else + return 0; // incorrect file format + } + + if ( goOn ) + theLineBeg++; + + } while ( !stopReading ); + + return nbRead; +} + +//======================================================================= +//function : Load +//purpose : Load a pattern from +//======================================================================= + +bool SMESH_Pattern::Load (const char* theFileContents) +{ + MESSAGE("Load( file ) "); + + // file structure: + + // ! This is a comment + // NB_POINTS ! 1 integer - the number of points in the pattern. + // X1 Y1 [Z1] ! 2 or 3 reals - nodes coordinates within 2D or 3D domain: + // X2 Y2 [Z2] ! the pattern dimention is defined by the number of coordinates + // ... + // [ ID1 ID2 ... IDn ] ! Indices of key-points for a 2D pattern (only). + // ! elements description goes after all + // ID1 ID2 ... IDn ! 2-4 or 4-8 integers - nodal connectivity of a 2D or 3D element. + // ... + + Clear(); + + const char* lineBeg = theFileContents; + list fields; + const bool clearFields = true; + + // NB_POINTS ! 1 integer - the number of points in the pattern. + + if ( readLine( fields, lineBeg, clearFields ) != 1 ) { + MESSAGE("Error reading NB_POINTS"); + return setErrorCode( ERR_READ_NB_POINTS ); + } + int nbPoints = getInt( fields.front() ); + + // X1 Y1 [Z1] ! 2 or 3 reals - nodes coordinates within 2D or 3D domain: + + // read the first point coordinates to define pattern dimention + int dim = readLine( fields, lineBeg, clearFields ); + if ( dim == 2 ) + myIs2D = true; + else if ( dim == 3 ) + myIs2D = false; + else { + MESSAGE("Error reading points: wrong nb of coordinates"); + return setErrorCode( ERR_READ_POINT_COORDS ); + } + if ( nbPoints <= dim ) { + MESSAGE(" Too few points "); + return setErrorCode( ERR_READ_TOO_FEW_POINTS ); + } + + // read the rest points + int iPoint; + for ( iPoint = 1; iPoint < nbPoints; iPoint++ ) + if ( readLine( fields, lineBeg, !clearFields ) != dim ) { + MESSAGE("Error reading points : wrong nb of coordinates "); + return setErrorCode( ERR_READ_POINT_COORDS ); + } + // store point coordinates + myPoints.resize( nbPoints ); + list ::iterator fIt = fields.begin(); + for ( iPoint = 0; iPoint < nbPoints; iPoint++ ) + { + TPoint & p = myPoints[ iPoint ]; + for ( int iCoord = 1; iCoord <= dim; iCoord++, fIt++ ) + { + double coord = getDouble( *fIt ); + if ( !myIs2D && ( coord < 0.0 || coord > 1.0 )) { + MESSAGE("Error reading 3D points, value should be in [0,1]: " << coord); + Clear(); + return setErrorCode( ERR_READ_3D_COORD ); + } + p.myInitXYZ.SetCoord( iCoord, coord ); + if ( myIs2D ) + p.myInitUV.SetCoord( iCoord, coord ); + } + } + + // [ ID1 ID2 ... IDn ] ! Indices of key-points for a 2D pattern (only). + if ( myIs2D ) + { + if ( readLine( fields, lineBeg, clearFields ) == 0 ) { + MESSAGE("Error: missing key-points"); + Clear(); + return setErrorCode( ERR_READ_NO_KEYPOINT ); + } + set idSet; + for ( fIt = fields.begin(); fIt != fields.end(); fIt++ ) + { + int pointIndex = getInt( *fIt ); + if ( pointIndex >= nbPoints || pointIndex < 0 ) { + MESSAGE("Error: invalid point index " << pointIndex ); + Clear(); + return setErrorCode( ERR_READ_BAD_INDEX ); + } + if ( idSet.insert( pointIndex ).second ) // unique? + myKeyPointIDs.push_back( pointIndex ); + } + } + + // ID1 ID2 ... IDn ! 2-4 or 4-8 integers - nodal connectivity of a 2D or 3D element. + + while ( readLine( fields, lineBeg, clearFields )) + { + myElemPointIDs.push_back( list< int >() ); + list< int >& elemPoints = myElemPointIDs.back(); + for ( fIt = fields.begin(); fIt != fields.end(); fIt++ ) + { + int pointIndex = getInt( *fIt ); + if ( pointIndex >= nbPoints || pointIndex < 0 ) { + MESSAGE("Error: invalid point index " << pointIndex ); + Clear(); + return setErrorCode( ERR_READ_BAD_INDEX ); + } + elemPoints.push_back( pointIndex ); + } + // check the nb of nodes in element + bool Ok = true; + switch ( elemPoints.size() ) { + case 3: if ( !myIs2D ) Ok = false; break; + case 4: break; + case 5: + case 6: + case 8: if ( myIs2D ) Ok = false; break; + default: Ok = false; + } + if ( !Ok ) { + MESSAGE("Error: wrong nb of nodes in element " << elemPoints.size() ); + Clear(); + return setErrorCode( ERR_READ_ELEM_POINTS ); + } + } + if ( myElemPointIDs.empty() ) { + MESSAGE("Error: no elements"); + Clear(); + return setErrorCode( ERR_READ_NO_ELEMS ); + } + + findBoundaryPoints(); // sort key-points + + return setErrorCode( ERR_OK ); +} + +//======================================================================= +//function : Save +//purpose : Save the loaded pattern into the file +//======================================================================= + +bool SMESH_Pattern::Save (ostream& theFile) +{ + MESSAGE(" ::Save(file) " ); + if ( !IsLoaded() ) { + MESSAGE(" Pattern not loaded "); + return setErrorCode( ERR_SAVE_NOT_LOADED ); + } + + theFile << "!!! SALOME Mesh Pattern file" << endl; + theFile << "!!!" << endl; + theFile << "!!! Nb of points:" << endl; + theFile << myPoints.size() << endl; + + // point coordinates + const int width = 8; +// theFile.width( 8 ); +// theFile.setf(ios::fixed);// use 123.45 floating notation +// theFile.setf(ios::right); +// theFile.flags( theFile.flags() & ~ios::showpoint); // do not show trailing zeros +// theFile.setf(ios::showpoint); // do not show trailing zeros + vector< TPoint >::const_iterator pVecIt = myPoints.begin(); + for ( int i = 0; pVecIt != myPoints.end(); pVecIt++, i++ ) { + const gp_XYZ & xyz = (*pVecIt).myInitXYZ; + theFile << " " << setw( width ) << xyz.X() << " " << setw( width ) << xyz.Y(); + if ( !myIs2D ) theFile << " " << setw( width ) << xyz.Z(); + theFile << " !- " << i << endl; // point id to ease reading by a human being + } + // key-points + if ( myIs2D ) { + theFile << "!!! Indices of " << myKeyPointIDs.size() << " key-points:" << endl; + list< int >::const_iterator kpIt = myKeyPointIDs.begin(); + for ( ; kpIt != myKeyPointIDs.end(); kpIt++ ) + theFile << " " << *kpIt; + if ( !myKeyPointIDs.empty() ) + theFile << endl; + } + // elements + theFile << "!!! Indices of points of " << myElemPointIDs.size() << " elements:" << endl; + list >::const_iterator epIt = myElemPointIDs.begin(); + for ( ; epIt != myElemPointIDs.end(); epIt++ ) + { + const list< int > & elemPoints = *epIt; + list< int >::const_iterator iIt = elemPoints.begin(); + for ( ; iIt != elemPoints.end(); iIt++ ) + theFile << " " << *iIt; + theFile << endl; + } + + theFile << endl; + + return setErrorCode( ERR_OK ); +} + +//======================================================================= +//function : sortBySize +//purpose : sort theListOfList by size +//======================================================================= + +template struct TSizeCmp { + bool operator ()( const list < T > & l1, const list < T > & l2 ) + const { return l1.size() < l2.size(); } +}; + +template void sortBySize( list< list < T > > & theListOfList ) +{ + if ( theListOfList.size() > 2 ) { + // keep the car + //list < T > & aFront = theListOfList.front(); + // sort the whole list + TSizeCmp< T > SizeCmp; + theListOfList.sort( SizeCmp ); + } +} + +//======================================================================= +//function : getOrderedEdges +//purpose : return nb wires and a list of oredered edges +//======================================================================= + +static int getOrderedEdges (const TopoDS_Face& theFace, + const TopoDS_Vertex& theFirstVertex, + list< TopoDS_Edge >& theEdges, + list< int > & theNbVertexInWires) +{ + // put wires in a list, so that an outer wire comes first + list aWireList; + TopoDS_Wire anOuterWire = BRepTools::OuterWire( theFace ); + aWireList.push_back( anOuterWire ); + for ( TopoDS_Iterator wIt (theFace); wIt.More(); wIt.Next() ) + if ( !anOuterWire.IsSame( wIt.Value() )) + aWireList.push_back( TopoDS::Wire( wIt.Value() )); + + // loop on edges of wires + theNbVertexInWires.clear(); + list::iterator wlIt = aWireList.begin(); + for ( ; wlIt != aWireList.end(); wlIt++ ) + { + int iE; + BRepTools_WireExplorer wExp( *wlIt, theFace ); + for ( iE = 0; wExp.More(); wExp.Next(), iE++ ) + { + TopoDS_Edge edge = wExp.Current(); + edge = TopoDS::Edge( edge.Oriented( wExp.Orientation() )); + theEdges.push_back( edge ); + } + theNbVertexInWires.push_back( iE ); + iE = 0; + if ( wlIt == aWireList.begin() && theEdges.size() > 1 ) { // the outer wire + // orient closed edges + list< TopoDS_Edge >::iterator eIt, eIt2; + for ( eIt = theEdges.begin(); eIt != theEdges.end(); eIt++ ) + { + TopoDS_Edge& edge = *eIt; + if ( TopExp::FirstVertex( edge ).IsSame( TopExp::LastVertex( edge ) )) + { + eIt2 = eIt; + bool isNext = ( eIt2 == theEdges.begin() ); + TopoDS_Edge edge2 = isNext ? *(++eIt2) : *(--eIt2); + double f1,l1,f2,l2; + Handle(Geom2d_Curve) c1 = BRep_Tool::CurveOnSurface( edge, theFace, f1,l1 ); + Handle(Geom2d_Curve) c2 = BRep_Tool::CurveOnSurface( edge2, theFace, f2,l2 ); + gp_Pnt2d pf = c1->Value( edge.Orientation() == TopAbs_FORWARD ? f1 : l1 ); + gp_Pnt2d pl = c1->Value( edge.Orientation() == TopAbs_FORWARD ? l1 : f1 ); + bool isFirst = ( edge2.Orientation() == TopAbs_FORWARD ? isNext : !isNext ); + gp_Pnt2d p2 = c2->Value( isFirst ? f2 : l2 ); + isFirst = ( p2.SquareDistance( pf ) < p2.SquareDistance( pl )); + if ( isNext ? isFirst : !isFirst ) + edge.Reverse(); + } + } + // rotate theEdges until it begins from theFirstVertex + if ( ! theFirstVertex.IsNull() ) + while ( !theFirstVertex.IsSame( TopExp::FirstVertex( theEdges.front(), true ))) + { + theEdges.splice(theEdges.end(), theEdges, + theEdges.begin(), ++ theEdges.begin()); + if ( iE++ > theNbVertexInWires.back() ) + break; // break infinite loop + } + } + } + + return aWireList.size(); +} + +//======================================================================= +//function : project +//purpose : +//======================================================================= + +static gp_XY project (const SMDS_MeshNode* theNode, + Extrema_GenExtPS & theProjectorPS) +{ + gp_Pnt P( theNode->X(), theNode->Y(), theNode->Z() ); + theProjectorPS.Perform( P ); + if ( !theProjectorPS.IsDone() ) { + MESSAGE( "SMESH_Pattern: point projection FAILED"); + return gp_XY(0.,0.); + } + double u, v, minVal = DBL_MAX; + for ( int i = theProjectorPS.NbExt(); i > 0; i-- ) + if ( theProjectorPS.Value( i ) < minVal ) { + minVal = theProjectorPS.Value( i ); + theProjectorPS.Point( i ).Parameter( u, v ); + } + return gp_XY( u, v ); +} + +//======================================================================= +//function : isMeshBoundToShape +//purpose : return true if all 2d elements are bound to shape +//======================================================================= + +static bool isMeshBoundToShape(SMESH_Mesh* theMesh) +{ + // check faces binding + SMESHDS_Mesh * aMeshDS = theMesh->GetMeshDS(); + SMESHDS_SubMesh * aMainSubMesh = aMeshDS->MeshElements( aMeshDS->ShapeToMesh() ); + if ( aMeshDS->NbFaces() != aMainSubMesh->NbElements() ) + return false; + + // check face nodes binding + SMDS_FaceIteratorPtr fIt = aMeshDS->facesIterator(); + while ( fIt->more() ) + { + SMDS_ElemIteratorPtr nIt = fIt->next()->nodesIterator(); + while ( nIt->more() ) + { + const SMDS_MeshNode* node = static_cast( nIt->next() ); + SMDS_PositionPtr pos = node->GetPosition(); + if ( !pos || !pos->GetShapeId() ) + return false; + } + } + return true; +} + +//======================================================================= +//function : Load +//purpose : Create a pattern from the mesh built on . +// ==true makes override nodes positions +// on computed by mesher +//======================================================================= + +bool SMESH_Pattern::Load (SMESH_Mesh* theMesh, + const TopoDS_Face& theFace, + bool theProject) +{ + MESSAGE(" ::Load(face) " ); + Clear(); + myIs2D = true; + + SMESHDS_Mesh * aMeshDS = theMesh->GetMeshDS(); + SMESHDS_SubMesh * fSubMesh = aMeshDS->MeshElements( theFace ); + + int nbNodes = ( !fSubMesh ? 0 : fSubMesh->NbNodes() ); + int nbElems = ( !fSubMesh ? 0 : fSubMesh->NbElements() ); + if ( nbElems == 0 && aMeshDS->NbFaces() == 0 ) + { + MESSAGE( "No elements bound to the face"); + return setErrorCode( ERR_LOAD_EMPTY_SUBMESH ); + } + + // check that face is not closed + TopoDS_Vertex bidon; + list eList; + getOrderedEdges( theFace, bidon, eList, myNbKeyPntInBoundary ); + list::iterator elIt = eList.begin(); + for ( ; elIt != eList.end() ; elIt++ ) + if ( BRep_Tool::IsClosed( *elIt , theFace )) + return setErrorCode( ERR_LOADF_CLOSED_FACE ); + + + Extrema_GenExtPS projector; + GeomAdaptor_Surface aSurface( BRep_Tool::Surface( theFace )); + if ( theProject || nbElems == 0 ) + projector.Initialize( aSurface, 20,20, 1e-5,1e-5 ); + + int iPoint = 0; + TNodePointIDMap nodePointIDMap; + + if ( nbElems == 0 || (theProject && + theMesh->IsMainShape( theFace ) && + !isMeshBoundToShape( theMesh ))) + { + MESSAGE("Project the whole mesh"); + // --------------------------------------------------------------- + // The case where the whole mesh is projected to theFace + // --------------------------------------------------------------- + + // put nodes of all faces in the nodePointIDMap and fill myElemPointIDs + SMDS_FaceIteratorPtr fIt = aMeshDS->facesIterator(); + while ( fIt->more() ) + { + myElemPointIDs.push_back( list< int >() ); + list< int >& elemPoints = myElemPointIDs.back(); + SMDS_ElemIteratorPtr nIt = fIt->next()->nodesIterator(); + while ( nIt->more() ) + { + const SMDS_MeshElement* node = nIt->next(); + TNodePointIDMap::iterator nIdIt = nodePointIDMap.find( node ); + if ( nIdIt == nodePointIDMap.end() ) + { + elemPoints.push_back( iPoint ); + nodePointIDMap.insert( TNodePointIDMap::value_type( node, iPoint++ )); + } + else + elemPoints.push_back( (*nIdIt).second ); + } + } + myPoints.resize( iPoint ); + + // project all nodes of 2d elements to theFace + TNodePointIDMap::iterator nIdIt = nodePointIDMap.begin(); + for ( ; nIdIt != nodePointIDMap.end(); nIdIt++ ) + { + const SMDS_MeshNode* node = + static_cast( (*nIdIt).first ); + TPoint * p = & myPoints[ (*nIdIt).second ]; + p->myInitUV = project( node, projector ); + p->myInitXYZ.SetCoord( p->myInitUV.X(), p->myInitUV.Y(), 0 ); + } + // find key-points: the points most close to UV of vertices + TopExp_Explorer vExp( theFace, TopAbs_VERTEX ); + set foundIndices; + for ( ; vExp.More(); vExp.Next() ) { + const TopoDS_Vertex v = TopoDS::Vertex( vExp.Current() ); + gp_Pnt2d uv = BRep_Tool::Parameters( v, theFace ); + double minDist = DBL_MAX; + int index; + vector< TPoint >::const_iterator pVecIt = myPoints.begin(); + for ( iPoint = 0; pVecIt != myPoints.end(); pVecIt++, iPoint++ ) { + double dist = uv.SquareDistance( (*pVecIt).myInitUV ); + if ( dist < minDist ) { + minDist = dist; + index = iPoint; + } + } + if ( foundIndices.insert( index ).second ) // unique? + myKeyPointIDs.push_back( index ); + } + myIsBoundaryPointsFound = false; + + } + else + { + // --------------------------------------------------------------------- + // The case where a pattern is being made from the mesh built by mesher + // --------------------------------------------------------------------- + + // Load shapes in the consequent order and count nb of points + + // vertices + for ( elIt = eList.begin(); elIt != eList.end(); elIt++ ) { + myShapeIDMap.Add( TopExp::FirstVertex( *elIt, true )); + SMESHDS_SubMesh * eSubMesh = aMeshDS->MeshElements( *elIt ); + if ( eSubMesh ) + nbNodes += eSubMesh->NbNodes() + 1; + } + // edges + for ( elIt = eList.begin(); elIt != eList.end(); elIt++ ) + myShapeIDMap.Add( *elIt ); + // the face + myShapeIDMap.Add( theFace ); + + myPoints.resize( nbNodes ); + + // Load U of points on edges + + for ( elIt = eList.begin(); elIt != eList.end(); elIt++ ) + { + TopoDS_Edge & edge = *elIt; + list< TPoint* > & ePoints = getShapePoints( edge ); + double f, l; + Handle(Geom2d_Curve) C2d; + if ( !theProject ) + C2d = BRep_Tool::CurveOnSurface( edge, theFace, f, l ); + bool isForward = ( edge.Orientation() == TopAbs_FORWARD ); + + // the forward key-point + TopoDS_Shape v = TopExp::FirstVertex( edge, true ); + list< TPoint* > & vPoint = getShapePoints( v ); + if ( vPoint.empty() ) + { + SMESHDS_SubMesh * vSubMesh = aMeshDS->MeshElements( v ); + if ( vSubMesh && vSubMesh->NbNodes() ) { + myKeyPointIDs.push_back( iPoint ); + SMDS_NodeIteratorPtr nIt = vSubMesh->GetNodes(); + const SMDS_MeshNode* node = nIt->next(); + nodePointIDMap.insert( TNodePointIDMap::value_type( node, iPoint )); + + TPoint* keyPoint = &myPoints[ iPoint++ ]; + vPoint.push_back( keyPoint ); + if ( theProject ) + keyPoint->myInitUV = project( node, projector ); + else + keyPoint->myInitUV = C2d->Value( isForward ? f : l ).XY(); + keyPoint->myInitXYZ.SetCoord (keyPoint->myInitUV.X(), keyPoint->myInitUV.Y(), 0); + } + } + if ( !vPoint.empty() ) + ePoints.push_back( vPoint.front() ); + + // on-edge points + SMESHDS_SubMesh * eSubMesh = aMeshDS->MeshElements( edge ); + if ( eSubMesh && eSubMesh->NbNodes() ) + { + // loop on nodes of an edge: sort them by param on edge + typedef map < double, const SMDS_MeshNode* > TParamNodeMap; + TParamNodeMap paramNodeMap; + SMDS_NodeIteratorPtr nIt = eSubMesh->GetNodes(); + while ( nIt->more() ) + { + const SMDS_MeshNode* node = + static_cast( nIt->next() ); + const SMDS_EdgePosition* epos = + static_cast(node->GetPosition().get()); + double u = epos->GetUParameter(); + paramNodeMap.insert( TParamNodeMap::value_type( u, node )); + } + // put U in [0,1] so that the first key-point has U==0 + double du = l - f; + TParamNodeMap::iterator unIt = paramNodeMap.begin(); + TParamNodeMap::reverse_iterator unRIt = paramNodeMap.rbegin(); + while ( unIt != paramNodeMap.end() ) + { + TPoint* p = & myPoints[ iPoint ]; + ePoints.push_back( p ); + const SMDS_MeshNode* node = isForward ? (*unIt).second : (*unRIt).second; + nodePointIDMap.insert ( TNodePointIDMap::value_type( node, iPoint )); + + if ( theProject ) + p->myInitUV = project( node, projector ); + else { + double u = isForward ? (*unIt).first : (*unRIt).first; + p->myInitU = isForward ? (( u - f ) / du ) : ( 1.0 - ( u - f ) / du ); + p->myInitUV = C2d->Value( u ).XY(); + } + p->myInitXYZ.SetCoord( p->myInitUV.X(), p->myInitUV.Y(), 0 ); + unIt++; unRIt++; + iPoint++; + } + } + // the reverse key-point + v = TopExp::LastVertex( edge, true ).Reversed(); + list< TPoint* > & vPoint2 = getShapePoints( v ); + if ( vPoint2.empty() ) + { + SMESHDS_SubMesh * vSubMesh = aMeshDS->MeshElements( v ); + if ( vSubMesh && vSubMesh->NbNodes() ) { + myKeyPointIDs.push_back( iPoint ); + SMDS_NodeIteratorPtr nIt = vSubMesh->GetNodes(); + const SMDS_MeshNode* node = nIt->next(); + nodePointIDMap.insert( TNodePointIDMap::value_type( node, iPoint )); + + TPoint* keyPoint = &myPoints[ iPoint++ ]; + vPoint2.push_back( keyPoint ); + if ( theProject ) + keyPoint->myInitUV = project( node, projector ); + else + keyPoint->myInitUV = C2d->Value( isForward ? l : f ).XY(); + keyPoint->myInitXYZ.SetCoord( keyPoint->myInitUV.X(), keyPoint->myInitUV.Y(), 0 ); + } + } + if ( !vPoint2.empty() ) + ePoints.push_back( vPoint2.front() ); + + // compute U of edge-points + if ( theProject ) + { + double totalDist = 0; + list< TPoint* >::iterator pIt = ePoints.begin(); + TPoint* prevP = *pIt; + prevP->myInitU = totalDist; + for ( pIt++; pIt != ePoints.end(); pIt++ ) { + TPoint* p = *pIt; + totalDist += ( p->myInitUV - prevP->myInitUV ).Modulus(); + p->myInitU = totalDist; + prevP = p; + } + if ( totalDist > DBL_MIN) + for ( pIt = ePoints.begin(); pIt != ePoints.end(); pIt++ ) { + TPoint* p = *pIt; + p->myInitU /= totalDist; + } + } + } // loop on edges of a wire + + // Load in-face points and elements + + if ( fSubMesh && fSubMesh->NbElements() ) + { + list< TPoint* > & fPoints = getShapePoints( theFace ); + SMDS_NodeIteratorPtr nIt = fSubMesh->GetNodes(); + while ( nIt->more() ) + { + const SMDS_MeshNode* node = + static_cast( nIt->next() ); + nodePointIDMap.insert( TNodePointIDMap::value_type( node, iPoint )); + TPoint* p = &myPoints[ iPoint++ ]; + fPoints.push_back( p ); + if ( theProject ) + p->myInitUV = project( node, projector ); + else { + const SMDS_FacePosition* pos = + static_cast(node->GetPosition().get()); + p->myInitUV.SetCoord( pos->GetUParameter(), pos->GetVParameter() ); + } + p->myInitXYZ.SetCoord( p->myInitUV.X(), p->myInitUV.Y(), 0 ); + } + // load elements + SMDS_ElemIteratorPtr elemIt = fSubMesh->GetElements(); + while ( elemIt->more() ) { + SMDS_ElemIteratorPtr nIt = elemIt->next()->nodesIterator(); + myElemPointIDs.push_back( list< int >() ); + list< int >& elemPoints = myElemPointIDs.back(); + while ( nIt->more() ) + elemPoints.push_back( nodePointIDMap[ nIt->next() ]); + } + } + + myIsBoundaryPointsFound = true; + } + + // Assure that U range is proportional to V range + + Bnd_Box2d bndBox; + vector< TPoint >::iterator pVecIt = myPoints.begin(); + for ( ; pVecIt != myPoints.end(); pVecIt++ ) + bndBox.Add( gp_Pnt2d( (*pVecIt).myInitUV )); + double minU, minV, maxU, maxV; + bndBox.Get( minU, minV, maxU, maxV ); + double dU = maxU - minU, dV = maxV - minV; + if ( dU <= DBL_MIN || dV <= DBL_MIN ) { + Clear(); + return setErrorCode( ERR_LOADF_NARROW_FACE ); + } + double ratio = dU / dV, maxratio = 3, scale; + int iCoord = 0; + if ( ratio > maxratio ) { + scale = ratio / maxratio; + iCoord = 2; + } + else if ( ratio < 1./maxratio ) { + scale = maxratio / ratio; + iCoord = 1; + } + if ( iCoord ) { + SCRUTE( scale ); + for ( pVecIt = myPoints.begin(); pVecIt != myPoints.end(); pVecIt++ ) { + TPoint & p = *pVecIt; + p.myInitUV.SetCoord( iCoord, p.myInitUV.Coord( iCoord ) * scale ); + p.myInitXYZ.SetCoord( p.myInitUV.X(), p.myInitUV.Y(), 0 ); + } + } + if ( myElemPointIDs.empty() ) { + MESSAGE( "No elements bound to the face"); + return setErrorCode( ERR_LOAD_EMPTY_SUBMESH ); + } + + return setErrorCode( ERR_OK ); +} + +//======================================================================= +//function : computeUVOnEdge +//purpose : compute coordinates of points on theEdge +//======================================================================= + +void SMESH_Pattern::computeUVOnEdge (const TopoDS_Edge& theEdge, + const list< TPoint* > & ePoints ) +{ + bool isForward = ( theEdge.Orientation() == TopAbs_FORWARD ); + double f, l; + Handle(Geom2d_Curve) C2d = + BRep_Tool::CurveOnSurface( theEdge, TopoDS::Face( myShape ), f, l ); + + ePoints.back()->myInitU = 1.0; + list< TPoint* >::const_iterator pIt = ePoints.begin(); + for ( pIt++; pIt != ePoints.end(); pIt++ ) + { + TPoint* point = *pIt; + // U + double du = ( isForward ? point->myInitU : 1 - point->myInitU ); + point->myU = ( f * ( 1 - du ) + l * du ); + // UV + point->myUV = C2d->Value( point->myU ).XY(); + } +} + +//======================================================================= +//function : intersectIsolines +//purpose : +//======================================================================= + +static bool intersectIsolines(const gp_XY& uv11, const gp_XY& uv12, const double r1, + const gp_XY& uv21, const gp_XY& uv22, const double r2, + gp_XY& resUV, + bool& isDeformed) +{ + gp_XY loc1 = uv11 * ( 1 - r1 ) + uv12 * r1; + gp_XY loc2 = uv21 * ( 1 - r2 ) + uv22 * r2; + resUV = 0.5 * ( loc1 + loc2 ); + isDeformed = ( loc1 - loc2 ).SquareModulus() > 1e-8; +// double len1 = ( uv11 - uv12 ).Modulus(); +// double len2 = ( uv21 - uv22 ).Modulus(); +// resUV = loc1 * len2 / ( len1 + len2 ) + loc2 * len1 / ( len1 + len2 ); +// return true; + + +// gp_Lin2d line1( uv11, uv12 - uv11 ); +// gp_Lin2d line2( uv21, uv22 - uv21 ); +// double angle = Abs( line1.Angle( line2 ) ); + +// IntAna2d_AnaIntersection inter; +// inter.Perform( line1.Normal( loc1 ), line2.Normal( loc2 ) ); +// if ( inter.IsDone() && inter.NbPoints() == 1 ) +// { +// gp_Pnt2d interUV = inter.Point(1).Value(); +// resUV += interUV.XY(); +// inter.Perform( line1, line2 ); +// interUV = inter.Point(1).Value(); +// resUV += interUV.XY(); + +// resUV /= 2.; +// } + return true; +} + +//======================================================================= +//function : compUVByIsoIntersection +//purpose : +//======================================================================= + +bool SMESH_Pattern::compUVByIsoIntersection (const list< list< TPoint* > >& theBndPoints, + const gp_XY& theInitUV, + gp_XY& theUV, + bool & theIsDeformed ) +{ + // compute UV by intersection of 2 iso lines + //gp_Lin2d isoLine[2]; + gp_XY uv1[2], uv2[2]; + double ratio[2]; + const double zero = DBL_MIN; + for ( int iIso = 0; iIso < 2; iIso++ ) + { + // to build an iso line: + // find 2 pairs of consequent edge-points such that the range of their + // initial parameters encloses the in-face point initial parameter + gp_XY UV[2], initUV[2]; + int nbUV = 0, iCoord = iIso + 1; + double initParam = theInitUV.Coord( iCoord ); + + list< list< TPoint* > >::const_iterator bndIt = theBndPoints.begin(); + for ( ; bndIt != theBndPoints.end(); bndIt++ ) + { + const list< TPoint* > & bndPoints = * bndIt; + TPoint* prevP = bndPoints.back(); // this is the first point + list< TPoint* >::const_iterator pIt = bndPoints.begin(); + bool coincPrev = false; + // loop on the edge-points + for ( ; pIt != bndPoints.end(); pIt++ ) + { + double paramDiff = initParam - (*pIt)->myInitUV.Coord( iCoord ); + double prevParamDiff = initParam - prevP->myInitUV.Coord( iCoord ); + double sumOfDiff = Abs(prevParamDiff) + Abs(paramDiff); + if (!coincPrev && // ignore if initParam coincides with prev point param + sumOfDiff > zero && // ignore if both points coincide with initParam + prevParamDiff * paramDiff <= zero ) + { + // find UV in parametric space of theFace + double r = Abs(prevParamDiff) / sumOfDiff; + gp_XY uvInit = (*pIt)->myInitUV * r + prevP->myInitUV * ( 1 - r ); + int i = nbUV++; + if ( i >= 2 ) { + // throw away uv most distant from + gp_XY vec0 = initUV[0] - theInitUV; + gp_XY vec1 = initUV[1] - theInitUV; + gp_XY vec = uvInit - theInitUV; + bool isBetween = ( vec0 * vec1 < 0 ); // is theInitUV between initUV[0] and initUV[1] + double dist0 = vec0.SquareModulus(); + double dist1 = vec1.SquareModulus(); + double dist = vec .SquareModulus(); + if ( !isBetween || dist < dist0 || dist < dist1 ) { + i = ( dist0 < dist1 ? 1 : 0 ); + if ( isBetween && vec.Dot( i ? vec1 : vec0 ) < 0 ) + i = 3; // theInitUV must remain between + } + } + if ( i < 2 ) { + initUV[ i ] = uvInit; + UV[ i ] = (*pIt)->myUV * r + prevP->myUV * ( 1 - r ); + } + coincPrev = ( Abs(paramDiff) <= zero ); + } + else + coincPrev = false; + prevP = *pIt; + } + } + if ( nbUV < 2 || (UV[0]-UV[1]).SquareModulus() <= DBL_MIN*DBL_MIN ) { + MESSAGE(" consequent edge-points not found, nb UV found: " << nbUV << + ", for point: " << theInitUV.X() <<" " << theInitUV.Y() ); + return setErrorCode( ERR_APPLF_BAD_TOPOLOGY ); + } + // an iso line should be normal to UV[0] - UV[1] direction + // and be located at the same relative distance as from initial ends + //gp_Lin2d iso( UV[0], UV[0] - UV[1] ); + double r = + (initUV[0]-theInitUV).Modulus() / (initUV[0]-initUV[1]).Modulus(); + //gp_Pnt2d isoLoc = UV[0] * ( 1 - r ) + UV[1] * r; + //isoLine[ iIso ] = iso.Normal( isoLoc ); + uv1[ iIso ] = UV[0]; + uv2[ iIso ] = UV[1]; + ratio[ iIso ] = r; + } + if ( !intersectIsolines( uv1[0], uv2[0], ratio[0], + uv1[1], uv2[1], ratio[1], theUV, theIsDeformed )) { + MESSAGE(" Cant intersect isolines for a point "<myNext[ dir ]; + if ( n && !n->IsUVComputed()/* && node->IsMovable()*/ ) { + n = 0;//node->myBndNodes[ dir ]; +// MESSAGE("getNextNode: use bnd for node "<< +// node->myInitUV.X()<<" "<myInitUV.Y()); + } + return n; +} +//======================================================================= +//function : checkQuads +//purpose : check if newUV destortes quadrangles around node, +// and if ( crit == FIX_OLD ) fix newUV in this case +//======================================================================= + +enum { CHECK_NEW_IN, CHECK_NEW_OK, FIX_OLD }; + +static bool checkQuads (const TIsoNode* node, + gp_XY& newUV, + const bool reversed, + const int crit = FIX_OLD, + double fixSize = 0.) +{ + gp_XY oldUV = node->myUV, oldUVFixed[4], oldUVImpr[4]; + int nbOldFix = 0, nbOldImpr = 0; + double newBadRate = 0, oldBadRate = 0; + bool newIsOk = true, newIsIn = true, oldIsIn = true, oldIsOk = true; + int i, dir1 = 0, dir2 = 3; + for ( ; dir1 < 4; dir1++, dir2++ ) // loop on 4 quadrangles around + { + if ( dir2 > 3 ) dir2 = 0; + TIsoNode* n[3]; + // walking counterclockwise around a quad, + // nodes are in the order: node, n[0], n[1], n[2] + n[0] = getNextNode( node, dir1 ); + n[2] = getNextNode( node, dir2 ); + if ( !n[0] || !n[2] ) continue; + n[1] = getNextNode( n[0], dir2 ); + if ( !n[1] ) n[1] = getNextNode( n[2], dir1 ); + bool isTriangle = ( !n[1] ); + if ( reversed ) { + TIsoNode* tmp = n[0]; n[0] = n[2]; n[2] = tmp; + } +// if ( fixSize != 0 ) { +// cout<<"NODE: "<myInitUV.X()<<" "<myInitUV.Y()<<" UV: "<myUV.X()<<" "<myUV.Y()<myInitUV.X()<<" "<myInitUV.Y()<<" UV: "<myUV.X()<<" "<myUV.Y()<myInitUV.X()<<" "<myInitUV.Y()<<" UV: "<myUV.X()<<" "<myUV.Y()<myInitUV.X()<<" "<myInitUV.Y()<<" UV: "<myUV.X()<<" "<myUV.Y()<myUV - n[1]->myUV ).SquareModulus() <= DBL_MIN ) || + (( n[2]->myUV - n[1]->myUV ).SquareModulus() <= DBL_MIN ))) + isTriangle = true; + if ( isTriangle && + ( n[0]->myUV - n[2]->myUV ).SquareModulus() <= DBL_MIN ) + continue; + + // find min size of the diagonal node-n[1] + double minDiag = fixSize; + if ( minDiag == 0. ) { + double maxLen2 = ( node->myUV - n[0]->myUV ).SquareModulus(); + if ( !isTriangle ) { + maxLen2 = Max( maxLen2, ( n[0]->myUV - n[1]->myUV ).SquareModulus() ); + maxLen2 = Max( maxLen2, ( n[1]->myUV - n[2]->myUV ).SquareModulus() ); + } + maxLen2 = Max( maxLen2, ( n[2]->myUV - node->myUV ).SquareModulus() ); + minDiag = sqrt( maxLen2 ) * PI / 60.; // ~ maxLen * Sin( 3 deg ) + } + + // check if newUV is behind 3 dirs: n[0]-n[1], n[1]-n[2] and n[0]-n[2] + // ( behind means "to the right of") + // it is OK if + // 1. newUV is not behind 01 and 12 dirs + // 2. or newUV is not behind 02 dir and n[2] is convex + bool newIn[3] = { true, true, true }, newOk[3] = { true, true, true }; + bool wasIn[3] = { true, true, true }, wasOk[3] = { true, true, true }; + gp_Vec2d moveVec[3], outVec[3]; + for ( i = isTriangle ? 2 : 0; i < 3; i++ ) + { + bool isDiag = ( i == 2 ); + if ( isDiag && newOk[0] && newOk[1] && !isTriangle ) + break; + gp_Vec2d sideDir; + if ( isDiag ) + sideDir = gp_Vec2d( n[0]->myUV, n[2]->myUV ); + else + sideDir = gp_Vec2d( n[i]->myUV, n[i+1]->myUV ); + + gp_Vec2d outDir( sideDir.Y(), -sideDir.X() ); // to the right + outDir.Normalize(); + gp_Vec2d newDir( n[i]->myUV, newUV ); + gp_Vec2d oldDir( n[i]->myUV, oldUV ); + outVec[i] = outDir; + if ( newIsOk ) newOk[i] = ( outDir * newDir < -minDiag ); + if ( newIsIn ) newIn[i] = ( outDir * newDir < 0 ); + if ( crit == FIX_OLD ) { + wasIn[i] = ( outDir * oldDir < 0 ); + wasOk[i] = ( outDir * oldDir < -minDiag ); + if ( !newOk[i] ) + newBadRate += outDir * newDir; + if ( !wasOk[i] ) + oldBadRate += outDir * oldDir; + // push node inside + if ( !wasOk[i] ) { + double oldDist = - outDir * oldDir;//, l2 = outDir * newDir; + // double r = ( l1 - minDiag ) / ( l1 + l2 ); + // moveVec[i] = r * gp_Vec2d( node->myUV, newUV ); + moveVec[i] = ( oldDist - minDiag ) * outDir; + } + } + } + + // check if n[2] is convex + bool convex = true; + if ( !isTriangle ) + convex = ( outVec[0] * gp_Vec2d( n[1]->myUV, n[2]->myUV ) < 0 ); + + bool isNewOk = ( newOk[0] && newOk[1] ) || ( newOk[2] && convex ); + bool isNewIn = ( newIn[0] && newIn[1] ) || ( newIn[2] && convex ); + newIsOk = ( newIsOk && isNewOk ); + newIsIn = ( newIsIn && isNewIn ); + + if ( crit != FIX_OLD ) { + if ( crit == CHECK_NEW_OK && !newIsOk ) break; + if ( crit == CHECK_NEW_IN && !newIsIn ) break; + continue; + } + + bool isOldIn = ( wasIn[0] && wasIn[1] ) || ( wasIn[2] && convex ); + bool isOldOk = ( wasOk[0] && wasOk[1] ) || ( wasOk[2] && convex ); + oldIsIn = ( oldIsIn && isOldIn ); + oldIsOk = ( oldIsOk && isOldIn ); + + + if ( !isOldIn ) { // node is outside a quadrangle + // move newUV inside a quadrangle +//MESSAGE("Quad "<< dir1 << " WAS IN " << wasIn[0]<<" "<myUV + n[2]->myUV ) - minDiag * outVec[2].XY(); + } + else { + gp_Vec2d out = outVec[0].Normalized() + outVec[1].Normalized(); + double outSize = out.Magnitude(); + if ( outSize > DBL_MIN ) + out /= outSize; + else + out.SetCoord( -outVec[1].Y(), outVec[1].X() ); + uv = n[1]->myUV - minDiag * out.XY(); + } + oldUVFixed[ nbOldFix++ ] = uv; + //node->myUV = newUV; + } + else if ( !isOldOk ) { + // try to fix old UV: move node inside as less as possible +//MESSAGE("Quad "<< dir1 << " old is BAD, try to fix old, minDiag: "<< minDiag); + gp_XY uv1, uv2 = node->myUV; + for ( i = isTriangle ? 2 : 0; i < 3; i++ ) // mark not computed vectors + if ( wasOk[i] ) + moveVec[ i ].SetCoord( 1, 2e100); // not use this vector + while ( !isOldOk ) { + // find the least moveVec + int i, iMin = 4; + double minMove2 = 1e100; + for ( i = isTriangle ? 2 : 0; i < 3; i++ ) + { + if ( moveVec[i].Coord(1) < 1e100 ) { + double move2 = moveVec[i].SquareMagnitude(); + if ( move2 < minMove2 ) { + minMove2 = move2; + iMin = i; + } + } + } + if ( iMin == 4 ) { + break; + } + // move node to newUV + uv1 = node->myUV + moveVec[ iMin ].XY(); + uv2 += moveVec[ iMin ].XY(); + moveVec[ iMin ].SetCoord( 1, 2e100); // not use this vector more + // check if uv1 is ok + for ( i = isTriangle ? 2 : 0; i < 3; i++ ) + wasOk[i] = ( outVec[i] * gp_Vec2d( n[i]->myUV, uv1 ) < -minDiag ); + isOldOk = ( wasOk[0] && wasOk[1] ) || ( wasOk[2] && convex ); + if ( isOldOk ) + oldUVImpr[ nbOldImpr++ ] = uv1; + else { + // check if uv2 is ok + for ( i = isTriangle ? 2 : 0; i < 3; i++ ) + wasOk[i] = ( outVec[i] * gp_Vec2d( n[i]->myUV, uv2 ) < -minDiag ); + isOldOk = ( wasOk[0] && wasOk[1] ) || ( wasOk[2] && convex ); + if ( isOldOk ) + oldUVImpr[ nbOldImpr++ ] = uv2; + } + } + } + + } // loop on 4 quadrangles around + + if ( crit == CHECK_NEW_OK ) + return newIsOk; + if ( crit == CHECK_NEW_IN ) + return newIsIn; + + if ( newIsOk ) + return true; + + if ( oldIsOk ) + newUV = oldUV; + else { + if ( oldIsIn && nbOldImpr ) { +// MESSAGE(" Try to improve UV, init: "<myInitUV.X()<<" "<myInitUV.Y()<< +// " uv: "<myInitUV.X()<<" "<myInitUV.Y()<< +// " uv: "< >& theBndPoints, + const list< TPoint* >& thePntToCompute) +{ +//cout << "============================== KEY POINTS =============================="<::iterator kpIt = myKeyPointIDs.begin(); +// for ( ; kpIt != myKeyPointIDs.end(); kpIt++ ) { +// TPoint& p = myPoints[ *kpIt ]; +// cout << "INIT: " << p.myInitUV.X() << " " << p.myInitUV.Y() << +// " UV: " << p.myUV.X() << " " << p.myUV.Y() << endl; +// } +//cout << "=============================="< paramSet[ 2 ]; + list< list< TPoint* > >::const_iterator pListIt; + list< TPoint* >::const_iterator pIt; + for ( pListIt = theBndPoints.begin(); pListIt != theBndPoints.end(); pListIt++ ) { + const list< TPoint* > & pList = * pListIt; + for ( pIt = pList.begin(); pIt != pList.end(); pIt++ ) { + paramSet[0].insert( (*pIt)->myInitUV.X() ); + paramSet[1].insert( (*pIt)->myInitUV.Y() ); + } + } + for ( pIt = thePntToCompute.begin(); pIt != thePntToCompute.end(); pIt++ ) { + paramSet[0].insert( (*pIt)->myInitUV.X() ); + paramSet[1].insert( (*pIt)->myInitUV.Y() ); + } + // unite close parameters and split too long segments + int iDir; + double tol[ 2 ]; + for ( iDir = 0; iDir < 2; iDir++ ) + { + set< double > & params = paramSet[ iDir ]; + double range = ( *params.rbegin() - *params.begin() ); + double toler = range / 1e6; + tol[ iDir ] = toler; +// double maxSegment = range / params.size() / 2.; +// +// set< double >::iterator parIt = params.begin(); +// double prevPar = *parIt; +// for ( parIt++; parIt != params.end(); parIt++ ) +// { +// double segLen = (*parIt) - prevPar; +// if ( segLen < toler ) +// ;//params.erase( prevPar ); // unite +// else if ( segLen > maxSegment ) +// params.insert( prevPar + 0.5 * segLen ); // split +// prevPar = (*parIt); +// } + } + + // Make nodes of a grid of iso-poly-lines + + list < TIsoNode > nodes; + typedef list < TIsoNode *> TIsoLine; + map < double, TIsoLine > isoMap[ 2 ]; + + set< double > & params0 = paramSet[ 0 ]; + set< double >::iterator par0It = params0.begin(); + for ( ; par0It != params0.end(); par0It++ ) + { + TIsoLine & isoLine0 = isoMap[0][ *par0It ]; // vertical isoline with const U + set< double > & params1 = paramSet[ 1 ]; + set< double >::iterator par1It = params1.begin(); + for ( ; par1It != params1.end(); par1It++ ) + { + nodes.push_back( TIsoNode( *par0It, *par1It ) ); + isoLine0.push_back( & nodes.back() ); + isoMap[1][ *par1It ].push_back( & nodes.back() ); + } + } + + // Compute intersections of boundaries with iso-lines: + // only boundary nodes will have computed UV so far + + Bnd_Box2d uvBnd; + list< list< TPoint* > >::const_iterator bndIt = theBndPoints.begin(); + list< TIsoNode* > bndNodes; // nodes corresponding to outer theBndPoints + for ( ; bndIt != theBndPoints.end(); bndIt++ ) + { + const list< TPoint* > & bndPoints = * bndIt; + TPoint* prevP = bndPoints.back(); // this is the first point + list< TPoint* >::const_iterator pIt = bndPoints.begin(); + // loop on the edge-points + for ( ; pIt != bndPoints.end(); pIt++ ) + { + TPoint* point = *pIt; + for ( iDir = 0; iDir < 2; iDir++ ) + { + const int iCoord = iDir + 1; + const int iOtherCoord = 2 - iDir; + double par1 = prevP->myInitUV.Coord( iCoord ); + double par2 = point->myInitUV.Coord( iCoord ); + double parDif = par2 - par1; + if ( Abs( parDif ) <= DBL_MIN ) + continue; + // find iso-lines intersecting a bounadry + double toler = tol[ 1 - iDir ]; + double minPar = Min ( par1, par2 ); + double maxPar = Max ( par1, par2 ); + map < double, TIsoLine >& isos = isoMap[ iDir ]; + map < double, TIsoLine >::iterator isoIt = isos.begin(); + for ( ; isoIt != isos.end(); isoIt++ ) + { + double isoParam = (*isoIt).first; + if ( isoParam < minPar || isoParam > maxPar ) + continue; + double r = ( isoParam - par1 ) / parDif; + gp_XY uv = ( 1 - r ) * prevP->myUV + r * point->myUV; + gp_XY initUV = ( 1 - r ) * prevP->myInitUV + r * point->myInitUV; + double otherPar = initUV.Coord( iOtherCoord ); // along isoline + // find existing node with otherPar or insert a new one + TIsoLine & isoLine = (*isoIt).second; + double nodePar; + TIsoLine::iterator nIt = isoLine.begin(); + for ( ; nIt != isoLine.end(); nIt++ ) { + nodePar = (*nIt)->myInitUV.Coord( iOtherCoord ); + if ( nodePar >= otherPar ) + break; + } + TIsoNode * node; + if ( Abs( nodePar - otherPar ) <= toler ) + node = ( nIt == isoLine.end() ) ? isoLine.back() : (*nIt); + else { + nodes.push_back( TIsoNode( initUV.X(), initUV.Y() ) ); + node = & nodes.back(); + isoLine.insert( nIt, node ); + } + node->SetNotMovable(); + node->myUV = uv; + uvBnd.Add( gp_Pnt2d( uv )); +// cout << "bnd: "<myInitUV.X()<<" "<myInitUV.Y()<<" UV: "<myUV.X()<<" "<myUV.Y()<myUV - prevP->myUV ); + if ( ::IsEqual( r, 1. )) + node->myDir[ 0 ] = tgt; + else if ( ::IsEqual( r, 0. )) + node->myDir[ 1 ] = tgt; + else + node->myDir[ 1 ] = node->myDir[ 0 ] = tgt; + // keep boundary nodes corresponding to boundary points + if ( bndIt == theBndPoints.begin() && ::IsEqual( r, 1. )) + if ( bndNodes.empty() || bndNodes.back() != node ) + bndNodes.push_back( node ); + } // loop on isolines + } // loop on 2 directions + prevP = point; + } // loop on boundary points + } // loop on boundaries + + // Define orientation + + // find the point with the least X + double leastX = DBL_MAX; + TIsoNode * leftNode; + list < TIsoNode >::iterator nodeIt = nodes.begin(); + for ( ; nodeIt != nodes.end(); nodeIt++ ) { + TIsoNode & node = *nodeIt; + if ( node.IsUVComputed() && node.myUV.X() < leastX ) { + leastX = node.myUV.X(); + leftNode = &node; + } +// if ( node.IsUVComputed() ) { +// cout << "bndNode INIT: " << node.myInitUV.X()<<" "<myDir[0].Y() + leftNode->myDir[1].Y() > 0 ); + //SCRUTE( reversed ); + + // Prepare internal nodes: + // 1. connect nodes + // 2. compute ratios + // 3. find boundary nodes for each node + // 4. remove nodes out of the boundary + for ( iDir = 0; iDir < 2; iDir++ ) + { + const int iCoord = 2 - iDir; // coord changing along an isoline + map < double, TIsoLine >& isos = isoMap[ iDir ]; + map < double, TIsoLine >::iterator isoIt = isos.begin(); + for ( ; isoIt != isos.end(); isoIt++ ) + { + TIsoLine & isoLine = (*isoIt).second; + bool firstCompNodeFound = false; + TIsoLine::iterator lastCompNodePos, nPrevIt, nIt, nNextIt, nIt2; + nPrevIt = nIt = nNextIt = isoLine.begin(); + nIt++; + nNextIt++; nNextIt++; + while ( nIt != isoLine.end() ) + { + // 1. connect prev - cur + TIsoNode* node = *nIt, * prevNode = *nPrevIt; + if ( !firstCompNodeFound && prevNode->IsUVComputed() ) { + firstCompNodeFound = true; + lastCompNodePos = nPrevIt; + } + if ( firstCompNodeFound ) { + node->SetNext( prevNode, iDir, 0 ); + prevNode->SetNext( node, iDir, 1 ); + } + // 2. compute ratio + if ( nNextIt != isoLine.end() ) { + double par1 = prevNode->myInitUV.Coord( iCoord ); + double par2 = node->myInitUV.Coord( iCoord ); + double par3 = (*nNextIt)->myInitUV.Coord( iCoord ); + node->myRatio[ iDir ] = ( par2 - par1 ) / ( par3 - par1 ); + } + // 3. find boundary nodes + if ( node->IsUVComputed() ) + lastCompNodePos = nIt; + else if ( firstCompNodeFound && nNextIt != isoLine.end() ) { + TIsoNode* bndNode1 = *lastCompNodePos, *bndNode2 = 0; + for ( nIt2 = nNextIt; nIt2 != isoLine.end(); nIt2++ ) + if ( (*nIt2)->IsUVComputed() ) + break; + if ( nIt2 != isoLine.end() ) { + bndNode2 = *nIt2; + node->SetBoundaryNode( bndNode1, iDir, 0 ); + node->SetBoundaryNode( bndNode2, iDir, 1 ); +// cout << "--------------------------------------------------"<myUV.X()<<" "<myUV.Y()<myDir[0].X()<<" "<myDir[0].Y() << +// " dir1: "<myDir[1].X()<<" "<myDir[1].Y() << endl; +// cout << "bndNode2: " << bndNode2->myUV.X()<<" "<myUV.Y()<myDir[0].X()<<" "<myDir[0].Y() << +// " dir1: "<myDir[1].X()<<" "<myDir[1].Y() << endl; + } + } + nIt++; nPrevIt++; + if ( nNextIt != isoLine.end() ) nNextIt++; + // 4. remove nodes out of the boundary + if ( !firstCompNodeFound ) + isoLine.pop_front(); + } // loop on isoLine nodes + + // remove nodes after the boundary +// for ( nIt = ++lastCompNodePos; nIt != isoLine.end(); nIt++ ) +// (*nIt)->SetNotMovable(); + isoLine.erase( ++lastCompNodePos, isoLine.end() ); + } // loop on isolines + } // loop on 2 directions + + // Compute local isoline direction for internal nodes + + /* + map < double, TIsoLine >& isos = isoMap[ 0 ]; // vertical isolines with const U + map < double, TIsoLine >::iterator isoIt = isos.begin(); + for ( ; isoIt != isos.end(); isoIt++ ) + { + TIsoLine & isoLine = (*isoIt).second; + TIsoLine::iterator nIt = isoLine.begin(); + for ( ; nIt != isoLine.end(); nIt++ ) + { + TIsoNode* node = *nIt; + if ( node->IsUVComputed() || !node->IsMovable() ) + continue; + gp_Vec2d aTgt[2], aNorm[2]; + double ratio[2]; + bool OK = true; + for ( iDir = 0; iDir < 2; iDir++ ) + { + TIsoNode* bndNode1 = node->GetBoundaryNode( iDir, 0 ); + TIsoNode* bndNode2 = node->GetBoundaryNode( iDir, 1 ); + if ( !bndNode1 || !bndNode2 ) { + OK = false; + break; + } + const int iCoord = 2 - iDir; // coord changing along an isoline + double par1 = bndNode1->myInitUV.Coord( iCoord ); + double par2 = node->myInitUV.Coord( iCoord ); + double par3 = bndNode2->myInitUV.Coord( iCoord ); + ratio[ iDir ] = ( par2 - par1 ) / ( par3 - par1 ); + + gp_Vec2d tgt1( bndNode1->myDir[0].XY() + bndNode1->myDir[1].XY() ); + gp_Vec2d tgt2( bndNode2->myDir[0].XY() + bndNode2->myDir[1].XY() ); + if ( bool( iDir ) == reversed ) tgt2.Reverse(); // along perpend. isoline + else tgt1.Reverse(); +//cout<<" tgt: " << tgt1.X()<<" "< PI / 2. ) { + // check direction of the last but one perpendicular isoline + TIsoNode* prevNode = bndNode2->GetNext( iDir, 0 ); + bndNode1 = prevNode->GetBoundaryNode( 1 - iDir, 0 ); + bndNode2 = prevNode->GetBoundaryNode( 1 - iDir, 1 ); + gp_Vec2d isoDir( bndNode1->myUV, bndNode2->myUV ); + if ( isoDir * tgt2 < 0 ) + isoDir.Reverse(); + double angle2 = tgt1.Angle( isoDir ); + //cout << " isoDir: "<< isoDir.X() <<" "< Abs( angle ) || + ( angle2 * angle < 0 && Abs( angle2 ) > Abs( angle - angle2 ))) { + //MESSAGE("Add PI"); + // cout << "NODE: "<myInitUV.X()<<" "<myInitUV.Y()<myUV.X()<<" "<myUV.Y()<< endl; + // cout << "bndNode2: " << bndNode2->myUV.X()<<" "<myUV.Y()<myDir[iDir] = //aTgt[iDir]; + aNorm[1-iDir] * r + aTgt[iDir] * ( 1. - r ); + } +// cout << "NODE: "<myInitUV.X()<<" "<myInitUV.Y()<myDir[0].X() <<" "<myDir[0].Y()<<" | " +// << node->myDir[1].X() <<" "<myDir[1].Y()< startNodes; + list< TIsoNode* >::iterator nIt = bndNodes.end(); + TIsoNode* node = *(--nIt); + TIsoNode* prevNode = *(--nIt); + for ( nIt = bndNodes.begin(); nIt != bndNodes.end(); nIt++ ) + { + TIsoNode* nextNode = *nIt; + gp_Vec2d initTgt1( prevNode->myInitUV, node->myInitUV ); + gp_Vec2d initTgt2( node->myInitUV, nextNode->myInitUV ); + double initAngle = initTgt1.Angle( initTgt2 ); + double angle = node->myDir[0].Angle( node->myDir[1] ); + if ( reversed ) angle = -angle; + if ( initAngle > angle && initAngle - angle > PI / 2.1 ) { + // find a close internal node + TIsoNode* nClose = 0; + list< TIsoNode* > testNodes; + testNodes.push_back( node ); + list< TIsoNode* >::iterator it = testNodes.begin(); + for ( ; !nClose && it != testNodes.end(); it++ ) + { + for (int i = 0; i < 4; i++ ) + { + nClose = (*it)->myNext[ i ]; + if ( nClose ) { + if ( !nClose->IsUVComputed() ) + break; + else { + testNodes.push_back( nClose ); + nClose = 0; + } + } + } + } + startNodes.push_back( nClose ); +// cout << "START: "<myInitUV.X()<<" "<myInitUV.Y()<<" UV: "<< +// node->myUV.X()<<" "<myUV.Y()<myDir[ 0 ].X() <<" "<myDir[ 0 ].Y()<<" | "<< +// node->myDir[ 1 ].X() <<" "<myDir[ 1 ].Y()<myInitUV.X()<<" "<myInitUV.Y()< internNodes; + bool needIteration = true; + if ( startNodes.empty() ) { + MESSAGE( " Starting UV by compUVByIsoIntersection()"); + needIteration = false; + map < double, TIsoLine >& isos = isoMap[ 0 ]; + map < double, TIsoLine >::iterator isoIt = isos.begin(); + for ( ; isoIt != isos.end(); isoIt++ ) + { + TIsoLine & isoLine = (*isoIt).second; + TIsoLine::iterator nIt = isoLine.begin(); + for ( ; !needIteration && nIt != isoLine.end(); nIt++ ) + { + TIsoNode* node = *nIt; + if ( !node->IsUVComputed() && node->IsMovable() ) { + internNodes.push_back( node ); + //bool isDeformed; + if ( !compUVByIsoIntersection(theBndPoints, node->myInitUV, + node->myUV, needIteration )) + node->myUV = node->myInitUV; + } + } + } + if ( needIteration ) + for ( nIt = bndNodes.begin(); nIt != bndNodes.end(); nIt++ ) + { + TIsoNode* node = *nIt, *nClose = 0; + list< TIsoNode* > testNodes; + testNodes.push_back( node ); + list< TIsoNode* >::iterator it = testNodes.begin(); + for ( ; !nClose && it != testNodes.end(); it++ ) + { + for (int i = 0; i < 4; i++ ) + { + nClose = (*it)->myNext[ i ]; + if ( nClose ) { + if ( !nClose->IsUVComputed() && nClose->IsMovable() ) + break; + else { + testNodes.push_back( nClose ); + nClose = 0; + } + } + } + } + startNodes.push_back( nClose ); + } + } + + double aMin[2], aMax[2], step[2]; + uvBnd.Get( aMin[0], aMin[1], aMax[0], aMax[1] ); + double minUvSize = Min ( aMax[0]-aMin[0], aMax[1]-aMin[1] ); + step[0] = minUvSize / paramSet[ 0 ].size() / 10; + step[1] = minUvSize / paramSet[ 1 ].size() / 10; +//cout << "STEPS: " << step[0] << " " << step[1]<< endl; + + for ( nIt = startNodes.begin(); nIt != startNodes.end(); nIt++ ) + { + TIsoNode* prevN[2], *node = *nIt; + if ( node->IsUVComputed() || !node->IsMovable() ) + continue; + gp_XY newUV( 0, 0 ), sumDir( 0, 0 ); + int nbComp = 0, nbPrev = 0; + for ( iDir = 0; iDir < 2; iDir++ ) + { + TIsoNode* prevNode1 = 0, *prevNode2 = 0; + TIsoNode* n = node->GetNext( iDir, 0 ); + if ( n->IsUVComputed() ) + prevNode1 = n; + else + startNodes.push_back( n ); + n = node->GetNext( iDir, 1 ); + if ( n->IsUVComputed() ) + prevNode2 = n; + else + startNodes.push_back( n ); + if ( !prevNode1 ) { + prevNode1 = prevNode2; + prevNode2 = 0; + } + if ( prevNode1 ) nbPrev++; + if ( prevNode2 ) nbPrev++; + if ( prevNode1 ) { + gp_XY dir; + double prevPar = prevNode1->myInitUV.Coord( 2 - iDir ); + double par = node->myInitUV.Coord( 2 - iDir ); + bool isEnd = ( prevPar > par ); +// dir = node->myDir[ 1 - iDir ].XY() * ( isEnd ? -1. : 1. ); + //cout << "__________"<myInitUV.X()<<" "<myInitUV.Y()<GetBoundaryNode( iDir, isEnd ); + gp_XY tgt( bndNode->myDir[0].XY() + bndNode->myDir[1].XY() ); + dir.SetCoord( 1, tgt.Y() * ( reversed ? 1 : -1 )); + dir.SetCoord( 2, tgt.X() * ( reversed ? -1 : 1 )); + //cout << "bndNode UV: " << bndNode->myUV.X()<<" "<myUV.Y()<< endl; + // cout << " tgt: "<< bndNode->myDir[ 0 ].X() <<" "<myDir[ 0 ].Y()<<" | "<< + // bndNode->myDir[ 1 ].X() <<" "<myDir[ 1 ].Y()<myUV.X()<<" "<myUV.Y()<< + //" par: " << prevPar << endl; + // cout <<" tgt: " << tgt.X()<<" "<myInitUV.X()<<" "<myInitUV.Y()<myUV; + gp_XY & uv2 = prevNode2->myUV; +// dir = ( uv2 - uv1 ); +// double len = dir.Modulus(); +// if ( len > DBL_MIN ) +// dir /= len * 0.5; + double r = node->myRatio[ iDir ]; + newUV += uv1 * ( 1 - r ) + uv2 * r; + } + else { + newUV += prevNode1->myUV + dir * step[ iDir ]; + } + sumDir += dir; + prevN[ iDir ] = prevNode1; + nbComp++; + } + } + newUV /= nbComp; + node->myUV = newUV; + //cout << "NODE: "<myInitUV.X()<<" "<myInitUV.Y()< 1 ) { + //int crit = ( nbPrev == 4 ) ? FIX_OLD : CHECK_NEW_IN; + if ( !checkQuads( node, newUV, reversed, FIX_OLD, step[0] + step[1] )) { + //cout <<" newUV: " << node->myUV.X() << " "<myUV.Y() << " nbPrev: "<myUV = newUV; + } + } + internNodes.push_back( node ); + } + + // Move nodes + + static int maxNbIter = 100; +#ifdef DEB_COMPUVBYELASTICISOLINES +// maxNbIter++; + bool useNbMoveNode = 0; + static int maxNbNodeMove = 100; + maxNbNodeMove++; + int nbNodeMove = 0; + if ( !useNbMoveNode ) + maxNbIter = ( maxNbIter < 0 ) ? 100 : -1; +#endif + double maxMove; + int nbIter = 0; + do { + if ( !needIteration) break; +#ifdef DEB_COMPUVBYELASTICISOLINES + if ( nbIter >= maxNbIter ) break; +#endif + maxMove = 0.0; + list < TIsoNode* >::iterator nIt = internNodes.begin(); + for ( ; nIt != internNodes.end(); nIt++ ) { +#ifdef DEB_COMPUVBYELASTICISOLINES + if (useNbMoveNode ) + cout << nbNodeMove <<" =================================================="<GetNext( iDir, 0 )->myUV; + gp_XY & uv2 = node->GetNext( iDir, 1 )->myUV; + double r = node->myRatio[ iDir ]; + loc[ iDir ] = uv1 * ( 1 - r ) + uv2 * r; +// line[ iDir ].SetLocation( loc[ iDir ] ); +// line[ iDir ].SetDirection( node->myDir[ iDir ] ); + } + // define ratio + double locR[2] = { 0, 0 }; + for ( iDir = 0; iDir < 2; iDir++ ) + { + const int iCoord = 2 - iDir; // coord changing along an isoline + TIsoNode* bndNode1 = node->GetBoundaryNode( iDir, 0 ); + TIsoNode* bndNode2 = node->GetBoundaryNode( iDir, 1 ); + double par1 = bndNode1->myInitUV.Coord( iCoord ); + double par2 = node->myInitUV.Coord( iCoord ); + double par3 = bndNode2->myInitUV.Coord( iCoord ); + double r = ( par2 - par1 ) / ( par3 - par1 ); + r = Abs ( r - 0.5 ) * 2.0; // [0,1] - distance from the middle + locR[ iDir ] = ( 1 - r * r ) * 0.25; + } + //locR[0] = locR[1] = 0.25; + // intersect the 2 lines and move a node + //IntAna2d_AnaIntersection inter( line[0], line[1] ); + if ( /*inter.IsDone() && inter.NbPoints() ==*/ 1 ) + { +// double intR = 1 - locR[0] - locR[1]; +// gp_XY newUV = inter.Point(1).Value().XY(); +// if ( !checkQuads( node, newUV, reversed, CHECK_NEW_IN )) +// newUV = ( locR[0] * loc[0] + locR[1] * loc[1] ) / ( 1 - intR ); +// else +// newUV = intR * newUV + locR[0] * loc[0] + locR[1] * loc[1]; + gp_XY newUV = 0.5 * ( loc[0] + loc[1] ); + // avoid parallel isolines intersection + checkQuads( node, newUV, reversed ); + + maxMove = Max( maxMove, ( newUV - node->myUV ).SquareModulus()); + node->myUV = newUV; + } // intersection found +#ifdef DEB_COMPUVBYELASTICISOLINES + if (useNbMoveNode && ++nbNodeMove >= maxNbNodeMove ) break; +#endif + } // loop on internal nodes +#ifdef DEB_COMPUVBYELASTICISOLINES + if (useNbMoveNode && nbNodeMove >= maxNbNodeMove ) break; +#endif + } while ( maxMove > 1e-8 && nbIter++ < maxNbIter ); + + MESSAGE( "compUVByElasticIsolines(): Nb iterations " << nbIter << " dist: " << sqrt( maxMove )); + + if ( nbIter >= maxNbIter && sqrt(maxMove) > minUvSize * 0.05 ) { + MESSAGE( "compUVByElasticIsolines() failed: "<"<myUV; + double minDist = DBL_MAX; + list < TIsoNode >::iterator nIt = nodes.begin(); + for ( ; nIt != nodes.end(); nIt++ ) { + double dist = ( (*nIt).myInitUV - point->myInitUV ).SquareModulus(); + if ( dist < minDist ) { + minDist = dist; + point->myUV = (*nIt).myUV; + } + } + } + + + return true; +} + + +//======================================================================= +//function : setFirstEdge +//purpose : choose the best first edge of theWire; return the summary distance +// between point UV computed by isolines intersection and +// eventual UV got from edge p-curves +//======================================================================= + +//#define DBG_SETFIRSTEDGE +double SMESH_Pattern::setFirstEdge (list< TopoDS_Edge > & theWire, int theFirstEdgeID) +{ + int iE, nbEdges = theWire.size(); + if ( nbEdges == 1 ) + return 0; + + // Transform UVs computed by iso to fit bnd box of a wire + + // max nb of points on an edge + int maxNbPnt = 0; + int eID = theFirstEdgeID; + for ( iE = 0; iE < nbEdges; iE++ ) + maxNbPnt = Max ( maxNbPnt, getShapePoints( eID++ ).size() ); + + // compute bnd boxes + TopoDS_Face face = TopoDS::Face( myShape ); + Bnd_Box2d bndBox, eBndBox; + eID = theFirstEdgeID; + list< TopoDS_Edge >::iterator eIt; + list< TPoint* >::iterator pIt; + for ( eIt = theWire.begin(); eIt != theWire.end(); eIt++ ) + { + // UV by isos stored in TPoint.myXYZ + list< TPoint* > & ePoints = getShapePoints( eID++ ); + for ( pIt = ePoints.begin(); pIt != ePoints.end(); pIt++ ) { + TPoint* p = (*pIt); + bndBox.Add( gp_Pnt2d( p->myXYZ.X(), p->myXYZ.Y() )); + } + // UV by an edge p-curve + double f, l; + Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface( *eIt, face, f, l ); + double dU = ( l - f ) / ( maxNbPnt - 1 ); + for ( int i = 0; i < maxNbPnt; i++ ) + eBndBox.Add( C2d->Value( f + i * dU )); + } + + // transform UVs by isos + double minPar[2], maxPar[2], eMinPar[2], eMaxPar[2]; + bndBox.Get( minPar[0], minPar[1], maxPar[0], maxPar[1] ); + eBndBox.Get( eMinPar[0], eMinPar[1], eMaxPar[0], eMaxPar[1] ); +#ifdef DBG_SETFIRSTEDGE + cout << "EDGES: X: " << eMinPar[0] << " - " << eMaxPar[0] << " Y: " + << eMinPar[1] << " - " << eMaxPar[1] << endl; +#endif + for ( int iC = 1, i = 0; i < 2; iC++, i++ ) // loop on 2 coordinates + { + double dMin = eMinPar[i] - minPar[i]; + double dMax = eMaxPar[i] - maxPar[i]; + double dPar = maxPar[i] - minPar[i]; + eID = theFirstEdgeID; + for ( iE = 0; iE < nbEdges; iE++ ) // loop on edges of a boundary + { + list< TPoint* > & ePoints = getShapePoints( eID++ ); + for ( pIt = ++ePoints.begin(); pIt != ePoints.end(); pIt++ ) // loop on edge points + { + double par = (*pIt)->myXYZ.Coord( iC ); + double r = ( par - minPar[i] ) / dPar; + par += ( 1 - r ) * dMin + r * dMax; + (*pIt)->myXYZ.SetCoord( iC, par ); + } + } + } + + TopoDS_Edge eBest; + double minDist = DBL_MAX; + for ( iE = 0 ; iE < nbEdges; iE++ ) + { +#ifdef DBG_SETFIRSTEDGE + cout << " VARIANT " << iE << endl; +#endif + // evaluate the distance between UV computed by the 2 methods: + // by isos intersection ( myXYZ ) and by edge p-curves ( myUV ) + double dist = 0; + int eID = theFirstEdgeID; + for ( eIt = theWire.begin(); eIt != theWire.end(); eIt++ ) + { + list< TPoint* > & ePoints = getShapePoints( eID++ ); + computeUVOnEdge( *eIt, ePoints ); + for ( pIt = ++ePoints.begin(); pIt != ePoints.end(); pIt++ ) { + TPoint* p = (*pIt); + dist += ( p->myUV - gp_XY( p->myXYZ.X(), p->myXYZ.Y() )).SquareModulus(); +#ifdef DBG_SETFIRSTEDGE + cout << " ISO : ( " << p->myXYZ.X() << ", "<< p->myXYZ.Y() << " ) PCURVE : ( " << + p->myUV.X() << ", " << p->myUV.Y() << ") " << endl; +#endif + } + } +#ifdef DBG_SETFIRSTEDGE + cout << "dist -- " << dist << endl; +#endif + if ( dist < minDist ) { + minDist = dist; + eBest = theWire.front(); + } + // check variant with another first edge + theWire.splice( theWire.begin(), theWire, --theWire.end(), theWire.end() ); + } + // put the best first edge to the theWire front + if ( eBest != theWire.front() ) { + eIt = find ( theWire.begin(), theWire.end(), eBest ); + theWire.splice( theWire.begin(), theWire, eIt, theWire.end() ); + } + + return minDist; +} + +//======================================================================= +//function : sortSameSizeWires +//purpose : sort wires in theWireList from theFromWire until theToWire, +// the wires are set in the order to correspond to the order +// of boundaries; after sorting, edges in the wires are put +// in a good order, point UVs on edges are computed and points +// are appended to theEdgesPointsList +//======================================================================= + +bool SMESH_Pattern::sortSameSizeWires (TListOfEdgesList & theWireList, + const TListOfEdgesList::iterator& theFromWire, + const TListOfEdgesList::iterator& theToWire, + const int theFirstEdgeID, + list< list< TPoint* > >& theEdgesPointsList ) +{ + TopoDS_Face F = TopoDS::Face( myShape ); + int iW, nbWires = 0; + TListOfEdgesList::iterator wlIt = theFromWire; + while ( wlIt++ != theToWire ) + nbWires++; + + // Recompute key-point UVs by isolines intersection, + // compute CG of key-points for each wire and bnd boxes of GCs + + bool aBool; + gp_XY orig( gp::Origin2d().XY() ); + vector< gp_XY > vGcVec( nbWires, orig ), gcVec( nbWires, orig ); + Bnd_Box2d bndBox, vBndBox; + int eID = theFirstEdgeID; + list< TopoDS_Edge >::iterator eIt; + for ( iW = 0, wlIt = theFromWire; wlIt != theToWire; wlIt++, iW++ ) + { + list< TopoDS_Edge > & wire = *wlIt; + for ( eIt = wire.begin(); eIt != wire.end(); eIt++ ) + { + list< TPoint* > & ePoints = getShapePoints( eID++ ); + TPoint* p = ePoints.front(); + if ( !compUVByIsoIntersection( theEdgesPointsList, p->myInitUV, p->myUV, aBool )) { + MESSAGE("cant sortSameSizeWires()"); + return false; + } + gcVec[iW] += p->myUV; + bndBox.Add( gp_Pnt2d( p->myUV )); + TopoDS_Vertex V = TopExp::FirstVertex( *eIt, true ); + gp_Pnt2d vXY = BRep_Tool::Parameters( V, F ); + vGcVec[iW] += vXY.XY(); + vBndBox.Add( vXY ); + // keep the computed UV to compare against by setFirstEdge() + p->myXYZ.SetCoord( p->myUV.X(), p->myUV.Y(), 0. ); + } + gcVec[iW] /= nbWires; + vGcVec[iW] /= nbWires; +// cout << " Wire " << iW << " iso: " << gcVec[iW].X() << " " << gcVec[iW].Y() << endl << +// " \t vertex: " << vGcVec[iW].X() << " " << vGcVec[iW].Y() << endl; + } + + // Transform GCs computed by isos to fit in bnd box of GCs by vertices + + double minPar[2], maxPar[2], vMinPar[2], vMaxPar[2]; + bndBox.Get( minPar[0], minPar[1], maxPar[0], maxPar[1] ); + vBndBox.Get( vMinPar[0], vMinPar[1], vMaxPar[0], vMaxPar[1] ); + for ( int iC = 1, i = 0; i < 2; iC++, i++ ) // loop on 2 coordinates + { + double dMin = vMinPar[i] - minPar[i]; + double dMax = vMaxPar[i] - maxPar[i]; + double dPar = maxPar[i] - minPar[i]; + if ( Abs( dPar ) <= DBL_MIN ) + continue; + for ( iW = 0; iW < nbWires; iW++ ) { // loop on GCs of wires + double par = gcVec[iW].Coord( iC ); + double r = ( par - minPar[i] ) / dPar; + par += ( 1 - r ) * dMin + r * dMax; + gcVec[iW].SetCoord( iC, par ); + } + } + + // Define boundary - wire correspondence by GC closeness + + TListOfEdgesList tmpWList; + tmpWList.splice( tmpWList.end(), theWireList, theFromWire, theToWire ); + typedef map< int, TListOfEdgesList::iterator > TIntWirePosMap; + TIntWirePosMap bndIndWirePosMap; + vector< bool > bndFound( nbWires, false ); + for ( iW = 0, wlIt = tmpWList.begin(); iW < nbWires; iW++, wlIt++ ) + { +// cout << " TRSF Wire " << iW << " iso: " << gcVec[iW].X() << " " << gcVec[iW].Y() << endl << +// " \t vertex: " << vGcVec[iW].X() << " " << vGcVec[iW].Y() << endl; + double minDist = DBL_MAX; + gp_XY & wGc = vGcVec[ iW ]; + int bIndex; + for ( int iB = 0; iB < nbWires; iB++ ) { + if ( bndFound[ iB ] ) continue; + double dist = ( wGc - gcVec[ iB ] ).SquareModulus(); + if ( dist < minDist ) { + minDist = dist; + bIndex = iB; + } + } + bndFound[ bIndex ] = true; + bndIndWirePosMap.insert( TIntWirePosMap::value_type( bIndex, wlIt )); + } + + // Treat each wire + + TIntWirePosMap::iterator bIndWPosIt = bndIndWirePosMap.begin(); + eID = theFirstEdgeID; + for ( ; bIndWPosIt != bndIndWirePosMap.end(); bIndWPosIt++ ) + { + TListOfEdgesList::iterator wirePos = (*bIndWPosIt).second; + list < TopoDS_Edge > & wire = ( *wirePos ); + + // choose the best first edge of a wire + setFirstEdge( wire, eID ); + + // compute eventual UV and fill theEdgesPointsList + theEdgesPointsList.push_back( list< TPoint* >() ); + list< TPoint* > & edgesPoints = theEdgesPointsList.back(); + for ( eIt = wire.begin(); eIt != wire.end(); eIt++ ) + { + list< TPoint* > & ePoints = getShapePoints( eID++ ); + computeUVOnEdge( *eIt, ePoints ); + edgesPoints.insert( edgesPoints.end(), ePoints.begin(), (--ePoints.end())); + } + // put wire back to theWireList + wlIt = wirePos++; + theWireList.splice( theToWire, tmpWList, wlIt, wirePos ); + } + + return true; +} + +//======================================================================= +//function : Apply +//purpose : Compute nodes coordinates applying +// the loaded pattern to . The first key-point +// will be mapped into +//======================================================================= + +bool SMESH_Pattern::Apply (const TopoDS_Face& theFace, + const TopoDS_Vertex& theVertexOnKeyPoint1, + const bool theReverse) +{ + MESSAGE(" ::Apply(face) " ); + TopoDS_Face face = theReverse ? TopoDS::Face( theFace.Reversed() ) : theFace; + if ( !setShapeToMesh( face )) + return false; + + // find points on edges, it fills myNbKeyPntInBoundary + if ( !findBoundaryPoints() ) + return false; + + // Define the edges order so that the first edge starts at + // theVertexOnKeyPoint1 + + list< TopoDS_Edge > eList; + list< int > nbVertexInWires; + int nbWires = getOrderedEdges( face, theVertexOnKeyPoint1, eList, nbVertexInWires); + if ( !theVertexOnKeyPoint1.IsSame( TopExp::FirstVertex( eList.front(), true ))) + { + MESSAGE( " theVertexOnKeyPoint1 not found in the outer wire "); + return setErrorCode( ERR_APPLF_BAD_VERTEX ); + } + // check nb wires and edges + list< int > l1 = myNbKeyPntInBoundary, l2 = nbVertexInWires; + l1.sort(); l2.sort(); + if ( l1 != l2 ) + { + MESSAGE( "Wrong nb vertices in wires" ); + return setErrorCode( ERR_APPL_BAD_NB_VERTICES ); + } + + // here shapes get IDs, for the outer wire IDs are OK + list::iterator elIt = eList.begin(); + for ( ; elIt != eList.end(); elIt++ ) { + myShapeIDMap.Add( TopExp::FirstVertex( *elIt, true )); + if ( BRep_Tool::IsClosed( *elIt, theFace ) ) + myShapeIDMap.Add( TopExp::LastVertex( *elIt, true )); + } + int nbVertices = myShapeIDMap.Extent(); + + //int nbSeamShapes = 0; // count twice seam edge and its vertices + for ( elIt = eList.begin(); elIt != eList.end(); elIt++ ) + myShapeIDMap.Add( *elIt ); + + myShapeIDMap.Add( face ); + + if ( myShapeIDToPointsMap.size() != myShapeIDMap.Extent()/* + nbSeamShapes*/ ) { + MESSAGE( myShapeIDToPointsMap.size() <<" != " << myShapeIDMap.Extent()); + return setErrorCode( ERR_APPLF_INTERNAL_EEROR ); + } + + // points on edges to be used for UV computation of in-face points + list< list< TPoint* > > edgesPointsList; + edgesPointsList.push_back( list< TPoint* >() ); + list< TPoint* > * edgesPoints = & edgesPointsList.back(); + list< TPoint* >::iterator pIt; + + // compute UV of points on the outer wire + int iE, nbEdgesInOuterWire = nbVertexInWires.front(); + for (iE = 0, elIt = eList.begin(); + iE < nbEdgesInOuterWire && elIt != eList.end(); + iE++, elIt++ ) + { + list< TPoint* > & ePoints = getShapePoints( *elIt ); + // compute UV + computeUVOnEdge( *elIt, ePoints ); + // collect on-edge points (excluding the last one) + edgesPoints->insert( edgesPoints->end(), ePoints.begin(), --ePoints.end()); + } + + // If there are several wires, define the order of edges of inner wires: + // compute UV of inner edge-points using 2 methods: the one for in-face points + // and the one for on-edge points and then choose the best edge order + // by the best correspondance of the 2 results + if ( nbWires > 1 ) + { + // compute UV of inner edge-points using the method for in-face points + // and devide eList into a list of separate wires + bool aBool; + list< list< TopoDS_Edge > > wireList; + list::iterator eIt = elIt; + list::iterator nbEIt = nbVertexInWires.begin(); + for ( nbEIt++; nbEIt != nbVertexInWires.end(); nbEIt++ ) + { + int nbEdges = *nbEIt; + wireList.push_back( list< TopoDS_Edge >() ); + list< TopoDS_Edge > & wire = wireList.back(); + for ( iE = 0 ; iE < nbEdges; eIt++, iE++ ) + { + list< TPoint* > & ePoints = getShapePoints( *eIt ); + pIt = ePoints.begin(); + for ( pIt++; pIt != ePoints.end(); pIt++ ) { + TPoint* p = (*pIt); + if ( !compUVByIsoIntersection( edgesPointsList, p->myInitUV, p->myUV, aBool )) { + MESSAGE("cant Apply(face)"); + return false; + } + // keep the computed UV to compare against by setFirstEdge() + p->myXYZ.SetCoord( p->myUV.X(), p->myUV.Y(), 0. ); + } + wire.push_back( *eIt ); + } + } + // remove inner edges from eList + eList.erase( elIt, eList.end() ); + + // sort wireList by nb edges in a wire + sortBySize< TopoDS_Edge > ( wireList ); + + // an ID of the first edge of a boundary + int id1 = nbVertices + nbEdgesInOuterWire + 1; +// if ( nbSeamShapes > 0 ) +// id1 += 2; // 2 vertices more + + // find points - edge correspondence for wires of unique size, + // edge order within a wire should be defined only + + list< list< TopoDS_Edge > >::iterator wlIt = wireList.begin(); + while ( wlIt != wireList.end() ) + { + list< TopoDS_Edge >& wire = (*wlIt); + int nbEdges = wire.size(); + wlIt++; + if ( wlIt == wireList.end() || (*wlIt).size() != nbEdges ) // a unique size wire + { + // choose the best first edge of a wire + setFirstEdge( wire, id1 ); + + // compute eventual UV and collect on-edge points + edgesPointsList.push_back( list< TPoint* >() ); + edgesPoints = & edgesPointsList.back(); + int eID = id1; + for ( eIt = wire.begin(); eIt != wire.end(); eIt++ ) + { + list< TPoint* > & ePoints = getShapePoints( eID++ ); + computeUVOnEdge( *eIt, ePoints ); + edgesPoints->insert( edgesPoints->end(), ePoints.begin(), (--ePoints.end())); + } + } + id1 += nbEdges; + } + + // find boundary - wire correspondence for several wires of same size + + id1 = nbVertices + nbEdgesInOuterWire + 1; + wlIt = wireList.begin(); + while ( wlIt != wireList.end() ) + { + int nbSameSize = 0, nbEdges = (*wlIt).size(); + list< list< TopoDS_Edge > >::iterator wlIt2 = wlIt; + wlIt2++; + while ( wlIt2 != wireList.end() && (*wlIt2).size() == nbEdges ) { // a same size wire + nbSameSize++; + wlIt2++; + } + if ( nbSameSize > 0 ) + if (!sortSameSizeWires(wireList, wlIt, wlIt2, id1, edgesPointsList)) + return false; + wlIt = wlIt2; + id1 += nbEdges * ( nbSameSize + 1 ); + } + + // add well-ordered edges to eList + + for ( wlIt = wireList.begin(); wlIt != wireList.end(); wlIt++ ) + { + list< TopoDS_Edge >& wire = (*wlIt); + eList.splice( eList.end(), wire, wire.begin(), wire.end() ); + } + + // re-fill myShapeIDMap - all shapes get good IDs + + myShapeIDMap.Clear(); + for ( elIt = eList.begin(); elIt != eList.end(); elIt++ ) + myShapeIDMap.Add( TopExp::FirstVertex( *elIt, true )); + for ( elIt = eList.begin(); elIt != eList.end(); elIt++ ) + myShapeIDMap.Add( *elIt ); + myShapeIDMap.Add( face ); + + } // there are inner wires + + // Compute XYZ of on-edge points + + TopLoc_Location loc; + for ( iE = nbVertices + 1, elIt = eList.begin(); elIt != eList.end(); elIt++ ) + { + double f,l; + Handle(Geom_Curve) C3d = BRep_Tool::Curve( *elIt, loc, f, l ); + const gp_Trsf & aTrsf = loc.Transformation(); + list< TPoint* > & ePoints = getShapePoints( iE++ ); + pIt = ePoints.begin(); + for ( pIt++; pIt != ePoints.end(); pIt++ ) + { + TPoint* point = *pIt; + point->myXYZ = C3d->Value( point->myU ); + if ( !loc.IsIdentity() ) + aTrsf.Transforms( point->myXYZ.ChangeCoord() ); + } + } + + // Compute UV and XYZ of in-face points + + // try to use a simple algo + list< TPoint* > & fPoints = getShapePoints( face ); + bool isDeformed = false; + for ( pIt = fPoints.begin(); !isDeformed && pIt != fPoints.end(); pIt++ ) + if ( !compUVByIsoIntersection( edgesPointsList, (*pIt)->myInitUV, + (*pIt)->myUV, isDeformed )) { + MESSAGE("cant Apply(face)"); + return false; + } + // try to use a complex algo if it is a difficult case + if ( isDeformed && !compUVByElasticIsolines( edgesPointsList, fPoints )) + { + for ( ; pIt != fPoints.end(); pIt++ ) // continue with the simple algo + if ( !compUVByIsoIntersection( edgesPointsList, (*pIt)->myInitUV, + (*pIt)->myUV, isDeformed )) { + MESSAGE("cant Apply(face)"); + return false; + } + } + + Handle(Geom_Surface) aSurface = BRep_Tool::Surface( face, loc ); + const gp_Trsf & aTrsf = loc.Transformation(); + for ( pIt = fPoints.begin(); pIt != fPoints.end(); pIt++ ) + { + TPoint * point = *pIt; + point->myXYZ = aSurface->Value( point->myUV.X(), point->myUV.Y() ); + if ( !loc.IsIdentity() ) + aTrsf.Transforms( point->myXYZ.ChangeCoord() ); + } + + myIsComputed = true; + + return setErrorCode( ERR_OK ); +} + +// ========================================================= +// class calculating coordinates of 3D points by normalized +// parameters inside the block and vice versa +// ========================================================= + +class TBlock: public math_FunctionSetWithDerivatives +{ + public: + enum TBlockShapeID { // ids of the block sub-shapes + ID_V000 = 1, ID_V100, ID_V010, ID_V110, ID_V001, ID_V101, ID_V011, ID_V111, + + ID_Ex00, ID_Ex10, ID_Ex01, ID_Ex11, + ID_E0y0, ID_E1y0, ID_E0y1, ID_E1y1, + ID_E00z, ID_E10z, ID_E01z, ID_E11z, + + ID_Fxy0, ID_Fxy1, ID_Fx0z, ID_Fx1z, ID_F0yz, ID_F1yz, + + ID_Shell + }; + static inline +bool IsVertexID( int theShapeID ) + { return ( theShapeID >= ID_V000 && theShapeID <= ID_V111 ); } + static inline bool IsEdgeID( int theShapeID ) + { return ( theShapeID >= ID_Ex00 && theShapeID <= ID_E11z ); } + static inline bool IsFaceID( int theShapeID ) + { return ( theShapeID >= ID_Fxy0 && theShapeID <= ID_F1yz ); } + + + TBlock (const TopoDS_Shell& theBlock): + myShell( theBlock ), myNbIterations(0), mySumDist(0.) {} + + bool LoadBlockShapes(const TopoDS_Vertex& theVertex000, + const TopoDS_Vertex& theVertex001, +// TopTools_IndexedMapOfShape& theShapeIDMap + TopTools_IndexedMapOfOrientedShape& theShapeIDMap ); + // add sub-shapes of theBlock to theShapeIDMap so that they get + // IDs acoording to enum TBlockShapeID + + static int GetShapeIDByParams ( const gp_XYZ& theParams ); + // define an id of the block sub-shape by point parameters + + bool VertexPoint( const int theVertexID, gp_XYZ& thePoint ) const { + if ( !IsVertexID( theVertexID )) return false; + thePoint = myPnt[ theVertexID - ID_V000 ]; return true; + } + // return vertex coordinates + + bool EdgePoint( const int theEdgeID, const gp_XYZ& theParams, gp_XYZ& thePoint ) const { + if ( !IsEdgeID( theEdgeID )) return false; + thePoint = myEdge[ theEdgeID - ID_Ex00 ].Point( theParams ); return true; + } + // return coordinates of a point on edge + + bool FacePoint( const int theFaceID, const gp_XYZ& theParams, gp_XYZ& thePoint ) const { + if ( !IsFaceID ( theFaceID )) return false; + thePoint = myFace[ theFaceID - ID_Fxy0 ].Point( theParams ); return true; + } + // return coordinates of a point on face + + bool ShellPoint( const gp_XYZ& theParams, gp_XYZ& thePoint ) const; + // return coordinates of a point in shell + + bool ComputeParameters (const gp_Pnt& thePoint, + gp_XYZ& theParams, + const int theShapeID = ID_Shell); + // compute point parameters in the block + + static void GetFaceEdgesIDs (const int faceID, vector< int >& edgeVec ); + // return edges IDs of a face in the order u0, u1, 0v, 1v + + static int GetCoordIndOnEdge (const int theEdgeID) + { return (theEdgeID < ID_E0y0) ? 1 : (theEdgeID < ID_E00z) ? 2 : 3; } + // return an index of a coordinate which varies along the edge + + static double* GetShapeCoef (const int theShapeID); + // for theShapeID( TBlockShapeID ), returns 3 coefficients used + // to compute an addition of an on-theShape point to coordinates + // of an in-shell point. If an in-shell point has parameters (Px,Py,Pz), + // then the addition of a point P is computed as P*kx*ky*kz and ki is + // defined by the returned coef like this: + // ki = (coef[i] == 0) ? 1 : (coef[i] < 0) ? 1 - Pi : Pi + + static bool IsForwardEdge (const TopoDS_Edge & theEdge, + //TopTools_IndexedMapOfShape& theShapeIDMap + TopTools_IndexedMapOfOrientedShape& theShapeIDMap) { + int v1ID = theShapeIDMap.FindIndex( TopExp::FirstVertex( theEdge ).Oriented( TopAbs_FORWARD )); + int v2ID = theShapeIDMap.FindIndex( TopExp::LastVertex( theEdge ).Oriented( TopAbs_FORWARD )); + return ( v1ID < v2ID ); + } + // Return true if an in-block parameter increases along theEdge curve + + static void Swap(double& a, double& b) { double tmp = a; a = b; b = tmp; } + + // methods of math_FunctionSetWithDerivatives + Standard_Integer NbVariables() const; + Standard_Integer NbEquations() const; + Standard_Boolean Value(const math_Vector& X,math_Vector& F) ; + Standard_Boolean Derivatives(const math_Vector& X,math_Matrix& D) ; + Standard_Boolean Values(const math_Vector& X,math_Vector& F,math_Matrix& D) ; + Standard_Integer GetStateNumber (); + + static ostream& DumpShapeID (const int theBlockShapeID, ostream& stream); + // DEBUG: dump an id of a block sub-shape + + private: + + struct TEdge { + int myCoordInd; + double myFirst; + double myLast; + Handle(Geom_Curve) myC3d; + gp_Trsf myTrsf; + double GetU( const gp_XYZ& theParams ) const; + gp_XYZ Point( const gp_XYZ& theParams ) const; + }; + + struct TFace { + // 4 edges in the order u0, u1, 0v, 1v + int myCoordInd[ 4 ]; + double myFirst [ 4 ]; + double myLast [ 4 ]; + Handle(Geom2d_Curve) myC2d [ 4 ]; + // 4 corner points in the order 00, 10, 11, 01 + gp_XY myCorner [ 4 ]; + // surface + Handle(Geom_Surface) myS; + gp_Trsf myTrsf; + gp_XY GetUV( const gp_XYZ& theParams ) const; + gp_XYZ Point( const gp_XYZ& theParams ) const; + int GetUInd() const { return myCoordInd[ 0 ]; } + int GetVInd() const { return myCoordInd[ 2 ]; } + }; + + TopoDS_Shell myShell; + // geometry: + // 8 vertices + gp_XYZ myPnt[ 8 ]; + // 12 edges + TEdge myEdge[ 12 ]; + // 6 faces + TFace myFace[ 6 ]; + + // for param computation + + int myFaceIndex; + double myFaceParam; + int myNbIterations; + double mySumDist; + + gp_XYZ myPoint; // the given point + gp_XYZ myParam; // the best parameters guess + double myValues[ 4 ]; // values computed at myParam + + typedef pair TxyzPair; + TxyzPair my3x3x3GridNodes[ 27 ]; + bool myGridComputed; +}; + +//======================================================================= +//function : Load +//purpose : Create a pattern from the mesh built on +//======================================================================= + +bool SMESH_Pattern::Load (SMESH_Mesh* theMesh, + const TopoDS_Shell& theBlock) +{ + MESSAGE(" ::Load(volume) " ); + Clear(); + myIs2D = false; + SMESHDS_Mesh * aMeshDS = theMesh->GetMeshDS(); + + // load shapes in myShapeIDMap + TBlock block( theBlock ); + TopoDS_Vertex v1, v2; + if ( !block.LoadBlockShapes( v1, v2, myShapeIDMap )) + return setErrorCode( ERR_LOADV_BAD_SHAPE ); + + // count nodes + int nbNodes = 0, shapeID; + for ( shapeID = 1; shapeID <= myShapeIDMap.Extent(); shapeID++ ) + { + const TopoDS_Shape& S = myShapeIDMap( shapeID ); + SMESHDS_SubMesh * aSubMesh = aMeshDS->MeshElements( S ); + if ( aSubMesh ) + nbNodes += aSubMesh->NbNodes(); + } + myPoints.resize( nbNodes ); + + // load U of points on edges + TNodePointIDMap nodePointIDMap; + int iPoint = 0; + for ( shapeID = 1; shapeID <= myShapeIDMap.Extent(); shapeID++ ) + { + const TopoDS_Shape& S = myShapeIDMap( shapeID ); + list< TPoint* > & shapePoints = getShapePoints( shapeID ); + SMESHDS_SubMesh * aSubMesh = aMeshDS->MeshElements( S ); + if ( ! aSubMesh ) continue; + SMDS_NodeIteratorPtr nIt = aSubMesh->GetNodes(); + if ( !nIt->more() ) continue; + + // store a node and a point + while ( nIt->more() ) { + const SMDS_MeshNode* node = static_cast( nIt->next() ); + nodePointIDMap.insert( TNodePointIDMap::value_type( node, iPoint )); + if ( block.IsVertexID( shapeID )) + myKeyPointIDs.push_back( iPoint ); + TPoint* p = & myPoints[ iPoint++ ]; + shapePoints.push_back( p ); + p->myXYZ.SetCoord( node->X(), node->Y(), node->Z() ); + p->myInitXYZ.SetCoord( 0,0,0 ); + } + list< TPoint* >::iterator pIt = shapePoints.begin(); + + // compute init XYZ + switch ( S.ShapeType() ) + { + case TopAbs_VERTEX: + case TopAbs_EDGE: { + + for ( ; pIt != shapePoints.end(); pIt++ ) { + double * coef = block.GetShapeCoef( shapeID ); + for ( int iCoord = 1; iCoord <= 3; iCoord++ ) + if ( coef[ iCoord - 1] > 0 ) + (*pIt)->myInitXYZ.SetCoord( iCoord, 1. ); + } + if ( S.ShapeType() == TopAbs_VERTEX ) + break; + + const TopoDS_Edge& edge = TopoDS::Edge( S ); + double f,l; + BRep_Tool::Range( edge, f, l ); + int iCoord = TBlock::GetCoordIndOnEdge( shapeID ); + bool isForward = TBlock::IsForwardEdge( edge, myShapeIDMap ); + pIt = shapePoints.begin(); + nIt = aSubMesh->GetNodes(); + for ( ; nIt->more(); pIt++ ) + { + const SMDS_MeshNode* node = + static_cast( nIt->next() ); + const SMDS_EdgePosition* epos = + static_cast(node->GetPosition().get()); + double u = ( epos->GetUParameter() - f ) / ( l - f ); + (*pIt)->myInitXYZ.SetCoord( iCoord, isForward ? u : 1 - u ); + } + break; + } + default: + for ( ; pIt != shapePoints.end(); pIt++ ) + { + if ( !block.ComputeParameters( (*pIt)->myXYZ, (*pIt)->myInitXYZ, shapeID )) { + MESSAGE( "!block.ComputeParameters()" ); + return setErrorCode( ERR_LOADV_COMPUTE_PARAMS ); + } + } + } + } // loop on block sub-shapes + + // load elements + + SMESHDS_SubMesh * aSubMesh = aMeshDS->MeshElements( theBlock ); + if ( aSubMesh ) + { + SMDS_ElemIteratorPtr elemIt = aSubMesh->GetElements(); + while ( elemIt->more() ) { + SMDS_ElemIteratorPtr nIt = elemIt->next()->nodesIterator(); + myElemPointIDs.push_back( list< int >() ); + list< int >& elemPoints = myElemPointIDs.back(); + while ( nIt->more() ) + elemPoints.push_back( nodePointIDMap[ nIt->next() ]); + } + } + + myIsBoundaryPointsFound = true; + + return setErrorCode( ERR_OK ); +} + +//======================================================================= +//function : Apply +//purpose : Compute nodes coordinates applying +// the loaded pattern to . The (0,0,0) key-point +// will be mapped into . The (0,0,1) +// fifth key-point will be mapped into . +//======================================================================= + +bool SMESH_Pattern::Apply (const TopoDS_Shell& theBlock, + const TopoDS_Vertex& theVertex000, + const TopoDS_Vertex& theVertex001) +{ + MESSAGE(" ::Apply(volume) " ); + + TBlock block( theBlock ); + + if (!findBoundaryPoints() || // bind ID to points + !setShapeToMesh( theBlock )) // check theBlock is a suitable shape + return false; + + if (!block.LoadBlockShapes( theVertex000, theVertex001, myShapeIDMap )) // bind ID to shape + return setErrorCode( ERR_APPLV_BAD_SHAPE ); + + // compute XYZ of points on shapes + + for ( int shapeID = 1; shapeID <= myShapeIDMap.Extent(); shapeID++ ) + { + list< TPoint* > & shapePoints = getShapePoints( shapeID ); + list< TPoint* >::iterator pIt = shapePoints.begin(); + const TopoDS_Shape& S = myShapeIDMap( shapeID ); + switch ( S.ShapeType() ) + { + case TopAbs_VERTEX: { + + for ( ; pIt != shapePoints.end(); pIt++ ) + block.VertexPoint( shapeID, (*pIt)->myXYZ.ChangeCoord() ); + break; + } + case TopAbs_EDGE: { + + for ( ; pIt != shapePoints.end(); pIt++ ) + block.EdgePoint( shapeID, (*pIt)->myInitXYZ, (*pIt)->myXYZ.ChangeCoord() ); + break; + } + case TopAbs_FACE: { + + for ( ; pIt != shapePoints.end(); pIt++ ) + block.FacePoint( shapeID, (*pIt)->myInitXYZ, (*pIt)->myXYZ.ChangeCoord() ); + break; + } + default: + for ( ; pIt != shapePoints.end(); pIt++ ) + block.ShellPoint( (*pIt)->myInitXYZ, (*pIt)->myXYZ.ChangeCoord() ); + } + } // loop on block sub-shapes + + myIsComputed = true; + + return setErrorCode( ERR_OK ); +} + +//======================================================================= +//function : MakeMesh +//purpose : Create nodes and elements in using nodes +// coordinates computed by either of Apply...() methods +//======================================================================= + +bool SMESH_Pattern::MakeMesh(SMESH_Mesh* theMesh) +{ + MESSAGE(" ::MakeMesh() " ); + if ( !myIsComputed ) + return setErrorCode( ERR_MAKEM_NOT_COMPUTED ); + + SMESHDS_Mesh* aMeshDS = theMesh->GetMeshDS(); + + // clear elements and nodes existing on myShape + SMESH_subMesh * aSubMesh = theMesh->GetSubMeshContaining( myShape ); + SMESHDS_SubMesh * aSubMeshDS = aMeshDS->MeshElements( myShape ); + if ( aSubMesh ) + aSubMesh->ComputeStateEngine( SMESH_subMesh::CLEAN ); + else if ( aSubMeshDS ) + { + SMDS_ElemIteratorPtr eIt = aSubMeshDS->GetElements(); + while ( eIt->more() ) + aMeshDS->RemoveElement( eIt->next() ); + SMDS_NodeIteratorPtr nIt = aSubMeshDS->GetNodes(); + while ( nIt->more() ) + aMeshDS->RemoveNode( static_cast( nIt->next() )); + } + + // loop on sub-shapes of myShape: create nodes and build point-node map + typedef map< TPoint*, const SMDS_MeshNode* > TPointNodeMap; + TPointNodeMap pointNodeMap; + map< int, list< TPoint* > >::iterator idPointIt = myShapeIDToPointsMap.begin(); + for ( ; idPointIt != myShapeIDToPointsMap.end(); idPointIt++ ) + { + const TopoDS_Shape & S = myShapeIDMap( (*idPointIt).first ); + list< TPoint* > & points = (*idPointIt).second; + SMESHDS_SubMesh * subMeshDS = aMeshDS->MeshElements( S ); + SMESH_subMesh * subMesh = theMesh->GetSubMeshContaining( myShape ); + list< TPoint* >::iterator pIt = points.begin(); + for ( ; pIt != points.end(); pIt++ ) + { + TPoint* point = *pIt; + if ( pointNodeMap.find( point ) != pointNodeMap.end() ) + continue; + SMDS_MeshNode* node = aMeshDS->AddNode (point->myXYZ.X(), + point->myXYZ.Y(), + point->myXYZ.Z()); + pointNodeMap.insert( TPointNodeMap::value_type( point, node )); + if ( subMeshDS ) { + switch ( S.ShapeType() ) { + case TopAbs_VERTEX: { + aMeshDS->SetNodeOnVertex( node, TopoDS::Vertex( S )); + break; + } + case TopAbs_EDGE: { + aMeshDS->SetNodeOnEdge( node, TopoDS::Edge( S )); + SMDS_EdgePosition* epos = + dynamic_cast(node->GetPosition().get()); + epos->SetUParameter( point->myU ); + break; + } + case TopAbs_FACE: { + aMeshDS->SetNodeOnFace( node, TopoDS::Face( S )); + SMDS_FacePosition* pos = + dynamic_cast(node->GetPosition().get()); + pos->SetUParameter( point->myUV.X() ); + pos->SetVParameter( point->myUV.Y() ); + break; + } + default: + aMeshDS->SetNodeInVolume( node, TopoDS::Shell( S )); + } + } + } + // make that SMESH_subMesh::_computeState = COMPUTE_OK + // so that operations with hypotheses will erase the mesh + // being built + if ( subMesh ) + subMesh->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE ); + } + + // create elements + list >::iterator epIt = myElemPointIDs.begin(); + for ( ; epIt != myElemPointIDs.end(); epIt++ ) + { + list< int > & elemPoints = *epIt; + // retrieve nodes + const SMDS_MeshNode* nodes[ 8 ]; + list< int >::iterator iIt = elemPoints.begin(); + int nbNodes; + for ( nbNodes = 0; iIt != elemPoints.end(); iIt++ ) { + nodes[ nbNodes++ ] = pointNodeMap[ & myPoints[ *iIt ]]; + } + // add an element + const SMDS_MeshElement* elem = 0; + if ( myIs2D ) { + switch ( nbNodes ) { + case 3: + elem = aMeshDS->AddFace( nodes[0], nodes[1], nodes[2] ); break; + case 4: + elem = aMeshDS->AddFace( nodes[0], nodes[1], nodes[2], nodes[3] ); break; + default:; + } + } + else { + switch ( nbNodes ) { + case 4: + elem = aMeshDS->AddVolume (nodes[0], nodes[1], nodes[2], nodes[3] ); break; + case 5: + elem = aMeshDS->AddVolume (nodes[0], nodes[1], nodes[2], nodes[3], + nodes[4] ); break; + case 6: + elem = aMeshDS->AddVolume (nodes[0], nodes[1], nodes[2], nodes[3], + nodes[4], nodes[5] ); break; + case 8: + elem = aMeshDS->AddVolume (nodes[0], nodes[1], nodes[2], nodes[3], + nodes[4], nodes[5], nodes[6], nodes[7] ); break; + default:; + } + } + if ( elem ) + aMeshDS->SetMeshElementOnShape( elem, myShape ); + } + + return setErrorCode( ERR_OK ); +} + + +//======================================================================= +//function : arrangeBoundaries +//purpose : if there are several wires, arrange boundaryPoints so that +// the outer wire goes first and fix inner wires orientation +// update myKeyPointIDs to correspond to the order of key-points +// in boundaries; sort internal boundaries by the nb of key-points +//======================================================================= + +void SMESH_Pattern::arrangeBoundaries (list< list< TPoint* > >& boundaryList) +{ + typedef list< list< TPoint* > >::iterator TListOfListIt; + TListOfListIt bndIt; + list< TPoint* >::iterator pIt; + + int nbBoundaries = boundaryList.size(); + if ( nbBoundaries > 1 ) + { + // sort boundaries by nb of key-points + if ( nbBoundaries > 2 ) + { + // move boundaries in tmp list + list< list< TPoint* > > tmpList; + tmpList.splice( tmpList.begin(), boundaryList, boundaryList.begin(), boundaryList.end()); + // make a map nb-key-points to boundary-position-in-tmpList, + // boundary-positions get ordered in it + typedef map< int, TListOfListIt > TNbKpBndPosMap; + TNbKpBndPosMap nbKpBndPosMap; + bndIt = tmpList.begin(); + list< int >::iterator nbKpIt = myNbKeyPntInBoundary.begin(); + for ( ; nbKpIt != myNbKeyPntInBoundary.end(); nbKpIt++, bndIt++ ) { + int nb = *nbKpIt * nbBoundaries; + while ( nbKpBndPosMap.find ( nb ) != nbKpBndPosMap.end() ) + nb++; + nbKpBndPosMap.insert( TNbKpBndPosMap::value_type( nb, bndIt )); + } + // move boundaries back to boundaryList + TNbKpBndPosMap::iterator nbKpBndPosIt = nbKpBndPosMap.begin(); + for ( ; nbKpBndPosIt != nbKpBndPosMap.end(); nbKpBndPosIt++ ) { + TListOfListIt & bndPos2 = (*nbKpBndPosIt).second; + TListOfListIt bndPos1 = bndPos2++; + boundaryList.splice( boundaryList.end(), tmpList, bndPos1, bndPos2 ); + } + } + + // Look for the outer boundary: the one with the point with the least X + double leastX = DBL_MAX; + TListOfListIt outerBndPos; + for ( bndIt = boundaryList.begin(); bndIt != boundaryList.end(); bndIt++ ) + { + list< TPoint* >& boundary = (*bndIt); + for ( pIt = boundary.begin(); pIt != boundary.end(); pIt++) + { + TPoint* point = *pIt; + if ( point->myInitXYZ.X() < leastX ) { + leastX = point->myInitXYZ.X(); + outerBndPos = bndIt; + } + } + } + + if ( outerBndPos != boundaryList.begin() ) + boundaryList.splice( boundaryList.begin(), boundaryList, outerBndPos, ++outerBndPos ); + + } // if nbBoundaries > 1 + + // Check boundaries orientation and re-fill myKeyPointIDs + + set< TPoint* > keyPointSet; + list< int >::iterator kpIt = myKeyPointIDs.begin(); + for ( ; kpIt != myKeyPointIDs.end(); kpIt++ ) + keyPointSet.insert( & myPoints[ *kpIt ]); + myKeyPointIDs.clear(); + + // update myNbKeyPntInBoundary also + list< int >::iterator nbKpIt = myNbKeyPntInBoundary.begin(); + + for ( bndIt = boundaryList.begin(); bndIt != boundaryList.end(); bndIt++, nbKpIt++ ) + { + // find the point with the least X + double leastX = DBL_MAX; + list< TPoint* >::iterator xpIt; + list< TPoint* >& boundary = (*bndIt); + for ( pIt = boundary.begin(); pIt != boundary.end(); pIt++) + { + TPoint* point = *pIt; + if ( point->myInitXYZ.X() < leastX ) { + leastX = point->myInitXYZ.X(); + xpIt = pIt; + } + } + // find points next to the point with the least X + TPoint* p = *xpIt, *pPrev, *pNext; + if ( p == boundary.front() ) + pPrev = *(++boundary.rbegin()); + else { + xpIt--; + pPrev = *xpIt; + xpIt++; + } + if ( p == boundary.back() ) + pNext = *(++boundary.begin()); + else { + xpIt++; + pNext = *xpIt; + } + // vectors of boundary direction near

    + gp_Vec2d v1( pPrev->myInitUV, p->myInitUV ), v2( p->myInitUV, pNext->myInitUV ); + // rotate vectors counterclockwise + v1.SetCoord( -v1.Y(), v1.X() ); + v2.SetCoord( -v2.Y(), v2.X() ); + // in-face direction + gp_Vec2d dirInFace = v1 + v2; + // for the outer boundary dirInFace should go to the right + bool reverse; + if ( bndIt == boundaryList.begin() ) // outer boundary + reverse = dirInFace.X() < 0; + else + reverse = dirInFace.X() > 0; + if ( reverse ) + boundary.reverse(); + + // Put key-point IDs of a well-oriented boundary in myKeyPointIDs + (*nbKpIt) = 0; // count nb of key-points again + pIt = boundary.begin(); + for ( ; pIt != boundary.end(); pIt++) + { + TPoint* point = *pIt; + if ( keyPointSet.find( point ) == keyPointSet.end() ) + continue; + // find an index of a keypoint + int index = 0; + vector< TPoint >::const_iterator pVecIt = myPoints.begin(); + for ( ; pVecIt != myPoints.end(); pVecIt++, index++ ) + if ( &(*pVecIt) == point ) + break; + myKeyPointIDs.push_back( index ); + (*nbKpIt)++; + } + myKeyPointIDs.pop_back(); // remove the first key-point from the back + (*nbKpIt)--; + + } // loop on a list of boundaries + + ASSERT( myKeyPointIDs.size() == keyPointSet.size() ); +} + +//======================================================================= +//function : findBoundaryPoints +//purpose : if loaded from file, find points to map on edges and faces and +// compute their parameters +//======================================================================= + +bool SMESH_Pattern::findBoundaryPoints() +{ + if ( myIsBoundaryPointsFound ) return true; + + MESSAGE(" findBoundaryPoints() "); + + if ( myIs2D ) + { + set< TPoint* > pointsInElems; + + // Find free links of elements: + // put links of all elements in a set and remove links encountered twice + + typedef pair< TPoint*, TPoint*> TLink; + set< TLink > linkSet; + list >::iterator epIt = myElemPointIDs.begin(); + for ( ; epIt != myElemPointIDs.end(); epIt++ ) + { + list< int > & elemPoints = *epIt; + list< int >::iterator pIt = elemPoints.begin(); + int prevP = elemPoints.back(); + for ( ; pIt != elemPoints.end(); pIt++ ) { + TPoint* p1 = & myPoints[ prevP ]; + TPoint* p2 = & myPoints[ *pIt ]; + TLink link(( p1 < p2 ? p1 : p2 ), ( p1 < p2 ? p2 : p1 )); + ASSERT( link.first != link.second ); + pair::iterator,bool> itUniq = linkSet.insert( link ); + if ( !itUniq.second ) + linkSet.erase( itUniq.first ); + prevP = *pIt; + + pointsInElems.insert( p1 ); + } + } + // Now linkSet contains only free links, + // find the points order that they have in boundaries + + // 1. make a map of key-points + set< TPoint* > keyPointSet; + list< int >::iterator kpIt = myKeyPointIDs.begin(); + for ( ; kpIt != myKeyPointIDs.end(); kpIt++ ) + keyPointSet.insert( & myPoints[ *kpIt ]); + + // 2. chain up boundary points + list< list< TPoint* > > boundaryList; + boundaryList.push_back( list< TPoint* >() ); + list< TPoint* > * boundary = & boundaryList.back(); + + TPoint *point1, *point2, *keypoint1; + kpIt = myKeyPointIDs.begin(); + point1 = keypoint1 = & myPoints[ *kpIt++ ]; + // loop on free links: look for the next point + int iKeyPoint = 0; + set< TLink >::iterator lIt = linkSet.begin(); + while ( lIt != linkSet.end() ) + { + if ( (*lIt).first == point1 ) + point2 = (*lIt).second; + else if ( (*lIt).second == point1 ) + point2 = (*lIt).first; + else { + lIt++; + continue; + } + linkSet.erase( lIt ); + lIt = linkSet.begin(); + + if ( keyPointSet.find( point2 ) == keyPointSet.end() ) // not a key-point + { + boundary->push_back( point2 ); + } + else // a key-point found + { + keyPointSet.erase( point2 ); // keyPointSet contains not found key-points only + iKeyPoint++; + if ( point2 != keypoint1 ) // its not the boundary end + { + boundary->push_back( point2 ); + } + else // the boundary end reached + { + boundary->push_front( keypoint1 ); + boundary->push_back( keypoint1 ); + myNbKeyPntInBoundary.push_back( iKeyPoint ); + if ( keyPointSet.empty() ) + break; // all boundaries containing key-points are found + + // prepare to search for the next boundary + boundaryList.push_back( list< TPoint* >() ); + boundary = & boundaryList.back(); + point2 = keypoint1 = (*keyPointSet.begin()); + } + } + point1 = point2; + } // loop on the free links set + + if ( boundary->empty() ) { + MESSAGE(" a separate key-point"); + return setErrorCode( ERR_READ_BAD_KEY_POINT ); + } + + // if there are several wires, arrange boundaryPoints so that + // the outer wire goes first and fix inner wires orientation; + // sort myKeyPointIDs to correspond to the order of key-points + // in boundaries + arrangeBoundaries( boundaryList ); + + // Find correspondence shape ID - points, + // compute points parameter on edge + + keyPointSet.clear(); + for ( kpIt = myKeyPointIDs.begin(); kpIt != myKeyPointIDs.end(); kpIt++ ) + keyPointSet.insert( & myPoints[ *kpIt ]); + + set< TPoint* > edgePointSet; // to find in-face points + int vertexID = 1; // the first index in TopTools_IndexedMapOfShape + int edgeID = myKeyPointIDs.size() + 1; + + list< list< TPoint* > >::iterator bndIt = boundaryList.begin(); + for ( ; bndIt != boundaryList.end(); bndIt++ ) + { + boundary = & (*bndIt); + double edgeLength = 0; + list< TPoint* >::iterator pIt = boundary->begin(); + getShapePoints( edgeID ).push_back( *pIt ); + for ( pIt++; pIt != boundary->end(); pIt++) + { + list< TPoint* > & edgePoints = getShapePoints( edgeID ); + TPoint* prevP = edgePoints.empty() ? 0 : edgePoints.back(); + TPoint* point = *pIt; + edgePointSet.insert( point ); + if ( keyPointSet.find( point ) == keyPointSet.end() ) // inside-edge point + { + edgePoints.push_back( point ); + edgeLength += ( point->myInitUV - prevP->myInitUV ).Modulus(); + point->myInitU = edgeLength; + } + else // a key-point + { + // treat points on the edge which ends up: compute U [0,1] + edgePoints.push_back( point ); + if ( edgePoints.size() > 2 ) { + edgeLength += ( point->myInitUV - prevP->myInitUV ).Modulus(); + list< TPoint* >::iterator epIt = edgePoints.begin(); + for ( ; epIt != edgePoints.end(); epIt++ ) + (*epIt)->myInitU /= edgeLength; + } + // begin the next edge treatment + edgeLength = 0; + getShapePoints( vertexID++ ).push_back( point ); + edgeID++; + if ( point != boundary->front() ) + getShapePoints( edgeID ).push_back( point ); + } + } + } + + // find in-face points + list< TPoint* > & facePoints = getShapePoints( edgeID ); + vector< TPoint >::iterator pVecIt = myPoints.begin(); + for ( ; pVecIt != myPoints.end(); pVecIt++ ) { + TPoint* point = &(*pVecIt); + if ( edgePointSet.find( point ) == edgePointSet.end() && + pointsInElems.find( point ) != pointsInElems.end()) + facePoints.push_back( point ); + } + + } // 2D case + + else // 3D case + { + // bind points to shapes according to point parameters + vector< TPoint >::iterator pVecIt = myPoints.begin(); + for ( int i = 0; pVecIt != myPoints.end(); pVecIt++, i++ ) { + TPoint* point = &(*pVecIt); + int shapeID = TBlock::GetShapeIDByParams( point->myInitXYZ ); + getShapePoints( shapeID ).push_back( point ); + // detect key-points + if ( TBlock::IsVertexID( shapeID )) + myKeyPointIDs.push_back( i ); + } + } + + myIsBoundaryPointsFound = true; + return myIsBoundaryPointsFound; +} + +//======================================================================= +//function : Clear +//purpose : clear fields +//======================================================================= + +void SMESH_Pattern::Clear() +{ + myIsComputed = myIsBoundaryPointsFound = false; + + myPoints.clear(); + myKeyPointIDs.clear(); + myElemPointIDs.clear(); + myShapeIDToPointsMap.clear(); + myShapeIDMap.Clear(); + myShape.Nullify(); + myNbKeyPntInBoundary.clear(); +} + +//======================================================================= +//function : setShapeToMesh +//purpose : set a shape to be meshed. Return True if meshing is possible +//======================================================================= + +bool SMESH_Pattern::setShapeToMesh(const TopoDS_Shape& theShape) +{ + if ( !IsLoaded() ) { + MESSAGE( "Pattern not loaded" ); + return setErrorCode( ERR_APPL_NOT_LOADED ); + } + + TopAbs_ShapeEnum aType = theShape.ShapeType(); + bool dimOk = ( myIs2D ? aType == TopAbs_FACE : aType == TopAbs_SHELL ); + if ( !dimOk ) { + MESSAGE( "Pattern dimention mismatch" ); + return setErrorCode( ERR_APPL_BAD_DIMENTION ); + } + + // check if a face is closed + int nbNodeOnSeamEdge = 0; + if ( myIs2D ) { + TopoDS_Face face = TopoDS::Face( theShape ); + TopExp_Explorer eExp( theShape, TopAbs_EDGE ); + for ( ; eExp.More() && nbNodeOnSeamEdge == 0; eExp.Next() ) + if ( BRep_Tool::IsClosed( TopoDS::Edge( eExp.Current() ), face )) + nbNodeOnSeamEdge = 2; + } + + // check nb of vertices + TopTools_IndexedMapOfShape vMap; + TopExp::MapShapes( theShape, TopAbs_VERTEX, vMap ); + if ( vMap.Extent() + nbNodeOnSeamEdge != myKeyPointIDs.size() ) { + MESSAGE( myKeyPointIDs.size() << " != " << vMap.Extent() ); + return setErrorCode( ERR_APPL_BAD_NB_VERTICES ); + } + + myShapeIDMap.Clear(); + myShape = theShape; + return true; +} + +//======================================================================= +//function : GetMappedPoints +//purpose : Return nodes coordinates computed by Apply() method +//======================================================================= + +bool SMESH_Pattern::GetMappedPoints ( list< const gp_XYZ * > & thePoints ) +{ + thePoints.clear(); + if ( !myIsComputed ) + return false; + + vector< TPoint >::iterator pVecIt = myPoints.begin(); + for ( ; pVecIt != myPoints.end(); pVecIt++ ) + thePoints.push_back( & (*pVecIt).myXYZ.XYZ() ); + + return ( thePoints.size() > 0 ); +} + + +//======================================================================= +//function : GetPoints +//purpose : Return nodes coordinates of the pattern +//======================================================================= + +bool SMESH_Pattern::GetPoints ( list< const gp_XYZ * > & thePoints ) const +{ + thePoints.clear(); + + if ( !IsLoaded() ) + return false; + + vector< TPoint >::const_iterator pVecIt = myPoints.begin(); + for ( ; pVecIt != myPoints.end(); pVecIt++ ) + thePoints.push_back( & (*pVecIt).myInitXYZ ); + + return ( thePoints.size() > 0 ); +} + +//======================================================================= +//function : getShapePoints +//purpose : return list of points located on theShape +//======================================================================= + +list< SMESH_Pattern::TPoint* > & + SMESH_Pattern::getShapePoints(const TopoDS_Shape& theShape) +{ + int aShapeID; + if ( !myShapeIDMap.Contains( theShape )) + aShapeID = myShapeIDMap.Add( theShape ); + else + aShapeID = myShapeIDMap.FindIndex( theShape ); + + return myShapeIDToPointsMap[ aShapeID ]; +} + +//======================================================================= +//function : getShapePoints +//purpose : return list of points located on the shape +//======================================================================= + +list< SMESH_Pattern::TPoint* > & SMESH_Pattern::getShapePoints(const int theShapeID) +{ + return myShapeIDToPointsMap[ theShapeID ]; +} + +//======================================================================= +//function : DumpPoints +//purpose : Debug +//======================================================================= + +void SMESH_Pattern::DumpPoints() const +{ +#ifdef _DEBUG_ + vector< TPoint >::const_iterator pVecIt = myPoints.begin(); + for ( int i = 0; pVecIt != myPoints.end(); pVecIt++, i++ ) + cout << i << ": " << *pVecIt; +#endif +} + +//======================================================================= +//function : TPoint() +//purpose : +//======================================================================= + +SMESH_Pattern::TPoint::TPoint() +{ +#ifdef _DEBUG_ + myInitXYZ.SetCoord(0,0,0); + myInitUV.SetCoord(0.,0.); + myInitU = 0; + myXYZ.SetCoord(0,0,0); + myUV.SetCoord(0.,0.); + myU = 0; +#endif +} + +//======================================================================= +//function : operator << +//purpose : +//======================================================================= + +ostream & operator <<(ostream & OS, const SMESH_Pattern::TPoint& p) +{ + gp_XYZ xyz = p.myInitXYZ; + OS << "\tinit( xyz( " << xyz.X() << " " << xyz.Y() << " " << xyz.Z() << " )"; + gp_XY xy = p.myInitUV; + OS << " uv( " << xy.X() << " " << xy.Y() << " )"; + double u = p.myInitU; + OS << " u( " << u << " )) " << &p << endl; + xyz = p.myXYZ.XYZ(); + OS << "\t ( xyz( " << xyz.X() << " " << xyz.Y() << " " << xyz.Z() << " )"; + xy = p.myUV; + OS << " uv( " << xy.X() << " " << xy.Y() << " )"; + u = p.myU; + OS << " u( " << u << " ))" << endl; + + return OS; +} + +//======================================================================= +//function : TBlock::TEdge::GetU +//purpose : +//======================================================================= + +double TBlock::TEdge::GetU( const gp_XYZ& theParams ) const +{ + double u = theParams.Coord( myCoordInd ); + return ( 1 - u ) * myFirst + u * myLast; +} + +//======================================================================= +//function : TBlock::TEdge::Point +//purpose : +//======================================================================= + +gp_XYZ TBlock::TEdge::Point( const gp_XYZ& theParams ) const +{ + gp_XYZ p = myC3d->Value( GetU( theParams )).XYZ(); + if ( myTrsf.Form() != gp_Identity ) + myTrsf.Transforms( p ); + return p; +} + +//======================================================================= +//function : TBlock::TFace::GetUV +//purpose : +//======================================================================= + +gp_XY TBlock::TFace::GetUV( const gp_XYZ& theParams ) const +{ + gp_XY uv(0.,0.); + double dU = theParams.Coord( GetUInd() ); + double dV = theParams.Coord( GetVInd() ); + for ( int iE = 0; iE < 4; iE++ ) // loop on 4 edges + { + double Ecoef = 0, Vcoef = 0; + switch ( iE ) { + case 0: + Ecoef = ( 1 - dV ); // u0 + Vcoef = ( 1 - dU ) * ( 1 - dV ); break; // 00 + case 1: + Ecoef = dV; // u1 + Vcoef = dU * ( 1 - dV ); break; // 10 + case 2: + Ecoef = ( 1 - dU ); // 0v + Vcoef = dU * dV ; break; // 11 + case 3: + Ecoef = dU ; // 1v + Vcoef = ( 1 - dU ) * dV ; break; // 01 + default:; + } + // edge addition + double u = theParams.Coord( myCoordInd[ iE ] ); + u = ( 1 - u ) * myFirst[ iE ] + u * myLast[ iE ]; + uv += Ecoef * myC2d[ iE ]->Value( u ).XY(); + // corner addition + uv -= Vcoef * myCorner[ iE ]; + } + return uv; +} + +//======================================================================= +//function : TBlock::TFace::Point +//purpose : +//======================================================================= + +gp_XYZ TBlock::TFace::Point( const gp_XYZ& theParams ) const +{ + gp_XY uv = GetUV( theParams ); + gp_XYZ p = myS->Value( uv.X(), uv.Y() ).XYZ(); + if ( myTrsf.Form() != gp_Identity ) + myTrsf.Transforms( p ); + return p; +} + +//======================================================================= +//function : GetShapeCoef +//purpose : +//======================================================================= + +double* TBlock::GetShapeCoef (const int theShapeID) +{ + static double shapeCoef[][3] = { + // V000, V100, V010, V110 + { -1,-1,-1 }, { 1,-1,-1 }, { -1, 1,-1 }, { 1, 1,-1 }, + // V001, V101, V011, V111, + { -1,-1, 1 }, { 1,-1, 1 }, { -1, 1, 1 }, { 1, 1, 1 }, + // Ex00, Ex10, Ex01, Ex11, + { 0,-1,-1 }, { 0, 1,-1 }, { 0,-1, 1 }, { 0, 1, 1 }, + // E0y0, E1y0, E0y1, E1y1, + { -1, 0,-1 }, { 1, 0,-1 }, { -1, 0, 1 }, { 1, 0, 1 }, + // E00z, E10z, E01z, E11z, + { -1,-1, 0 }, { 1,-1, 0 }, { -1, 1, 0 }, { 1, 1, 0 }, + // Fxy0, Fxy1, Fx0z, Fx1z, F0yz, F1yz, + { 0, 0,-1 }, { 0, 0, 1 }, { 0,-1, 0 }, { 0, 1, 0 }, { -1, 0, 0 }, { 1, 0, 0 }, + // ID_Shell + { 0, 0, 0 } + }; + if ( theShapeID < ID_V000 || theShapeID > ID_F1yz ) + return shapeCoef[ ID_Shell - 1 ]; + + return shapeCoef[ theShapeID - 1 ]; +} + +//======================================================================= +//function : ShellPoint +//purpose : return coordinates of a point in shell +//======================================================================= + +bool TBlock::ShellPoint( const gp_XYZ& theParams, gp_XYZ& thePoint ) const +{ + thePoint.SetCoord( 0., 0., 0. ); + for ( int shapeID = ID_V000; shapeID < ID_Shell; shapeID++ ) + { + // coef + double* coefs = GetShapeCoef( shapeID ); + double k = 1; + for ( int iCoef = 0; iCoef < 3; iCoef++ ) { + if ( coefs[ iCoef ] != 0 ) { + if ( coefs[ iCoef ] < 0 ) + k *= ( 1. - theParams.Coord( iCoef + 1 )); + else + k *= theParams.Coord( iCoef + 1 ); + } + } + // point on a shape + gp_XYZ Ps; + if ( shapeID < ID_Ex00 ) // vertex + VertexPoint( shapeID, Ps ); + else if ( shapeID < ID_Fxy0 ) { // edge + EdgePoint( shapeID, theParams, Ps ); + k = -k; + } else // face + FacePoint( shapeID, theParams, Ps ); + + thePoint += k * Ps; + } + return true; +} + +//======================================================================= +//function : NbVariables +//purpose : +//======================================================================= + +Standard_Integer TBlock::NbVariables() const +{ + return 3; +} + +//======================================================================= +//function : NbEquations +//purpose : +//======================================================================= + +Standard_Integer TBlock::NbEquations() const +{ + return 1; +} + +//======================================================================= +//function : Value +//purpose : +//======================================================================= + +Standard_Boolean TBlock::Value(const math_Vector& theXYZ, math_Vector& theFxyz) +{ + gp_XYZ P, params( theXYZ(1), theXYZ(2), theXYZ(3) ); + if ( params.IsEqual( myParam, DBL_MIN )) { // same param + theFxyz( 1 ) = myValues[ 0 ]; + } + else { + ShellPoint( params, P ); + gp_Vec dP( P - myPoint ); + theFxyz(1) = SQRT_FUNC ? dP.SquareMagnitude() : dP.Magnitude(); + } + return true; +} + +//======================================================================= +//function : Derivatives +//purpose : +//======================================================================= + +Standard_Boolean TBlock::Derivatives(const math_Vector& XYZ,math_Matrix& Df) +{ + MESSAGE( "TBlock::Derivatives()"); + math_Vector F(1,3); + return Values(XYZ,F,Df); +} + +//======================================================================= +//function : Values +//purpose : +//======================================================================= + +Standard_Boolean TBlock::Values(const math_Vector& theXYZ, + math_Vector& theFxyz, + math_Matrix& theDf) +{ +// MESSAGE( endl<<"TBlock::Values( "< DBL_MIN ) + dPi /= mag; + drv[ iP - 1 ] = dPi; + } + for ( int iP = 0; iP < 3; iP++ ) { + if ( iP == myFaceIndex ) + theDf( 1, iP + 1 ) = myFaceParam; + else { + // like IntAna_IntConicQuad::Perform (const gp_Lin& L, const gp_Pln& P) + // where L is (P -> myPoint), P is defined by the 2 other derivative direction + int iPrev = ( iP ? iP - 1 : 2 ); + int iNext = ( iP == 2 ? 0 : iP + 1 ); + gp_Vec plnNorm = drv[ iPrev ].Crossed( drv [ iNext ] ); + double Direc = plnNorm * drv[ iP ]; + if ( Abs(Direc) <= DBL_MIN ) + theDf( 1, iP + 1 ) = dP * drv[ iP ]; + else { + double Dis = plnNorm * P - plnNorm * myPoint; + theDf( 1, iP + 1 ) = Dis/Direc; + } + } + } + //myNbIterations +=3; // how many time call ShellPoint() + + // store better values + myParam = params; + myValues[0]= theFxyz(1); + myValues[1]= theDf(1,1); + myValues[2]= theDf(1,2); + myValues[3]= theDf(1,3); + +// SCRUTE( theFxyz(1) ); +// SCRUTE( theDf( 1,1 )); +// SCRUTE( theDf( 1,2 )); +// SCRUTE( theDf( 1,3 )); + } + + return true; +} + +//======================================================================= +//function : ComputeParameters +//purpose : compute point parameters in the block +//======================================================================= + +bool TBlock::ComputeParameters(const gp_Pnt& thePoint, + gp_XYZ& theParams, + const int theShapeID) +{ +// MESSAGE( endl<<"TBlock::ComputeParameters( " +// < zero ) { + par = v0P.Dot( v01 ) / len2; + if ( par < 0 || par > 1 ) { + needGrid = true; + break; + } + } + start( iParam ) += par; + } + start( iParam ) /= 4.; + } + if ( needGrid ) { + // compute nodes of 3 x 3 x 3 grid + int iNode = 0; + for ( double x = 0.25; x < 0.9; x += 0.25 ) + for ( double y = 0.25; y < 0.9; y += 0.25 ) + for ( double z = 0.25; z < 0.9; z += 0.25 ) { + TxyzPair & prmPtn = my3x3x3GridNodes[ iNode++ ]; + prmPtn.first.SetCoord( x, y, z ); + ShellPoint( prmPtn.first, prmPtn.second ); + } + myGridComputed = true; + } + } + if ( myGridComputed ) { + double minDist = DBL_MAX; + gp_XYZ* bestParam = 0; + for ( int iNode = 0; iNode < 27; iNode++ ) { + TxyzPair & prmPtn = my3x3x3GridNodes[ iNode ]; + double dist = ( thePoint.XYZ() - prmPtn.second ).SquareModulus(); + if ( dist < minDist ) { + minDist = dist; + bestParam = & prmPtn.first; + } + } + start( 1 ) = bestParam->X(); + start( 2 ) = bestParam->Y(); + start( 3 ) = bestParam->Z(); + } + + int myFaceIndex = -1; + if ( isOnFace ) { + // put a point on the face + for ( int iCoord = 0; iCoord < 3; iCoord++ ) + if ( coef[ iCoord ] ) { + myFaceIndex = iCoord; + myFaceParam = ( coef[ myFaceIndex ] < 0.5 ) ? 0.0 : 1.0; + start( iCoord + 1 ) = myFaceParam; + } + } + math_Vector low ( 1, 3, 0.0 ); + math_Vector up ( 1, 3, 1.0 ); + math_Vector tol ( 1, 3, 1e-4 ); + math_FunctionSetRoot paramSearch( *this, tol ); + + int nbLoops = 0; + while ( myValues[0] > 1e-1 && nbLoops++ < 10 ) { + paramSearch.Perform ( *this, start, low, up ); + if ( !paramSearch.IsDone() ) { + //MESSAGE( " !paramSearch.IsDone() " ); + } + else { + //MESSAGE( " NB ITERATIONS: " << paramSearch.NbIterations() ); + } + start( 1 ) = myParam.X(); + start( 2 ) = myParam.Y(); + start( 3 ) = myParam.Z(); + //MESSAGE( "Distance: " << ( SQRT_FUNC ? sqrt(myValues[0]) : myValues[0] )); + } +// MESSAGE( endl << myParam.X() << " " << myParam.Y() << " " << myParam.Z() << endl); +// mySumDist += myValues[0]; +// MESSAGE( " TOTAL NB ITERATIONS: " << myNbIterations << +// " DIST: " << ( SQRT_FUNC ? sqrt(mySumDist) : mySumDist )); + + + theParams = myParam; + + return true; +} + +//======================================================================= +//function : GetStateNumber +//purpose : +//======================================================================= + +Standard_Integer TBlock::GetStateNumber () +{ +// MESSAGE( endl<<"TBlock::GetStateNumber( "< 26 || id < 0 ) { + MESSAGE( "GetShapeIDByParams() = " << id + <<" "<< theCoord.X() <<" "<< theCoord.Y() <<" "<< theCoord.Z() ); + } + + return id + 1; // shape ids start at 1 +} + +//======================================================================= +//function : LoadBlockShapes +//purpose : add sub-shapes of theBlock to theShapeIDMap so that they get +// IDs acoording to enum TBlockShapeID +//======================================================================= + +bool TBlock::LoadBlockShapes(const TopoDS_Vertex& theVertex000, + const TopoDS_Vertex& theVertex001, +// TopTools_IndexedMapOfShape& theShapeIDMap + TopTools_IndexedMapOfOrientedShape& theShapeIDMap ) +{ + MESSAGE(" ::LoadBlockShapes()"); + myGridComputed = false; + + // 6 vertices + TopoDS_Shape V000, V100, V010, V110, V001, V101, V011, V111; + // 12 edges + TopoDS_Shape Ex00, Ex10, Ex01, Ex11; + TopoDS_Shape E0y0, E1y0, E0y1, E1y1; + TopoDS_Shape E00z, E10z, E01z, E11z; + // 6 faces + TopoDS_Shape Fxy0, Fx0z, F0yz, Fxy1, Fx1z, F1yz; + + // nb of faces bound to a vertex in TopTools_IndexedDataMapOfShapeListOfShape + // filled by TopExp::MapShapesAndAncestors() + const int NB_FACES_BY_VERTEX = 6; + + TopTools_IndexedDataMapOfShapeListOfShape vfMap; + TopExp::MapShapesAndAncestors( myShell, TopAbs_VERTEX, TopAbs_FACE, vfMap ); + if ( vfMap.Extent() != 8 ) { + MESSAGE(" Wrong nb of vertices in the block: " << vfMap.Extent() ); + return false; + } + + V000 = theVertex000; + V001 = theVertex001; + + if ( V000.IsNull() ) { + // find vertex 000 - the one with smallest coordinates + double minVal = DBL_MAX, minX, val; + for ( int i = 1; i <= 8; i++ ) { + const TopoDS_Vertex& v = TopoDS::Vertex( vfMap.FindKey( i )); + gp_Pnt P = BRep_Tool::Pnt( v ); + val = P.X() + P.Y() + P.Z(); + if ( val < minVal || ( val == minVal && P.X() < minX )) { + V000 = v; + minVal = val; + minX = P.X(); + } + } + // find vertex 001 - the one on the most vertical edge passing through V000 + TopTools_IndexedDataMapOfShapeListOfShape veMap; + TopExp::MapShapesAndAncestors( myShell, TopAbs_VERTEX, TopAbs_EDGE, veMap ); + gp_Vec dir001 = gp::DZ(); + gp_Pnt p000 = BRep_Tool::Pnt( TopoDS::Vertex( V000 )); + double maxVal = -DBL_MAX; + TopTools_ListIteratorOfListOfShape eIt ( veMap.FindFromKey( V000 )); + for ( ; eIt.More(); eIt.Next() ) { + const TopoDS_Edge& e = TopoDS::Edge( eIt.Value() ); + TopoDS_Vertex v = TopExp::FirstVertex( e ); + if ( v.IsSame( V000 )) + v = TopExp::LastVertex( e ); + val = dir001 * gp_Vec( p000, BRep_Tool::Pnt( v )).Normalized(); + if ( val > maxVal ) { + V001 = v; + maxVal = val; + } + } + } + + // find the bottom (Fxy0), Fx0z and F0yz faces + + const TopTools_ListOfShape& f000List = vfMap.FindFromKey( V000 ); + const TopTools_ListOfShape& f001List = vfMap.FindFromKey( V001 ); + if (f000List.Extent() != NB_FACES_BY_VERTEX || + f001List.Extent() != NB_FACES_BY_VERTEX ) { + MESSAGE(" LoadBlockShapes() " << f000List.Extent() << " " << f001List.Extent()); + return false; + } + TopTools_ListIteratorOfListOfShape f001It, f000It ( f000List ); + int i, j, iFound1, iFound2; + for ( j = 0; f000It.More(); f000It.Next(), j++ ) + { + if ( NB_FACES_BY_VERTEX == 6 && j % 2 ) continue; // each face encounters twice + const TopoDS_Shape& F = f000It.Value(); + for ( i = 0, f001It.Initialize( f001List ); f001It.More(); f001It.Next(), i++ ) { + if ( NB_FACES_BY_VERTEX == 6 && i % 2 ) continue; // each face encounters twice + if ( F.IsSame( f001It.Value() )) + break; + } + if ( f001It.More() ) // Fx0z or F0yz found + if ( Fx0z.IsNull() ) { + Fx0z = F; + iFound1 = i; + } else { + F0yz = F; + iFound2 = i; + } + else // F is the bottom face + Fxy0 = F; + } + if ( Fxy0.IsNull() || Fx0z.IsNull() || F0yz.IsNull() ) { + MESSAGE( Fxy0.IsNull() <<" "<< Fx0z.IsNull() <<" "<< F0yz.IsNull() ); + return false; + } + + // choose the top face (Fxy1) + for ( i = 0, f001It.Initialize( f001List ); f001It.More(); f001It.Next(), i++ ) { + if ( NB_FACES_BY_VERTEX == 6 && i % 2 ) continue; // each face encounters twice + if ( i != iFound1 && i != iFound2 ) + break; + } + Fxy1 = f001It.Value(); + if ( Fxy1.IsNull() ) { + MESSAGE(" LoadBlockShapes() error "); + return false; + } + + // find bottom edges and veritices + list< TopoDS_Edge > eList; + list< int > nbVertexInWires; + getOrderedEdges( TopoDS::Face( Fxy0 ), TopoDS::Vertex( V000 ), eList, nbVertexInWires ); + if ( nbVertexInWires.size() != 1 || nbVertexInWires.front() != 4 ) { + MESSAGE(" LoadBlockShapes() error "); + return false; + } + list< TopoDS_Edge >::iterator elIt = eList.begin(); + for ( i = 0; elIt != eList.end(); elIt++, i++ ) + switch ( i ) { + case 0: E0y0 = *elIt; V010 = TopExp::LastVertex( *elIt, true ); break; + case 1: Ex10 = *elIt; V110 = TopExp::LastVertex( *elIt, true ); break; + case 2: E1y0 = *elIt; V100 = TopExp::LastVertex( *elIt, true ); break; + case 3: Ex00 = *elIt; break; + default:; + } + if ( i != 4 || E0y0.IsNull() || Ex10.IsNull() || E1y0.IsNull() || Ex00.IsNull() ) { + MESSAGE(" LoadBlockShapes() error, eList.size()=" << eList.size()); + return false; + } + + + // find top edges and veritices + eList.clear(); + getOrderedEdges( TopoDS::Face( Fxy1 ), TopoDS::Vertex( V001 ), eList, nbVertexInWires ); + if ( nbVertexInWires.size() != 1 || nbVertexInWires.front() != 4 ) { + MESSAGE(" LoadBlockShapes() error "); + return false; + } + for ( i = 0, elIt = eList.begin(); elIt != eList.end(); elIt++, i++ ) + switch ( i ) { + case 0: Ex01 = *elIt; V101 = TopExp::LastVertex( *elIt, true ); break; + case 1: E1y1 = *elIt; V111 = TopExp::LastVertex( *elIt, true ); break; + case 2: Ex11 = *elIt; V011 = TopExp::LastVertex( *elIt, true ); break; + case 3: E0y1 = *elIt; break; + default:; + } + if ( i != 4 || Ex01.IsNull() || E1y1.IsNull() || Ex11.IsNull() || E0y1.IsNull() ) { + MESSAGE(" LoadBlockShapes() error, eList.size()=" << eList.size()); + return false; + } + + // swap Fx0z and F0yz if necessary + TopExp_Explorer exp( Fx0z, TopAbs_VERTEX ); + for ( ; exp.More(); exp.Next() ) // Fx0z shares V101 and V100 + if ( V101.IsSame( exp.Current() ) || V100.IsSame( exp.Current() )) + break; // V101 or V100 found + if ( !exp.More() ) { // not found + TopoDS_Shape f = Fx0z; Fx0z = F0yz; F0yz = f; + } + + // find Fx1z and F1yz faces + const TopTools_ListOfShape& f111List = vfMap.FindFromKey( V111 ); + const TopTools_ListOfShape& f110List = vfMap.FindFromKey( V110 ); + if (f111List.Extent() != NB_FACES_BY_VERTEX || + f110List.Extent() != NB_FACES_BY_VERTEX ) { + MESSAGE(" LoadBlockShapes() " << f111List.Extent() << " " << f110List.Extent()); + return false; + } + TopTools_ListIteratorOfListOfShape f111It, f110It ( f110List); + for ( j = 0 ; f110It.More(); f110It.Next(), j++ ) { + if ( NB_FACES_BY_VERTEX == 6 && j % 2 ) continue; // each face encounters twice + const TopoDS_Shape& F = f110It.Value(); + for ( i = 0, f111It.Initialize( f111List ); f111It.More(); f111It.Next(), i++ ) { + if ( NB_FACES_BY_VERTEX == 6 && i % 2 ) continue; // each face encounters twice + if ( F.IsSame( f111It.Value() )) { // Fx1z or F1yz found + if ( Fx1z.IsNull() ) + Fx1z = F; + else + F1yz = F; + } + } + } + if ( Fx1z.IsNull() || F1yz.IsNull() ) { + MESSAGE(" LoadBlockShapes() error "); + return false; + } + + // swap Fx1z and F1yz if necessary + for ( exp.Init( Fx1z, TopAbs_VERTEX ); exp.More(); exp.Next() ) + if ( V010.IsSame( exp.Current() ) || V011.IsSame( exp.Current() )) + break; + if ( !exp.More() ) { + TopoDS_Shape f = Fx1z; Fx1z = F1yz; F1yz = f; + } + + // find vertical edges + for ( exp.Init( Fx0z, TopAbs_EDGE ); exp.More(); exp.Next() ) { + const TopoDS_Edge& edge = TopoDS::Edge( exp.Current() ); + const TopoDS_Shape& vFirst = TopExp::FirstVertex( edge, true ); + if ( vFirst.IsSame( V001 )) + E00z = edge; + else if ( vFirst.IsSame( V100 )) + E10z = edge; + } + if ( E00z.IsNull() || E10z.IsNull() ) { + MESSAGE(" LoadBlockShapes() error "); + return false; + } + for ( exp.Init( Fx1z, TopAbs_EDGE ); exp.More(); exp.Next() ) { + const TopoDS_Edge& edge = TopoDS::Edge( exp.Current() ); + const TopoDS_Shape& vFirst = TopExp::FirstVertex( edge, true ); + if ( vFirst.IsSame( V111 )) + E11z = edge; + else if ( vFirst.IsSame( V010 )) + E01z = edge; + } + if ( E01z.IsNull() || E11z.IsNull() ) { + MESSAGE(" LoadBlockShapes() error "); + return false; + } + + // load shapes in theShapeIDMap + + theShapeIDMap.Clear(); + + theShapeIDMap.Add(V000.Oriented( TopAbs_FORWARD )); + theShapeIDMap.Add(V100.Oriented( TopAbs_FORWARD )); + theShapeIDMap.Add(V010.Oriented( TopAbs_FORWARD )); + theShapeIDMap.Add(V110.Oriented( TopAbs_FORWARD )); + theShapeIDMap.Add(V001.Oriented( TopAbs_FORWARD )); + theShapeIDMap.Add(V101.Oriented( TopAbs_FORWARD )); + theShapeIDMap.Add(V011.Oriented( TopAbs_FORWARD )); + theShapeIDMap.Add(V111.Oriented( TopAbs_FORWARD )); + + theShapeIDMap.Add(Ex00); + theShapeIDMap.Add(Ex10); + theShapeIDMap.Add(Ex01); + theShapeIDMap.Add(Ex11); + + theShapeIDMap.Add(E0y0); + theShapeIDMap.Add(E1y0); + theShapeIDMap.Add(E0y1); + theShapeIDMap.Add(E1y1); + + theShapeIDMap.Add(E00z); + theShapeIDMap.Add(E10z); + theShapeIDMap.Add(E01z); + theShapeIDMap.Add(E11z); + + theShapeIDMap.Add(Fxy0); + theShapeIDMap.Add(Fxy1); + theShapeIDMap.Add(Fx0z); + theShapeIDMap.Add(Fx1z); + theShapeIDMap.Add(F0yz); + theShapeIDMap.Add(F1yz); + + theShapeIDMap.Add(myShell); + + if ( theShapeIDMap.Extent() != 27 ) { + MESSAGE("LoadBlockShapes() " << theShapeIDMap.Extent() ); + return false; + } + + // store shapes geometry + for ( int shapeID = 1; shapeID < theShapeIDMap.Extent(); shapeID++ ) + { + const TopoDS_Shape& S = theShapeIDMap( shapeID ); + switch ( S.ShapeType() ) + { + case TopAbs_VERTEX: { + + if ( shapeID > ID_V111 ) { + MESSAGE(" shapeID =" << shapeID ); + return false; + } + myPnt[ shapeID - ID_V000 ] = + BRep_Tool::Pnt( TopoDS::Vertex( S )).XYZ(); + break; + } + case TopAbs_EDGE: { + + const TopoDS_Edge& edge = TopoDS::Edge( S ); + if ( shapeID < ID_Ex00 || shapeID > ID_E11z || edge.IsNull() ) { + MESSAGE(" shapeID =" << shapeID ); + return false; + } + TEdge& tEdge = myEdge[ shapeID - ID_Ex00 ]; + tEdge.myCoordInd = GetCoordIndOnEdge( shapeID ); + TopLoc_Location loc; + tEdge.myC3d = BRep_Tool::Curve( edge, loc, tEdge.myFirst, tEdge.myLast ); + if ( !IsForwardEdge( edge, theShapeIDMap )) + Swap( tEdge.myFirst, tEdge.myLast ); + tEdge.myTrsf = loc; + break; + } + case TopAbs_FACE: { + + const TopoDS_Face& face = TopoDS::Face( S ); + if ( shapeID < ID_Fxy0 || shapeID > ID_F1yz || face.IsNull() ) { + MESSAGE(" shapeID =" << shapeID ); + return false; + } + TFace& tFace = myFace[ shapeID - ID_Fxy0 ]; + // pcurves + vector< int > edgeIdVec(4, -1); + GetFaceEdgesIDs( shapeID, edgeIdVec ); + for ( int iE = 0; iE < 4; iE++ ) // loop on 4 edges + { + const TopoDS_Edge& edge = TopoDS::Edge( theShapeIDMap( edgeIdVec[ iE ])); + tFace.myCoordInd[ iE ] = GetCoordIndOnEdge( edgeIdVec[ iE ] ); + tFace.myC2d[ iE ] = + BRep_Tool::CurveOnSurface( edge, face, tFace.myFirst[iE], tFace.myLast[iE] ); + if ( !IsForwardEdge( edge, theShapeIDMap )) + Swap( tFace.myFirst[ iE ], tFace.myLast[ iE ] ); + } + // 2d corners + tFace.myCorner[ 0 ] = tFace.myC2d[ 0 ]->Value( tFace.myFirst[0] ).XY(); + tFace.myCorner[ 1 ] = tFace.myC2d[ 0 ]->Value( tFace.myLast[0] ).XY(); + tFace.myCorner[ 2 ] = tFace.myC2d[ 1 ]->Value( tFace.myLast[1] ).XY(); + tFace.myCorner[ 3 ] = tFace.myC2d[ 1 ]->Value( tFace.myFirst[1] ).XY(); + // sufrace + TopLoc_Location loc; + tFace.myS = BRep_Tool::Surface( face, loc ); + tFace.myTrsf = loc; + break; + } + default: break; + } + } // loop on shapes in theShapeIDMap + + return true; +} + +//======================================================================= +//function : GetFaceEdgesIDs +//purpose : return edges IDs in the order u0, u1, 0v, 1v +// u0 means "|| u, v == 0" +//======================================================================= + +void TBlock::GetFaceEdgesIDs (const int faceID, vector< int >& edgeVec ) +{ + switch ( faceID ) { + case ID_Fxy0: + edgeVec[ 0 ] = ID_Ex00; + edgeVec[ 1 ] = ID_Ex10; + edgeVec[ 2 ] = ID_E0y0; + edgeVec[ 3 ] = ID_E1y0; + break; + case ID_Fxy1: + edgeVec[ 0 ] = ID_Ex01; + edgeVec[ 1 ] = ID_Ex11; + edgeVec[ 2 ] = ID_E0y1; + edgeVec[ 3 ] = ID_E1y1; + break; + case ID_Fx0z: + edgeVec[ 0 ] = ID_Ex00; + edgeVec[ 1 ] = ID_Ex01; + edgeVec[ 2 ] = ID_E00z; + edgeVec[ 3 ] = ID_E10z; + break; + case ID_Fx1z: + edgeVec[ 0 ] = ID_Ex10; + edgeVec[ 1 ] = ID_Ex11; + edgeVec[ 2 ] = ID_E01z; + edgeVec[ 3 ] = ID_E11z; + break; + case ID_F0yz: + edgeVec[ 0 ] = ID_E0y0; + edgeVec[ 1 ] = ID_E0y1; + edgeVec[ 2 ] = ID_E00z; + edgeVec[ 3 ] = ID_E01z; + break; + case ID_F1yz: + edgeVec[ 0 ] = ID_E1y0; + edgeVec[ 1 ] = ID_E1y1; + edgeVec[ 2 ] = ID_E10z; + edgeVec[ 3 ] = ID_E11z; + break; + default: + MESSAGE(" GetFaceEdgesIDs(), wrong face ID: " << faceID ); + } +} diff --git a/src/SMESH/SMESH_Pattern.hxx b/src/SMESH/SMESH_Pattern.hxx new file mode 100644 index 000000000..b658a2502 --- /dev/null +++ b/src/SMESH/SMESH_Pattern.hxx @@ -0,0 +1,258 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +// File : SMESH_Pattern.hxx +// Created : Mon Aug 2 10:30:00 2004 +// Author : Edward AGAPOV (eap) + +#ifndef SMESH_Pattern_HeaderFile +#define SMESH_Pattern_HeaderFile + +#include +#include +#include +#include + +#include +//#include +#include +#include +#include +#include + +class SMESH_Mesh; +class TopoDS_Shell; +class TopoDS_Vertex; +class TopoDS_Face; +class TopoDS_Edge; + +// +// Class allowing meshing by mapping of pre-defined patterns: it generates +// a 2D mesh on a geometrical face or a 3D mesh inside a geometrical block +// of 6 faces. +// + +class SMESH_Pattern { + public: + + SMESH_Pattern (); + + void Clear(); + // clear fields + + bool Load (const char* theFileContents); + // Load a pattern from + + bool Load (SMESH_Mesh* theMesh, + const TopoDS_Face& theFace, + bool theProject); + // Create a pattern from the mesh built on . + // ==true makes override nodes positions + // on computed by mesher + + bool Load (SMESH_Mesh* theMesh, + const TopoDS_Shell& theBlock); + // Create a pattern from the mesh built on + + bool Save (std::ostream& theFile); + // Save the loaded pattern into theFile + + bool Apply (const TopoDS_Face& theFace, + const TopoDS_Vertex& theVertexOnKeyPoint1, + const bool theReverse); + // Compute nodes coordinates applying + // the loaded pattern to . The first key-point + // will be mapped into , which must + // be in the outer wire of theFace + + bool Apply (const TopoDS_Shell& theBlock, + const TopoDS_Vertex& theVertex000, + const TopoDS_Vertex& theVertex001); + // Compute nodes coordinates applying + // the loaded pattern to . The (0,0,0) key-point + // will be mapped into . The + // (0,0,1) key-point will be mapped into . + + bool GetMappedPoints ( std::list & thePoints ); + // Return nodes coordinates computed by Apply() method + + bool MakeMesh(SMESH_Mesh* theMesh); + // Create nodes and elements in using nodes + // coordinates computed by either of Apply...() methods + + + // Inquiries + + enum ErrorCode { + ERR_OK, + // Load(file) + ERR_READ_NB_POINTS, // couldn't read nb of points + ERR_READ_POINT_COORDS, // invalid nb of point coordinates + ERR_READ_TOO_FEW_POINTS, // too few points in a pattern + ERR_READ_3D_COORD, // coordinate of 3D point out of [0,1] range + ERR_READ_NO_KEYPOINT, // no key-points in 2D pattern + ERR_READ_BAD_INDEX, // invalid point index + ERR_READ_ELEM_POINTS, // invalid nb of points in element + ERR_READ_NO_ELEMS, // no elements in a pattern + ERR_READ_BAD_KEY_POINT, // a key-point not on a boundary + // Save(file) + ERR_SAVE_NOT_LOADED, // pattern was not loaded + // Load(shape) + ERR_LOAD_EMPTY_SUBMESH, // no elements to load + // Load(face) + ERR_LOADF_NARROW_FACE, // too narrow face + ERR_LOADF_CLOSED_FACE, // closed face + // Load(volume) + ERR_LOADV_BAD_SHAPE, // volume is not a brick of 6 faces + ERR_LOADV_COMPUTE_PARAMS, // cant compute point parameters + // Apply(shape) + ERR_APPL_NOT_COMPUTED, // mapping failed + ERR_APPL_NOT_LOADED, // pattern was not loaded + ERR_APPL_BAD_DIMENTION, // wrong shape dimention + ERR_APPL_BAD_NB_VERTICES, // keypoints - vertices mismatch + // Apply(face) + ERR_APPLF_BAD_TOPOLOGY, // bad pattern topology + ERR_APPLF_BAD_VERTEX, // first vertex not on an outer face boundary + ERR_APPLF_INTERNAL_EEROR, // program error + // Apply(volume) + ERR_APPLV_BAD_SHAPE, // volume is not a brick of 6 faces + // MakeMesh + ERR_MAKEM_NOT_COMPUTED // mapping failed + }; + + ErrorCode GetErrorCode() const { return myErrorCode; } + // return ErrorCode of the last operation + + bool IsLoaded() const { return !myPoints.empty() && !myElemPointIDs.empty(); } + // Return true if a pattern was successfully loaded + + bool Is2D() const { return myIs2D; } + // Return true if the loaded pattern is a 2D one + + bool GetPoints ( std::list & thePoints ) const; + // Return nodes coordinates of the pattern + + const std::list< int > & GetKeyPointIDs () const { return myKeyPointIDs; } + // Return indices of key-points within the sequences returned by + // GetPoints() and GetMappedPoints() + + const std::list< std::list< int > >& GetElementPointIDs () const + { return myElemPointIDs; } + // Return nodal connectivity of the elements of the pattern + + void DumpPoints() const; + // Debug + + + private: + // private methods + + struct TPoint { + gp_XYZ myInitXYZ; // loaded postion + gp_XY myInitUV; + double myInitU; // [0,1] + gp_Pnt myXYZ; // position to compute + gp_XY myUV; + double myU; + TPoint(); + }; + friend std::ostream & operator <<(std::ostream & OS, const TPoint& p); + + bool setErrorCode( const ErrorCode theErrorCode ) + { myErrorCode = theErrorCode; return myErrorCode == ERR_OK; } + // set ErrorCode and return true if it is Ok + + bool setShapeToMesh(const TopoDS_Shape& theShape); + // Set a shape to be meshed. Return True if meshing is possible + + list< TPoint* > & getShapePoints(const TopoDS_Shape& theShape); + // Return list of points located on theShape. + // A list of edge-points include vertex-points (for 2D pattern only). + // A list of face-points doesnt include edge-points. + // A list of volume-points doesnt include face-points. + + list< TPoint* > & getShapePoints(const int theShapeID); + // Return list of points located on the shape + + bool findBoundaryPoints(); + // If loaded from file, find points to map on edges and faces and + // compute their parameters + + void arrangeBoundaries (list< list< TPoint* > >& boundaryPoints); + // if there are several wires, arrange boundaryPoints so that + // the outer wire goes first and fix inner wires orientation; + // update myKeyPointIDs to correspond to the order of key-points + // in boundaries; sort internal boundaries by the nb of key-points + + void computeUVOnEdge( const TopoDS_Edge& theEdge, const list< TPoint* > & ePoints ); + // compute coordinates of points on theEdge + + bool compUVByIsoIntersection (const list< list< TPoint* > >& boundaryPoints, + const gp_XY& theInitUV, + gp_XY& theUV, + bool & theIsDeformed); + // compute UV by intersection of iso-lines found by points on edges + + bool compUVByElasticIsolines(const list< list< TPoint* > >& boundaryPoints, + const list< TPoint* >& pointsToCompute); + // compute UV as nodes of iso-poly-lines consisting of + // segments keeping relative size as in the pattern + + double setFirstEdge (list< TopoDS_Edge > & theWire, int theFirstEdgeID); + // choose the best first edge of theWire; return the summary distance + // between point UV computed by isolines intersection and + // eventual UV got from edge p-curves + + typedef list< list< TopoDS_Edge > > TListOfEdgesList; + + bool sortSameSizeWires (TListOfEdgesList & theWireList, + const TListOfEdgesList::iterator& theFromWire, + const TListOfEdgesList::iterator& theToWire, + const int theFirstEdgeID, + list< list< TPoint* > >& theEdgesPointsList ); + // sort wires in theWireList from theFromWire until theToWire, + // the wires are set in the order to correspond to the order + // of boundaries; after sorting, edges in the wires are put + // in a good order, point UVs on edges are computed and points + // are appended to theEdgesPointsList + + private: + // fields + + bool myIs2D; + std::vector< TPoint > myPoints; + std::list< int > myKeyPointIDs; + std::list< std::list< int > > myElemPointIDs; + + ErrorCode myErrorCode; + bool myIsComputed; + bool myIsBoundaryPointsFound; + + TopoDS_Shape myShape; + // all functions assure that shapes are indexed so that first go + // ordered vertices, then ordered edge, then faces and a shell + TopTools_IndexedMapOfOrientedShape myShapeIDMap; + //TopTools_IndexedMapOfShape myShapeIDMap; + std::map< int, list< TPoint* > > myShapeIDToPointsMap; + + std::list< int > myNbKeyPntInBoundary; //for the 2d case +}; + + +#endif diff --git a/src/SMESH/SMESH_subMesh.cxx b/src/SMESH/SMESH_subMesh.cxx index 2b78950b9..89e9e2684 100644 --- a/src/SMESH/SMESH_subMesh.cxx +++ b/src/SMESH/SMESH_subMesh.cxx @@ -1,23 +1,23 @@ // 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -43,6 +43,12 @@ using namespace std; #include #include +#ifdef _DEBUG_ +#include +#include +#include +#endif + //============================================================================= /*! * default constructor: @@ -57,7 +63,6 @@ SMESH_subMesh::SMESH_subMesh(int Id, SMESH_Mesh * father, SMESHDS_Mesh * meshDS, _subMeshDS = meshDS->MeshElements(_subShape); // may be null ... _father = father; _Id = Id; - _vertexSet = false; // only for Vertex subMesh _dependenceAnalysed = false; if (_subShape.ShapeType() == TopAbs_VERTEX) @@ -74,7 +79,7 @@ SMESH_subMesh::SMESH_subMesh(int Id, SMESH_Mesh * father, SMESHDS_Mesh * meshDS, //============================================================================= /*! - * + * */ //============================================================================= @@ -86,7 +91,7 @@ SMESH_subMesh::~SMESH_subMesh() //============================================================================= /*! - * + * */ //============================================================================= @@ -98,7 +103,7 @@ int SMESH_subMesh::GetId() const //============================================================================= /*! - * + * */ //============================================================================= @@ -121,7 +126,7 @@ SMESHDS_SubMesh * SMESH_subMesh::GetSubMeshDS() //============================================================================= /*! - * + * */ //============================================================================= @@ -135,156 +140,148 @@ SMESHDS_SubMesh* SMESH_subMesh::CreateSubMeshDS() //============================================================================= /*! - * + * */ //============================================================================= SMESH_subMesh *SMESH_subMesh::GetFirstToCompute() { - //MESSAGE("SMESH_subMesh::GetFirstToCompute"); - const map < int, SMESH_subMesh * >&subMeshes = DependsOn(); - SMESH_subMesh *firstToCompute = 0; + //MESSAGE("SMESH_subMesh::GetFirstToCompute"); + const map < int, SMESH_subMesh * >&subMeshes = DependsOn(); + SMESH_subMesh *firstToCompute = 0; - map < int, SMESH_subMesh * >::const_iterator itsub; - for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++) - { - SMESH_subMesh *sm = (*itsub).second; -// SCRUTE(sm->GetId()); -// SCRUTE(sm->GetComputeState()); - bool readyToCompute = (sm->GetComputeState() == READY_TO_COMPUTE); - if (readyToCompute) - { - firstToCompute = sm; - //SCRUTE(sm->GetId()); - break; - } - } - if (firstToCompute) - { - //MESSAGE("--- submesh to compute"); - return firstToCompute; // a subMesh of this - } - if (_computeState == READY_TO_COMPUTE) - { - //MESSAGE("--- this to compute"); - return this; // this - } - //MESSAGE("--- nothing to compute"); - return 0; // nothing to compute + map < int, SMESH_subMesh * >::const_iterator itsub; + for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++) + { + SMESH_subMesh *sm = (*itsub).second; + // SCRUTE(sm->GetId()); + // SCRUTE(sm->GetComputeState()); + bool readyToCompute = (sm->GetComputeState() == READY_TO_COMPUTE); + if (readyToCompute) + { + firstToCompute = sm; + //SCRUTE(sm->GetId()); + break; + } + } + if (firstToCompute) + { + return firstToCompute; // a subMesh of this + } + if (_computeState == READY_TO_COMPUTE) + { + return this; // this + } + return 0; // nothing to compute } //============================================================================= /*! - * + * */ //============================================================================= bool SMESH_subMesh::SubMeshesComputed() { - //MESSAGE("SMESH_subMesh::SubMeshesComputed"); - const map < int, SMESH_subMesh * >&subMeshes = DependsOn(); + //MESSAGE("SMESH_subMesh::SubMeshesComputed"); + const map < int, SMESH_subMesh * >&subMeshes = DependsOn(); - bool subMeshesComputed = true; - map < int, SMESH_subMesh * >::const_iterator itsub; - for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++) - { - SMESH_subMesh *sm = (*itsub).second; - - const TopoDS_Shape & ss = sm->GetSubShape(); - int type = ss.ShapeType(); -// SCRUTE(sm->GetId()); -// SCRUTE(sm->GetComputeState()); - bool computeOk = (sm->GetComputeState() == COMPUTE_OK); - if (!computeOk) - { - subMeshesComputed = false; - - switch (type) - { - case TopAbs_COMPOUND: - { - MESSAGE("The not computed sub mesh is a COMPOUND"); - break; - } - case TopAbs_COMPSOLID: - { - MESSAGE("The not computed sub mesh is a COMPSOLID"); - break; - } - case TopAbs_SHELL: - { - MESSAGE("The not computed sub mesh is a SHEL"); - break; - } - case TopAbs_WIRE: - { - MESSAGE("The not computed sub mesh is a WIRE"); - break; - } - case TopAbs_SOLID: - { - MESSAGE("The not computed sub mesh is a SOLID"); - break; - } - case TopAbs_FACE: - { - MESSAGE("The not computed sub mesh is a FACE"); - break; - } - case TopAbs_EDGE: - { - MESSAGE("The not computed sub mesh is a EDGE"); - break; - } - default: - { - MESSAGE("The not computed sub mesh is of unknown type"); - break; - } - } - - SCRUTE(sm->GetId()); - break; - } - } - return subMeshesComputed; + bool subMeshesComputed = true; + map < int, SMESH_subMesh * >::const_iterator itsub; + for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++) + { + SMESH_subMesh *sm = (*itsub).second; + + const TopoDS_Shape & ss = sm->GetSubShape(); + int type = ss.ShapeType(); + bool computeOk = (sm->GetComputeState() == COMPUTE_OK); + if (!computeOk) + { + subMeshesComputed = false; + + switch (type) + { + case TopAbs_COMPOUND: + { + MESSAGE("The not computed sub mesh is a COMPOUND"); + break; + } + case TopAbs_COMPSOLID: + { + MESSAGE("The not computed sub mesh is a COMPSOLID"); + break; + } + case TopAbs_SHELL: + { + MESSAGE("The not computed sub mesh is a SHEL"); + break; + } + case TopAbs_WIRE: + { + MESSAGE("The not computed sub mesh is a WIRE"); + break; + } + case TopAbs_SOLID: + { + MESSAGE("The not computed sub mesh is a SOLID"); + break; + } + case TopAbs_FACE: + { + MESSAGE("The not computed sub mesh is a FACE"); + break; + } + case TopAbs_EDGE: + { + MESSAGE("The not computed sub mesh is a EDGE"); + break; + } + default: + { + MESSAGE("The not computed sub mesh is of unknown type"); + break; + } + } + + break; + } + } + return subMeshesComputed; } //============================================================================= /*! - * + * */ //============================================================================= bool SMESH_subMesh::SubMeshesReady() { - MESSAGE("SMESH_subMesh::SubMeshesReady"); - const map < int, SMESH_subMesh * >&subMeshes = DependsOn(); + MESSAGE("SMESH_subMesh::SubMeshesReady"); + const map < int, SMESH_subMesh * >&subMeshes = DependsOn(); - bool subMeshesReady = true; - map < int, SMESH_subMesh * >::const_iterator itsub; - for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++) - { - SMESH_subMesh *sm = (*itsub).second; -// SCRUTE(sm->GetId()); -// SCRUTE(sm->GetComputeState()); - bool computeOk = ((sm->GetComputeState() == COMPUTE_OK) - || (sm->GetComputeState() == READY_TO_COMPUTE)); - if (!computeOk) - { - subMeshesReady = false; - SCRUTE(sm->GetId()); - break; - } - } - return subMeshesReady; + bool subMeshesReady = true; + map < int, SMESH_subMesh * >::const_iterator itsub; + for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++) + { + SMESH_subMesh *sm = (*itsub).second; + bool computeOk = ((sm->GetComputeState() == COMPUTE_OK) + || (sm->GetComputeState() == READY_TO_COMPUTE)); + if (!computeOk) + { + subMeshesReady = false; + SCRUTE(sm->GetId()); + break; + } + } + return subMeshesReady; } //============================================================================= /*! - * Construct dependence on first level subMeshes. complex shapes (compsolid, + * Construct dependence on first level subMeshes. complex shapes (compsolid, * shell, wire) are not analysed the same way as simple shapes (solid, face, - * edge). + * edge). * For collection shapes (compsolid, shell, wire) prepare a list of submeshes * with possible multiples occurences. Multiples occurences corresponds to * internal frontiers within shapes of the collection and must not be keeped. @@ -294,167 +291,111 @@ bool SMESH_subMesh::SubMeshesReady() const map < int, SMESH_subMesh * >&SMESH_subMesh::DependsOn() { - if (_dependenceAnalysed) - return _mapDepend; + if (_dependenceAnalysed) + return _mapDepend; - //MESSAGE("SMESH_subMesh::DependsOn"); + //MESSAGE("SMESH_subMesh::DependsOn"); - int type = _subShape.ShapeType(); - //SCRUTE(type); - switch (type) - { - case TopAbs_COMPOUND: - { - //MESSAGE("compound"); - list < TopoDS_Shape > shellInSolid; - for (TopExp_Explorer exp(_subShape, TopAbs_SOLID); exp.More(); - exp.Next()) - { - InsertDependence(exp.Current()); - for (TopExp_Explorer - exp2(exp.Current(), TopAbs_SHELL); exp2.More(); exp2.Next()) - { - shellInSolid.push_back(exp2.Current()); - } - } - for (TopExp_Explorer exp(_subShape, TopAbs_SHELL); exp.More(); - exp.Next()) - { - list < TopoDS_Shape >::iterator it1; - bool isInSolid = false; - for (it1 = shellInSolid.begin(); it1 != shellInSolid.end(); it1++) - { - TopoDS_Shape aShape = (*it1); - if (aShape.IsSame(exp.Current())) - { - isInSolid = true; - break; - } - } - if (!isInSolid) - InsertDependence(exp.Current()); //only shell not in solid - } - for (TopExp_Explorer exp(_subShape, TopAbs_FACE); exp.More(); - exp.Next()) - { - InsertDependence(exp.Current()); - } - for (TopExp_Explorer exp(_subShape, TopAbs_EDGE); exp.More(); - exp.Next()) - { - InsertDependence(exp.Current()); - } - break; - } - case TopAbs_COMPSOLID: - { + int type = _subShape.ShapeType(); + //SCRUTE(type); + switch (type) + { + case TopAbs_COMPOUND: + { + //MESSAGE("compound"); + for (TopExp_Explorer exp(_subShape, TopAbs_SOLID); exp.More(); + exp.Next()) + { + InsertDependence(exp.Current()); + } + for (TopExp_Explorer exp(_subShape, TopAbs_SHELL, TopAbs_SOLID); exp.More(); + exp.Next()) + { + InsertDependence(exp.Current()); //only shell not in solid + } + for (TopExp_Explorer exp(_subShape, TopAbs_FACE, TopAbs_SHELL); exp.More(); + exp.Next()) + { + InsertDependence(exp.Current()); + } + for (TopExp_Explorer exp(_subShape, TopAbs_EDGE, TopAbs_FACE); exp.More(); + exp.Next()) + { + InsertDependence(exp.Current()); + } + break; + } + case TopAbs_COMPSOLID: + { //MESSAGE("compsolid"); - for (TopExp_Explorer exp(_subShape, TopAbs_SOLID); exp.More(); - exp.Next()) - { - InsertDependence(exp.Current()); - } -// list shapeList; -// for (TopExp_Explorer exp(_subShape,TopAbs_SOLID);exp.More();exp.Next()) -// { -// for (TopExp_Explorer -// exp2(exp.Current(),TopAbs_FACE);exp2.More();exp2.Next()) -// { -// shapeList.push_back(exp2.Current()); -// } -// } -// FinalizeDependence(shapeList); - break; - } - case TopAbs_SHELL: - { - //MESSAGE("shell"); - for (TopExp_Explorer exp(_subShape, TopAbs_FACE); exp.More(); - exp.Next()) - { - InsertDependence(exp.Current()); - } -// list shapeList; -// for (TopExp_Explorer exp(_subShape,TopAbs_FACE);exp.More();exp.Next()) -// { -// for (TopExp_Explorer -// exp2(exp.Current(),TopAbs_EDGE);exp2.More();exp2.Next()) -// { -// shapeList.push_back(exp2.Current()); -// } -// } -// FinalizeDependence(shapeList); - break; - } - case TopAbs_WIRE: - { - //MESSAGE("wire"); - for (TopExp_Explorer exp(_subShape, TopAbs_EDGE); exp.More(); - exp.Next()) - { - InsertDependence(exp.Current()); - } -// list shapeList; -// for (TopExp_Explorer exp(_subShape,TopAbs_EDGE);exp.More();exp.Next()) -// { -// for (TopExp_Explorer -// exp2(exp.Current(),TopAbs_VERTEX);exp2.More();exp2.Next()) -// { -// shapeList.push_back(exp2.Current()); -// } -// } -// FinalizeDependence(shapeList); - break; - } - case TopAbs_SOLID: - { - //MESSAGE("solid"); -// for (TopExp_Explorer exp(_subShape,TopAbs_SHELL);exp.More();exp.Next()) -// { -// InsertDependence(exp.Current()); -// } - for (TopExp_Explorer exp(_subShape, TopAbs_FACE); exp.More(); - exp.Next()) - { - InsertDependence(exp.Current()); - } - break; - } - case TopAbs_FACE: - { - //MESSAGE("face"); -// for (TopExp_Explorer exp(_subShape,TopAbs_WIRE);exp.More();exp.Next()) -// { -// InsertDependence(exp.Current()); -// } - for (TopExp_Explorer exp(_subShape, TopAbs_EDGE); exp.More(); - exp.Next()) - { - InsertDependence(exp.Current()); - } - break; - } - case TopAbs_EDGE: - { - //MESSAGE("edge"); - for (TopExp_Explorer exp(_subShape, TopAbs_VERTEX); exp.More(); - exp.Next()) - { + for (TopExp_Explorer exp(_subShape, TopAbs_SOLID); exp.More(); + exp.Next()) + { + InsertDependence(exp.Current()); + } + break; + } + case TopAbs_SHELL: + { + //MESSAGE("shell"); + for (TopExp_Explorer exp(_subShape, TopAbs_FACE); exp.More(); + exp.Next()) + { + InsertDependence(exp.Current()); + } + break; + } + case TopAbs_WIRE: + { + //MESSAGE("wire"); + for (TopExp_Explorer exp(_subShape, TopAbs_EDGE); exp.More(); + exp.Next()) + { + InsertDependence(exp.Current()); + } + break; + } + case TopAbs_SOLID: + { + //MESSAGE("solid"); + for (TopExp_Explorer exp(_subShape, TopAbs_FACE); exp.More(); + exp.Next()) + { + InsertDependence(exp.Current()); + } + break; + } + case TopAbs_FACE: + { + //MESSAGE("face"); + for (TopExp_Explorer exp(_subShape, TopAbs_EDGE); exp.More(); + exp.Next()) + { + InsertDependence(exp.Current()); + } + break; + } + case TopAbs_EDGE: + { + //MESSAGE("edge"); + for (TopExp_Explorer exp(_subShape, TopAbs_VERTEX); exp.More(); + exp.Next()) + { InsertDependence(exp.Current()); - } - break; - } - case TopAbs_VERTEX: - { - break; - } - default: - { - break; - } - } - _dependenceAnalysed = true; - return _mapDepend; + } + break; + } + case TopAbs_VERTEX: + { + break; + } + default: + { + break; + } + } + _dependenceAnalysed = true; + return _mapDepend; } //============================================================================= @@ -465,31 +406,31 @@ const map < int, SMESH_subMesh * >&SMESH_subMesh::DependsOn() void SMESH_subMesh::InsertDependence(const TopoDS_Shape aSubShape) { - //MESSAGE("SMESH_subMesh::InsertDependence"); - SMESH_subMesh *aSubMesh = _father->GetSubMesh(aSubShape); - int type = aSubShape.ShapeType(); - int ordType = 9 - type; // 2 = Vertex, 8 = CompSolid - int cle = aSubMesh->GetId(); - cle += 10000000 * ordType; // sort map by ordType then index - if (_mapDepend.find(cle) == _mapDepend.end()) - { - _mapDepend[cle] = aSubMesh; - const map < int, SMESH_subMesh * >&subMap = aSubMesh->DependsOn(); - map < int, SMESH_subMesh * >::const_iterator im; - for (im = subMap.begin(); im != subMap.end(); im++) - { - int clesub = (*im).first; - SMESH_subMesh *sm = (*im).second; - if (_mapDepend.find(clesub) == _mapDepend.end()) - _mapDepend[clesub] = sm; - } - } + //MESSAGE("SMESH_subMesh::InsertDependence"); + SMESH_subMesh *aSubMesh = _father->GetSubMesh(aSubShape); + int type = aSubShape.ShapeType(); + int ordType = 9 - type; // 2 = Vertex, 8 = CompSolid + int cle = aSubMesh->GetId(); + cle += 10000000 * ordType; // sort map by ordType then index + if (_mapDepend.find(cle) == _mapDepend.end()) + { + _mapDepend[cle] = aSubMesh; + const map < int, SMESH_subMesh * >&subMap = aSubMesh->DependsOn(); + map < int, SMESH_subMesh * >::const_iterator im; + for (im = subMap.begin(); im != subMap.end(); im++) + { + int clesub = (*im).first; + SMESH_subMesh *sm = (*im).second; + if (_mapDepend.find(clesub) == _mapDepend.end()) + _mapDepend[clesub] = sm; + } + } } //============================================================================= /*! - * + * */ //============================================================================= @@ -514,7 +455,7 @@ bool SMESH_subMesh::CanAddHypothesis(const SMESH_Hypothesis* theHypothesis) cons return true; // if ( aHypDim < aShapeDim ) // return ( _father->IsMainShape( _subShape )); - + return false; } @@ -552,7 +493,7 @@ bool SMESH_subMesh::IsApplicableHypotesis(const SMESH_Hypothesis* theHypothesis) //============================================================================= /*! - * + * */ //============================================================================= @@ -563,17 +504,21 @@ SMESH_Hypothesis::Hypothesis_Status //SCRUTE(_algoState); //SCRUTE(event); + SMESH_Hypothesis::Hypothesis_Status aux_ret, ret = SMESH_Hypothesis::HYP_OK; + // **** les retour des evenement shape sont significatifs // (add ou remove fait ou non) // le retour des evenement father n'indiquent pas que add ou remove fait int dim = SMESH_Gen::GetShapeDim(_subShape); - SMESH_Hypothesis::Hypothesis_Status aux_ret, ret = SMESH_Hypothesis::HYP_OK; if (dim < 1) - { - _algoState = HYP_OK; - return ret; - } + { + _algoState = HYP_OK; + if (event == ADD_HYP || event == ADD_ALGO) + return SMESH_Hypothesis::HYP_BAD_DIM; // do not allow to assign any hyp + else + return SMESH_Hypothesis::HYP_OK; + } SMESH_Gen* gen =_father->GetGen(); // bool ret = false; @@ -591,7 +536,7 @@ SMESH_Hypothesis::Hypothesis_Status !IsConform( static_cast< SMESH_Algo* >( anHyp ))) return SMESH_Hypothesis::HYP_NOTCONFORM; } - + // ---------------------------------- // add a hypothesis to DS if possible // ---------------------------------- @@ -600,7 +545,7 @@ SMESH_Hypothesis::Hypothesis_Status if ( ! CanAddHypothesis( anHyp )) return SMESH_Hypothesis::HYP_BAD_DIM; - if ( GetNbAttached( _subShape, anHyp ) > 0 ) + if ( GetSimilarAttached( _subShape, anHyp ) ) return SMESH_Hypothesis::HYP_ALREADY_EXIST; if ( !_meshDS->AddHypothesis(_subShape, anHyp)) @@ -634,7 +579,7 @@ SMESH_Hypothesis::Hypothesis_Status case ADD_ALGO: { SMESH_Algo* algo = gen->GetAlgo((*_father), _subShape); ASSERT(algo); - if (algo->CheckHypothesis((*_father),_subShape, ret)) + if (algo->CheckHypothesis((*_father),_subShape, aux_ret)) SetAlgoState(HYP_OK); else SetAlgoState(MISSING_HYP); @@ -765,7 +710,7 @@ SMESH_Hypothesis::Hypothesis_Status break; // ---------------------------------------------------------------------- - + case HYP_OK: switch (event) { @@ -776,16 +721,23 @@ SMESH_Hypothesis::Hypothesis_Status { MESSAGE("two applying algo on the same shape not allowed"); _meshDS->RemoveHypothesis(_subShape, anHyp); - //ret = SMESH_Hypothesis::HYP_ALREADY_EXIST; + if ( !SMESH_Hypothesis::IsStatusFatal( ret )) + // ret should be fatal: anHyp was not added + ret = SMESH_Hypothesis::HYP_INCOMPATIBLE; } else if (SMESH_Hypothesis::IsStatusFatal( ret )) + { _meshDS->RemoveHypothesis(_subShape, anHyp); + } else if (!_father->IsUsedHypothesis( anHyp, _subShape )) { _meshDS->RemoveHypothesis(_subShape, anHyp); ret = SMESH_Hypothesis::HYP_INCOMPATIBLE; } - modifiedHyp = _father->IsUsedHypothesis( anHyp, _subShape ); // new Hyp? + else + { + modifiedHyp = true; + } break; } case ADD_ALGO: { //already existing algo : on father ? @@ -805,9 +757,6 @@ SMESH_Hypothesis::Hypothesis_Status else SetAlgoState(MISSING_HYP); modifiedHyp = true; - // report only severe errors - if ( SMESH_Hypothesis::IsStatusFatal( aux_ret )) - ret = aux_ret; break; } case REMOVE_ALGO: { // perhaps a father algo applies ? @@ -822,10 +771,9 @@ SMESH_Hypothesis::Hypothesis_Status SetAlgoState(HYP_OK); else SetAlgoState(MISSING_HYP); - modifiedHyp = true; - // report only severe errors - if ( SMESH_Hypothesis::IsStatusFatal( aux_ret )) - ret = aux_ret; + // check if same algo remains + if ( anHyp != algo && strcmp( anHyp->GetName(), algo->GetName()) ) + modifiedHyp = true; } break; } @@ -860,7 +808,9 @@ SMESH_Hypothesis::Hypothesis_Status SetAlgoState(HYP_OK); else SetAlgoState(MISSING_HYP); - modifiedHyp = true; + // is there the same local hyp or maybe a new father algo applied? + if ( !GetSimilarAttached( _subShape, anHyp ) ) + modifiedHyp = true; break; } case REMOVE_FATHER_ALGO: { @@ -875,7 +825,9 @@ SMESH_Hypothesis::Hypothesis_Status SetAlgoState(HYP_OK); else SetAlgoState(MISSING_HYP); - modifiedHyp = true; + // is there the same local algo or maybe a new father algo applied? + if ( !GetSimilarAttached( _subShape, anHyp )) + modifiedHyp = true; } break; } @@ -884,9 +836,9 @@ SMESH_Hypothesis::Hypothesis_Status break; } break; - + // ---------------------------------------------------------------------- - + default: ASSERT(0); break; @@ -919,7 +871,7 @@ SMESH_Hypothesis::Hypothesis_Status bool SMESH_subMesh::IsConform(const SMESH_Algo* theAlgo) { - MESSAGE( "SMESH_subMesh::IsConform" ); +// MESSAGE( "SMESH_subMesh::IsConform" ); if ( !theAlgo ) return false; @@ -929,7 +881,7 @@ bool SMESH_subMesh::IsConform(const SMESH_Algo* theAlgo) return true; SMESH_Gen* gen =_father->GetGen(); - + // only local algo is to be checked if ( gen->IsGlobalAlgo( theAlgo, *_father )) return true; @@ -964,7 +916,7 @@ bool SMESH_subMesh::IsConform(const SMESH_Algo* theAlgo) //============================================================================= /*! - * + * */ //============================================================================= @@ -977,37 +929,37 @@ void SMESH_subMesh::SetAlgoState(int state) //============================================================================= /*! - * + * */ //============================================================================= -SMESH_Hypothesis::Hypothesis_Status - SMESH_subMesh::SubMeshesAlgoStateEngine(int event, - SMESH_Hypothesis * anHyp) +SMESH_Hypothesis::Hypothesis_Status + SMESH_subMesh::SubMeshesAlgoStateEngine(int event, + SMESH_Hypothesis * anHyp) { - //MESSAGE("SMESH_subMesh::SubMeshesAlgoStateEngine"); + //MESSAGE("SMESH_subMesh::SubMeshesAlgoStateEngine"); SMESH_Hypothesis::Hypothesis_Status ret = SMESH_Hypothesis::HYP_OK; - //EAP: a wire (dim==1) should notify edges (dim==1) - //EAP: int dim = SMESH_Gen::GetShapeDim(_subShape); - if (/*EAP:dim > 1*/ _subShape.ShapeType() < TopAbs_EDGE ) - { - const map < int, SMESH_subMesh * >&subMeshes = DependsOn(); + //EAP: a wire (dim==1) should notify edges (dim==1) + //EAP: int dim = SMESH_Gen::GetShapeDim(_subShape); + if (/*EAP:dim > 1*/ _subShape.ShapeType() < TopAbs_EDGE ) + { + const map < int, SMESH_subMesh * >&subMeshes = DependsOn(); - map < int, SMESH_subMesh * >::const_iterator itsub; - for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++) - { - SMESH_subMesh *sm = (*itsub).second; - SMESH_Hypothesis::Hypothesis_Status ret2 = - sm->AlgoStateEngine(event, anHyp); - if ( ret2 > ret ) - ret = ret2; - } - } + map < int, SMESH_subMesh * >::const_iterator itsub; + for (itsub = subMeshes.begin(); itsub != subMeshes.end(); itsub++) + { + SMESH_subMesh *sm = (*itsub).second; + SMESH_Hypothesis::Hypothesis_Status ret2 = + sm->AlgoStateEngine(event, anHyp); + if ( ret2 > ret ) + ret = ret2; + } + } return ret; } //============================================================================= /*! - * + * */ //============================================================================= @@ -1030,7 +982,7 @@ void SMESH_subMesh::CleanDependsOn() //============================================================================= /*! - * + * */ //============================================================================= @@ -1082,7 +1034,7 @@ void SMESH_subMesh::DumpAlgoState(bool isMain) //============================================================================= /*! - * + * */ //============================================================================= @@ -1096,16 +1048,15 @@ bool SMESH_subMesh::ComputeStateEngine(int event) if (dim < 1) { - if (_vertexSet) + if ( IsMeshComputed() ) _computeState = COMPUTE_OK; else _computeState = READY_TO_COMPUTE; - //SCRUTE(_computeState); return true; } SMESH_Gen *gen = _father->GetGen(); SMESH_Algo *algo = 0; - bool ret; + bool ret = true; SMESH_Hypothesis::Hypothesis_Status hyp_status; switch (_computeState) @@ -1135,7 +1086,13 @@ bool SMESH_subMesh::ComputeStateEngine(int event) case SUBMESH_COMPUTED: // nothing to do break; case SUBMESH_RESTORED: - ComputeSubMeshStateEngine( SUBMESH_RESTORED ); + ComputeSubMeshStateEngine( CHECK_COMPUTE_STATE ); + break; + case MESH_ENTITY_REMOVED: + break; + case CHECK_COMPUTE_STATE: + if ( IsMeshComputed() ) + _computeState = COMPUTE_OK; break; default: ASSERT(0); @@ -1180,18 +1137,28 @@ bool SMESH_subMesh::ComputeStateEngine(int event) _computeState = FAILED_TO_COMPUTE; break; } + RemoveSubMeshElementsAndNodes(); // compute if (!algo->NeedDescretBoundary() && !algo->OnlyUnaryInput()) ret = ApplyToCollection( algo, GetCollection( gen, algo ) ); else ret = algo->Compute((*_father), _subShape); - + if (!ret) { MESSAGE("problem in algo execution: failed to compute"); _computeState = FAILED_TO_COMPUTE; if (!algo->NeedDescretBoundary()) UpdateSubMeshState( FAILED_TO_COMPUTE ); + +#ifdef _DEBUG_ + // Show vertices location of a failed shape + TopExp_Explorer exp( _subShape, TopAbs_VERTEX); + for ( ; exp.More(); exp.Next() ) { + gp_Pnt P( BRep_Tool::Pnt( TopoDS::Vertex( exp.Current() ))); + cout << P.X() << " " << P.Y() << " " << P.Z() << " " << endl; + } +#endif break; } else @@ -1222,10 +1189,14 @@ bool SMESH_subMesh::ComputeStateEngine(int event) case SUBMESH_RESTORED: // check if a mesh is already computed that may // happen after retrieval from a file - if ( IsMeshComputed() ) { + ComputeStateEngine( CHECK_COMPUTE_STATE ); + ComputeSubMeshStateEngine( CHECK_COMPUTE_STATE ); + break; + case MESH_ENTITY_REMOVED: + break; + case CHECK_COMPUTE_STATE: + if ( IsMeshComputed() ) _computeState = COMPUTE_OK; - } - ComputeSubMeshStateEngine( SUBMESH_RESTORED ); break; default: ASSERT(0); @@ -1269,7 +1240,20 @@ bool SMESH_subMesh::ComputeStateEngine(int event) case SUBMESH_COMPUTED: // nothing to do break; case SUBMESH_RESTORED: - ComputeSubMeshStateEngine( SUBMESH_RESTORED ); + ComputeStateEngine( CHECK_COMPUTE_STATE ); + ComputeSubMeshStateEngine( CHECK_COMPUTE_STATE ); + break; + case MESH_ENTITY_REMOVED: + UpdateDependantsState( CHECK_COMPUTE_STATE ); + ComputeStateEngine( CHECK_COMPUTE_STATE ); + ComputeSubMeshStateEngine( CHECK_COMPUTE_STATE ); + break; + case CHECK_COMPUTE_STATE: + if ( !IsMeshComputed() ) + if (_algoState == HYP_OK) + _computeState = READY_TO_COMPUTE; + else + _computeState = NOT_READY; break; default: ASSERT(0); @@ -1294,7 +1278,7 @@ bool SMESH_subMesh::ComputeStateEngine(int event) else _computeState = NOT_READY; break; - case COMPUTE: // nothing to do + case COMPUTE: // nothing to do break; case CLEAN: RemoveSubMeshElementsAndNodes(); @@ -1313,7 +1297,18 @@ bool SMESH_subMesh::ComputeStateEngine(int event) _computeState = NOT_READY; break; case SUBMESH_RESTORED: - ComputeSubMeshStateEngine( SUBMESH_RESTORED ); + ComputeSubMeshStateEngine( CHECK_COMPUTE_STATE ); + break; + case MESH_ENTITY_REMOVED: + break; + case CHECK_COMPUTE_STATE: + if ( IsMeshComputed() ) + _computeState = COMPUTE_OK; + else + if (_algoState == HYP_OK) + _computeState = READY_TO_COMPUTE; + else + _computeState = NOT_READY; break; default: ASSERT(0); @@ -1373,7 +1368,7 @@ bool SMESH_subMesh::ApplyToCollection (SMESH_Algo* theAlgo, //======================================================================= //function : UpdateSubMeshState -//purpose : +//purpose : //======================================================================= void SMESH_subMesh::UpdateSubMeshState(const compute_state theState) @@ -1389,7 +1384,7 @@ void SMESH_subMesh::UpdateSubMeshState(const compute_state theState) //======================================================================= //function : ComputeSubMeshStateEngine -//purpose : +//purpose : //======================================================================= void SMESH_subMesh::ComputeSubMeshStateEngine(int event) @@ -1405,7 +1400,7 @@ void SMESH_subMesh::ComputeSubMeshStateEngine(int event) //======================================================================= //function : UpdateDependantsState -//purpose : +//purpose : //======================================================================= void SMESH_subMesh::UpdateDependantsState(const compute_event theEvent) @@ -1424,7 +1419,7 @@ void SMESH_subMesh::UpdateDependantsState(const compute_event theEvent) //============================================================================= /*! - * + * */ //============================================================================= @@ -1447,7 +1442,7 @@ void SMESH_subMesh::CleanDependants() //============================================================================= /*! - * + * */ //============================================================================= @@ -1468,6 +1463,7 @@ static void removeSubMesh( SMESHDS_Mesh * meshDS, const TopoDS_Shape& subShape) while(itn->more()) { const SMDS_MeshNode * node = itn->next(); + //MESSAGE( " RM node: "<GetID()); meshDS->RemoveNode(node); } } @@ -1475,7 +1471,7 @@ static void removeSubMesh( SMESHDS_Mesh * meshDS, const TopoDS_Shape& subShape) //============================================================================= /*! - * + * */ //============================================================================= @@ -1544,7 +1540,7 @@ TopoDS_Shape SMESH_subMesh::GetCollection(SMESH_Gen * theGen, SMESH_Algo* theAlg { MESSAGE("SMESH_subMesh::GetCollection"); ASSERT (!theAlgo->NeedDescretBoundary()); - + TopoDS_Shape mainShape = _father->GetMeshDS()->ShapeToMesh(); if ( mainShape.IsSame( _subShape )) @@ -1552,7 +1548,7 @@ TopoDS_Shape SMESH_subMesh::GetCollection(SMESH_Gen * theGen, SMESH_Algo* theAlg list aUsedHyp = theAlgo->GetUsedHypothesis( *_father, _subShape ); // copy - + // put in a compound all shapes with the same hypothesis assigned // and a good ComputState @@ -1579,49 +1575,45 @@ TopoDS_Shape SMESH_subMesh::GetCollection(SMESH_Gen * theGen, SMESH_Algo* theAlg } //======================================================================= -//function : GetNbAttached +//function : GetSimilarAttached //purpose : return nb of hypotheses attached to theShape. // If theHyp is provided, similar but not same hypotheses -// are countered; else only applicable ones are countered -// depending on theAlgos flag +// are countered; else only applicable ones having theHypType +// are countered //======================================================================= -int SMESH_subMesh::GetNbAttached(const TopoDS_Shape& theShape, - const SMESH_Hypothesis * theHyp, - const bool theAlgos) +const SMESH_Hypothesis* SMESH_subMesh::GetSimilarAttached(const TopoDS_Shape& theShape, + const SMESH_Hypothesis * theHyp, + const int theHypType) { - int nb = 0; - const list& aHypList = _father->GetHypothesisList( theShape ); list::const_iterator it = aHypList.begin(); - while (it!=aHypList.end()) + for ( ; it != aHypList.end(); it++ ) { const SMESH_Hypothesis* hyp = static_cast< const SMESH_Hypothesis *>( *it ); - it++; - if ( theHyp ) { - // count similar + // find similar if (hyp != theHyp && hyp->GetType() == theHyp->GetType() && hyp->GetDim() == theHyp->GetDim()) - nb++; + return hyp; } else { - bool isAlgo = ( hyp->GetType() > SMESHDS_Hypothesis::PARAM_ALGO ); - if ( theAlgos == isAlgo && IsApplicableHypotesis( hyp )) - nb++; + if ( hyp->GetType() == theHypType && IsApplicableHypotesis( hyp )) + return hyp; } } - return nb; + return 0; } //======================================================================= //function : CheckConcurentHypothesis -//purpose : check if there are several applicable hypothesis on fathers +//purpose : check if there are several applicable hypothesis attached to +// ansestors //======================================================================= SMESH_Hypothesis::Hypothesis_Status @@ -1630,20 +1622,25 @@ SMESH_Hypothesis::Hypothesis_Status MESSAGE ("SMESH_subMesh::CheckConcurentHypothesis"); // is there local hypothesis on me? - if ( GetNbAttached( _subShape, 0, theHypType > SMESHDS_Hypothesis::PARAM_ALGO ) > 0 ) + if ( GetSimilarAttached( _subShape, 0, theHypType ) ) return SMESH_Hypothesis::HYP_OK; - + TopoDS_Shape aPrevWithHyp; + const SMESH_Hypothesis* aPrevHyp = 0; TopTools_ListIteratorOfListOfShape it( _father->GetAncestors( _subShape )); for (; it.More(); it.Next()) { const TopoDS_Shape& ancestor = it.Value(); - if ( GetNbAttached( ancestor, 0, theHypType > SMESHDS_Hypothesis::PARAM_ALGO ) > 0 ) + const SMESH_Hypothesis* hyp = GetSimilarAttached( ancestor, 0, theHypType ); + if ( hyp ) { if ( aPrevWithHyp.IsNull() || aPrevWithHyp.IsSame( ancestor )) + { aPrevWithHyp = ancestor; - else if ( aPrevWithHyp.ShapeType() == ancestor.ShapeType() ) + aPrevHyp = hyp; + } + else if ( aPrevWithHyp.ShapeType() == ancestor.ShapeType() && aPrevHyp != hyp ) return SMESH_Hypothesis::HYP_CONCURENT; else return SMESH_Hypothesis::HYP_OK; diff --git a/src/SMESH/SMESH_subMesh.hxx b/src/SMESH/SMESH_subMesh.hxx index 937479da7..307ddf2c9 100644 --- a/src/SMESH/SMESH_subMesh.hxx +++ b/src/SMESH/SMESH_subMesh.hxx @@ -70,7 +70,7 @@ class SMESH_subMesh const TopoDS_Shape & GetSubShape(); - bool _vertexSet; // only for vertex subMesh, set to false for dim > 0 +// bool _vertexSet; // only for vertex subMesh, set to false for dim > 0 enum compute_state { @@ -91,7 +91,8 @@ class SMESH_subMesh enum compute_event { MODIF_HYP, MODIF_ALGO_STATE, COMPUTE, - CLEAN, CLEANDEP, SUBMESH_COMPUTED, SUBMESH_RESTORED + CLEAN, CLEANDEP, SUBMESH_COMPUTED, SUBMESH_RESTORED, + MESH_ENTITY_REMOVED, CHECK_COMPUTE_STATE }; SMESH_Hypothesis::Hypothesis_Status @@ -152,13 +153,13 @@ class SMESH_subMesh SMESH_Hypothesis::Hypothesis_Status CheckConcurentHypothesis (const int theHypType); // check if there are several applicable hypothesis on fathers - int GetNbAttached(const TopoDS_Shape& theShape, - const SMESH_Hypothesis * theHyp, - const bool theAlgos = false); - // return nb of hypotheses attached to theShape. + const SMESH_Hypothesis* GetSimilarAttached(const TopoDS_Shape& theShape, + const SMESH_Hypothesis * theHyp, + const int theHypType = 0); + // return a hypothesis attached to theShape. // If theHyp is provided, similar but not same hypotheses - // are countered; else only applicable ones are countered - // depending on theAlgos flag + // is returned; else an applicable ones having theHypType + // is returned TopoDS_Shape _subShape; SMESHDS_Mesh * _meshDS; @@ -166,12 +167,9 @@ class SMESH_subMesh int _Id; SMESH_Mesh *_father; map < int, SMESH_subMesh * >_mapDepend; - //map < int, SMESH_subMesh * >_mapDependants; bool _dependenceAnalysed; - //bool _dependantsFound; int _algoState; - //int _oldAlgoState; int _computeState; }; diff --git a/src/SMESHDS/Makefile.in b/src/SMESHDS/Makefile.in index 2b4d5391e..50d4fa742 100644 --- a/src/SMESHDS/Makefile.in +++ b/src/SMESHDS/Makefile.in @@ -43,7 +43,9 @@ LIB_SRC = \ SMESHDS_Command.cxx \ SMESHDS_SubMesh.cxx \ SMESHDS_Mesh.cxx \ - SMESHDS_Group.cxx + SMESHDS_GroupBase.cxx \ + SMESHDS_Group.cxx \ + SMESHDS_GroupOnGeom.cxx LIB_CLIENT_IDL = LIB_SERVER_IDL = @@ -63,12 +65,14 @@ EXPORT_HEADERS= \ SMESHDS_Command.hxx \ SMESHDS_CommandType.hxx \ SMESHDS_SubMesh.hxx \ - SMESHDS_Group.hxx + SMESHDS_GroupBase.hxx \ + SMESHDS_Group.hxx \ + SMESHDS_GroupOnGeom.hxx # additionnal information to compil and link file CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome $(BOOST_CPPFLAGS) CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome -LDFLAGS += $(OCC_KERNEL_LIBS) +LDFLAGS += $(OCC_KERNEL_LIBS) -lSMDS # additional file to be cleaned diff --git a/src/SMESHDS/SMESHDS_Command.cxx b/src/SMESHDS/SMESHDS_Command.cxx index 05f529d0e..4e7dc3f3b 100644 --- a/src/SMESHDS/SMESHDS_Command.cxx +++ b/src/SMESHDS/SMESHDS_Command.cxx @@ -26,10 +26,12 @@ // Module : SMESH // $Header: -using namespace std; #include "SMESHDS_Command.hxx" + #include "utilities.h" +using namespace std; + //======================================================================= //function : //purpose : @@ -252,6 +254,44 @@ void SMESHDS_Command::RemoveElement(int ElementID) myNumber++; } +//======================================================================= +//function : ChangeElementNodes +//purpose : +//======================================================================= + +void SMESHDS_Command::ChangeElementNodes(int ElementID, int nodes[], int nbnodes) +{ + if (!myType == SMESHDS_ChangeElementNodes) + { + MESSAGE("SMESHDS_Command::RemoveElement : Bad Type"); + return; + } + myIntegers.push_back(ElementID); + myIntegers.push_back(nbnodes); + for ( int i = 0; i < nbnodes; i++ ) + myIntegers.push_back( nodes[ i ] ); + + myNumber++; +} + +//======================================================================= +//function : Renumber +//purpose : +//======================================================================= + +void SMESHDS_Command::Renumber (const bool isNodes, const int startID, const int deltaID) +{ + if (!myType == SMESHDS_Renumber) + { + MESSAGE("SMESHDS_Command::Renumber : Bad Type"); + return; + } + myIntegers.push_back(isNodes); + myIntegers.push_back(startID); + myIntegers.push_back(deltaID); + myNumber++; +} + //======================================================================= //function : //purpose : diff --git a/src/SMESHDS/SMESHDS_Command.hxx b/src/SMESHDS/SMESHDS_Command.hxx index 7c3014e7d..b72b21b86 100644 --- a/src/SMESHDS/SMESHDS_Command.hxx +++ b/src/SMESHDS/SMESHDS_Command.hxx @@ -51,15 +51,17 @@ class SMESHDS_Command void MoveNode(int NewNodeID, double x, double y, double z); void RemoveNode(int NodeID); void RemoveElement(int ElementID); + void ChangeElementNodes(int ElementID, int nodes[], int nbnodes); + void Renumber (const bool isNodes, const int startID, const int deltaID); SMESHDS_CommandType GetType(); int GetNumber(); - const list & GetIndexes(); - const list & GetCoords(); + const std::list & GetIndexes(); + const std::list & GetCoords(); ~SMESHDS_Command(); private: SMESHDS_CommandType myType; int myNumber; - list myReals; - list myIntegers; + std::list myReals; + std::list myIntegers; }; #endif diff --git a/src/SMESHDS/SMESHDS_CommandType.hxx b/src/SMESHDS/SMESHDS_CommandType.hxx index fd64ba005..e906020cb 100644 --- a/src/SMESHDS/SMESHDS_CommandType.hxx +++ b/src/SMESHDS/SMESHDS_CommandType.hxx @@ -27,23 +27,23 @@ #ifndef _SMESHDS_CommandType_HeaderFile #define _SMESHDS_CommandType_HeaderFile +//#include + enum SMESHDS_CommandType { SMESHDS_AddNode, -SMESHDS_AddEdge, -SMESHDS_AddTriangle, -SMESHDS_AddQuadrangle, -SMESHDS_AddTetrahedron, -SMESHDS_AddPyramid, -SMESHDS_AddPrism, -SMESHDS_AddHexahedron, -SMESHDS_RemoveNode, -SMESHDS_RemoveElement, -SMESHDS_MoveNode + SMESHDS_AddEdge, + SMESHDS_AddTriangle, + SMESHDS_AddQuadrangle, + SMESHDS_AddTetrahedron, + SMESHDS_AddPyramid, + SMESHDS_AddPrism, + SMESHDS_AddHexahedron, + SMESHDS_RemoveNode, + SMESHDS_RemoveElement, + SMESHDS_MoveNode, + SMESHDS_ChangeElementNodes, + SMESHDS_Renumber }; -#ifndef _Standard_PrimitiveTypes_HeaderFile -#include -#endif - #endif diff --git a/src/SMESHDS/SMESHDS_Document.cxx b/src/SMESHDS/SMESHDS_Document.cxx index 1a07cf0ba..f533a72a7 100644 --- a/src/SMESHDS/SMESHDS_Document.cxx +++ b/src/SMESHDS/SMESHDS_Document.cxx @@ -29,6 +29,8 @@ #include "SMESHDS_Document.hxx" #include "utilities.h" +using namespace std; + //======================================================================= //function : Create //purpose : diff --git a/src/SMESHDS/SMESHDS_Document.hxx b/src/SMESHDS/SMESHDS_Document.hxx index 4da7a3c47..e95269f11 100644 --- a/src/SMESHDS/SMESHDS_Document.hxx +++ b/src/SMESHDS/SMESHDS_Document.hxx @@ -27,10 +27,10 @@ #ifndef _SMESHDS_Document_HeaderFile #define _SMESHDS_Document_HeaderFile -#include #include "SMESHDS_Mesh.hxx" #include "SMESHDS_Hypothesis.hxx" -using namespace std; +#include + class SMESHDS_Document { @@ -54,10 +54,10 @@ class SMESHDS_Document private: int myUserID; - map myMeshes; - map myHypothesis; - map::iterator myMeshesIt; - map::iterator myHypothesisIt; + std::map myMeshes; + std::map myHypothesis; + std::map::iterator myMeshesIt; + std::map::iterator myHypothesisIt; }; #endif diff --git a/src/SMESHDS/SMESHDS_Group.cxx b/src/SMESHDS/SMESHDS_Group.cxx index 29d7db4f4..ecd6efb8c 100644 --- a/src/SMESHDS/SMESHDS_Group.cxx +++ b/src/SMESHDS/SMESHDS_Group.cxx @@ -21,12 +21,13 @@ // // // File : SMESHDS_Group.cxx -// Author : Michael Sazonov, OCC // Module : SMESH // $Header$ -#include -#include +#include "SMESHDS_Group.hxx" +#include "SMESHDS_Mesh.hxx" + +using namespace std; //============================================================================= /*! @@ -34,11 +35,32 @@ */ //============================================================================= -SMESHDS_Group::SMESHDS_Group (const SMESHDS_Mesh* theMesh, +SMESHDS_Group::SMESHDS_Group (const int theID, + const SMESHDS_Mesh* theMesh, const SMDSAbs_ElementType theType) - : SMDS_MeshGroup(theMesh,theType), myStoreName(""), - myCurIndex(0), myCurID(0) + : SMESHDS_GroupBase(theID,theMesh,theType), + myGroup(theMesh,theType) +{ +} + +//======================================================================= +//function : Extent +//purpose : +//======================================================================= + +int SMESHDS_Group::Extent() +{ + return myGroup.Extent(); +} + +//======================================================================= +//function : IsEmpty +//purpose : +//======================================================================= + +bool SMESHDS_Group::IsEmpty() { + return myGroup.IsEmpty(); } //============================================================================= @@ -47,11 +69,11 @@ SMESHDS_Group::SMESHDS_Group (const SMESHDS_Mesh* theMesh, */ //============================================================================= -bool SMESHDS_Group::Contains (const int theID) const +bool SMESHDS_Group::Contains (const int theID) { const SMDS_MeshElement* aElem = findInMesh (theID); if (aElem) - return SMDS_MeshGroup::Contains(aElem); + return myGroup.Contains(aElem); return false; } @@ -64,9 +86,13 @@ bool SMESHDS_Group::Contains (const int theID) const bool SMESHDS_Group::Add (const int theID) { const SMDS_MeshElement* aElem = findInMesh (theID); - if (!aElem || SMDS_MeshGroup::Contains(aElem)) + if (!aElem || myGroup.Contains(aElem)) return false; - SMDS_MeshGroup::Add (aElem); + + if (myGroup.IsEmpty()) + SetType( aElem->GetType() ); + + myGroup.Add (aElem); return true; } @@ -79,51 +105,57 @@ bool SMESHDS_Group::Add (const int theID) bool SMESHDS_Group::Remove (const int theID) { const SMDS_MeshElement* aElem = findInMesh (theID); - if (!aElem || !SMDS_MeshGroup::Contains(aElem)) + if (!aElem || !myGroup.Contains(aElem)) return false; - SMDS_MeshGroup::Remove (aElem); + myGroup.Remove (aElem); return true; } -//============================================================================= -/*! - * - */ -//============================================================================= +//======================================================================= +//function : Clear +//purpose : +//======================================================================= -int SMESHDS_Group::GetID (const int theIndex) +void SMESHDS_Group::Clear() { - if (theIndex < 1 || theIndex > Extent()) - return -1; - if (myCurIndex < 1 || myCurIndex > theIndex) { - InitIterator(); - myCurIndex = 0; - myCurID = -1; - } - while (myCurIndex < theIndex && More()) { - myCurIndex++; - myCurID = Next()->GetID(); - } - return myCurID; + myGroup.Clear(); } -//============================================================================= -/*! - * - */ -//============================================================================= +// ===================== +// class MyGroupIterator +// ===================== -const SMDS_MeshElement* SMESHDS_Group::findInMesh (const int theID) const +class MyGroupIterator: public SMDS_ElemIterator { - SMDSAbs_ElementType aType = GetType(); - const SMDS_MeshElement* aElem = NULL; - if (aType == SMDSAbs_Node) { - aElem = GetMesh()->FindNode(theID); - } - else if (aType != SMDSAbs_All) { - aElem = GetMesh()->FindElement(theID); - if (aElem && aType != aElem->GetType()) - aElem = NULL; + const SMDS_MeshGroup& myGroup; + public: + MyGroupIterator(const SMDS_MeshGroup& group): myGroup(group) { myGroup.InitIterator(); } + bool more() { return myGroup.More(); } + const SMDS_MeshElement* next() { return myGroup.Next(); } +}; + +//======================================================================= +//function : GetElements +//purpose : +//======================================================================= + +SMDS_ElemIteratorPtr SMESHDS_Group::GetElements() +{ + return SMDS_ElemIteratorPtr( new MyGroupIterator ( myGroup )); +} + +//======================================================================= +//function : SetType +//purpose : +//======================================================================= + +void SMESHDS_Group::SetType(SMDSAbs_ElementType theType) +{ + if ( myGroup.IsEmpty() || GetType() == SMDSAbs_All ) { + SMESHDS_GroupBase::SetType( theType ); + myGroup.SetType ( theType ); } - return aElem; + else + SMESHDS_GroupBase::SetType( myGroup.GetType() ); } + diff --git a/src/SMESHDS/SMESHDS_Group.hxx b/src/SMESHDS/SMESHDS_Group.hxx index 444914cee..b318a0f97 100644 --- a/src/SMESHDS/SMESHDS_Group.hxx +++ b/src/SMESHDS/SMESHDS_Group.hxx @@ -21,51 +21,47 @@ // // // File : SMESHDS_Group.hxx -// Author : Michael Sazonov (OCC) // Module : SMESH // $Header$ #ifndef _SMESHDS_Group_HeaderFile #define _SMESHDS_Group_HeaderFile -#include #include +#include "SMESHDS_GroupBase.hxx" +#include "SMDS_MeshGroup.hxx" class SMESHDS_Mesh; -class SMESHDS_Group : public SMDS_MeshGroup +class SMESHDS_Group : public SMESHDS_GroupBase { public: - SMESHDS_Group (const SMESHDS_Mesh* theMesh, + SMESHDS_Group (const int theID, + const SMESHDS_Mesh* theMesh, const SMDSAbs_ElementType theType); - void SetStoreName (const char* theName) - { myStoreName = theName; } + virtual void SetType(SMDSAbs_ElementType theType); - const char* GetStoreName () const - { return myStoreName.c_str(); } + virtual int Extent(); - bool Contains (const int theID) const; + virtual bool IsEmpty(); - bool Add (const int theID); - bool Remove (const int theID); + virtual bool Contains (const int theID); - int GetID (const int theIndex); - // use it for iterations 1..Extent() as alternative to parent's - // InitIterator(), More(), Next() + virtual SMDS_ElemIteratorPtr GetElements(); - private: - SMESHDS_Group (const SMESHDS_Group& theOther); - // prohibited copy constructor - SMESHDS_Group& operator = (const SMESHDS_Group& theOther); - // prohibited assign operator + bool SMESHDS_Group::Add (const int theID); + + bool SMESHDS_Group::Remove (const int theID); + + void Clear(); - const SMDS_MeshElement* findInMesh (const int theID) const; + SMDS_MeshGroup& SMDSGroup() { return myGroup; } + + private: - string myStoreName; - int myCurIndex; - int myCurID; + SMDS_MeshGroup myGroup; }; diff --git a/src/SMESHDS/SMESHDS_GroupBase.cxx b/src/SMESHDS/SMESHDS_GroupBase.cxx new file mode 100644 index 000000000..c3fc31d70 --- /dev/null +++ b/src/SMESHDS/SMESHDS_GroupBase.cxx @@ -0,0 +1,138 @@ +// SMESH SMESHDS : idl implementation based on 'SMESH' unit's classes +// +// Copyright (C) 2004 CEA +// +// 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.org +// +// +// +// File : SMESHDS_Group.cxx +// Module : SMESH +// $Header$ + +#include "SMESHDS_GroupBase.hxx" +#include "SMESHDS_Mesh.hxx" + +#include "utilities.h" + +using namespace std; + +//============================================================================= +/*! + * + */ +//============================================================================= + +SMESHDS_GroupBase::SMESHDS_GroupBase (const int theID, + const SMESHDS_Mesh* theMesh, + const SMDSAbs_ElementType theType): + myID(theID), myMesh(theMesh), myType(theType), myStoreName(""), + myCurIndex(0), myCurID(0) +{ +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +int SMESHDS_GroupBase::GetID (const int theIndex) +{ + if (myCurIndex < 1 || myCurIndex > theIndex) { + myIterator = GetElements(); + myCurIndex = 0; + myCurID = -1; + } + while (myCurIndex < theIndex && myIterator->more()) { + myCurIndex++; + myCurID = myIterator->next()->GetID(); + } + return myCurIndex == theIndex ? myCurID : -1; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +const SMDS_MeshElement* SMESHDS_GroupBase::findInMesh (const int theID) const +{ + SMDSAbs_ElementType aType = GetType(); + const SMDS_MeshElement* aElem = NULL; + if (aType == SMDSAbs_Node) { + aElem = GetMesh()->FindNode(theID); + } + else if (aType != SMDSAbs_All) { + aElem = GetMesh()->FindElement(theID); + if (aElem && aType != aElem->GetType()) + aElem = NULL; + } + return aElem; +} + +//======================================================================= +//function : Extent +//purpose : +//======================================================================= + +int SMESHDS_GroupBase::Extent() +{ + SMDS_ElemIteratorPtr it = GetElements(); + int nb = 0; + if ( it ) + for ( ; it->more(); it->next() ) + nb++; + return nb; +} + +//======================================================================= +//function : IsEmpty +//purpose : +//======================================================================= + +bool SMESHDS_GroupBase::IsEmpty() +{ + SMDS_ElemIteratorPtr it = GetElements(); + return ( !it || !it->more() ); +} + +//======================================================================= +//function : Contains +//purpose : +//======================================================================= + +bool SMESHDS_GroupBase::Contains (const int theID) +{ + SMDS_ElemIteratorPtr it = GetElements(); + bool contains = false; + if ( it ) + while ( !contains && it->more() ) + contains = ( it->next()->GetID() == theID ); + return contains; +} + +//======================================================================= +//function : SetType +//purpose : +//======================================================================= + +void SMESHDS_GroupBase::SetType(SMDSAbs_ElementType theType) +{ + myType = theType; +} diff --git a/src/SMESHDS/SMESHDS_GroupBase.hxx b/src/SMESHDS/SMESHDS_GroupBase.hxx new file mode 100644 index 000000000..fbb91414a --- /dev/null +++ b/src/SMESHDS/SMESHDS_GroupBase.hxx @@ -0,0 +1,89 @@ +// SMESH SMESHDS : management of mesh data and SMESH document +// +// Copyright (C) 2004 CEA +// +// 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.org +// +// +// +// File : SMESHDS_Group.hxx +// Module : SMESH +// $Header$ + +#ifndef _SMESHDS_GroupBase_HeaderFile +#define _SMESHDS_GroupBase_HeaderFile + +#include +#include "SMDSAbs_ElementType.hxx" +#include "SMDS_MeshElement.hxx" + +class SMESHDS_Mesh; + +class SMESHDS_GroupBase +{ + public: + + SMESHDS_GroupBase (const int theID, + const SMESHDS_Mesh* theMesh, + const SMDSAbs_ElementType theType); + + int GetID() const { return myID; } + + const SMESHDS_Mesh* GetMesh() const { return myMesh; } + + virtual void SetType(SMDSAbs_ElementType theType); + + SMDSAbs_ElementType GetType() const { return myType; } + + void SetStoreName (const char* theName) { myStoreName = theName; } + + const char* GetStoreName () const { return myStoreName.c_str(); } + + virtual int Extent(); + + virtual bool IsEmpty(); + + virtual bool Contains (const int theID); + + virtual SMDS_ElemIteratorPtr GetElements() = 0; + + int GetID (const int theIndex); + // use it for iterations 1..Extent() + + virtual ~SMESHDS_GroupBase() {} + + protected: + const SMDS_MeshElement* findInMesh (const int theID) const; + + private: + SMESHDS_GroupBase (const SMESHDS_GroupBase& theOther); + // prohibited copy constructor + SMESHDS_GroupBase& operator = (const SMESHDS_GroupBase& theOther); + // prohibited assign operator + + int myID; + const SMESHDS_Mesh* myMesh; + SMDSAbs_ElementType myType; + std::string myStoreName; + // for GetID() + int myCurIndex; + int myCurID; + SMDS_ElemIteratorPtr myIterator; + +}; + +#endif diff --git a/src/SMESHDS/SMESHDS_GroupOnGeom.cxx b/src/SMESHDS/SMESHDS_GroupOnGeom.cxx new file mode 100644 index 000000000..187357a67 --- /dev/null +++ b/src/SMESHDS/SMESHDS_GroupOnGeom.cxx @@ -0,0 +1,112 @@ +// SMESH SMESHDS : idl implementation based on 'SMESH' unit's classes +// +// Copyright (C) 2004 CEA +// +// 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.org +// +// +// +// File : SMESHDS_GroupOnGeom.cxx +// Module : SMESH +// $Header$ + +#include "SMESHDS_GroupOnGeom.hxx" +#include "SMESHDS_Mesh.hxx" +#include "utilities.h" + +using namespace std; + +//============================================================================= +/*! + * + */ +//============================================================================= + +SMESHDS_GroupOnGeom::SMESHDS_GroupOnGeom (const int theID, + const SMESHDS_Mesh* theMesh, + const SMDSAbs_ElementType theType, + const TopoDS_Shape& theShape) + : SMESHDS_GroupBase(theID,theMesh,theType), myShape(theShape) +{ + SMESHDS_Mesh* aMesh = const_cast(theMesh); + mySubMesh = aMesh->MeshElements( aMesh->AddCompoundSubmesh( theShape )); +} + +// ===================== +// class MyGroupIterator +// ===================== + +class MyIterator: public SMDS_ElemIterator +{ + SMDSAbs_ElementType myType; + SMDS_ElemIteratorPtr myElemIt; + SMDS_NodeIteratorPtr myNodeIt; + const SMDS_MeshElement* myElem; + public: + MyIterator(SMDSAbs_ElementType type, const SMESHDS_SubMesh* subMesh) + : myType(type), myElem(0) + { + if ( subMesh ) + if ( myType == SMDSAbs_Node ) + myNodeIt = subMesh->GetNodes(); + else { + myElemIt = subMesh->GetElements(); + next(); + } + } + bool more() + { + if ( myType == SMDSAbs_Node && myNodeIt ) + return myNodeIt->more(); + return ( myElem != 0 ); + } + const SMDS_MeshElement* next() + { + if ( myType == SMDSAbs_Node && myNodeIt ) + return myNodeIt->next(); + const SMDS_MeshElement* res = myElem; + myElem = 0; + while ( myElemIt && myElemIt->more() ) { + myElem = myElemIt->next(); + if ( myElem && myElem->GetType() == myType ) + break; + else + myElem = 0; + } + return res; + } +}; + +//======================================================================= +//function : GetElements +//purpose : +//======================================================================= + +SMDS_ElemIteratorPtr SMESHDS_GroupOnGeom::GetElements() +{ + return SMDS_ElemIteratorPtr( new MyIterator ( GetType(), mySubMesh )); +} + +//======================================================================= +//function : Contains +//purpose : +//======================================================================= + +bool SMESHDS_GroupOnGeom::Contains (const int theID) +{ + return mySubMesh->Contains( findInMesh( theID )); +} diff --git a/src/SMESHDS/SMESHDS_GroupOnGeom.hxx b/src/SMESHDS/SMESHDS_GroupOnGeom.hxx new file mode 100644 index 000000000..6a514e2f1 --- /dev/null +++ b/src/SMESHDS/SMESHDS_GroupOnGeom.hxx @@ -0,0 +1,56 @@ +// SMESH SMESHDS : management of mesh data and SMESH document +// +// Copyright (C) 2004 CEA +// +// 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.org +// +// +// +// File : SMESHDS_GroupOnGeom.hxx +// Module : SMESH +// $Header$ + +#ifndef _SMESHDS_GroupOnGeom_HeaderFile +#define _SMESHDS_GroupOnGeom_HeaderFile + +#include "SMESHDS_GroupBase.hxx" +#include + +class SMESHDS_SubMesh; + +class SMESHDS_GroupOnGeom: public SMESHDS_GroupBase +{ + public: + + SMESHDS_GroupOnGeom (const int theID, + const SMESHDS_Mesh* theMesh, + const SMDSAbs_ElementType theType, + const TopoDS_Shape& theShape); + + TopoDS_Shape GetShape() const { return myShape; } + + virtual bool Contains (const int theID); + + virtual SMDS_ElemIteratorPtr GetElements(); + + private: + + TopoDS_Shape myShape; + const SMESHDS_SubMesh* mySubMesh; +}; + +#endif diff --git a/src/SMESHDS/SMESHDS_Hypothesis.cxx b/src/SMESHDS/SMESHDS_Hypothesis.cxx index b1cf717b8..29501c440 100644 --- a/src/SMESHDS/SMESHDS_Hypothesis.cxx +++ b/src/SMESHDS/SMESHDS_Hypothesis.cxx @@ -26,10 +26,9 @@ // Module : SMESH // $Header$ -using namespace std; -using namespace std; #include "SMESHDS_Hypothesis.hxx" +using namespace std; //============================================================================= /*! diff --git a/src/SMESHDS/SMESHDS_Hypothesis.hxx b/src/SMESHDS/SMESHDS_Hypothesis.hxx index 3a79039b8..9fb413fbd 100644 --- a/src/SMESHDS/SMESHDS_Hypothesis.hxx +++ b/src/SMESHDS/SMESHDS_Hypothesis.hxx @@ -29,16 +29,8 @@ #ifndef _SMESHDS_HYPOTHESIS_HXX_ #define _SMESHDS_HYPOTHESIS_HXX_ -#if (__GNUC__>2) #include -#include -#include -#else -#include -#include -#include -#endif -using namespace std; +#include class SMESHDS_Hypothesis { @@ -50,13 +42,13 @@ public: int GetID() const; int GetType() const; - virtual ostream & SaveTo(ostream & save)=0; - virtual istream & LoadFrom(istream & load)=0; + virtual std::ostream & SaveTo(std::ostream & save)=0; + virtual std::istream & LoadFrom(std::istream & load)=0; enum hypothesis_type {PARAM_ALGO, ALGO, ALGO_1D, ALGO_2D, ALGO_3D}; protected: - string _name; + std::string _name; int _hypId; int _type; }; diff --git a/src/SMESHDS/SMESHDS_Mesh.cxx b/src/SMESHDS/SMESHDS_Mesh.cxx index a6cae5391..f0fa21912 100644 --- a/src/SMESHDS/SMESHDS_Mesh.cxx +++ b/src/SMESHDS/SMESHDS_Mesh.cxx @@ -27,13 +27,19 @@ // $Header: #include "SMESHDS_Mesh.hxx" + +#include "SMESHDS_Group.hxx" #include "SMDS_VertexPosition.hxx" #include "SMDS_EdgePosition.hxx" #include "SMDS_FacePosition.hxx" #include #include +#include #include "utilities.h" + +using namespace std; + //======================================================================= //function : Create //purpose : @@ -124,7 +130,39 @@ void SMESHDS_Mesh::MoveNode(const SMDS_MeshNode *n, double x, double y, double z } //======================================================================= -//function : AddEdge +//function : ChangeElementNodes +//purpose : +//======================================================================= + +bool SMESHDS_Mesh::ChangeElementNodes(const SMDS_MeshElement * elem, + const SMDS_MeshNode * nodes[], + const int nbnodes) +{ + if ( ! SMDS_Mesh::ChangeElementNodes( elem, nodes, nbnodes )) + return false; + + ASSERT( nbnodes < 9 ); + int i, IDs[ 8 ]; + for ( i = 0; i < nbnodes; i++ ) + IDs [ i ] = nodes[ i ]->GetID(); + myScript->ChangeElementNodes( elem->GetID(), IDs, nbnodes); + + return true; +} + +//======================================================================= +//function : Renumber +//purpose : +//======================================================================= + +void SMESHDS_Mesh::Renumber (const bool isNodes, const int startID, const int deltaID) +{ + SMDS_Mesh::Renumber( isNodes, startID, deltaID ); + myScript->Renumber( isNodes, startID, deltaID ); +} + +//======================================================================= +//function :AddEdgeWithID //purpose : //======================================================================= SMDS_MeshEdge* SMESHDS_Mesh::AddEdgeWithID(int n1, int n2, int ID) @@ -405,20 +443,45 @@ SMDS_MeshVolume* SMESHDS_Mesh::AddVolume(const SMDS_MeshNode * n1, return anElem; } //======================================================================= -//function : removeFromSubMeshes +//function : removeFromContainers //purpose : //======================================================================= -static void removeFromSubMeshes (map & theSubMeshes, - list & theElems, - const bool isNode) +static void removeFromContainers (map & theSubMeshes, + set& theGroups, + list & theElems, + const bool isNode) { if ( theElems.empty() ) return; - + + // Rm from group + // Element can belong to several groups + if ( !theGroups.empty() ) + { + set::iterator GrIt = theGroups.begin(); + for ( ; GrIt != theGroups.end(); GrIt++ ) + { + SMESHDS_Group* group = dynamic_cast( *GrIt ); + if ( !group || group->IsEmpty() ) continue; + + list::iterator elIt = theElems.begin(); + for ( ; elIt != theElems.end(); elIt++ ) + { + group->SMDSGroup().Remove( *elIt ); + if ( group->IsEmpty() ) break; + } + } + } + + // Rm from sub-meshes + // Element should belong to only one sub-mesh map::iterator SubIt = theSubMeshes.begin(); for ( ; SubIt != theSubMeshes.end(); SubIt++ ) { + int size = isNode ? (*SubIt).second->NbNodes() : (*SubIt).second->NbElements(); + if ( size == 0 ) continue; + list::iterator elIt = theElems.begin(); while ( elIt != theElems.end() ) { @@ -455,8 +518,8 @@ void SMESHDS_Mesh::RemoveNode(const SMDS_MeshNode * n) SMDS_Mesh::RemoveElement( n, removedElems, removedNodes, true ); - removeFromSubMeshes( myShapeIndexToSubMesh, removedElems, false ); - removeFromSubMeshes( myShapeIndexToSubMesh, removedNodes, true ); + removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false ); + removeFromContainers( myShapeIndexToSubMesh, myGroups, removedNodes, true ); } //======================================================================= @@ -478,7 +541,7 @@ void SMESHDS_Mesh::RemoveElement(const SMDS_MeshElement * elt) SMDS_Mesh::RemoveElement(elt, removedElems, removedNodes, false); - removeFromSubMeshes( myShapeIndexToSubMesh, removedElems, false ); + removeFromContainers( myShapeIndexToSubMesh, myGroups, removedElems, false ); } //======================================================================= @@ -621,6 +684,26 @@ TopoDS_Shape SMESHDS_Mesh::ShapeToMesh() const return myShape; } +//======================================================================= +//function : IsGroupOfSubShapes +//purpose : return true if at least one subshape of theShape is a subshape +// of myShape or theShape == myShape +//======================================================================= + +bool SMESHDS_Mesh::IsGroupOfSubShapes (const TopoDS_Shape& theShape) const +{ + if ( myShape.IsSame( theShape )) + return true; + + for ( TopoDS_Iterator it( theShape ); it.More(); it.Next() ) { + if (myIndexToShape.Contains( it.Value() ) || + IsGroupOfSubShapes( it.Value() )) + return true; + } + + return false; +} + /////////////////////////////////////////////////////////////////////////////// /// Return the sub mesh linked to the a given TopoDS_Shape or NULL if the given /// TopoDS_Shape is unknown @@ -629,7 +712,7 @@ SMESHDS_SubMesh * SMESHDS_Mesh::MeshElements(const TopoDS_Shape & S) { if (myShape.IsNull()) MESSAGE("myShape is NULL"); - int Index = myIndexToShape.FindIndex(S); + int Index = ShapeToIndex(S); if (myShapeIndexToSubMesh.find(Index)!=myShapeIndexToSubMesh.end()) return myShapeIndexToSubMesh[Index]; else @@ -720,13 +803,53 @@ bool SMESHDS_Mesh::HasHypothesis(const TopoDS_Shape & S) //function : NewSubMesh //purpose : //======================================================================= -void SMESHDS_Mesh::NewSubMesh(int Index) +SMESHDS_SubMesh * SMESHDS_Mesh::NewSubMesh(int Index) { - if (myShapeIndexToSubMesh.find(Index)==myShapeIndexToSubMesh.end()) - { - SMESHDS_SubMesh* SM = new SMESHDS_SubMesh(); - myShapeIndexToSubMesh[Index]=SM; - } + SMESHDS_SubMesh* SM = 0; + if (myShapeIndexToSubMesh.find(Index)==myShapeIndexToSubMesh.end()) + { + SM = new SMESHDS_SubMesh(); + myShapeIndexToSubMesh[Index]=SM; + } + else + SM = myShapeIndexToSubMesh[Index]; + return SM; +} + +//======================================================================= +//function : AddCompoundSubmesh +//purpose : +//======================================================================= + +int SMESHDS_Mesh::AddCompoundSubmesh(const TopoDS_Shape& S, + TopAbs_ShapeEnum type) +{ + int aMainIndex = 0; + if ( IsGroupOfSubShapes( S )) + { + aMainIndex = myIndexToShape.Add( S ); + bool all = ( type == TopAbs_SHAPE ); + if ( all ) // corresponding simple submesh may exist + aMainIndex = -aMainIndex; + //MESSAGE("AddCompoundSubmesh index = " << aMainIndex ); + SMESHDS_SubMesh * aNewSub = NewSubMesh( aMainIndex ); + if ( !aNewSub->IsComplexSubmesh() ) // is empty + { + int shapeType = all ? myShape.ShapeType() : type; + int typeLimit = all ? TopAbs_VERTEX : type; + for ( ; shapeType <= typeLimit; shapeType++ ) + { + TopExp_Explorer exp( S, TopAbs_ShapeEnum( shapeType )); + for ( ; exp.More(); exp.Next() ) + { + int index = myIndexToShape.FindIndex( exp.Current() ); + if ( index ) + aNewSub->AddSubMesh( NewSubMesh( index )); + } + } + } + } + return aMainIndex; } //======================================================================= @@ -744,8 +867,12 @@ TopoDS_Shape SMESHDS_Mesh::IndexToShape(int ShapeIndex) //======================================================================= int SMESHDS_Mesh::ShapeToIndex(const TopoDS_Shape & S) { - if (myShape.IsNull()) MESSAGE("myShape is NULL"); - return myIndexToShape.FindIndex(S); + if (myShape.IsNull()) + MESSAGE("myShape is NULL"); + + int index = myIndexToShape.FindIndex(S); + + return index; } //======================================================================= diff --git a/src/SMESHDS/SMESHDS_Mesh.hxx b/src/SMESHDS/SMESHDS_Mesh.hxx index 62b03798d..dece6ab48 100644 --- a/src/SMESHDS/SMESHDS_Mesh.hxx +++ b/src/SMESHDS/SMESHDS_Mesh.hxx @@ -45,16 +45,23 @@ //Not portable see http://gcc.gnu.org/onlinedocs/libstdc++/faq/index.html#5_4 to know more. #ifdef __GNUC__ -#if __GNUC__ < 3 - #include - // _CS_gbo_100504 Do not forget to define the namespace alias gstd - namespace gstd { using ::hash_map; } // inherits globals -#else - #include - namespace gstd = __gnu_cxx; -#endif + #if __GNUC__ < 3 + #include + namespace gstd { using ::hash_map; }; // inherit globals + #else + #include + #if __GNUC_MINOR__ == 0 + namespace gstd = std; // GCC 3.0 + #else + namespace gstd = ::__gnu_cxx; // GCC 3.1 and later + #endif + #endif +#else // ... there are other compilers, right? + namespace gstd = std; #endif +class SMESHDS_GroupBase; + class SMESHDS_Mesh:public SMDS_Mesh{ public: SMESHDS_Mesh(int MeshID); @@ -153,6 +160,10 @@ public: void MoveNode(const SMDS_MeshNode *, double x, double y, double z); virtual void RemoveNode(const SMDS_MeshNode *); void RemoveElement(const SMDS_MeshElement *); + bool ChangeElementNodes(const SMDS_MeshElement * elem, + const SMDS_MeshNode * nodes[], + const int nbnodes); + void Renumber (const bool isNodes, const int startID=1, const int deltaID=1); void SetNodeInVolume(SMDS_MeshNode * aNode, const TopoDS_Shell & S); void SetNodeOnFace(SMDS_MeshNode * aNode, const TopoDS_Face & S); @@ -178,13 +189,21 @@ public: int ShapeToIndex(const TopoDS_Shape & aShape); TopoDS_Shape IndexToShape(int ShapeIndex); - void NewSubMesh(int Index); + SMESHDS_SubMesh * NewSubMesh(int Index); + int AddCompoundSubmesh(const TopoDS_Shape& S, TopAbs_ShapeEnum type = TopAbs_SHAPE); void SetNodeInVolume(const SMDS_MeshNode * aNode, int Index); void SetNodeOnFace(SMDS_MeshNode * aNode, int Index); void SetNodeOnEdge(SMDS_MeshNode * aNode, int Index); void SetNodeOnVertex(SMDS_MeshNode * aNode, int Index); void SetMeshElementOnShape(const SMDS_MeshElement * anElt, int Index); + void AddGroup (SMESHDS_GroupBase* theGroup) { myGroups.insert(theGroup); } + void RemoveGroup (SMESHDS_GroupBase* theGroup) { myGroups.erase(theGroup); } + int GetNbGroups() const { return myGroups.size(); } + const set& GetGroups() const { return myGroups; } + + bool IsGroupOfSubShapes (const TopoDS_Shape& aSubShape) const; + ~SMESHDS_Mesh(); private: @@ -195,13 +214,14 @@ private: }; typedef std::list THypList; typedef gstd::hash_map ShapeToHypothesis; - ShapeToHypothesis myShapeToHypothesis; + ShapeToHypothesis myShapeToHypothesis; - int myMeshID; - TopoDS_Shape myShape; + int myMeshID; + TopoDS_Shape myShape; TopTools_IndexedMapOfShape myIndexToShape; - std::map myShapeIndexToSubMesh; - SMESHDS_Script* myScript; + map myShapeIndexToSubMesh; + set myGroups; + SMESHDS_Script* myScript; }; diff --git a/src/SMESHDS/SMESHDS_Script.cxx b/src/SMESHDS/SMESHDS_Script.cxx index 57baf301c..97e158432 100644 --- a/src/SMESHDS/SMESHDS_Script.cxx +++ b/src/SMESHDS/SMESHDS_Script.cxx @@ -26,31 +26,41 @@ // Module : SMESH // $Header: -using namespace std; #include "SMESHDS_Script.hxx" +using namespace std; + +//======================================================================= +//function : getCommand +//purpose : +//======================================================================= +SMESHDS_Command* SMESHDS_Script::getCommand(const SMESHDS_CommandType aType) +{ + SMESHDS_Command* com; + if (myCommands.empty()) + { + com = new SMESHDS_Command(aType); + myCommands.insert(myCommands.end(),com); + } + else + { + com = myCommands.back(); + if (com->GetType() != aType) + { + com = new SMESHDS_Command(aType); + myCommands.insert(myCommands.end(),com); + } + } + return com; +} + //======================================================================= //function : //purpose : //======================================================================= void SMESHDS_Script::AddNode(int NewNodeID, double x, double y, double z) { - SMESHDS_Command* com; - if (myCommands.empty()) - { - com = new SMESHDS_Command(SMESHDS_AddNode); - myCommands.insert(myCommands.end(),com); - } - else - { - com = myCommands.back(); - if (com->GetType() != SMESHDS_AddNode) - { - com = new SMESHDS_Command(SMESHDS_AddNode); - myCommands.insert(myCommands.end(),com); - } - } - com->AddNode(NewNodeID, x, y, z); + getCommand(SMESHDS_AddNode)->AddNode(NewNodeID, x, y, z); } //======================================================================= @@ -59,22 +69,7 @@ void SMESHDS_Script::AddNode(int NewNodeID, double x, double y, double z) //======================================================================= void SMESHDS_Script::AddEdge(int NewEdgeID, int idnode1, int idnode2) { - SMESHDS_Command* com; - if (myCommands.empty()) - { - com = new SMESHDS_Command(SMESHDS_AddEdge); - myCommands.insert(myCommands.end(), com); - } - else - { - com = myCommands.back(); - if (com->GetType() != SMESHDS_AddEdge) - { - com = new SMESHDS_Command(SMESHDS_AddEdge); - myCommands.insert(myCommands.end(), com); - } - } - com->AddEdge(NewEdgeID, idnode1, idnode2); + getCommand(SMESHDS_AddEdge)->AddEdge(NewEdgeID, idnode1, idnode2); } //======================================================================= @@ -82,24 +77,10 @@ void SMESHDS_Script::AddEdge(int NewEdgeID, int idnode1, int idnode2) //purpose : //======================================================================= void SMESHDS_Script::AddFace(int NewFaceID, - int idnode1, int idnode2, int idnode3) + int idnode1, int idnode2, int idnode3) { - SMESHDS_Command * com; - if (myCommands.empty()) - { - com = new SMESHDS_Command(SMESHDS_AddTriangle); - myCommands.insert(myCommands.end(),com); - } - else - { - com = myCommands.back(); - if (com->GetType() != SMESHDS_AddTriangle) - { - com = new SMESHDS_Command(SMESHDS_AddTriangle); - myCommands.insert(myCommands.end(),com); - } - } - com->AddFace(NewFaceID, idnode1, idnode2, idnode3); + getCommand(SMESHDS_AddTriangle)->AddFace(NewFaceID, + idnode1, idnode2, idnode3); } //======================================================================= @@ -107,24 +88,12 @@ void SMESHDS_Script::AddFace(int NewFaceID, //purpose : //======================================================================= void SMESHDS_Script::AddFace(int NewFaceID, - int idnode1, int idnode2, int idnode3, int idnode4) + int idnode1, int idnode2, + int idnode3, int idnode4) { - SMESHDS_Command * com; - if (myCommands.empty()) - { - com = new SMESHDS_Command(SMESHDS_AddQuadrangle); - myCommands.insert(myCommands.end(),com); - } - else - { - com = myCommands.back(); - if (com->GetType() != SMESHDS_AddQuadrangle) - { - com = new SMESHDS_Command(SMESHDS_AddQuadrangle); - myCommands.insert(myCommands.end(),com); - } - } - com->AddFace(NewFaceID, idnode1, idnode2, idnode3, idnode4); + getCommand(SMESHDS_AddQuadrangle)->AddFace(NewFaceID, + idnode1, idnode2, + idnode3, idnode4); } //======================================================================= @@ -132,24 +101,12 @@ void SMESHDS_Script::AddFace(int NewFaceID, //purpose : //======================================================================= void SMESHDS_Script::AddVolume(int NewID, - int idnode1, int idnode2, int idnode3, int idnode4) + int idnode1, int idnode2, + int idnode3, int idnode4) { - SMESHDS_Command * com; - if (myCommands.empty()) - { - com = new SMESHDS_Command(SMESHDS_AddTetrahedron); - myCommands.insert(myCommands.end(),com); - } - else - { - com = myCommands.back(); - if (com->GetType() != SMESHDS_AddTetrahedron) - { - com = new SMESHDS_Command(SMESHDS_AddTetrahedron); - myCommands.insert(myCommands.end(),com); - } - } - com->AddVolume(NewID, idnode1, idnode2, idnode3, idnode4); + getCommand(SMESHDS_AddTetrahedron)->AddVolume(NewID, + idnode1, idnode2, + idnode3, idnode4); } //======================================================================= @@ -157,24 +114,12 @@ void SMESHDS_Script::AddVolume(int NewID, //purpose : //======================================================================= void SMESHDS_Script::AddVolume(int NewID, - int idnode1, int idnode2, int idnode3, int idnode4, int idnode5) + int idnode1, int idnode2, + int idnode3, int idnode4, int idnode5) { - SMESHDS_Command * com; - if (myCommands.empty()) - { - com = new SMESHDS_Command(SMESHDS_AddPyramid); - myCommands.insert(myCommands.end(),com); - } - else - { - com = myCommands.back(); - if (com->GetType() != SMESHDS_AddPyramid) - { - com = new SMESHDS_Command(SMESHDS_AddPyramid); - myCommands.insert(myCommands.end(),com); - } - } - com->AddVolume(NewID, idnode1, idnode2, idnode3, idnode4, idnode5); + getCommand(SMESHDS_AddPyramid)->AddVolume(NewID, + idnode1, idnode2, + idnode3, idnode4, idnode5); } //======================================================================= @@ -182,25 +127,12 @@ void SMESHDS_Script::AddVolume(int NewID, //purpose : //======================================================================= void SMESHDS_Script::AddVolume(int NewID, - int idnode1, - int idnode2, int idnode3, int idnode4, int idnode5, int idnode6) + int idnode1, int idnode2, int idnode3, + int idnode4, int idnode5, int idnode6) { - SMESHDS_Command * com; - if (myCommands.empty()) - { - com = new SMESHDS_Command(SMESHDS_AddPrism); - myCommands.insert(myCommands.end(),com); - } - else - { - com = myCommands.back(); - if (com->GetType() != SMESHDS_AddPrism) - { - com = new SMESHDS_Command(SMESHDS_AddPrism); - myCommands.insert(myCommands.end(),com); - } - } - com->AddVolume(NewID, idnode1, idnode2, idnode3, idnode4, idnode5, idnode6); + getCommand(SMESHDS_AddPrism)->AddVolume(NewID, + idnode1, idnode2, idnode3, + idnode4, idnode5, idnode6); } //======================================================================= @@ -208,28 +140,12 @@ void SMESHDS_Script::AddVolume(int NewID, //purpose : //======================================================================= void SMESHDS_Script::AddVolume(int NewID, - int idnode1, - int idnode2, - int idnode3, - int idnode4, int idnode5, int idnode6, int idnode7, int idnode8) + int idnode1, int idnode2, int idnode3, int idnode4, + int idnode5, int idnode6, int idnode7, int idnode8) { - SMESHDS_Command * com; - if (myCommands.empty()) - { - com = new SMESHDS_Command(SMESHDS_AddHexahedron); - myCommands.insert(myCommands.end(),com); - } - else - { - com = myCommands.back(); - if (com->GetType() != SMESHDS_AddHexahedron) - { - com = new SMESHDS_Command(SMESHDS_AddHexahedron); - myCommands.insert(myCommands.end(),com); - } - } - com->AddVolume(NewID, idnode1, idnode2, idnode3, idnode4, - idnode5, idnode6, idnode7, idnode8); + getCommand(SMESHDS_AddHexahedron)->AddVolume(NewID, + idnode1, idnode2, idnode3, idnode4, + idnode5, idnode6, idnode7, idnode8); } //======================================================================= @@ -238,22 +154,7 @@ void SMESHDS_Script::AddVolume(int NewID, //======================================================================= void SMESHDS_Script::MoveNode(int NewNodeID, double x, double y, double z) { - SMESHDS_Command * com; - if (myCommands.empty()) - { - com = new SMESHDS_Command(SMESHDS_MoveNode); - myCommands.insert(myCommands.end(),com); - } - else - { - com = myCommands.back(); - if (com->GetType() != SMESHDS_MoveNode) - { - com = new SMESHDS_Command(SMESHDS_MoveNode); - myCommands.insert(myCommands.end(),com); - } - } - com->MoveNode(NewNodeID, x, y, z); + getCommand(SMESHDS_MoveNode)->MoveNode(NewNodeID, x, y, z); } //======================================================================= @@ -262,22 +163,7 @@ void SMESHDS_Script::MoveNode(int NewNodeID, double x, double y, double z) //======================================================================= void SMESHDS_Script::RemoveNode(int ID) { - SMESHDS_Command * com; - if (myCommands.empty()) - { - com = new SMESHDS_Command(SMESHDS_RemoveNode); - myCommands.insert(myCommands.end(),com); - } - else - { - com = myCommands.back(); - if (com->GetType() != SMESHDS_RemoveNode) - { - com = new SMESHDS_Command(SMESHDS_RemoveNode); - myCommands.insert(myCommands.end(),com); - } - } - com->RemoveNode(ID); + getCommand(SMESHDS_RemoveNode)->RemoveNode(ID); } //======================================================================= @@ -286,22 +172,27 @@ void SMESHDS_Script::RemoveNode(int ID) //======================================================================= void SMESHDS_Script::RemoveElement(int ElementID) { - SMESHDS_Command * com; - if (myCommands.empty()) - { - com = new SMESHDS_Command(SMESHDS_RemoveElement); - myCommands.insert(myCommands.end(),com); - } - else - { - com = myCommands.back(); - if (com->GetType() != SMESHDS_RemoveElement) - { - com = new SMESHDS_Command(SMESHDS_RemoveElement); - myCommands.insert(myCommands.end(),com); - } - } - com->RemoveElement(ElementID); + getCommand(SMESHDS_RemoveElement)->RemoveElement(ElementID); +} + +//======================================================================= +//function : ChangeElementNodes +//purpose : +//======================================================================= + +void SMESHDS_Script::ChangeElementNodes(int ElementID, int nodes[], int nbnodes) +{ + getCommand(SMESHDS_ChangeElementNodes)->ChangeElementNodes( ElementID, nodes, nbnodes ); +} + +//======================================================================= +//function : Renumber +//purpose : +//======================================================================= + +void SMESHDS_Script::Renumber (const bool isNodes, const int startID, const int deltaID) +{ + getCommand(SMESHDS_Renumber)->Renumber( isNodes, startID, deltaID ); } //======================================================================= diff --git a/src/SMESHDS/SMESHDS_Script.hxx b/src/SMESHDS/SMESHDS_Script.hxx index 8a67c98fe..e51d3ec98 100644 --- a/src/SMESHDS/SMESHDS_Script.hxx +++ b/src/SMESHDS/SMESHDS_Script.hxx @@ -28,8 +28,9 @@ #define _SMESHDS_Script_HeaderFile #include "SMESHDS_Command.hxx" + #include -using namespace std; + class SMESHDS_Script { @@ -50,12 +51,16 @@ class SMESHDS_Script void MoveNode(int NewNodeID, double x, double y, double z); void RemoveNode(int NodeID); void RemoveElement(int ElementID); + void ChangeElementNodes(int ElementID, int nodes[], int nbnodes); + void Renumber (const bool isNodes, const int startID, const int deltaID); void Clear(); - const list & GetCommands(); + const std::list & GetCommands(); ~SMESHDS_Script(); private: - list myCommands; + SMESHDS_Command* getCommand(const SMESHDS_CommandType aType); + + std::list myCommands; }; #endif diff --git a/src/SMESHDS/SMESHDS_SubMesh.cxx b/src/SMESHDS/SMESHDS_SubMesh.cxx index c7ad4c210..4218db744 100644 --- a/src/SMESHDS/SMESHDS_SubMesh.cxx +++ b/src/SMESHDS/SMESHDS_SubMesh.cxx @@ -26,16 +26,20 @@ // Module : SMESH // $Header: -using namespace std; #include "SMESHDS_SubMesh.hxx" +#include "utilities.h" + +using namespace std; + //======================================================================= //function : AddElement //purpose : //======================================================================= void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME) { - myElements.insert(ME); + if ( !IsComplexSubmesh() ) + myElements.insert(ME); } //======================================================================= @@ -44,7 +48,7 @@ void SMESHDS_SubMesh::AddElement(const SMDS_MeshElement * ME) //======================================================================= bool SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME) { - if ( NbElements() ) + if ( !IsComplexSubmesh() && NbElements() ) return myElements.erase(ME); return false; @@ -56,16 +60,18 @@ bool SMESHDS_SubMesh::RemoveElement(const SMDS_MeshElement * ME) //======================================================================= void SMESHDS_SubMesh::AddNode(const SMDS_MeshNode * N) { - myNodes.insert(N); + if ( !IsComplexSubmesh() ) + myNodes.insert(N); } //======================================================================= //function : RemoveNode //purpose : //======================================================================= + bool SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N) { - if ( NbNodes() ) + if ( !IsComplexSubmesh() && NbNodes() ) return myNodes.erase(N); return false; @@ -77,18 +83,39 @@ bool SMESHDS_SubMesh::RemoveNode(const SMDS_MeshNode * N) //======================================================================= int SMESHDS_SubMesh::NbElements() const { - return myElements.size(); + if ( !IsComplexSubmesh() ) + return myElements.size(); + + int nbElems = 0; + set::iterator it = mySubMeshes.begin(); + for ( ; it != mySubMeshes.end(); it++ ) + nbElems += (*it)->NbElements(); + + return nbElems; } //======================================================================= //function : NbNodes //purpose : //======================================================================= + int SMESHDS_SubMesh::NbNodes() const { - return myNodes.size(); + if ( !IsComplexSubmesh() ) + return myNodes.size(); + + int nbElems = 0; + set::iterator it = mySubMeshes.begin(); + for ( ; it != mySubMeshes.end(); it++ ) + nbElems += (*it)->NbNodes(); + + return nbElems; } +// ===================== +// class MySetIterator +// ===================== + template class MySetIterator:public SMDS_Iterator { typedef const set TSet; @@ -111,21 +138,154 @@ template class MySetIterator:public SMDS_Iterator return t; } }; -/////////////////////////////////////////////////////////////////////////////// -///Return an iterator on the elements of submesh -///The created iterator must be free by the caller -/////////////////////////////////////////////////////////////////////////////// + +// ===================== +// class MyIterator +// ===================== + +template class MyIterator : public SMDS_Iterator +{ + public: + MyIterator (const set& theSubMeshes) + : mySubMeshes( theSubMeshes ), mySubIt( theSubMeshes.begin() ), myMore(false) + {} + bool more() + { + while (( !myElemIt.get() || !myElemIt->more() ) && + mySubIt != mySubMeshes.end()) + { + myElemIt = getElements(*mySubIt); + mySubIt++; + } + myMore = myElemIt.get() && myElemIt->more(); + return myMore; + } + VALUE next() + { + VALUE elem = 0; + if ( myMore ) + elem = myElemIt->next(); + return elem; + } + protected: + virtual boost::shared_ptr< SMDS_Iterator > + getElements(const SMESHDS_SubMesh*) const = 0; + + private: + bool myMore; + const set& mySubMeshes; + set::const_iterator mySubIt; + boost::shared_ptr< SMDS_Iterator > myElemIt; +}; + +// ===================== +// class MyElemIterator +// ===================== + +class MyElemIterator: public MyIterator +{ + public: + MyElemIterator (const set& theSubMeshes) + :MyIterator( theSubMeshes ) {} + SMDS_ElemIteratorPtr getElements(const SMESHDS_SubMesh* theSubMesh) const + { return theSubMesh->GetElements(); } +}; + +// ===================== +// class MyNodeIterator +// ===================== + +class MyNodeIterator: public MyIterator +{ + public: + MyNodeIterator (const set& theSubMeshes) + :MyIterator( theSubMeshes ) {} + SMDS_NodeIteratorPtr getElements(const SMESHDS_SubMesh* theSubMesh) const + { return theSubMesh->GetNodes(); } +}; + +//======================================================================= +//function : GetElements +//purpose : +//======================================================================= + SMDS_ElemIteratorPtr SMESHDS_SubMesh::GetElements() const { + if ( IsComplexSubmesh() ) + return SMDS_ElemIteratorPtr( new MyElemIterator( mySubMeshes )); + return SMDS_ElemIteratorPtr(new MySetIterator(myElements)); } -/////////////////////////////////////////////////////////////////////////////// -///Return an iterator on the nodes of submesh -///The created iterator must be free by the caller -/////////////////////////////////////////////////////////////////////////////// +//======================================================================= +//function : GetNodes +//purpose : +//======================================================================= + SMDS_NodeIteratorPtr SMESHDS_SubMesh::GetNodes() const { + if ( IsComplexSubmesh() ) + return SMDS_NodeIteratorPtr( new MyNodeIterator( mySubMeshes )); + return SMDS_NodeIteratorPtr(new MySetIterator(myNodes)); } +//======================================================================= +//function : Contains +//purpose : check if elem or node is in +//======================================================================= + +bool SMESHDS_SubMesh::Contains(const SMDS_MeshElement * ME) const +{ + // DO NOT TRY TO FIND A REMOVED ELEMENT !! + if ( !ME ) + return false; + + if ( IsComplexSubmesh() ) + { + set::const_iterator aSubIt = mySubMeshes.begin(); + for ( ; aSubIt != mySubMeshes.end(); aSubIt++ ) + if ( (*aSubIt)->Contains( ME )) + return true; + return false; + } + + if ( ME->GetType() == SMDSAbs_Node ) + { + const SMDS_MeshNode* n = static_cast( ME ); + return ( myNodes.find( n ) != myNodes.end() ); + } + + return ( myElements.find( ME ) != myElements.end() ); +} + +//======================================================================= +//function : AddSubMesh +//purpose : +//======================================================================= + +void SMESHDS_SubMesh::AddSubMesh( const SMESHDS_SubMesh* theSubMesh ) +{ + ASSERT( theSubMesh ); + mySubMeshes.insert( theSubMesh ); +} + +//======================================================================= +//function : RemoveSubMesh +//purpose : +//======================================================================= + +bool SMESHDS_SubMesh::RemoveSubMesh( const SMESHDS_SubMesh* theSubMesh ) +{ + return mySubMeshes.erase( theSubMesh ); +} + +//======================================================================= +//function : ContainsSubMesh +//purpose : +//======================================================================= + +bool SMESHDS_SubMesh::ContainsSubMesh( const SMESHDS_SubMesh* theSubMesh ) const +{ + return mySubMeshes.find( theSubMesh ) != mySubMeshes.end(); +} diff --git a/src/SMESHDS/SMESHDS_SubMesh.hxx b/src/SMESHDS/SMESHDS_SubMesh.hxx index be7e7462a..7b202b9a4 100644 --- a/src/SMESHDS/SMESHDS_SubMesh.hxx +++ b/src/SMESHDS/SMESHDS_SubMesh.hxx @@ -30,23 +30,34 @@ #include "SMDS_Mesh.hxx" #include -using namespace std; - class SMESHDS_SubMesh { - public: - void AddElement(const SMDS_MeshElement * ME); - bool RemoveElement(const SMDS_MeshElement * ME); // ret true if ME was in - void AddNode(const SMDS_MeshNode * ME); - bool RemoveNode(const SMDS_MeshNode * ME); // ret true if ME was in - int NbElements() const; - SMDS_ElemIteratorPtr GetElements() const; - int NbNodes() const; - SMDS_NodeIteratorPtr GetNodes() const; - - private: - const SMDS_Mesh * myMesh; - set myElements; - set myNodes; + public: + + bool IsComplexSubmesh() const { return !mySubMeshes.empty(); } + + // if !IsComplexSubmesh() + void AddElement(const SMDS_MeshElement * ME); + bool RemoveElement(const SMDS_MeshElement * ME); // ret true if ME was in + void AddNode(const SMDS_MeshNode * ME); + bool RemoveNode(const SMDS_MeshNode * ME); // ret true if ME was in + + // if IsComplexSubmesh() + void AddSubMesh( const SMESHDS_SubMesh* theSubMesh ); + bool RemoveSubMesh( const SMESHDS_SubMesh* theSubMesh ); + bool ContainsSubMesh( const SMESHDS_SubMesh* theSubMesh ) const; + + // for both types + int NbElements() const; + SMDS_ElemIteratorPtr GetElements() const; + int NbNodes() const; + SMDS_NodeIteratorPtr GetNodes() const; + bool Contains(const SMDS_MeshElement * ME) const; // check if elem or node is in + + private: + //const SMDS_Mesh * myMesh; + std::set myElements; + std::set myNodes; + std::set mySubMeshes; }; #endif diff --git a/src/SMESHFiltersSelection/Makefile.in b/src/SMESHFiltersSelection/Makefile.in index 7e9e8b878..fa9869176 100644 --- a/src/SMESHFiltersSelection/Makefile.in +++ b/src/SMESHFiltersSelection/Makefile.in @@ -29,7 +29,7 @@ top_srcdir=@top_srcdir@ top_builddir=../.. srcdir=@srcdir@ -VPATH=.:@srcdir@:@top_srcdir@/idl +VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl @COMMENCE@ @@ -37,19 +37,35 @@ VPATH=.:@srcdir@:@top_srcdir@/idl # Libraries targets LIB = libSMESHFiltersSelection.la -LIB_SRC = SMESH_TypeFilter.cxx +LIB_SRC = SMESH_TypeFilter.cxx \ + SMESH_NumberFilter.cxx \ + SMESH_LogicalFilter.cxx -LIB_CLIENT_IDL = SALOME_Component.idl SALOMEDS.idl SALOME_Exception.idl +LIB_CLIENT_IDL = SALOME_Exception.idl \ + GEOM_Gen.idl \ + SMESH_Gen.idl \ + SMESH_Mesh.idl \ + SMESH_Hypothesis.idl \ + SMESH_Group.idl \ + SALOMEDS.idl \ + SALOMEDS_Attributes.idl \ + SALOME_ModuleCatalog.idl \ + SALOME_Component.idl \ + SMESH_Filter.idl \ + SMESH_Pattern.idl \ + SALOME_GenericObj.idl # header files EXPORT_HEADERS= SMESH_Type.h \ SMESH_TypeFilter.hxx \ - Handle_SMESH_TypeFilter.hxx + Handle_SMESH_TypeFilter.hxx \ + SMESH_NumberFilter.hxx \ + SMESH_LogicalFilter.hxx # additionnal information to compil and link file -CPPFLAGS += $(OCC_INCLUDES) $(QT_INCLUDES) $(PYTHON_INCLUDES) $(VTK_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome -LDFLAGS += $(OCC_KERNEL_LIBS) +CPPFLAGS += $(OCC_INCLUDES) $(QT_INCLUDES) $(PYTHON_INCLUDES) $(VTK_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome +CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome +LDFLAGS += $(OCC_KERNEL_LIBS) -L${GEOM_ROOT_DIR}/lib/salome # additional file to be cleaned MOSTLYCLEAN = diff --git a/src/SMESHFiltersSelection/SMESH_LogicalFilter.cxx b/src/SMESHFiltersSelection/SMESH_LogicalFilter.cxx new file mode 100644 index 000000000..47b6356ae --- /dev/null +++ b/src/SMESHFiltersSelection/SMESH_LogicalFilter.cxx @@ -0,0 +1,148 @@ +// SALOME SALOMEGUI : implementation of desktop and GUI kernel +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESH_LogicalFilter.cxx +// Author : Sergey LITONIN +// Module : SMESH + +#include "SMESH_LogicalFilter.hxx" + +/* + Class : SMESH_LogicalFilter + Description : Filter for combaining several filters with logical operation (OR or AND) +*/ + +IMPLEMENT_STANDARD_HANDLE( SMESH_LogicalFilter, SALOME_Filter ) +IMPLEMENT_STANDARD_RTTIEXT( SMESH_LogicalFilter, SALOME_Filter ) + +//======================================================================= +// name : SMESH_LogicalFilter::SMESH_LogicalFilter +// Purpose : Constructor +//======================================================================= +SMESH_LogicalFilter::SMESH_LogicalFilter( const SMESH_ListOfFilter& theFilters, + const int theLogOp ) +{ + myFilters = theFilters; + myLogOp = theLogOp; +} + +//======================================================================= +// name : SMESH_LogicalFilter::~SMESH_LogicalFilter +// Purpose : Destructor +//======================================================================= +SMESH_LogicalFilter::~SMESH_LogicalFilter() +{ +} + +//======================================================================= +// name : SMESH_LogicalFilter::IsOk +// Purpose : Verify validity of entry object +//======================================================================= +Standard_Boolean SMESH_LogicalFilter::IsOk( const Handle(SALOME_InteractiveObject)& theIO ) const +{ + SMESH_ListOfFilter::Iterator anIter( myFilters ); + for ( ; anIter.More(); anIter.Next() ) + { + Handle(SALOME_Filter) aFilter = anIter.Value(); + if ( !aFilter.IsNull() ) + { + if ( myLogOp == LO_OR && anIter.Value()->IsOk( theIO ) ) + return true; + if ( myLogOp == LO_AND && !anIter.Value()->IsOk( theIO ) ) + return false; + } + } + + return myLogOp == LO_OR ? false : true; +} + +//======================================================================= +// name : SMESH_LogicalFilter::SetFilters +// Purpose : Set new list of filters. Old wilters are removed +//======================================================================= +void SMESH_LogicalFilter::SetFilters( const SMESH_ListOfFilter& theFilters ) +{ + myFilters = theFilters; +} + +//======================================================================= +// name : SMESH_LogicalFilter::SetLogOp +// Purpose : Set logical operation +//======================================================================= +void SMESH_LogicalFilter::SetLogOp( const int theLogOp ) +{ + myLogOp = theLogOp; +} + +//======================================================================= +// name : SMESH_LogicalFilter::GetFilters +// Purpose : Get list of filters +//======================================================================= +const SMESH_ListOfFilter& SMESH_LogicalFilter::GetFilters() const +{ + return myFilters; +} + +//======================================================================= +// name : SMESH_LogicalFilter::GetLogOp +// Purpose : Get logical operation +//======================================================================= +int SMESH_LogicalFilter::GetLogOp() const +{ + return myLogOp; +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SMESHFiltersSelection/SMESH_LogicalFilter.hxx b/src/SMESHFiltersSelection/SMESH_LogicalFilter.hxx new file mode 100644 index 000000000..ec10f865b --- /dev/null +++ b/src/SMESHFiltersSelection/SMESH_LogicalFilter.hxx @@ -0,0 +1,102 @@ +// SALOME SALOMEGUI : implementation of desktop and GUI kernel +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESH_LogicalFilter.hxx +// Author : Sergey LITONIN +// Module : SMESH + +#ifndef _SMESH_LogicalFilter_HeaderFile +#define _SMESH_LogicalFilter_HeaderFile + +#include "SALOME_Filter.hxx" + +#include +#include +#include + +DEFINE_STANDARD_HANDLE( SMESH_LogicalFilter, SALOME_Filter ) + +DEFINE_BASECOLLECTION( SMESH_FilterColl, Handle(SALOME_Filter) ) +DEFINE_LIST( SMESH_ListOfFilter, SMESH_FilterColl, Handle(SALOME_Filter) ) + + +/* + Class : SMESH_LogicalFilter + Description : Filter for combaining several filters with logical operation (OR or AND) +*/ + +class SMESH_LogicalFilter : public SALOME_Filter +{ +public: + + enum { LO_OR, LO_AND, LO_UNDEFINED }; + +public: + + SMESH_LogicalFilter( const SMESH_ListOfFilter&, const int ); + + + virtual ~SMESH_LogicalFilter(); + virtual Standard_Boolean IsOk( const Handle(SALOME_InteractiveObject)& ) const; + + void SetFilters( const SMESH_ListOfFilter& ); + void SetLogOp( const int ); + const SMESH_ListOfFilter& GetFilters() const; + int GetLogOp() const; + +private: + + SMESH_ListOfFilter myFilters; + int myLogOp; + +public: + DEFINE_STANDARD_RTTI( SMESH_LogicalFilter ) +}; + +#endif + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SMESHFiltersSelection/SMESH_NumberFilter.cxx b/src/SMESHFiltersSelection/SMESH_NumberFilter.cxx new file mode 100644 index 000000000..8a7c43a58 --- /dev/null +++ b/src/SMESHFiltersSelection/SMESH_NumberFilter.cxx @@ -0,0 +1,225 @@ +// SALOME SALOMEGUI : implementation of desktop and GUI kernel +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESH_NumberFilter.cxx +// Author : Sergey LITONIN +// Module : SMESH + +#include "SMESH_NumberFilter.hxx" +#include "GEOMBase.h" +#include "TopTools_MapOfShape.hxx" +#include "TopExp_Explorer.hxx" +#include "SALOME_InteractiveObject.hxx" +#include "QAD_Application.h" +#include "QAD_Desktop.h" + + +/* + Class : SMESH_NumberFilter + Description : Filter for geom objects. + Filter geom objects by number of subshapes of the given type +*/ + +IMPLEMENT_STANDARD_HANDLE( SMESH_NumberFilter, SALOME_TypeFilter ) +IMPLEMENT_STANDARD_RTTIEXT( SMESH_NumberFilter, SALOME_TypeFilter ) + +//======================================================================= +// name : SMESH_NumberFilter::SMESH_NumberFilter +// Purpose : Constructor +//======================================================================= +SMESH_NumberFilter::SMESH_NumberFilter( const char* theKind, + const TopAbs_ShapeEnum theSubShapeType, + const int theNumber, + const TopAbs_ShapeEnum theShapeType, + GEOM::GEOM_Object_ptr theMainObj, + const bool theIsClosedOnly ) +: SALOME_TypeFilter( (char*)theKind ) +{ + mySubShapeType = theSubShapeType; + myNumber = theNumber; + myIsClosedOnly = theIsClosedOnly; + myShapeTypes.Add( theShapeType ); + myMainObj = GEOM::GEOM_Object::_duplicate( theMainObj ); +} + +//======================================================================= +// name : SMESH_NumberFilter::SMESH_NumberFilter +// Purpose : Constructor +//======================================================================= +SMESH_NumberFilter::SMESH_NumberFilter( const char* theKind, + const TopAbs_ShapeEnum theSubShapeType, + const int theNumber, + const TColStd_MapOfInteger& theShapeTypes, + GEOM::GEOM_Object_ptr theMainObj, + const bool theIsClosedOnly ) +: SALOME_TypeFilter( (char*)theKind ) +{ + mySubShapeType = theSubShapeType; + myNumber = theNumber; + myIsClosedOnly = theIsClosedOnly; + myShapeTypes = theShapeTypes; + myMainObj = GEOM::GEOM_Object::_duplicate( theMainObj ); +} + +SMESH_NumberFilter::~SMESH_NumberFilter() +{ +} + +//======================================================================= +// name : SMESH_NumberFilter::SMESH_NumberFilter +// Purpose : Verify validity of entry object +//======================================================================= +Standard_Boolean SMESH_NumberFilter::IsOk( const Handle(SALOME_InteractiveObject)& theObj ) const +{ + if ( theObj.IsNull() || !SALOME_TypeFilter::IsOk( theObj ) ) + return false; + + // Get geom object from IO + GEOM::GEOM_Object_var aGeomObj = getGeom( theObj ); + if ( aGeomObj->_is_nil() ) + return false; + + // Get shape from geom object and verify its parameters + TopoDS_Shape aShape; + if ( !GEOMBase::GetShape( aGeomObj, aShape ) || + aShape.IsNull() || + !myShapeTypes.Contains( aShape.ShapeType() ) || + myIsClosedOnly && aShape.ShapeType() == TopAbs_SHELL && !aShape.Closed() ) + return false; + + // Verify whether shape of entry object is sub-shape of myMainObj + if ( !myMainObj->_is_nil() ) + { + TopoDS_Shape aMainShape; + if ( !GEOMBase::GetShape( myMainObj, aMainShape ) ) + return false; + + bool isFound = false; + TopAbs_ShapeEnum aShapeType = aShape.ShapeType(); + TopExp_Explorer anExp( aMainShape, aShapeType ); + for ( ; anExp.More(); anExp.Next() ) + if ( anExp.Current() == aShape ) + { + isFound = true; + break; + } + if ( !isFound ) + return false; + } + // Verify number of sub-shapes + if ( mySubShapeType == TopAbs_SHAPE ); + return true; + + int nbShapes = 0; + TopExp_Explorer anExp2( aShape, mySubShapeType ); + TopTools_MapOfShape aMap; + for ( ; anExp2.More(); anExp2.Next() ) + aMap.Add( anExp2.Current() ); + + return myNumber == aMap.Extent(); +} + +//======================================================================= +// name : SMESH_NumberFilter::getGeom +// Purpose : Retrieve geom object from SALOME_InteractiveObject +//======================================================================= +GEOM::GEOM_Object_ptr SMESH_NumberFilter::getGeom( + const Handle(SALOME_InteractiveObject)& theObj ) const +{ + if ( theObj->isComponentType( "GEOM" ) ) + { + Standard_Boolean aRes = Standard_False; + GEOM::GEOM_Object_var aGeomObj = GEOMBase::ConvertIOinGEOMObject( theObj, aRes ); + return aRes ? aGeomObj._retn() : GEOM::GEOM_Object::_nil(); + } + else + { + // Get geom object corresponding to the mesh + SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); + SALOMEDS::SObject_var aSO = aStudy->FindObjectID( theObj->getEntry() ); + if ( aSO->_is_nil() ) + return GEOM::GEOM_Object::_nil(); + + SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator( aSO ); + for( ; anIter->More(); anIter->Next() ) + { + SALOMEDS::SObject_var aSO = anIter->Value(); + SALOMEDS::SObject_var aRefSO; + + GEOM::GEOM_Object_var aMeshShape = GEOM::GEOM_Object::_narrow( + aSO->ReferencedObject( aRefSO )? aRefSO->GetObject() : aSO->GetObject() ); + + if ( !aMeshShape->_is_nil() ) + return aMeshShape._retn(); + } + + return GEOM::GEOM_Object::_nil(); + } +} + + +void SMESH_NumberFilter::SetSubShapeType( const TopAbs_ShapeEnum theSubShapeType ) +{ + mySubShapeType = theSubShapeType; +} + +void SMESH_NumberFilter::SetNumber( const int theNumber ) +{ + myNumber = theNumber; +} + +void SMESH_NumberFilter::SetClosedOnly( const bool theIsClosedOnly ) +{ + myIsClosedOnly = theIsClosedOnly; +} + +void SMESH_NumberFilter::SetShapeType( const TopAbs_ShapeEnum theShapeType ) +{ + myShapeTypes.Add( theShapeType ); +} + +void SMESH_NumberFilter::SetMainShape( GEOM::GEOM_Object_ptr theMainObj ) +{ + myMainObj = GEOM::GEOM_Object::_duplicate( theMainObj ); +} + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SMESHFiltersSelection/SMESH_NumberFilter.hxx b/src/SMESHFiltersSelection/SMESH_NumberFilter.hxx new file mode 100644 index 000000000..a4fc8df16 --- /dev/null +++ b/src/SMESHFiltersSelection/SMESH_NumberFilter.hxx @@ -0,0 +1,124 @@ +// SALOME SALOMEGUI : implementation of desktop and GUI kernel +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESH_NumberFilter.hxx +// Author : Sergey LITONIN +// Module : SMESH + +#ifndef _SMESH_NumberFilter_HeaderFile +#define _SMESH_NumberFilter_HeaderFile + +#include +#include "SALOME_TypeFilter.hxx" +#include +#include + +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) +#include CORBA_SERVER_HEADER(GEOM_Gen) + +DEFINE_STANDARD_HANDLE( SMESH_NumberFilter, SALOME_TypeFilter ) + +/* + Class : SMESH_NumberFilter + Description : Filter for geom or smesh objects. + Filter geom objects by number of subshapes of the given type + Parameters of constructor: + * theSubShapeType - Type of subshape + * theNumber - Number of subshapes. Object is selected if it contains theNumber of + theSubShapeType sub-shapes + * theShapeType - This map specifies types of object to be selected + * theMainObject - Sub-shapes of this object is selected only + * theIsClosedOnly - Closed shapes is selected if this parameter is true +*/ +class SMESH_NumberFilter : public SALOME_TypeFilter +{ + +public: + + SMESH_NumberFilter( const char* theKind, + const TopAbs_ShapeEnum theSubShapeType, + const int theNumber, + const TopAbs_ShapeEnum theShapeType = TopAbs_SHAPE, + GEOM::GEOM_Object_ptr theMainObj = GEOM::GEOM_Object::_nil(), + const bool theIsClosedOnly = false ); + + SMESH_NumberFilter( const char* theKind, + const TopAbs_ShapeEnum theSubShapeType, + const int theNumber, + const TColStd_MapOfInteger& theShapeTypes, + GEOM::GEOM_Object_ptr theMainObj = GEOM::GEOM_Object::_nil(), + const bool theIsClosedOnly = false ); + + virtual ~SMESH_NumberFilter(); + virtual Standard_Boolean IsOk( const Handle(SALOME_InteractiveObject)& ) const; + + void SetSubShapeType( const TopAbs_ShapeEnum ); + void SetNumber( const int ); + void SetClosedOnly( const bool ); + void SetShapeType( const TopAbs_ShapeEnum ); + void SetShapeTypes( const TColStd_MapOfInteger& ); + void SetMainShape( GEOM::GEOM_Object_ptr ); + +private: + GEOM::GEOM_Object_ptr getGeom( const Handle(SALOME_InteractiveObject)& theObj ) const; + + +private: + TopAbs_ShapeEnum mySubShapeType; + int myNumber; + bool myIsClosedOnly; + TColStd_MapOfInteger myShapeTypes; + GEOM::GEOM_Object_var myMainObj; + +public: + DEFINE_STANDARD_RTTI( SMESH_NumberFilter ) +}; + +#endif + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx b/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx index 6514bfd80..9f17ae1b4 100644 --- a/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx +++ b/src/SMESHFiltersSelection/SMESH_TypeFilter.cxx @@ -1,4 +1,3 @@ -using namespace std; // File : SMESH_TypeFilter.cxx // Created : Fri Dec 07 09:57:24 2001 // Author : Nicolas REJNERI @@ -17,6 +16,7 @@ using namespace std; #include "QAD_Desktop.h" #include "QAD_Study.h" +using namespace std; SMESH_TypeFilter::SMESH_TypeFilter(MeshObjectType aType) { @@ -25,7 +25,7 @@ SMESH_TypeFilter::SMESH_TypeFilter(MeshObjectType aType) Standard_Boolean SMESH_TypeFilter::IsOk(const Handle(SALOME_InteractiveObject)& anObj) const { - Handle(SALOME_TypeFilter) meshFilter = new SALOME_TypeFilter( "MESH" ); + Handle(SALOME_TypeFilter) meshFilter = new SALOME_TypeFilter( "SMESH" ); if ( !meshFilter->IsOk(anObj) ) return false; @@ -39,78 +39,93 @@ Standard_Boolean SMESH_TypeFilter::IsOk(const Handle(SALOME_InteractiveObject)& SALOMEDS::SObject_var objFather = obj->GetFather(); SALOMEDS::SComponent_var objComponent = obj->GetFatherComponent(); - if ( strlen( obj->GetID() ) <= strlen( objComponent->GetID() ) ) + int aLevel = obj->Depth() - objComponent->Depth(); + + // Max level under the component is 4: + // + // 0 Mesh Component + // 1 |- Hypotheses + // 2 | |- Regular 1D + // |- Algorithms + // |- Mesh 1 + // |- Applied Hypotheses + // |- Applied Algorithms + // |- Submeshes on Face + // 3 | |- SubmeshFace + // 4 | |- Applied algorithms ( selectable in Use Case Browser ) + // |- Group Of Nodes + + if ( aLevel <= 0 ) return false; switch ( myKind ) { case HYPOTHESIS: { - if (( objFather->Tag() == 1 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) ) + if ( aLevel == 2 && ( objFather->Tag() == 1 )) Ok = true; break; } case ALGORITHM: { - if (( objFather->Tag() == 2 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) ) + if ( aLevel == 2 && ( objFather->Tag() == 2 )) Ok = true; break; } case MESH: { - if (( obj->Tag() >= 3 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) == 0 ) ) + if ( aLevel == 1 && ( obj->Tag() >= 3 )) Ok = true; break; } case SUBMESH: { - if (( objFather->Tag() >= 4 && objFather->Tag() < 9 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) ) + // see SMESH_Gen_i.cxx for tag numbers + if ( aLevel == 3 && ( objFather->Tag() >= 4 && objFather->Tag() <= 10 )) Ok = true; break; } case MESHorSUBMESH: { - if (( obj->Tag() >= 3 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) == 0 ) ) + if ( aLevel == 1 && ( obj->Tag() >= 3 )) + Ok = true; // mesh + else if ( aLevel == 3 && ( objFather->Tag() >= 4 && objFather->Tag() <= 10 )) Ok = true; - - if (( objFather->Tag() >= 4 && objFather->Tag() < 9 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) ) - Ok = true; - break; } case SUBMESH_VERTEX: // Label "SubMeshes on vertexes" { - if (( obj->Tag() == 4 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 )) + if ( aLevel == 3 && ( objFather->Tag() == 4 )) Ok = true; break; } case SUBMESH_EDGE: { - if (( obj->Tag() == 5 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 )) + if ( aLevel == 3 && ( objFather->Tag() == 5 )) Ok = true; break; } case SUBMESH_FACE: { - if (( obj->Tag() == 6 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 )) + if ( aLevel == 3 && ( objFather->Tag() == 7 )) Ok = true; break; } case SUBMESH_SOLID: { - if (( obj->Tag() == 7 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 )) + if ( aLevel == 3 && ( objFather->Tag() == 9 )) Ok = true; break; } case SUBMESH_COMPOUND: { - if (( obj->Tag() == 8 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) && ( objFather->Tag() >= 3 )) + if ( aLevel == 3 && ( objFather->Tag() == 10 )) Ok = true; break; } case GROUP: { - if (( objFather->Tag() >= 9 ) && (strcmp( objFather->GetID(), objComponent->GetID() ) != 0 ) ) + if ( aLevel == 3 && ( objFather->Tag() > 10 )) Ok = true; break; } diff --git a/src/SMESHGUI/Makefile.in b/src/SMESHGUI/Makefile.in index a183879da..973071422 100644 --- a/src/SMESHGUI/Makefile.in +++ b/src/SMESHGUI/Makefile.in @@ -38,9 +38,12 @@ VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl EXPORT_HEADERS= SMESHGUI_Swig.hxx \ SMESHGUI_Swig.i \ SMESHGUI.h \ + SMESHGUI_Utils.h \ SMESHGUI_Hypotheses.h \ + SMESHGUI_HypothesesUtils.h \ SMESHGUI_SpinBox.h \ - SMESHGUI_StudyAPI.h + SMESHGUI_aParameter.h \ + SMESHGUI_aParameterDlg.h # .po files to transform in .qm PO_FILES = \ @@ -50,14 +53,15 @@ PO_FILES = \ # Libraries targets LIB = libSMESHGUI.la LIB_SRC = SMESHGUI.cxx \ - SMESHGUI_StudyAPI.cxx \ + SMESHGUI_PatternWidget.cxx \ + SMESHGUI_CreatePatternDlg.cxx \ + SMESHGUI_MeshPatternDlg.cxx \ SMESHGUI_SpinBox.cxx \ SMESHGUI_NodesDlg.cxx \ - SMESHGUI_AddHypothesisDlg.cxx \ - SMESHGUI_AddAlgorithmDlg.cxx \ SMESHGUI_InitMeshDlg.cxx \ SMESHGUI_AddSubMeshDlg.cxx \ SMESHGUI_TransparencyDlg.cxx \ + SMESHGUI_ClippingDlg.cxx \ SMESHGUI_GroupDlg.cxx \ SMESHGUI_RemoveNodesDlg.cxx \ SMESHGUI_RemoveElementsDlg.cxx \ @@ -67,28 +71,50 @@ LIB_SRC = SMESHGUI.cxx \ SMESHGUI_Preferences_SelectionDlg.cxx \ SMESHGUI_aParameterDlg.cxx \ SMESHGUI_Swig.cxx \ - SMESHGUI_ComputeScalarValue.cxx \ SMESHGUI_MoveNodesDlg.cxx \ - SMESHGUI_OrientationElementsDlg.cxx \ - SMESHGUI_DiagonalInversionDlg.cxx \ - SMESHGUI_AddFaceDlg.cxx \ - SMESHGUI_AddVolumeDlg.cxx \ - SMESHGUI_AddEdgeDlg.cxx \ + SMESHGUI_AddMeshElementDlg.cxx \ SMESHGUI_EditHypothesesDlg.cxx \ SMESHGUI_CreateHypothesesDlg.cxx \ SMESHGUI_XmlHandler.cxx \ SMESHGUI_Filter.cxx \ - SMESHGUI_FilterDlg.cxx + SMESHGUI_FilterDlg.cxx \ + SMESHGUI_FilterLibraryDlg.cxx \ + SMESHGUI_SingleEditDlg.cxx \ + SMESHGUI_MultiEditDlg.cxx \ + SMESHGUI_aParameter.cxx \ + SMESHGUI_DeleteGroupDlg.cxx \ + SMESHGUI_GroupOpDlg.cxx \ + SMESHGUI_SmoothingDlg.cxx \ + SMESHGUI_RenumberingDlg.cxx \ + SMESHGUI_ExtrusionDlg.cxx \ + SMESHGUI_RevolutionDlg.cxx \ + SMESHGUI_RotationDlg.cxx \ + SMESHGUI_TranslationDlg.cxx \ + SMESHGUI_SymmetryDlg.cxx \ + SMESHGUI_SewingDlg.cxx \ + SMESHGUI_MergeNodesDlg.cxx \ + SMESHGUI_Utils.cxx \ + SMESHGUI_SMESHGenUtils.cxx \ + SMESHGUI_GEOMGenUtils.cxx \ + SMESHGUI_MeshUtils.cxx \ + SMESHGUI_GroupUtils.cxx \ + SMESHGUI_FilterUtils.cxx \ + SMESHGUI_PatternUtils.cxx \ + SMESHGUI_HypothesesUtils.cxx \ + SMESHGUI_PrecisionDlg.cxx \ + SMESHGUI_VTKUtils.cxx LIB_MOC = \ SMESHGUI.h \ + SMESHGUI_PatternWidget.h \ + SMESHGUI_MeshPatternDlg.h \ + SMESHGUI_CreatePatternDlg.h \ SMESHGUI_NodesDlg.h \ SMESHGUI_SpinBox.h \ - SMESHGUI_AddHypothesisDlg.h \ - SMESHGUI_AddAlgorithmDlg.h \ SMESHGUI_InitMeshDlg.h \ SMESHGUI_AddSubMeshDlg.h \ SMESHGUI_TransparencyDlg.h \ + SMESHGUI_ClippingDlg.h \ SMESHGUI_GroupDlg.h \ SMESHGUI_RemoveNodesDlg.h \ SMESHGUI_RemoveElementsDlg.h \ @@ -98,18 +124,28 @@ LIB_MOC = \ SMESHGUI_Preferences_SelectionDlg.h \ SMESHGUI_aParameterDlg.h \ SMESHGUI_MoveNodesDlg.h \ - SMESHGUI_OrientationElementsDlg.h \ - SMESHGUI_DiagonalInversionDlg.h \ - SMESHGUI_AddEdgeDlg.h \ - SMESHGUI_AddVolumeDlg.h \ - SMESHGUI_AddFaceDlg.h \ + SMESHGUI_AddMeshElementDlg.h \ SMESHGUI_EditHypothesesDlg.h \ SMESHGUI_CreateHypothesesDlg.h \ - SMESHGUI_FilterDlg.h - + SMESHGUI_FilterDlg.h \ + SMESHGUI_FilterLibraryDlg.h \ + SMESHGUI_SingleEditDlg.h \ + SMESHGUI_MultiEditDlg.h \ + SMESHGUI_DeleteGroupDlg.h \ + SMESHGUI_GroupOpDlg.h \ + SMESHGUI_SmoothingDlg.h \ + SMESHGUI_RenumberingDlg.h \ + SMESHGUI_ExtrusionDlg.h \ + SMESHGUI_RevolutionDlg.h \ + SMESHGUI_RotationDlg.h \ + SMESHGUI_TranslationDlg.h \ + SMESHGUI_SymmetryDlg.h \ + SMESHGUI_SewingDlg.h \ + SMESHGUI_PrecisionDlg.h \ + SMESHGUI_MergeNodesDlg.h + LIB_CLIENT_IDL = SALOME_Exception.idl \ GEOM_Gen.idl \ - GEOM_Shape.idl \ SMESH_Gen.idl \ SMESH_Mesh.idl \ SMESH_Hypothesis.idl \ @@ -120,18 +156,25 @@ LIB_CLIENT_IDL = SALOME_Exception.idl \ SALOME_Component.idl \ MED.idl \ SMESH_Filter.idl \ - SALOME_GenericObj.idl + SMESH_Pattern.idl \ + SALOME_GenericObj.idl \ + SALOME_Comm.idl LIB_SERVER_IDL = # additionnal information to compil and link file +#BIN = SMESHBin + CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) \ $(MED2_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome \ $(BOOST_CPPFLAGS) + CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome -#$(OCC_CXXFLAGS) -LDFLAGS += -lOCCViewer -lVTKViewer -lSalomeObject -lSalomeGUI -lSMESHObject -lSMDS -lSMESHDS -lSMESHFiltersSelection -lGEOMClient -lMeshDriverDAT -lMeshDriverMED -lMeshDriverUNV $(OCC_KERNEL_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome -L${GEOM_ROOT_DIR}/lib/salome -lSalomeGenericObj + +LDFLAGS += -lSMESHObject -lSMESHFiltersSelection -lSMDS -lSMESHControls -lDlgRef $(OCC_KERNEL_LIBS) -lTKBO -L${KERNEL_ROOT_DIR}/lib/salome -lVTKViewer -lSalomeGUI -lSalomePrs -lSalomeNS -lqsplitterP -lSalomeLifeCycleCORBA -lOpUtil -lSalomeObject -lEvent -lSALOMELocalTrace -lSalomeVTKFilter -lOCCViewer -L${GEOM_ROOT_DIR}/lib/salome -lGEOMGUI -lGEOMClient -lGEOMFiltersSelection -lGEOMBase -lGEOMObject + +LDFLAGSFORBIN += $(LDFLAGS) @CONCLUDE@ diff --git a/src/SMESHGUI/SMESHBin.cxx b/src/SMESHGUI/SMESHBin.cxx new file mode 100644 index 000000000..61f9777fe --- /dev/null +++ b/src/SMESHGUI/SMESHBin.cxx @@ -0,0 +1,4 @@ +int main(int argc, char** argv){ + return 0; +} + diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 4d94be4c8..49baea8a3 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -25,12 +25,11 @@ // $Header$ #include "SMESHGUI.h" -#include "SMESHGUI_AddHypothesisDlg.h" -#include "SMESHGUI_AddAlgorithmDlg.h" #include "SMESHGUI_InitMeshDlg.h" #include "SMESHGUI_AddSubMeshDlg.h" #include "SMESHGUI_NodesDlg.h" #include "SMESHGUI_TransparencyDlg.h" +#include "SMESHGUI_ClippingDlg.h" #include "SMESHGUI_GroupDlg.h" #include "SMESHGUI_RemoveNodesDlg.h" #include "SMESHGUI_RemoveElementsDlg.h" @@ -38,26 +37,37 @@ #include "SMESHGUI_Preferences_ColorDlg.h" #include "SMESHGUI_Preferences_ScalarBarDlg.h" #include "SMESHGUI_Preferences_SelectionDlg.h" -#include "SMESHGUI_aParameterDlg.h" -#include "SMESHGUI_ComputeScalarValue.h" +#include "SMESHGUI_Hypotheses.h" +#include "SMESHGUI_HypothesesUtils.h" #include "SMESHGUI_MoveNodesDlg.h" -#include "SMESHGUI_OrientationElementsDlg.h" -#include "SMESHGUI_DiagonalInversionDlg.h" -#include "SMESHGUI_AddFaceDlg.h" -#include "SMESHGUI_AddEdgeDlg.h" -#include "SMESHGUI_AddVolumeDlg.h" +#include "SMESHGUI_AddMeshElementDlg.h" #include "SMESHGUI_EditHypothesesDlg.h" #include "SMESHGUI_CreateHypothesesDlg.h" #include "SMESHGUI_FilterDlg.h" -#include "SMESHGUI_XmlHandler.h" +#include "SMESHGUI_FilterLibraryDlg.h" +#include "SMESHGUI_SingleEditDlg.h" +#include "SMESHGUI_MultiEditDlg.h" +#include "SMESHGUI_GroupOpDlg.h" +#include "SMESHGUI_DeleteGroupDlg.h" +#include "SMESHGUI_SmoothingDlg.h" +#include "SMESHGUI_RenumberingDlg.h" +#include "SMESHGUI_ExtrusionDlg.h" +#include "SMESHGUI_RevolutionDlg.h" +#include "SMESHGUI_TranslationDlg.h" +#include "SMESHGUI_RotationDlg.h" +#include "SMESHGUI_SymmetryDlg.h" +#include "SMESHGUI_SewingDlg.h" +#include "SMESHGUI_MergeNodesDlg.h" +#include "SMESHGUI_MeshPatternDlg.h" +#include "SMESHGUI_PrecisionDlg.h" + +#include "VTKViewer_ViewFrame.h" +#include "VTKViewer_InteractorStyleSALOME.h" +#include "VTKViewer_RenderWindowInteractor.h" #include "SMESH_Actor.h" #include "SMESH_Object.h" -// SALOME Includes -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" - #include "QAD.h" #include "QAD_Tools.h" #include "QAD_Config.h" @@ -70,12 +80,6 @@ #include "QAD_ResourceMgr.h" #include "QAD_WaitCursor.h" -#include "OCCViewer_ViewPort.h" -#include "OCCViewer_ViewPort3d.h" -#include "OCCViewer_Viewer3d.h" - -#include "GEOM_InteractiveObject.hxx" - #include "SALOME_NamingService.hxx" #include "SALOME_ListIteratorOfListIO.hxx" #include "SALOME_InteractiveObject.hxx" @@ -85,28 +89,17 @@ #include "SALOMEGUI_ImportOperation.h" #include "SALOMEGUI_QtCatchCorbaException.hxx" -#include "utilities.h" -#include - -#include "SMDS_Mesh.hxx" -#include "SMESHDS_Document.hxx" -#include "Document_Reader.h" -#include "Document_Writer.h" -#include "Mesh_Reader.h" -#include "Mesh_Writer.h" - -#include "DriverDAT_R_SMESHDS_Document.h" -#include "DriverMED_R_SMESHDS_Document.h" -#include "DriverUNV_R_SMESHDS_Document.h" -#include "DriverDAT_W_SMESHDS_Document.h" -#include "DriverMED_W_SMESHDS_Document.h" -#include "DriverUNV_W_SMESHDS_Document.h" -#include "DriverDAT_R_SMESHDS_Mesh.h" -#include "DriverMED_R_SMESHDS_Mesh.h" -#include "DriverUNV_R_SMESHDS_Mesh.h" -#include "DriverDAT_W_SMESHDS_Mesh.h" -#include "DriverMED_W_SMESHDS_Mesh.h" -#include "DriverUNV_W_SMESHDS_Mesh.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_SMESHGenUtils.h" +#include "SMESHGUI_GEOMGenUtils.h" +#include "SMESHGUI_MeshUtils.h" +#include "SMESHGUI_GroupUtils.h" +#include "SMESHGUI_FilterUtils.h" +#include "SMESHGUI_PatternUtils.h" +#include "SMESHGUI_VTKUtils.h" + +#include "SALOMEconfig.h" +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) // QT Includes #define INCLUDE_MENUITEM_DEF @@ -117,6 +110,7 @@ #include #include #include +#include #include #include #include @@ -125,370 +119,594 @@ #include #include -// VTK Includes -#include "VTKViewer_Common.h" -#include "VTKViewer_ViewFrame.h" -#include "VTKViewer_InteractorStyleSALOME.h" +#include +#include +#include +#include #include -#include -#include -#include -#include -// Open CASCADE Includes -#include -#include +#include "utilities.h" -#include +using namespace std; -static SMESHGUI *smeshGUI = 0; -static CORBA::ORB_var _orb; +namespace{ + // Decalarations + //============================================================= + void ImportMeshesFromFile(QAD_Desktop * parent, + SMESH::SMESH_Gen_ptr theComponentMesh, + int theCommandID); -using namespace std; + void ExportMeshToFile(QAD_Desktop * parent, int theCommandID); -typedef pair TKeyOfVisualObj; -typedef boost::shared_ptr TVisualObjPtr; -typedef map TVisualObjCont; -static TVisualObjCont VISUALOBJCONT; - - -TVisualObjPtr GetVisualObj(int theStudyId, const char* theEntry){ - TVisualObjPtr aVisualObj; - try{ - TVisualObjCont::key_type aKey(theStudyId,theEntry); - TVisualObjCont::iterator anIter = VISUALOBJCONT.find(aKey); - if(anIter != VISUALOBJCONT.end()){ - aVisualObj = anIter->second; - }else{ - SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); - SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theEntry); - if(!CORBA::is_nil(aSObj)){ - SALOMEDS::GenericAttribute_var anAttr; - if(aSObj->FindAttribute(anAttr,"AttributeIOR")){ - SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - CORBA::String_var aVal = anIOR->Value(); - CORBA::Object_var anObj =_orb->string_to_object(aVal.in()); - if(!CORBA::is_nil(anObj)){ - //Try narrow to SMESH_Mesh interafce - SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(anObj); - if(!aMesh->_is_nil()){ - aVisualObj.reset(new SMESH_MeshObj(aMesh)); - aVisualObj->Update(); - TVisualObjCont::value_type aValue(aKey,aVisualObj); - VISUALOBJCONT.insert(aValue); - return aVisualObj; - } - //Try narrow to SMESH_Group interafce - SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_narrow(anObj); - if(!aGroup->_is_nil()){ - SALOMEDS::SObject_var aFatherSObj = aSObj->GetFather(); - if(aFatherSObj->_is_nil()) return aVisualObj; - aFatherSObj = aFatherSObj->GetFather(); - if(aFatherSObj->_is_nil()) return aVisualObj; - CORBA::String_var anEntry = aFatherSObj->GetID(); - TVisualObjPtr aVisObj = GetVisualObj(theStudyId,anEntry.in()); - if(SMESH_MeshObj* aMeshObj = dynamic_cast(aVisObj.get())){ - aVisualObj.reset(new SMESH_GroupObj(aGroup,aMeshObj)); - aVisualObj->Update(); - TVisualObjCont::value_type aValue(aKey,aVisualObj); - VISUALOBJCONT.insert(aValue); - return aVisualObj; - } - } - //Try narrow to SMESH_subMesh interafce - SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(anObj); - if(!aSubMesh->_is_nil()){ - SALOMEDS::SObject_var aFatherSObj = aSObj->GetFather(); - if(aFatherSObj->_is_nil()) return aVisualObj; - aFatherSObj = aFatherSObj->GetFather(); - if(aFatherSObj->_is_nil()) return aVisualObj; - CORBA::String_var anEntry = aFatherSObj->GetID(); - TVisualObjPtr aVisObj = GetVisualObj(theStudyId,anEntry.in()); - if(SMESH_MeshObj* aMeshObj = dynamic_cast(aVisObj.get())){ - aVisualObj.reset(new SMESH_subMeshObj(aSubMesh,aMeshObj)); - aVisualObj->Update(); - TVisualObjCont::value_type aValue(aKey,aVisualObj); - VISUALOBJCONT.insert(aValue); - return aVisualObj; - } + void SetViewMode(int theCommandID); + + void Control( int theCommandID ); + + void SetDisplaySettings(); + + + // Definitions + //============================================================= + void ImportMeshesFromFile(QAD_Desktop * parent, + SMESH::SMESH_Gen_ptr theComponentMesh, + int theCommandID) + { + QString filter; + string myExtension; + + if(theCommandID == 113){ + filter = QObject::tr("MED files (*.med)"); + }else if (theCommandID == 112){ + filter = QObject::tr("IDEAS files (*.unv)"); + }else if (theCommandID == 111){ + filter = QObject::tr("DAT files (*.dat)"); + } + QString filename = QAD_FileDlg::getFileName(parent, + "", + filter, + QObject::tr("Import mesh"), + true); + if(!filename.isEmpty()) { + QAD_WaitCursor wc; + SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); + + try { + SMESH::mesh_array_var aMeshes = new SMESH::mesh_array; + switch ( theCommandID ) { + case 112: + { + aMeshes->length( 1 ); + aMeshes[0] = theComponentMesh->CreateMeshesFromUNV(filename.latin1()); + break; + } + case 113: + { + SMESH::DriverMED_ReadStatus res; + aMeshes = theComponentMesh->CreateMeshesFromMED(filename.latin1(),res); + if ( res != SMESH::DRS_OK ) { + wc.stop(); + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + QObject::tr("SMESH_WRN_WARNING"), + QObject::tr(QString("SMESH_DRS_%1").arg(res)), + QObject::tr("SMESH_BUT_OK")); + aMeshes->length( 0 ); + wc.start(); } + break; } } + + bool isEmpty = false; + for ( int i = 0, iEnd = aMeshes->length(); i < iEnd; i++ ) { + SALOMEDS::SObject_var aMeshSO = SMESH::FindSObject( aMeshes[i] ); + if ( !aMeshSO->_is_nil() ) { + SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder(); + SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow( aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" ) ); + aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_IMPORTED"); + if ( theCommandID == 112 ) // mesh names aren't taken from the file for UNV import + SMESH::SetName( aMeshSO, QFileInfo(filename).fileName() ); + } else + isEmpty = true; + } + + if ( isEmpty ) { + wc.stop(); + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + QObject::tr("SMESH_WRN_WARNING"), + QObject::tr("SMESH_DRS_EMPTY"), + QObject::tr("SMESH_BUT_OK")); + wc.start(); + } + } + catch (const SALOME::SALOME_Exception& S_ex){ + wc.stop(); + QtCatchCorbaException(S_ex); + wc.start(); } } - }catch(...){ - INFOS("GetMeshObj - There is no SMESH_Mesh object for the SALOMEDS::Strudy and Entry!!!"); } - return aVisualObj; -} - -VTKViewer_ViewFrame* GetVtkViewFrame(QAD_StudyFrame* theStudyFrame){ - QAD_ViewFrame* aViewFrame = theStudyFrame->getRightFrame()->getViewFrame(); - return dynamic_cast(aViewFrame); -} -void UpdateSelectionProp() { - QAD_Study* aStudy = SMESHGUI::GetSMESHGUI()->GetActiveStudy(); - QList aFrameList = aStudy->getStudyFrames(); - - QString SCr, SCg, SCb; - SCr = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorRed"); - SCg = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorGreen"); - SCb = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorBlue"); - QColor aHiColor = Qt::white; - if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) - aHiColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); - - SCr = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorRed"); - SCg = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorGreen"); - SCb = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorBlue"); - QColor aSelColor = Qt::yellow; - if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) - aSelColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); - QString SW = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectWidth"); - if (SW.isEmpty()) SW = "5"; - - SCr = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorRed"); - SCg = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorGreen"); - SCb = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorBlue"); - QColor aPreColor = Qt::cyan; - if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) - aPreColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); - QString PW = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectWidth"); - if (PW.isEmpty()) PW = "5"; - - QString SP1 = QAD_CONFIG->getSetting("SMESH:SettingsNodeSelectTol"); - if (SP1.isEmpty()) SP1 = "0.025"; - QString SP2 = QAD_CONFIG->getSetting("SMESH:SettingsElementsSelectTol"); - if (SP2.isEmpty()) SP2 = "0.001"; - - for (QAD_StudyFrame* aStudyFrame = aFrameList.first(); aStudyFrame; aStudyFrame = aFrameList.next()) { - if (aStudyFrame->getTypeView() == VIEW_VTK) { - VTKViewer_ViewFrame* aVtkViewFrame = GetVtkViewFrame(aStudyFrame); - if (!aVtkViewFrame) continue; - // update VTK viewer properties - VTKViewer_RenderWindowInteractor* anInteractor = aVtkViewFrame->getRWInteractor(); - if (anInteractor) { - // mesh element selection - anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255., - aSelColor.blue()/255., SW.toInt()); - - // tolerances - anInteractor->SetSelectionTolerance(SP1.toDouble(), SP2.toDouble()); - - // pre-selection - VTKViewer_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME(); - if (aStyle) { - aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255., - aPreColor.blue()/255., PW.toInt()); + void ExportMeshToFile(QAD_Desktop * parent, int theCommandID) + { + SALOME_Selection *aSel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection()); + if(aSel->IObjectCount()){ + Handle(SALOME_InteractiveObject) anIObject = aSel->firstIObject(); + SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface(anIObject); + if ( !aMesh->_is_nil() ) { + QString aFilter, aTitle = QObject::tr("Export mesh"); + switch ( theCommandID ) { + case 122: + aFilter = QObject::tr("MED files (*.med)"); + break; + case 121: + aFilter = QObject::tr("DAT files (*.dat)"); + break; + case 123: { + if(aMesh->NbPyramids()){ + int aRet = QAD_MessageBox::warn2(QAD_Application::getDesktop(), + QObject::tr("SMESH_WRN_WARNING"), + QObject::tr("SMESH_EXPORT_UNV").arg(anIObject->getName()), + QObject::tr("SMESH_BUT_YES"), + QObject::tr("SMESH_BUT_NO"), + 0,1,0); + if(aRet) + return; + } + aFilter = QObject::tr("IDEAS files (*.unv)"); + break; + default: + return; + }} + + QString aFilename = QAD_FileDlg::getFileName(parent, "", aFilter, aTitle, false); + if ( !aFilename.isEmpty() ) { + // Check whether the file already exists and delete it if yes + QFile aFile( aFilename ); + if ( aFile.exists() ) + aFile.remove(); + QAD_WaitCursor wc; + switch ( theCommandID ) { + case 122: + aMesh->ExportMED( aFilename.latin1(), true ); // currently, automatic groups are always created + break; + case 121: + aMesh->ExportDAT( aFilename.latin1() ); + break; + case 123: + aMesh->ExportUNV( aFilename.latin1() ); + break; + default: + break; + } } } - // update actors - vtkRenderer* aRenderer = aVtkViewFrame->getRenderer(); - vtkActorCollection *aCollection = aRenderer->GetActors(); - aCollection->InitTraversal(); - while(vtkActor *anAct = aCollection->GetNextActor()){ - if(SMESH_Actor *anActor = dynamic_cast(anAct)){ - anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255., - aHiColor.blue()/255.); - anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255., - aPreColor.blue()/255.); + } + } + + void SetViewMode(int theCommandID){ + SALOME_Selection *Sel = SALOME_Selection::Selection(SMESH::GetActiveStudy()->getSelection()); + if(Sel->IObjectCount() >= 1){ + switch(theCommandID){ + case 1134:{ + SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); + SMESHGUI_ClippingDlg *aDlg = + new SMESHGUI_ClippingDlg(QAD_Application::getDesktop(),"",false); + return; + } + case 1133:{ + SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); + SMESHGUI_TransparencyDlg *aDlg = + new SMESHGUI_TransparencyDlg(QAD_Application::getDesktop(),"",false); + return; + }} + SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + for(; It.More(); It.Next()){ + Handle(SALOME_InteractiveObject) IObject = It.Value(); + if(IObject->hasEntry()){ + if(SMESH_Actor *anActor = SMESH::FindActorByEntry(IObject->getEntry())){ + switch(theCommandID){ + case 211: + anActor->SetRepresentation(SMESH_Actor::eEdge); + break; + case 212: + anActor->SetRepresentation(SMESH_Actor::eSurface); + break; + case 213: + if(anActor->IsShrunk()) + anActor->UnShrink(); + else + anActor->SetShrink(); + break; + case 215: + anActor->SetRepresentation(SMESH_Actor::ePoint); + break; + case 1132:{ + float color[3]; + anActor->GetSufaceColor(color[0], color[1], color[2]); + int c0 = int (color[0] * 255); + int c1 = int (color[1] * 255); + int c2 = int (color[2] * 255); + QColor c(c0, c1, c2); + + float edgecolor[3]; + anActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]); + c0 = int (edgecolor[0] * 255); + c1 = int (edgecolor[1] * 255); + c2 = int (edgecolor[2] * 255); + QColor e(c0, c1, c2); + + float backfacecolor[3]; + anActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]); + c0 = int (backfacecolor[0] * 255); + c1 = int (backfacecolor[1] * 255); + c2 = int (backfacecolor[2] * 255); + QColor b(c0, c1, c2); + + float nodecolor[3]; + anActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]); + c0 = int (nodecolor[0] * 255); + c1 = int (nodecolor[1] * 255); + c2 = int (nodecolor[2] * 255); + QColor n(c0, c1, c2); + + int Edgewidth = (int)anActor->GetLineWidth(); + if(Edgewidth == 0) + Edgewidth = 1; + int intValue = int(anActor->GetNodeSize()); + float Shrink = anActor->GetShrinkFactor(); + + SMESHGUI_Preferences_ColorDlg *aDlg = + new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(),""); + aDlg->SetColor(1, c); + aDlg->SetColor(2, e); + aDlg->SetColor(3, n); + aDlg->SetColor(4, b); + aDlg->SetIntValue(1, Edgewidth); + aDlg->SetIntValue(2, intValue); + aDlg->SetIntValue(3, int(Shrink*100.)); + if(aDlg->exec()){ + QColor color = aDlg->GetColor(1); + QColor edgecolor = aDlg->GetColor(2); + QColor nodecolor = aDlg->GetColor(3); + QColor backfacecolor = aDlg->GetColor(4); + /* actor color and backface color */ + anActor->SetSufaceColor(float (color.red()) / 255., + float (color.green()) / 255., + float (color.blue()) / 255.); + anActor->SetBackSufaceColor(float (backfacecolor.red()) / 255., + float (backfacecolor.green()) / 255., + float (backfacecolor.blue()) / 255.); + + /* edge color */ + anActor->SetEdgeColor(float (edgecolor.red()) / 255., + float (edgecolor.green()) / 255., + float (edgecolor.blue()) / 255.); + + /* Shrink factor and size edges */ + anActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.); + anActor->SetLineWidth(aDlg->GetIntValue(1)); + + /* Nodes color and size */ + anActor->SetNodeColor(float (nodecolor.red()) / 255., + float (nodecolor.green()) / 255., + float (nodecolor.blue()) / 255.); + anActor->SetNodeSize(aDlg->GetIntValue(2)); + + delete aDlg; + } + break; + }} + } } } + SMESH::RepaintCurrentView(); } } -} - -VTKViewer_ViewFrame* GetCurrentVtkView(){ - QAD_Study* aStudy = SMESHGUI::GetSMESHGUI()->GetActiveStudy(); - QAD_StudyFrame *aStudyFrame = aStudy->getActiveStudyFrame(); - return GetVtkViewFrame(aStudyFrame); -} -SMESH_Actor* FindActorByEntry(QAD_StudyFrame *theStudyFrame, - const char* theEntry) -{ - if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(theStudyFrame)){ - vtkRenderer *aRenderer = aViewFrame->getRenderer(); - vtkActorCollection *aCollection = aRenderer->GetActors(); - aCollection->InitTraversal(); - while(vtkActor *anAct = aCollection->GetNextActor()){ - if(SMESH_Actor *anActor = dynamic_cast(anAct)){ - if(anActor->hasIO()){ - Handle(SALOME_InteractiveObject) anIO = anActor->getIO(); - if(anIO->hasEntry() && strcmp(anIO->getEntry(),theEntry) == 0){ - return anActor; + void SetDisplaySettings() + { + SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); + SMESHGUI_Preferences_ColorDlg *aDlg = + new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(), ""); + + QColor color; + QString SCr, SCg, SCb; + SCr = QAD_CONFIG->getSetting("SMESH:SettingsFillColorRed"); + SCg = QAD_CONFIG->getSetting("SMESH:SettingsFillColorGreen"); + SCb = QAD_CONFIG->getSetting("SMESH:SettingsFillColorBlue"); + if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) + color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); + else color = QColor(0, 170, 255); + aDlg->SetColor(1, color); + + SCr = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorRed"); + SCg = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen"); + SCb = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue"); + if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) + color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); + else color = QColor(0, 170, 255); + aDlg->SetColor(2, color); + + SCr = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorRed"); + SCg = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorGreen"); + SCb = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorBlue"); + if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) + color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); + else color = Qt::red; + aDlg->SetColor(3, color); + + QString SBr = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorRed"); + QString SBg = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorGreen"); + QString SBb = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorBlue"); + if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) + color = QColor(SBr.toInt(), SBg.toInt(), SBb.toInt()); + else color = Qt::blue; + aDlg->SetColor(4, color); + + QString intValue = QAD_CONFIG->getSetting("SMESH:SettingsWidth"); + if (intValue.isEmpty()) intValue = "1"; + aDlg->SetIntValue(1, intValue.toInt()); + intValue = QAD_CONFIG->getSetting("SMESH:SettingsNodesSize"); + if (intValue.isEmpty()) intValue = "3"; + aDlg->SetIntValue(2, intValue.toInt()); + intValue = QAD_CONFIG->getSetting("SMESH:SettingsShrinkCoeff"); + if (intValue.isEmpty()) intValue = "75"; + aDlg->SetIntValue(3, intValue.toInt()); + + if (aDlg->exec()) { + QColor colorFill = aDlg->GetColor(1); + QAD_CONFIG->addSetting("SMESH:SettingsFillColorRed", colorFill.red()); + QAD_CONFIG->addSetting("SMESH:SettingsFillColorGreen", colorFill.green()); + QAD_CONFIG->addSetting("SMESH:SettingsFillColorBlue", colorFill.blue()); + + QColor colorOutline = aDlg->GetColor(2); + QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorRed", colorOutline.red()); + QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorGreen", colorOutline.green()); + QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorBlue", colorOutline.blue()); + + QColor colorNode = aDlg->GetColor(3); + QAD_CONFIG->addSetting("SMESH:SettingsNodeColorRed", colorNode.red()); + QAD_CONFIG->addSetting("SMESH:SettingsNodeColorGreen", colorNode.green()); + QAD_CONFIG->addSetting("SMESH:SettingsNodeColorBlue", colorNode.blue()); + + QColor colorBackFace = aDlg->GetColor(4); + QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorRed", colorBackFace.red()); + QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorGreen", colorBackFace.green()); + QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorBlue", colorBackFace.blue()); + + int width = aDlg->GetIntValue(1); + QAD_CONFIG->addSetting("SMESH:SettingsWidth", width); + + int nodes_size = aDlg->GetIntValue(2); + QAD_CONFIG->addSetting("SMESH:SettingsNodesSize", nodes_size); + + int shrink_coeff = aDlg->GetIntValue(3); + QAD_CONFIG->addSetting("SMESH:SettingsShrinkCoeff", shrink_coeff); + } + + delete aDlg; + } + + + void Control( int theCommandID ) + { + SALOME_Selection *Sel = SALOME_Selection::Selection( SMESH::GetActiveStudy()->getSelection() ); + if(Sel){ + Handle(SALOME_InteractiveObject) anIO = Sel->firstIObject(); + if(!anIO.IsNull()){ + QString aTitle; + SMESH_Actor::eControl aControl = SMESH_Actor::eNone; + if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIO->getEntry())){ + switch ( theCommandID ){ + case 6001: + aTitle = QObject::tr( "LENGTH_EDGES" ); + aControl = SMESH_Actor::eLengthEdges; + break; + case 6002: + aTitle = QObject::tr( "FREE_EDGES" ); + aControl = SMESH_Actor::eFreeEdges; + break; + case 6003: + aTitle = QObject::tr( "FREE_BORDERS" ); + aControl = SMESH_Actor::eFreeBorders; + break; + case 6004: + aTitle = QObject::tr( "MULTI_BORDERS" ); + aControl = SMESH_Actor::eMultiConnection; + break; + case 6011: + aTitle = QObject::tr( "AREA_ELEMENTS" ); + aControl = SMESH_Actor::eArea; + break; + case 6012: + aTitle = QObject::tr( "TAPER_ELEMENTS" ); + aControl = SMESH_Actor::eTaper; + break; + case 6013: + aTitle = QObject::tr( "ASPECTRATIO_ELEMENTS" ); + aControl = SMESH_Actor::eAspectRatio; + break; + case 6014: + aTitle = QObject::tr( "MINIMUMANGLE_ELEMENTS" ); + aControl = SMESH_Actor::eMinimumAngle; + break; + case 6015: + aTitle = QObject::tr( "WARP_ELEMENTS" ); + aControl = SMESH_Actor::eWarping; + break; + case 6016: + aTitle = QObject::tr( "SKEW_ELEMENTS" ); + aControl = SMESH_Actor::eSkew; + break; } + anActor->SetControlMode(aControl); + anActor->GetScalarBarActor()->SetTitle(aTitle.latin1()); } } } } - return NULL; -} - - -SMESH_Actor* FindActorByEntry(const char* theEntry){ - QAD_Study* aStudy = SMESHGUI::GetSMESHGUI()->GetActiveStudy(); - QAD_StudyFrame *aStudyFrame = aStudy->getActiveStudyFrame(); - return FindActorByEntry(aStudyFrame,theEntry); -} - + -SMESH_Actor* CreateActor(SALOMEDS::Study_ptr theStudy, - const char* theEntry, - int theIsClear = false) -{ - SMESH_Actor *anActor = NULL; - CORBA::Long anId = theStudy->StudyId(); - if(TVisualObjPtr aVisualObj = GetVisualObj(anId,theEntry)){ - SALOMEDS::SObject_var aSObj = theStudy->FindObjectID(theEntry); - if(!aSObj->_is_nil()){ - SALOMEDS::GenericAttribute_var anAttr; - if(aSObj->FindAttribute(anAttr,"AttributeName")){ - SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); - CORBA::String_var aVal = aName->Value(); - string aNameVal = aVal.in(); - SMESH::FilterManager_ptr aFilterMgr = smeshGUI->GetFilterMgr(); - anActor = SMESH_Actor::New(aVisualObj,aFilterMgr,theEntry,aNameVal.c_str(),theIsClear); - } + bool CheckOIType(const Handle(SALOME_InteractiveObject) & theIO, + MeshObjectType theType, + const QString theInTypeName, + QString & theOutTypeName) + { + SMESH_TypeFilter aTypeFilter( theType ); + if ( aTypeFilter.IsOk( theIO )) { + theOutTypeName = theInTypeName; + return true; } + return false; } - return anActor; -} - + -void DisplayActor(QAD_StudyFrame *theStudyFrame, SMESH_Actor* theActor){ - if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(theStudyFrame)){ - aViewFrame->AddActor(theActor); - aViewFrame->Repaint(); + QString CheckTypeObject(const Handle(SALOME_InteractiveObject) & theIO) + { + SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); + SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theIO->getEntry()); + if (!aSObj->_is_nil()) { + SALOMEDS::SComponent_var aSComp = aSObj->GetFatherComponent(); + CORBA::String_var anID = aSComp->GetID(); + if (!strcmp(anID.in(),theIO->getEntry())) + return "Component"; + } + + QString aTypeName; + if ( + CheckOIType ( theIO, HYPOTHESIS, "Hypothesis", aTypeName ) || + CheckOIType ( theIO, ALGORITHM, "Algorithm", aTypeName ) || + CheckOIType ( theIO, MESH, "Mesh", aTypeName ) || + CheckOIType ( theIO, SUBMESH, "SubMesh", aTypeName ) || + CheckOIType ( theIO, GROUP, "Group", aTypeName ) + ) + return aTypeName; + + return "NoType"; } -} -void RemoveActor(QAD_StudyFrame *theStudyFrame, SMESH_Actor* theActor){ - if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(theStudyFrame)){ - aViewFrame->RemoveActor(theActor); - aViewFrame->Repaint(); - } -} - + QString CheckHomogeneousSelection() + { + QAD_Study* aStudy = SMESH::GetActiveStudy(); + SALOME_Selection *aSel = SALOME_Selection::Selection(aStudy->getSelection()); + /* copy the list */ + SALOME_ListIO List; + SALOME_ListIteratorOfListIO Itinit(aSel->StoredIObjects()); + for (; Itinit.More(); Itinit.Next()) + { + List.Append(Itinit.Value()); + } -void FitAll(){ - if(VTKViewer_ViewFrame* aViewFrame = GetCurrentVtkView()){ - aViewFrame->onViewFitAll(); - aViewFrame->Repaint(); + QString RefType = CheckTypeObject(aSel->firstIObject()); + SALOME_ListIteratorOfListIO It(List); + for (; It.More(); It.Next()) + { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + QString Type = CheckTypeObject(IObject); + if (Type.compare(RefType) != 0) + return "Heterogeneous Selection"; + } + + aSel->ClearIObjects(); + SALOME_ListIteratorOfListIO It1(List); + for (; It1.More(); It1.Next()) + { + int res = aSel->AddIObject(It1.Value()); + if (res == -1) + aStudy->highlight(It1.Value(), false); + if (res == 0) + aStudy->highlight(It1.Value(), true); + } + return RefType; } -} - -vtkRenderer* GetCurrentRenderer(){ - if(VTKViewer_ViewFrame* aViewFrame = GetCurrentVtkView()) - return aViewFrame->getRenderer(); - return NULL; -} - -void RepaintCurrentView(){ - if(VTKViewer_ViewFrame* aViewFrame = GetCurrentVtkView()) - aViewFrame->Repaint(); -} + void OnEditDelete() + { + if (QAD_MessageBox::warn2 + (QAD_Application::getDesktop(), + QObject::tr("SMESH_WRN_WARNING"), + QObject::tr("SMESH_REALLY_DELETE"), + QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"), 1, 0, 0) != 1) + return; -enum EDisplaing {eDisplayAll, eDisplay, eDisplayOnly, eErase, eEraseAll}; -void UpdateView(QAD_StudyFrame *theStudyFrame, EDisplaing theAction, - const char* theEntry = "") -{ - if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(theStudyFrame)){ - vtkRenderer *aRenderer = aViewFrame->getRenderer(); - vtkActorCollection *aCollection = aRenderer->GetActors(); - aCollection->InitTraversal(); - switch(theAction){ - case eDisplayAll: { - while(vtkActor *anAct = aCollection->GetNextActor()){ - if(SMESH_Actor *anActor = dynamic_cast(anAct)){ - anActor->SetVisibility(true); + QAD_Study* anActiveStudy = SMESH::GetActiveStudy(); + int nbSf = anActiveStudy->getStudyFramesCount(); + + SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); + SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + + SALOME_Selection *Sel = SALOME_Selection::Selection(anActiveStudy->getSelection()); + SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + for(; It.More(); It.Next()){ + Handle(SALOME_InteractiveObject) IObject = It.Value(); + if(IObject->hasEntry()){ + SALOMEDS::SObject_var SO = aStudy->FindObjectID(IObject->getEntry()); + + /* Erase child graphical objects */ + SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO); + for(; it->More(); it->Next()){ + SALOMEDS::SObject_var CSO = it->Value(); + if(CSO->FindAttribute(anAttr, "AttributeIOR")){ + anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + + for(int i = 0; i < nbSf; i++){ + QAD_StudyFrame *sf = anActiveStudy->getStudyFrame(i); + CORBA::String_var anEntry = CSO->GetID(); + if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,anEntry.in())){ + SMESH::RemoveActor(sf,anActor); + } + } } } - break; - } - case eDisplayOnly: - case eEraseAll: { - while(vtkActor *anAct = aCollection->GetNextActor()){ - if(SMESH_Actor *anActor = dynamic_cast(anAct)){ - anActor->SetVisibility(false); + + /* Erase main graphical object */ + for(int i = 0; i < nbSf; i++){ + QAD_StudyFrame *sf = anActiveStudy->getStudyFrame(i); + if(SMESH_Actor* anActor = SMESH::FindActorByEntry(sf,IObject->getEntry())){ + SMESH::RemoveActor(sf,anActor); } } - } - default: { - if(SMESH_Actor *anActor = FindActorByEntry(theStudyFrame,theEntry)){ - switch(theAction) { - case eDisplay: - case eDisplayOnly: - anActor->SetVisibility(true); - break; - case eErase: - anActor->SetVisibility(false); - break; - } - } else { - switch(theAction){ - case eDisplay: - case eDisplayOnly:{ - QAD_Study* aStudy = theStudyFrame->getStudy(); - SALOMEDS::Study_var aDocument = aStudy->getStudyDocument(); - if(anActor = CreateActor(aDocument,theEntry,true)) { - DisplayActor(theStudyFrame,anActor); - FitAll(); - } - break; - } + + // Remove object(s) from data structures + SALOMEDS::SObject_var obj = aStudy->FindObjectID(IObject->getEntry()); + if(!obj->_is_nil()){ + SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(obj->GetObject()); + SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(obj->GetObject()); + + if ( !aGroup->_is_nil() ) { // DELETE GROUP + SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh(); + aMesh->RemoveGroup( aGroup ); + } + else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH + SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather(); + aMesh->RemoveSubMesh( aSubMesh ); + } + else {// default action: remove SObject from the study + // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH + //QAD_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy); + //op->start(); + aStudyBuilder->RemoveObjectWithChildren( obj ); + //op->finish(); } } - } - } + + } /* IObject->hasEntry() */ + } /* more/next */ + + /* Clear any previous selection */ + Sel->ClearIObjects(); + anActiveStudy->updateObjBrowser(); } -} - - -void UpdateView(EDisplaing theAction, const char* theEntry = ""){ - QAD_Study* aStudy = SMESHGUI::GetSMESHGUI()->GetActiveStudy(); - QAD_StudyFrame *aStudyFrame = aStudy->getActiveStudyFrame(); - UpdateView(aStudyFrame,theAction,theEntry); -} -static bool IsReferencedObject( SALOMEDS::SObject_ptr SO ) -{ - if ( !SO->_is_nil() ) { - SALOMEDS::GenericAttribute_var anAttr; - if ( SO->FindAttribute( anAttr, "AttributeTarget" ) ) { - SALOMEDS::AttributeTarget_var aTarget = SALOMEDS::AttributeTarget::_narrow( anAttr ); - SALOMEDS::Study::ListOfSObject_var aList = aTarget->Get(); - if ( aList->length() > 0 ) { - return true; - } - } - } - return false; -} -void SetPointRepresentation(bool theIsVisible){ - if(VTKViewer_ViewFrame* aViewFrame = GetCurrentVtkView()){ - vtkRenderer *aRenderer = aViewFrame->getRenderer(); - vtkActorCollection *aCollection = aRenderer->GetActors(); - aCollection->InitTraversal(); - while(vtkActor *anAct = aCollection->GetNextActor()){ - if(SMESH_Actor *anActor = dynamic_cast(anAct)){ - if(anActor->GetVisibility()){ - anActor->SetPointRepresentation(theIsVisible); - } - } - } - RepaintCurrentView(); - } } - //============================================================================= /*! * @@ -530,6 +748,15 @@ class CustomItem:public QCustomMenuItem SMESHGUI::SMESHGUI( const QString& theName, QObject* theParent ) : SALOMEGUI( theName, theParent ) { + myActiveDialogBox = 0 ; + myState = -1 ; + + SMESH::GetSMESHGen(); + SMESH::GetFilterManager(); + SMESH::GetPattern(); + + /* load resources for all available meshers */ + SMESH::InitAvailableHypotheses(); } //============================================================================= @@ -539,6 +766,7 @@ SMESHGUI::SMESHGUI( const QString& theName, QObject* theParent ) : //============================================================================= SMESHGUI::~SMESHGUI() { + SMESH::GetFilterManager()->Destroy(); } //============================================================================= @@ -548,9 +776,14 @@ SMESHGUI::~SMESHGUI() //============================================================================= SMESHGUI* SMESHGUI::GetSMESHGUI() { - if ( !smeshGUI ) - GetOrCreateSMESHGUI( QAD_Application::getDesktop() ); - return smeshGUI; + static SMESHGUI aSMESHGUI; + aSMESHGUI.myActiveStudy = SMESH::GetActiveStudy(); + SMESH::GetSMESHGen()->SetCurrentStudy( SMESH::GetActiveStudyDocument() ); + + /* Automatic Update flag */ + aSMESHGUI.myAutomaticUpdate = ( QAD_CONFIG->getSetting( "SMESH:AutomaticUpdate" ).compare( "true" ) == 0 ); + + return &aSMESHGUI; } extern "C" @@ -559,65 +792,16 @@ extern "C" return SMESHGUI::GetSMESHGUI(); } } + //============================================================================= /*! * */ //============================================================================= -SMESHGUI* SMESHGUI::GetOrCreateSMESHGUI( QAD_Desktop* desktop ) +void SMESHGUI::SetState(int aState) { - if( !smeshGUI ) { - setOrb(); - smeshGUI = new SMESHGUI; - smeshGUI->myActiveDialogBox = 0 ; - smeshGUI->myState = -1 ; - smeshGUI->myDesktop = desktop ; - - /* get smesh engine */ - Engines::Component_var comp = desktop->getEngine("FactoryServer", "SMESH"); - smeshGUI->myComponentMesh = SMESH::SMESH_Gen::_narrow(comp); - - /* get geom engine */ - Engines::Component_var comp1 = desktop->getEngine("FactoryServer", "GEOM"); - smeshGUI->myComponentGeom = GEOM::GEOM_Gen::_narrow(comp1); - - /* set current study */ - smeshGUI->myActiveStudy = desktop->getActiveStudy(); - smeshGUI->myStudyId = smeshGUI->myActiveStudy->getStudyId(); - smeshGUI->myStudy = smeshGUI->myActiveStudy->getStudyDocument(); - smeshGUI->myComponentGeom->GetCurrentStudy( smeshGUI->myStudyId ); - smeshGUI->myComponentMesh->SetCurrentStudy( smeshGUI->myStudy ); - // smeshGUI->myComponentGeom->NbLabels(); - - /* create service object */ - smeshGUI->myStudyAPI = SMESHGUI_StudyAPI(smeshGUI->myStudy, smeshGUI->myComponentMesh); - - smeshGUI->myDocument = new SMESHDS_Document(1);//NBU - - smeshGUI->mySimulationActors = vtkActorCollection::New(); - smeshGUI->mySimulationActors2D = vtkActor2DCollection::New(); - - /*filter manager*/ - smeshGUI->myFilterMgr = smeshGUI->myComponentMesh->CreateFilterManager(); - - /* load resources for all available meshers */ - smeshGUI->InitAvailableHypotheses(); - } else { - /* study may have changed - set current study */ - smeshGUI->myActiveStudy = desktop->getActiveStudy(); - smeshGUI->myStudyId = smeshGUI->myActiveStudy->getStudyId(); - smeshGUI->myStudy = smeshGUI->myActiveStudy->getStudyDocument(); - smeshGUI->myComponentGeom->GetCurrentStudy( smeshGUI->myStudyId ); - smeshGUI->myComponentMesh->SetCurrentStudy( smeshGUI->myStudy ); - - // Set active study to Study API - smeshGUI->myStudyAPI.Update( smeshGUI->myStudy ); - } - - /* Automatic Update flag */ - smeshGUI->myAutomaticUpdate = ( QAD_CONFIG->getSetting( "SMESH:AutomaticUpdate" ).compare( "true" ) == 0 ); - - return smeshGUI; + this->myState = aState; + return; } //============================================================================= @@ -625,9 +809,9 @@ SMESHGUI* SMESHGUI::GetOrCreateSMESHGUI( QAD_Desktop* desktop ) * */ //============================================================================= -void SMESHGUI::SetState(int aState) +void SMESHGUI::ResetState() { - this->myState = aState; + this->myState = -1; return; } @@ -636,9 +820,9 @@ void SMESHGUI::SetState(int aState) * */ //============================================================================= -void SMESHGUI::ResetState() +void SMESHGUI::EmitSignalDeactivateDialog() { - this->myState = -1; + emit this->SignalDeactivateActiveDialog(); return; } @@ -647,9 +831,9 @@ void SMESHGUI::ResetState() * */ //============================================================================= -void SMESHGUI::EmitSignalDeactivateDialog() +void SMESHGUI::EmitSignalStudyFrameChanged() { - emit this->SignalDeactivateActiveDialog(); + emit this->SignalStudyFrameChanged(); return; } @@ -695,26 +879,6 @@ QAD_Study *SMESHGUI::GetActiveStudy() return this->myActiveStudy; } -//============================================================================= -/*! - * - */ -//============================================================================= -SALOMEDS::Study_ptr SMESHGUI::GetStudy() -{ - return SALOMEDS::Study::_narrow(myStudy); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -SMESHGUI_StudyAPI SMESHGUI::GetStudyAPI() -{ - return myStudyAPI; -} - //============================================================================= /*! * @@ -722,7 +886,7 @@ SMESHGUI_StudyAPI SMESHGUI::GetStudyAPI() //============================================================================= QAD_Desktop *SMESHGUI::GetDesktop() { - return this->myDesktop; + return QAD_Application::getDesktop(); } //============================================================================= @@ -733,18 +897,17 @@ QAD_Desktop *SMESHGUI::GetDesktop() bool SMESHGUI::ActiveStudyChanged(QAD_Desktop* parent) { MESSAGE("SMESHGUI::activeStudyChanged init."); - QAD_Study* prevStudy = 0; - if ( smeshGUI ) - prevStudy = smeshGUI->myActiveStudy; + QAD_Study* prevStudy = myActiveStudy; /* Create or retrieve an object SMESHGUI */ MESSAGE("Active study changed : prev study =" << prevStudy); - SMESHGUI::GetOrCreateSMESHGUI( parent ); - MESSAGE("Active study changed : active study =" << smeshGUI->myActiveStudy); - if ( prevStudy != smeshGUI->myActiveStudy ) { - smeshGUI->EmitSignalCloseAllDialogs(); + SMESHGUI::GetSMESHGUI(); + EmitSignalStudyFrameChanged(); + MESSAGE("Active study changed : active study =" << myActiveStudy); + if ( prevStudy != myActiveStudy ) { + EmitSignalCloseAllDialogs(); MESSAGE("Active study changed : SMESHGUI nullified" << endl); //smeshGUI = 0; - ::UpdateSelectionProp(); + SMESH::UpdateSelectionProp(); } MESSAGE("SMESHGUI::activeStudyChanged done."); return true; @@ -771,108 +934,30 @@ bool SMESHGUI::DefineDlgPosition(QWidget * aDlg, int &x, int &y) * */ //============================================================================= -void SMESHGUI::EraseSimulationActors() -{ - if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) - { //VTK - vtkRenderer *theRenderer = - ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()-> - getRightFrame()->getViewFrame())->getRenderer(); - vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); - - if (mySimulationActors != NULL) - { - mySimulationActors->InitTraversal(); - vtkActor *ac = mySimulationActors->GetNextActor(); - while (!(ac == NULL)) - { - theRenderer->RemoveActor(ac); - ac = mySimulationActors->GetNextActor(); - } - mySimulationActors->RemoveAllItems(); - } - if (mySimulationActors2D != NULL) - { - mySimulationActors2D->InitTraversal(); - vtkActor2D *ac = mySimulationActors2D->GetNextActor2D(); - while (!(ac == NULL)) - { - theRenderer->RemoveActor2D(ac); - ac = mySimulationActors2D->GetNextActor2D(); - } - mySimulationActors2D->RemoveAllItems(); - } - SetPointRepresentation(false); +static int isStudyLocked(const SALOMEDS::Study_var& theStudy){ + return theStudy->GetProperties()->IsLocked(); +} + +static bool checkLock(const SALOMEDS::Study_var& theStudy) { + if (isStudyLocked(theStudy)) { + QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(), + QObject::tr("WRN_WARNING"), + QObject::tr("WRN_STUDY_LOCKED"), + QObject::tr("BUT_OK") ); + return true; } + return false; } -//============================================================================= -/*! - * - */ -//============================================================================= -SMESH::SMESH_Mesh_ptr SMESHGUI::InitMesh( GEOM::GEOM_Shape_ptr aShape, - QString NameMesh ) -{ - try { - if ( !myComponentMesh->_is_nil() && !aShape->_is_nil() ) { - SMESH::SMESH_Mesh_var aMesh = myComponentMesh->CreateMesh( aShape ); - if ( !aMesh->_is_nil() ) { - SALOMEDS::SObject_var SM = smeshGUI->myStudy->FindObjectIOR( _orb->object_to_string( aMesh ) ); - myStudyAPI.SetName( SM, NameMesh ); - return SMESH::SMESH_Mesh::_narrow(aMesh); - } - } - } - catch( const SALOME::SALOME_Exception& S_ex ) { - QtCatchCorbaException( S_ex ); - } - return SMESH::SMESH_Mesh::_nil(); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -SMESH::SMESH_subMesh_ptr SMESHGUI::AddSubMesh( SMESH::SMESH_Mesh_ptr aMesh, - GEOM::GEOM_Shape_ptr aShape, - QString NameMesh ) -{ - SMESH::SMESH_subMesh_var aSubMesh; - try { - if ( !aMesh->_is_nil() && !aShape->_is_nil() ) - // create sub mesh - aSubMesh = SMESH::SMESH_subMesh::_duplicate( aMesh->GetSubMesh( aShape, NameMesh.latin1() ) ); //VSR: published automatically - } - catch( const SALOME::SALOME_Exception& S_ex ) { - QtCatchCorbaException( S_ex ); - aSubMesh = SMESH::SMESH_subMesh::_nil(); - } - return aSubMesh._retn(); -} +//======================================================================= +//function : CheckActiveStudyLocked +//purpose : +//======================================================================= -//============================================================================= -/*! - * - */ -//============================================================================= -SMESH::SMESH_Group_ptr SMESHGUI::AddGroup( SMESH::SMESH_Mesh_ptr aMesh, - SMESH::ElementType aType, - QString aName ) +bool SMESHGUI::ActiveStudyLocked() { - SMESH::SMESH_Group_var aGroup; - try { - if ( !aMesh->_is_nil() ) - // create group - aGroup = SMESH::SMESH_Group::_duplicate( aMesh->CreateGroup( aType, strdup(aName) ) ); //VSR: published automatically - } - catch( const SALOME::SALOME_Exception& S_ex ) { - QtCatchCorbaException( S_ex ); - aGroup = SMESH::SMESH_Group::_nil(); - } - myActiveStudy->updateObjBrowser( true ); - return aGroup._retn(); + SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); + return checkLock( aStudy ); } //============================================================================= @@ -880,1541 +965,910 @@ SMESH::SMESH_Group_ptr SMESHGUI::AddGroup( SMESH::SMESH_Mesh_ptr aMesh, * */ //============================================================================= - -static void addMap( const map& theMap, - map& toMap) +bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) { - map::const_iterator it; - for ( it = theMap.begin(); it != theMap.end(); it++ ) - toMap.insert( *it ); -} + SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); //Document OCAF de l'etude active + switch (theCommandID) { + case 33: // DELETE + if(checkLock(aStudy)) break; + ::OnEditDelete(); + break; -//============================================================================= -/*! - * InitAvailableHypotheses (read from resource XML file) - */ -//============================================================================= -void SMESHGUI::InitAvailableHypotheses () -{ - QAD_WaitCursor wc; - if ((myHypothesesMap.begin() == myHypothesesMap.end()) && - (myAlgorithmsMap.begin() == myAlgorithmsMap.end())) - { - // Resource manager - QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager(); - if (!resMgr) return; - - // Find name of a resource XML file ("SMESH_Meshers.xml"); - QString HypsXml; - char* cenv = getenv("SMESH_MeshersList"); - if (cenv) - HypsXml.sprintf("%s", cenv); - - QStringList HypsXmlList = QStringList::split( ":", HypsXml, false ); - if (HypsXmlList.count() == 0) + case 113: // IMPORT + case 112: + case 111: { - QAD_MessageBox::error1(QAD_Application::getDesktop(), - tr("SMESH_WRN_WARNING"), - tr("MESHERS_FILE_NO_VARIABLE"), - tr("SMESH_BUT_OK")); - return; + if(checkLock(aStudy)) break; + ::ImportMeshesFromFile(parent,SMESH::GetSMESHGen(),theCommandID); + break; } - // loop on files in HypsXml - QString aNoAccessFiles; - for ( int i = 0; i < HypsXmlList.count(); i++ ) { - QString HypsXml = HypsXmlList[ i ]; - - // Find full path to the resource XML file - QString xmlFile = HypsXml + ".xml"; - xmlFile = QAD_Tools::addSlash(resMgr->findFile(xmlFile, HypsXml)) + xmlFile; - - QFile file (QAD_Tools::unix2win(xmlFile)); - if (file.exists() && file.open(IO_ReadOnly)) - { - file.close(); - - SMESHGUI_XmlHandler* myXmlHandler = new SMESHGUI_XmlHandler(); - ASSERT(myXmlHandler); - - QXmlInputSource source (file); - QXmlSimpleReader reader; - reader.setContentHandler(myXmlHandler); - reader.setErrorHandler(myXmlHandler); - bool ok = reader.parse(source); - file.close(); - if (ok) - { - addMap( myXmlHandler->myHypothesesMap, myHypothesesMap ); - addMap( myXmlHandler->myAlgorithmsMap, myAlgorithmsMap ); - } - else - { - QAD_MessageBox::error1(myDesktop, - tr("INF_PARSE_ERROR"), - tr(myXmlHandler->errorProtocol()), - tr("SMESH_BUT_OK")); - } - } - else - { - if (aNoAccessFiles.isEmpty()) - aNoAccessFiles = xmlFile; - else - aNoAccessFiles += ", " + xmlFile; - } - } // end loop - - - if (!aNoAccessFiles.isEmpty()) + case 122: // EXPORT MED + case 121: + case 123: { - QString aMess = tr("MESHERS_FILE_CANT_OPEN") + " " + aNoAccessFiles + "\n"; - aMess += tr("MESHERS_FILE_CHECK_VARIABLE"); - wc.stop(); - QAD_MessageBox::warn1(QAD_Application::getDesktop(), - tr("SMESH_WRN_WARNING"), - aMess, - tr("SMESH_BUT_OK")); - wc.start(); + ::ExportMeshToFile(parent, theCommandID); + break; } - } -} - -//============================================================================= -/*! - * GetAvailableHypotheses (read from resource XML file) - */ -//============================================================================= -QStringList SMESHGUI::GetAvailableHypotheses (const bool isAlgo) -{ - QStringList aHypList; - - // Init list of available hypotheses, if needed - InitAvailableHypotheses(); - // fill list of hypotheses/algorithms - map::iterator anIter; - if (isAlgo) - { - anIter = myAlgorithmsMap.begin(); - for (; anIter != myAlgorithmsMap.end(); anIter++) + case 200: // SCALAR BAR { - aHypList.append(((*anIter).first).c_str()); + SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + if( Sel && Sel->IObjectCount() ) { + Handle(SALOME_InteractiveObject) anIO = Sel->firstIObject(); + if( anIO->hasEntry() ) { + if( SMESH_Actor* anActor = SMESH::FindActorByEntry( anIO->getEntry() ) ) { + anActor->SetControlMode( SMESH_Actor::eNone ); + } + } + } + break; } - } - else - { - anIter = myHypothesesMap.begin(); - for (; anIter != myHypothesesMap.end(); anIter++) + case 201: { - aHypList.append(((*anIter).first).c_str()); + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( parent, Sel ); + break; } - } - - return aHypList; -} - -//============================================================================= -/*! - * GetHypothesisData - */ -//============================================================================= -HypothesisData* SMESHGUI::GetHypothesisData (const char* aHypType) -{ - HypothesisData* aHypData = 0; - - // Init list of available hypotheses, if needed - InitAvailableHypotheses(); - if (myHypothesesMap.find(aHypType) == myHypothesesMap.end()) - { - if (myAlgorithmsMap.find(aHypType) != myAlgorithmsMap.end()) + case 1134: // Clipping + case 1133: // Tranparency + case 1132: // Colors / Size + case 215: + case 213: + case 212: + case 211: { - aHypData = myAlgorithmsMap[aHypType]; + ::SetViewMode(theCommandID); + break; } - } - else - { - aHypData = myHypothesesMap[aHypType]; - } - return aHypData; -} - -//============================================================================= -/*! - * Get a Hypothesis Creator from a Plugin Library - */ -//============================================================================= -SMESHGUI_GenericHypothesisCreator* SMESHGUI::GetHypothesisCreator(const QString& aHypType) -{ - char* sHypType = (char*)aHypType.latin1(); - MESSAGE("Get HypothesisCreator for " << sHypType); - - SMESHGUI_GenericHypothesisCreator* aCreator = 0; - - // check, if creator for this hypothesis type already exists - if (myHypCreatorMap.find(sHypType) != myHypCreatorMap.end()) - { - aCreator = myHypCreatorMap[sHypType]; - } - else - { - // 1. Init list of available hypotheses, if needed - InitAvailableHypotheses(); - // 2. Get names of plugin libraries - HypothesisData* aHypData = GetHypothesisData(sHypType); - if (!aHypData) + case 214: // UPDATE { - return aCreator; + if(checkLock(aStudy)) break; + SMESH::UpdateView(); + break; } - QString aClientLibName = aHypData->ClientLibName; - QString aServerLibName = aHypData->ServerLibName; - // 3. Load Client Plugin Library - try + case 300: // ERASE + case 301: // DISPLAY + case 302: // DISPLAY ONLY { - // load plugin library - MESSAGE("Loading client meshers plugin library ..."); - void* libHandle = dlopen (aClientLibName, RTLD_LAZY); - if (!libHandle) - { - // report any error, if occured - const char* anError = dlerror(); - MESSAGE(anError); + SMESH::EDisplaing anAction; + switch(theCommandID){ + case 300: anAction = SMESH::eErase; break; + case 301: anAction = SMESH::eDisplay; break; + case 302: anAction = SMESH::eDisplayOnly; break; } - else - { - // get method, returning hypothesis creator - MESSAGE("Find GetHypothesisCreator() method ..."); - typedef SMESHGUI_GenericHypothesisCreator* (*GetHypothesisCreator) \ - (QString aHypType, QString aServerLibName, SMESHGUI* aSMESHGUI); - GetHypothesisCreator procHandle = - (GetHypothesisCreator)dlsym( libHandle, "GetHypothesisCreator" ); - if (!procHandle) - { - MESSAGE("bad hypothesis client plugin library"); - dlclose(libHandle); - } - else - { - // get hypothesis creator - MESSAGE("Get Hypothesis Creator for " << aHypType); - aCreator = procHandle(aHypType, aServerLibName, smeshGUI); - if (!aCreator) - { - MESSAGE("no such a hypothesis in this plugin"); - } - else - { - // map hypothesis creator to a hypothesis name - myHypCreatorMap[sHypType] = aCreator; - } - } + + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + for (; It.More(); It.Next()) { + Handle(SALOME_InteractiveObject) IOS = It.Value(); + if (IOS->hasEntry()) { + SMESH::UpdateView(anAction,IOS->getEntry()); + } + } } + Sel->ClearIObjects(); + break; } - catch (const SALOME::SALOME_Exception& S_ex) - { - QtCatchCorbaException(S_ex); - } - } - - return aCreator; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -SMESH::SMESH_Hypothesis_ptr SMESHGUI::CreateHypothesis (const QString& aHypType, - const QString& aHypName, - const bool isAlgo) -{ - MESSAGE("Create " << aHypType << " with name " << aHypName); - SMESH::SMESH_Hypothesis_var Hyp; - - HypothesisData* aHypData = GetHypothesisData((char*)aHypType.latin1()); - QString aServLib = aHypData->ServerLibName; - - try - { - Hyp = myComponentMesh->CreateHypothesis(aHypType, aServLib); - if (!Hyp->_is_nil()) + case 400: // NODES { - SALOMEDS::SObject_var SHyp = - smeshGUI->myStudy->FindObjectIOR( _orb->object_to_string( Hyp ) ); - if (!SHyp->_is_nil()) - { - if ( !aHypName.isEmpty() ) - myStudyAPI.SetName( SHyp, aHypName ); - myActiveStudy->updateObjBrowser(true); - return Hyp._retn(); - } - } - } - catch (const SALOME::SALOME_Exception & S_ex) - { - QtCatchCorbaException(S_ex); - } - - return SMESH::SMESH_Hypothesis::_nil(); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -bool SMESHGUI::AddHypothesisOnMesh(SMESH::SMESH_Mesh_ptr aMesh, - SMESH::SMESH_Hypothesis_ptr aHyp) -{ - int res = SMESH::HYP_UNKNOWN_FATAL; - QAD_WaitCursor wc; - - if ( !aMesh->_is_nil() ) { - SALOMEDS::SObject_var SM = myStudyAPI.FindObject( aMesh ); - GEOM::GEOM_Shape_var aShape = myStudyAPI.GetShapeOnMeshOrSubMesh(SM); - try { - res = aMesh->AddHypothesis( aShape, aHyp ); - if ( res < SMESH::HYP_UNKNOWN_FATAL ) { - SALOMEDS::SObject_var SH = myStudyAPI.FindObject(aHyp); - if ( !SM->_is_nil() && !SH->_is_nil() ) { - //myStudyAPI.SetHypothesis(SM, SH); // VSR: published automatically by engine - myStudyAPI.ModifiedMesh(SM, false); - } - } - if ( res >= SMESH::HYP_UNKNOWN_FATAL ) { - wc.stop(); - QAD_MessageBox::error1(QAD_Application::getDesktop(), - tr("SMESH_ERROR"), - tr(QString("SMESH_HYP_%1").arg(res)), - tr("SMESH_BUT_OK")); - wc.start(); + if(checkLock(aStudy)) break; + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + EmitSignalDeactivateDialog(); + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + SMESHGUI_NodesDlg *aDlg = new SMESHGUI_NodesDlg(parent, "", Sel); } - else if ( res > SMESH::HYP_OK ) { - wc.stop(); + else { QAD_MessageBox::warn1(QAD_Application::getDesktop(), - tr("SMESH_WRN_WARNING"), - tr(QString("SMESH_HYP_%1").arg(res)), + tr("SMESH_WRN_WARNING"), + tr("SMESH_WRN_VIEWER_VTK"), tr("SMESH_BUT_OK")); - wc.start(); } + break; } - catch( const SALOME::SALOME_Exception& S_ex ) { - wc.stop(); - QtCatchCorbaException( S_ex ); - res = SMESH::HYP_UNKNOWN_FATAL; - } - } - return res < SMESH::HYP_UNKNOWN_FATAL; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -bool SMESHGUI::RemoveHypothesisOrAlgorithmOnMesh - (const Handle(SALOME_InteractiveObject)& IObject) -{ - int res = SMESH::HYP_UNKNOWN_FATAL; - QAD_WaitCursor wc; - if (IObject->hasReference()) + case 2151: // FILTER { - try { - SMESH::SMESH_Hypothesis_var anHyp; - SALOMEDS::SObject_var SO_Hypothesis = - smeshGUI->myStudy->FindObjectID(IObject->getEntry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - - if (!SO_Hypothesis->_is_nil()) { - if (SO_Hypothesis->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - anHyp = SMESH::SMESH_Hypothesis::_narrow - (_orb->string_to_object(anIOR->Value())); - } - - SALOMEDS::SObject_var SO_Applied_Hypothesis = - smeshGUI->myStudy->FindObjectID(IObject->getReference()); - if (!SO_Applied_Hypothesis->_is_nil()) { - SALOMEDS::SObject_var MorSM = - smeshGUI->myStudyAPI.GetMeshOrSubmesh(SO_Applied_Hypothesis); - if (!MorSM->_is_nil()) { - GEOM::GEOM_Shape_var aShape = - smeshGUI->myStudyAPI.GetShapeOnMeshOrSubMesh(MorSM); - if (!aShape->_is_nil() && MorSM->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - SMESH::SMESH_Mesh_var aMesh = - SMESH::SMESH_Mesh::_narrow(_orb->string_to_object(anIOR->Value())); - SMESH::SMESH_subMesh_var aSubMesh = - SMESH::SMESH_subMesh::_narrow(_orb->string_to_object(anIOR->Value())); - - if (!aSubMesh->_is_nil()) - aMesh = aSubMesh->GetFather(); - - if (!aMesh->_is_nil()) - { - res = aMesh->RemoveHypothesis(aShape, anHyp); - if ( res < SMESH::HYP_UNKNOWN_FATAL ) - smeshGUI->myStudyAPI.ModifiedMesh(MorSM, false); - if ( res > SMESH::HYP_OK ) { - wc.stop(); - QAD_MessageBox::warn1(QAD_Application::getDesktop(), - tr("SMESH_WRN_WARNING"), - tr(QString("SMESH_HYP_%1").arg(res)), - tr("SMESH_BUT_OK")); - wc.start(); - } - } - } - } - } - } - } - catch( const SALOME::SALOME_Exception& S_ex ) { - wc.stop(); - QtCatchCorbaException( S_ex ); - res = SMESH::HYP_UNKNOWN_FATAL; + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) + { + EmitSignalDeactivateDialog(); + SMESHGUI_FilterDlg *aDlg = new SMESHGUI_FilterDlg( parent, SMESH::EDGE ); } + break; } - else if (IObject->hasEntry()) - { - MESSAGE("IObject entry " << IObject->getEntry()); - } - return res < SMESH::HYP_UNKNOWN_FATAL; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -bool SMESHGUI::RemoveHypothesisOrAlgorithmOnMesh(SALOMEDS::SObject_ptr MorSM, - SMESH::SMESH_Hypothesis_ptr anHyp) -{ - SALOMEDS::SObject_var AHR, aRef; - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - int res = SMESH::HYP_UNKNOWN_FATAL; - QAD_WaitCursor wc; - - if (!MorSM->_is_nil()) { - try { - GEOM::GEOM_Shape_var aShape = smeshGUI->myStudyAPI.GetShapeOnMeshOrSubMesh(MorSM); - if (!aShape->_is_nil()) { - if (MorSM->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - SMESH::SMESH_Mesh_var aMesh = - SMESH::SMESH_Mesh::_narrow(_orb->string_to_object(anIOR->Value())); - SMESH::SMESH_subMesh_var aSubMesh = - SMESH::SMESH_subMesh::_narrow(_orb->string_to_object(anIOR->Value())); - - if ( !aSubMesh->_is_nil() ) - aMesh = aSubMesh->GetFather(); - - if (!aMesh->_is_nil()) { - res = aMesh->RemoveHypothesis(aShape, anHyp); - if ( res < SMESH::HYP_UNKNOWN_FATAL ) - smeshGUI->myStudyAPI.ModifiedMesh(MorSM, false); - if ( res > SMESH::HYP_OK ) { - wc.stop(); - QAD_MessageBox::warn1(QAD_Application::getDesktop(), - tr("SMESH_WRN_WARNING"), - tr(QString("SMESH_HYP_%1").arg(res)), - tr("SMESH_BUT_OK")); - wc.start(); - } - } - } + + case 406: // MOVE NODE + { + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) + { + QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ), + tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) ); + break; } + + if(checkLock(aStudy)) break; + SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + SMESHGUI_MoveNodesDlg *aDlg = new SMESHGUI_MoveNodesDlg( parent, Sel ); + break; } - catch( const SALOME::SALOME_Exception& S_ex ) { - wc.stop(); - QtCatchCorbaException( S_ex ); - res = SMESH::HYP_UNKNOWN_FATAL; - } - } - return res < SMESH::HYP_UNKNOWN_FATAL; -} + + case 701: // COMPUTE MESH + { + if(checkLock(aStudy)) break; + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + int nbSel = Sel->IObjectCount(); + if (nbSel != 1){ + break; + } -//============================================================================= -/*! - * - */ -//============================================================================= -bool SMESHGUI::AddAlgorithmOnMesh( SMESH::SMESH_Mesh_ptr aMesh, - SMESH::SMESH_Hypothesis_ptr aHyp ) -{ - int res = SMESH::HYP_UNKNOWN_FATAL; - QAD_WaitCursor wc; - - if ( !aMesh->_is_nil() ) { - SALOMEDS::SObject_var SM = myStudyAPI.FindObject( aMesh ); - GEOM::GEOM_Shape_var aShape = myStudyAPI.GetShapeOnMeshOrSubMesh( SM ); - try { - res = aMesh->AddHypothesis( aShape, aHyp ); - if ( res < SMESH::HYP_UNKNOWN_FATAL ) { - //SALOMEDS::SObject_var SH = myStudyAPI.FindObject( aHyp ); - //if ( !SM->_is_nil() && !SH->_is_nil() ) { - //myStudyAPI.SetAlgorithms(SM, SH); - myStudyAPI.ModifiedMesh( SM, false ); - //} - } - if ( res >= SMESH::HYP_UNKNOWN_FATAL ) { - wc.stop(); - QAD_MessageBox::error1(QAD_Application::getDesktop(), - tr("SMESH_ERROR"), - tr(QString("SMESH_HYP_%1").arg(res)), - tr("SMESH_BUT_OK")); - wc.start(); - } - else if ( res > SMESH::HYP_OK ) { - wc.stop(); - QAD_MessageBox::warn1( QAD_Application::getDesktop(), - tr( "SMESH_WRN_WARNING" ), - tr(QString("SMESH_HYP_%1").arg(res)), - tr( "SMESH_BUT_OK" ) ); - wc.start(); - } - } - catch( const SALOME::SALOME_Exception& S_ex ) { - wc.stop(); - QtCatchCorbaException( S_ex ); - res = SMESH::HYP_UNKNOWN_FATAL; - } - } - return res < SMESH::HYP_UNKNOWN_FATAL; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -bool SMESHGUI::AddHypothesisOnSubMesh( SMESH::SMESH_subMesh_ptr aSubMesh, - SMESH::SMESH_Hypothesis_ptr aHyp ) -{ - int res = SMESH::HYP_UNKNOWN_FATAL; - QAD_WaitCursor wc; - - if ( !aSubMesh->_is_nil() ) { - try { - SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather(); - SALOMEDS::SObject_var SsubM = myStudyAPI.FindObject( aSubMesh ); - GEOM::GEOM_Shape_var aShape = myStudyAPI.GetShapeOnMeshOrSubMesh( SsubM ); - if ( !aMesh->_is_nil() && !SsubM->_is_nil() && !aShape->_is_nil() ) { - res = aMesh->AddHypothesis( aShape, aHyp ); - if ( res < SMESH::HYP_UNKNOWN_FATAL ) { - //SALOMEDS::SObject_var SH = myStudyAPI.FindObject(aHyp); - // if (!SsubM->_is_nil() && !SH->_is_nil()) - // { - // myStudyAPI.SetHypothesis(SsubM, SH); - myStudyAPI.ModifiedMesh( SsubM, false ); - // } - } - if ( res >= SMESH::HYP_UNKNOWN_FATAL ) { - wc.stop(); - QAD_MessageBox::error1(QAD_Application::getDesktop(), - tr("SMESH_ERROR"), - tr(QString("SMESH_HYP_%1").arg(res)), - tr("SMESH_BUT_OK")); - wc.start(); + SMESH::SMESH_Mesh_var aMesh; + SMESH::SMESH_subMesh_var aSubMesh; + Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); + if (IObject->hasEntry()){ + SALOMEDS::SObject_var aMeshSObj = aStudy->FindObjectID(IObject->getEntry()); + GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( aMeshSObj ); + if ( aShapeObject->_is_nil() ) { + // imported mesh + break; + } + if(!aMeshSObj->_is_nil()) { + SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface(aMeshSObj); + SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface(aMeshSObj); + + if (!aMesh->_is_nil()){ + GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj); + if (!refShapeObject->_is_nil()) { + if(!SMESH::GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject)){ + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + tr("SMESH_WRN_WARNING"), + tr("SMESH_WRN_MISSING_PARAMETERS"), + tr("SMESH_BUT_OK")); + break; + } + try{ + if (SMESH::GetSMESHGen()->Compute(aMesh,refShapeObject)) + SMESH::ModifiedMesh(aMeshSObj,true); + // TO Do : change icon of all submeshes + else + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + tr("SMESH_WRN_WARNING"), + tr("SMESH_WRN_COMPUTE_FAILED"), + tr("SMESH_BUT_OK")); + } + catch(const SALOME::SALOME_Exception & S_ex){ + QtCatchCorbaException(S_ex); + } + } + }else if(!aSubMesh->_is_nil()){ + aMesh = aSubMesh->GetFather(); + GEOM::GEOM_Object_var refShapeObject = SMESH::GetShapeOnMeshOrSubMesh(aMeshSObj); + if(!refShapeObject->_is_nil()){ + bool compute = SMESH::GetSMESHGen()->IsReadyToCompute(aMesh,refShapeObject); + if(!compute){ + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + tr("SMESH_WRN_WARNING"), + tr("SMESH_WRN_MISSING_PARAMETERS"), + tr("SMESH_BUT_OK")); + break; + } + try{ + if ( SMESH::GetSMESHGen()->Compute(aMesh,refShapeObject) ) + SMESH::ModifiedMesh(aMeshSObj,true); + // TO Do : change icon of all submeshes + else + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + tr("SMESH_WRN_WARNING"), + tr("SMESH_WRN_COMPUTE_FAILED"), + tr("SMESH_BUT_OK")); + }catch(const SALOME::SALOME_Exception & S_ex){ + QtCatchCorbaException(S_ex); + } + } + } + } } - else if ( res > SMESH::HYP_OK ) { - wc.stop(); - QAD_MessageBox::warn1(QAD_Application::getDesktop(), - tr( "SMESH_WRN_WARNING" ), - tr(QString("SMESH_HYP_%1").arg(res)), - tr( "SMESH_BUT_OK" ) ); - wc.start(); + CORBA::Long anId = aStudy->StudyId(); + TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,IObject->getEntry()); + if(myAutomaticUpdate && aVisualObj){ + aVisualObj->Update(); + SMESH_Actor* anActor = SMESH::FindActorByEntry(IObject->getEntry()); + if(!anActor){ + anActor = SMESH::CreateActor(aStudy,IObject->getEntry()); + if(anActor){ + SMESH::DisplayActor(myActiveStudy->getActiveStudyFrame(),anActor); //apo + SMESH::FitAll(); + } + } } + }else{ + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + tr("SMESH_WRN_WARNING"), + tr("SMESH_WRN_VIEWER_VTK"), + tr("SMESH_BUT_OK")); } + break; } - catch( const SALOME::SALOME_Exception& S_ex ) { - wc.stop(); - QtCatchCorbaException( S_ex ); - res = SMESH::HYP_UNKNOWN_FATAL; - } - } - return res < SMESH::HYP_UNKNOWN_FATAL; -} -//============================================================================= -/*! - * - */ -//============================================================================= -bool SMESHGUI::AddAlgorithmOnSubMesh( SMESH::SMESH_subMesh_ptr aSubMesh, - SMESH::SMESH_Hypothesis_ptr aHyp ) -{ - int res = SMESH::HYP_UNKNOWN_FATAL; - QAD_WaitCursor wc; - - if ( !aSubMesh->_is_nil() ) { - try { - SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather(); - SALOMEDS::SObject_var SsubM = myStudyAPI.FindObject(aSubMesh); - GEOM::GEOM_Shape_var aShape = myStudyAPI.GetShapeOnMeshOrSubMesh(SsubM); - if ( !aMesh->_is_nil() && !SsubM->_is_nil() && !aShape->_is_nil() ) { - res = aMesh->AddHypothesis( aShape, aHyp ); - if ( res < SMESH::HYP_UNKNOWN_FATAL ) { - //SALOMEDS::SObject_var SH = myStudyAPI.FindObject(aHyp); - //if (!SsubM->_is_nil() && !SH->_is_nil()) { - //myStudyAPI.SetAlgorithms(SsubM, SH); - myStudyAPI.ModifiedMesh( SsubM, false ); - //} - } - if ( res >= SMESH::HYP_UNKNOWN_FATAL ) { - wc.stop(); - QAD_MessageBox::error1(QAD_Application::getDesktop(), - tr("SMESH_ERROR"), - tr(QString("SMESH_HYP_%1").arg(res)), - tr("SMESH_BUT_OK")); - wc.start(); - } - else if ( res > SMESH::HYP_OK ) { - wc.stop(); - QAD_MessageBox::warn1(QAD_Application::getDesktop(), - tr( "SMESH_WRN_WARNING" ), - tr(QString("SMESH_HYP_%1").arg(res)), - tr( "SMESH_BUT_OK" ) ); - wc.start(); - } + case 702: // ADD SUB MESH + { + if(checkLock(aStudy)) break; + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + EmitSignalDeactivateDialog(); + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + SMESHGUI_AddSubMeshDlg *aDlg = new SMESHGUI_AddSubMeshDlg(parent, "", Sel); } - } - catch( const SALOME::SALOME_Exception& S_ex ) { - wc.stop(); - QtCatchCorbaException( S_ex ); - res = SMESH::HYP_UNKNOWN_FATAL; - } - } - return res < SMESH::HYP_UNKNOWN_FATAL; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -int SMESHGUI::GetNameOfSelectedIObjects(SALOME_Selection * Sel, QString & aName) -{ - int nbSel = Sel->IObjectCount(); - if (nbSel == 1) - { - Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); - aName = IObject->getName(); - } - else - { - aName = tr("SMESH_OBJECTS_SELECTED").arg(nbSel); - } - return nbSel; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -int SMESHGUI::GetNameOfSelectedNodes(SALOME_Selection * Sel, QString & aName){ - aName = ""; - if(Sel->IObjectCount() == 1){ - Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); - if(IObject->hasEntry()){ - if(SMESH_Actor *anActor = ::FindActorByEntry(IObject->getEntry())){ - TColStd_MapOfInteger MapIndex; - Sel->GetIndex(IObject, MapIndex); - TColStd_MapIteratorOfMapOfInteger ite(MapIndex); - for(; ite.More(); ite.Next()){ - aName += QString(" %1").arg(anActor->GetNodeObjId(ite.Key())); - } - return MapIndex.Extent(); + else { + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), + tr("SMESH_BUT_OK")); } + break; } - } - return -1; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -int SMESHGUI::GetNameOfSelectedElements(SALOME_Selection * Sel, QString & aName){ - aName = ""; - if(Sel->IObjectCount() == 1){ - Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); - if(IObject->hasEntry()){ - if(SMESH_Actor *anActor = ::FindActorByEntry(IObject->getEntry())){ - TColStd_MapOfInteger MapIndex; - Sel->GetIndex(IObject, MapIndex); - TColStd_MapIteratorOfMapOfInteger ite(MapIndex); - std::vector aList; - for(; ite.More(); ite.Next()){ - int aVtkId = ite.Key(); - int anObjId = anActor->GetElemObjId(aVtkId); - std::vector::iterator found = find(aList.begin(), aList.end(), anObjId); - // MESSAGE("GetNameOfSelectedElements(): VTK Id = " << aVtkId << ", OBJECT Id = " << anObjId); - if (found == aList.end()) { - aList.push_back(anObjId); - aName += QString(" %1").arg(anObjId); - } - } - return aList.size(); - } + + case 703: // INIT MESH + { + if(checkLock(aStudy)) break; + EmitSignalDeactivateDialog(); + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + SMESHGUI_InitMeshDlg *aDlg = new SMESHGUI_InitMeshDlg(parent, "", Sel); + break; } - } - return -1; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -int SMESHGUI::GetNameOfSelectedEdges(SALOME_Selection * Sel, QString & aName){ - aName = ""; - if(Sel->IObjectCount() == 1){ - Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); - if(IObject->hasEntry()){ - if(SMESH_Actor *anActor = ::FindActorByEntry(IObject->getEntry())){ - TColStd_MapOfInteger MapIndex; - Sel->GetIndex(IObject, MapIndex); - TColStd_MapIteratorOfMapOfInteger ite(MapIndex); - for(; ite.More(); ite.Next()){ - aName += QString(" %1").arg(ite.Key()); - } - return MapIndex.Extent(); - } + case 704: // EDIT Hypothesis + { + if(checkLock(aStudy)) break; + EmitSignalDeactivateDialog(); + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + SMESHGUI_EditHypothesesDlg *aDlg = new SMESHGUI_EditHypothesesDlg(parent, "", Sel); + break; } - } - return -1; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -SMESH_Actor *SMESHGUI::FindActorByEntry(QString theEntry, - Standard_Boolean & theResult, - bool onlyInActiveView) -{ - theResult = false; - int aNbStudyFrames = myActiveStudy->getStudyFramesCount(); - for (int i = 0; i < aNbStudyFrames; i++){ - QAD_StudyFrame *aStudyFrame = myActiveStudy->getStudyFrame(i); - if(SMESH_Actor *anActor = ::FindActorByEntry(aStudyFrame,theEntry.latin1())){ - theResult = true; - return anActor; + case 705: // EDIT Global Hypothesis + { + if(checkLock(aStudy)) break; + EmitSignalDeactivateDialog(); + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + SMESHGUI_EditHypothesesDlg *aDlg = new SMESHGUI_EditHypothesesDlg(parent, "", Sel); + break; } - } - return NULL; -} -//============================================================================= -/*! - * - */ -//============================================================================= -SMESH_Actor* SMESHGUI::FindActor(CORBA::Object_ptr theObj, - Standard_Boolean & theResult, - bool theOnlyInActiveView) -{ - theResult = false; - SMESH_Actor* aRes = NULL; - if ( !CORBA::is_nil( theObj ) ) { - SALOMEDS::SObject_var aSObject = SALOMEDS::SObject::_narrow( myStudy->FindObjectIOR( _orb->object_to_string( theObj ) ) ); - if( !aSObject->_is_nil()) { - CORBA::String_var anEntry = aSObject->GetID(); - aRes = FindActorByEntry( anEntry.in(), theResult, theOnlyInActiveView ); + case 706: // EDIT Local Hypothesis + { + if(checkLock(aStudy)) break; + EmitSignalDeactivateDialog(); + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + SMESHGUI_EditHypothesesDlg *aDlg = new SMESHGUI_EditHypothesesDlg(parent, "", Sel); + break; } - } - return aRes; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -SMESH::SMESH_Mesh_ptr SMESHGUI::ConvertIOinMesh(const Handle(SALOME_InteractiveObject) & IO, - Standard_Boolean & testResult) -{ - SMESH::SMESH_Mesh_var aMesh; - testResult = false; - /* case SObject */ - if (IO->hasEntry()) - { - SALOMEDS::SObject_var obj = myStudy->FindObjectID(IO->getEntry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if (!obj->_is_nil()) + case 407: // DIAGONAL INVERSION + case 408: // Delete diagonal { - if (obj->FindAttribute(anAttr, "AttributeIOR")) + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - aMesh = - SMESH::SMESH_Mesh::_narrow(_orb->string_to_object(anIOR->Value())); - if (!aMesh->_is_nil()) - { - testResult = true; - return SMESH::SMESH_Mesh::_duplicate(aMesh); - } - } + QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ), + tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) ); + break; + } + + if ( checkLock( aStudy ) ) + break; + + SALOME_Selection *aSel = + SALOME_Selection::Selection( myActiveStudy->getSelection() ); + /*Standard_Boolean aRes; + SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface(IObject); + if ( aMesh->_is_nil() ) + { + QAD_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ), + tr( "SMESH_BAD_SELECTION" ), tr( "SMESH_BUT_OK" ) ); + break; + } + */ + EmitSignalDeactivateDialog(); + if ( theCommandID == 407 ) + new SMESHGUI_TrianglesInversionDlg( parent, aSel ); + else + new SMESHGUI_UnionOfTwoTrianglesDlg( parent, aSel ); + break; } - } - return SMESH::SMESH_Mesh::_nil(); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -SMESH::SMESH_subMesh_ptr SMESHGUI::ConvertIOinSubMesh(const Handle(SALOME_InteractiveObject) & IO, - Standard_Boolean & testResult) -{ - SMESH::SMESH_subMesh_var aSubMesh; - testResult = false; - - /* case SObject */ - if (IO->hasEntry()) - { - SALOMEDS::SObject_var obj = myStudy->FindObjectID(IO->getEntry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if (!obj->_is_nil()) + case 409: // Change orientation + case 410: // Union of triangles + case 411: // Cutting of quadrangles { - if (obj->FindAttribute(anAttr, "AttributeIOR")) + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - aSubMesh = SMESH::SMESH_subMesh::_narrow(_orb->string_to_object(anIOR->Value())); - if (!aSubMesh->_is_nil()) - { - testResult = true; - return SMESH::SMESH_subMesh::_duplicate(aSubMesh); - } + QAD_MessageBox::warn1( GetDesktop(), tr( "SMESH_WRN_WARNING" ), + tr( "NOT_A_VTK_VIEWER" ),tr( "SMESH_BUT_OK" ) ); + break; } - } - } - return SMESH::SMESH_subMesh::_nil(); -} -//============================================================================= -/*! - * - */ -//============================================================================= -SMESH::SMESH_Hypothesis_ptr SMESHGUI::ConvertIOinSMESHHypothesis(const Handle(SALOME_InteractiveObject) & IO, - Standard_Boolean & testResult) -{ - SMESH::SMESH_Hypothesis_var aHyp; - testResult = false; + if ( checkLock( aStudy ) ) + break; - /* case SObject */ - if (IO->hasEntry()) - { - SALOMEDS::SObject_var obj = myStudy->FindObjectID(IO->getEntry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if (!obj->_is_nil()) - { - if (obj->FindAttribute(anAttr, "AttributeIOR")) - { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - aHyp = SMESH::SMESH_Hypothesis::_narrow(_orb->string_to_object(anIOR->Value())); - if (!aHyp->_is_nil()) - { - testResult = true; - return SMESH::SMESH_Hypothesis::_duplicate(aHyp); - } - } - } - } - return SMESH::SMESH_Hypothesis::_nil(); -} + SALOME_Selection *aSel = + SALOME_Selection::Selection( myActiveStudy->getSelection() ); -//============================================================================= -/*! - * - */ -//============================================================================= -SMESH::SMESH_Group_ptr SMESHGUI::ConvertIOinSMESHGroup(const Handle(SALOME_InteractiveObject) & IO, - Standard_Boolean & testResult) -{ - SMESH::SMESH_Group_var aGroup; - testResult = false; + EmitSignalDeactivateDialog(); + SMESHGUI_MultiEditDlg* aDlg; + if ( theCommandID == 409 ) + aDlg = new SMESHGUI_ChangeOrientationDlg( parent, aSel ); + else if ( theCommandID == 410 ) + aDlg = new SMESHGUI_UnionOfTrianglesDlg( parent, aSel ); + else + aDlg = new SMESHGUI_CuttingOfQuadsDlg( parent, aSel ); - /* case SObject */ - if (IO->hasEntry()) { - SALOMEDS::SObject_var obj = myStudy->FindObjectID(IO->getEntry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if (!obj->_is_nil()) { - if (obj->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - aGroup = SMESH::SMESH_Group::_narrow(_orb->string_to_object(anIOR->Value())); - if (!aGroup->_is_nil()) { - testResult = true; - return SMESH::SMESH_Group::_duplicate(aGroup); - } - } + int x, y ; + DefineDlgPosition( aDlg, x, y ); + aDlg->move( x, y ); + aDlg->show(); + break; } - } - return SMESH::SMESH_Group::_nil(); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -GEOM::GEOM_Shape_ptr SMESHGUI::ConvertIOinGEOMShape(const Handle(SALOME_InteractiveObject) & IO, - Standard_Boolean & testResult) -{ - GEOM::GEOM_Shape_var aShape; - testResult = false; - - /* case SObject */ - if (IO->hasEntry()) { - SALOMEDS::SObject_var obj = myStudy->FindObjectID(IO->getEntry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if (!obj->_is_nil()) { - if (obj->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - aShape = myComponentGeom->GetIORFromString(anIOR->Value()); - if (!aShape->_is_nil()) { - testResult = true; - return GEOM::GEOM_Shape::_duplicate(aShape); - } + case 412: // Smoothing + { + if(checkLock(aStudy)) break; + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + EmitSignalDeactivateDialog(); + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + SMESHGUI_SmoothingDlg *aDlg = new SMESHGUI_SmoothingDlg(parent, "", Sel); + } + else { + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), + tr("SMESH_BUT_OK")); } + break; } - } - return GEOM::GEOM_Shape::_nil(); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESHGUI::SetViewMode(int commandId){ - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - if(Sel->IObjectCount() >= 1){ - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - for(; It.More(); It.Next()){ - Handle(SALOME_InteractiveObject) IObject = It.Value(); - if(IObject->hasEntry()){ - if(SMESH_Actor *anActor = ::FindActorByEntry(IObject->getEntry())){ - switch(commandId){ - case 211: - ChangeRepresentation(anActor,0); - break; - case 212: - ChangeRepresentation(anActor,1); - break; - case 213: - ChangeRepresentation(anActor,2); - break; - case 215: - ChangeRepresentation(anActor,5); - break; - case 1132: - ChangeRepresentation(anActor,3); - break; - } - } + case 413: // Extrusion + { + if(checkLock(aStudy)) break; + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + EmitSignalDeactivateDialog(); + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + SMESHGUI_ExtrusionDlg *aDlg = new SMESHGUI_ExtrusionDlg(parent, "", Sel); + } + else { + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), + tr("SMESH_BUT_OK")); } + break; } - if(commandId == 1133) - ChangeRepresentation(NULL,4); - } -} - -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESHGUI::ChangeRepresentation(SMESH_Actor * theActor, int type){ - switch (type){ - case 0:{ - //theActor->UnShrink(); - theActor->SetRepresentation(SMESH_Actor::eEdge); - break; - } - case 1:{ - //theActor->UnShrink(); - theActor->SetRepresentation(SMESH_Actor::eSurface); - break; - } - case 2:{ - theActor->IsShrunk() ? theActor->UnShrink() : theActor->SetShrink(); - //theActor->SetRepresentation(SMESH_Actor::eSurface); - break; - } - case 5:{ - //theActor->UnShrink(); - theActor->SetRepresentation(SMESH_Actor::ePoint); - break; - } - case 3:{ - float color[3]; - theActor->GetSufaceColor(color[0], color[1], color[2]); - int c0 = int (color[0] * 255); - int c1 = int (color[1] * 255); - int c2 = int (color[2] * 255); - QColor c(c0, c1, c2); - - float edgecolor[3]; - theActor->GetEdgeColor(edgecolor[0], edgecolor[1], edgecolor[2]); - c0 = int (edgecolor[0] * 255); - c1 = int (edgecolor[1] * 255); - c2 = int (edgecolor[2] * 255); - QColor e(c0, c1, c2); - - float backfacecolor[3]; - theActor->GetBackSufaceColor(backfacecolor[0], backfacecolor[1], backfacecolor[2]); - c0 = int (backfacecolor[0] * 255); - c1 = int (backfacecolor[1] * 255); - c2 = int (backfacecolor[2] * 255); - QColor b(c0, c1, c2); - - float nodecolor[3]; - theActor->GetNodeColor(nodecolor[0], nodecolor[1], nodecolor[2]); - c0 = int (nodecolor[0] * 255); - c1 = int (nodecolor[1] * 255); - c2 = int (nodecolor[2] * 255); - QColor n(c0, c1, c2); - - int Edgewidth = (int)theActor->GetLineWidth(); - if(Edgewidth == 0) - Edgewidth = 1; - int intValue = int(theActor->GetNodeSize()); - float Shrink = theActor->GetShrinkFactor(); - - SMESHGUI_Preferences_ColorDlg *aDlg = new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(),""); - aDlg->SetColor(1, c); - aDlg->SetColor(2, e); - aDlg->SetColor(3, n); - aDlg->SetColor(4, b); - aDlg->SetIntValue(1, Edgewidth); - aDlg->SetIntValue(2, intValue); - aDlg->SetIntValue(3, int(Shrink*100.)); - if(aDlg->exec()){ - QColor color = aDlg->GetColor(1); - QColor edgecolor = aDlg->GetColor(2); - QColor nodecolor = aDlg->GetColor(3); - QColor backfacecolor = aDlg->GetColor(4); - /* actor color and backface color */ - theActor->SetSufaceColor(float (color.red()) / 255., - float (color.green()) / 255., - float (color.blue()) / 255.); - theActor->SetBackSufaceColor(float (backfacecolor.red()) / 255., - float (backfacecolor.green()) / 255., - float (backfacecolor.blue()) / 255.); - - /* edge color */ - theActor->SetEdgeColor(float (edgecolor.red()) / 255., - float (edgecolor.green()) / 255., - float (edgecolor.blue()) / 255.); - - /* Shrink factor and size edges */ - theActor->SetShrinkFactor(aDlg->GetIntValue(3) / 100.); - theActor->SetLineWidth(aDlg->GetIntValue(1)); - - /* Nodes color and size */ - theActor->SetNodeColor(float (nodecolor.red()) / 255., - float (nodecolor.green()) / 255., - float (nodecolor.blue()) / 255.); - theActor->SetNodeSize(aDlg->GetIntValue(2)); - - delete aDlg; + case 414: // Revolution + { + if(checkLock(aStudy)) break; + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + EmitSignalDeactivateDialog(); + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + SMESHGUI_RevolutionDlg *aDlg = new SMESHGUI_RevolutionDlg(parent, "", Sel); + } + else { + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), + tr("SMESH_BUT_OK")); + } + break; + } + case 415: // Pattern mapping + { + if ( checkLock( aStudy ) ) + break; + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) + { + EmitSignalDeactivateDialog(); + SALOME_Selection *Sel = SALOME_Selection::Selection( + myActiveStudy->getSelection() ); + new SMESHGUI_MeshPatternDlg( parent, Sel ); + } + else { + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), + tr("SMESH_BUT_OK")); + } + break; + } + case 801: // CREATE GROUP + { + if(checkLock(aStudy)) break; + EmitSignalDeactivateDialog(); + SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil(); + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + int nbSel = Sel->IObjectCount(); + if (nbSel == 1) { + // check if mesh is selected + aMesh = SMESH::GetMeshByIO(Sel->firstIObject()); + } + SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, aMesh); + aDlg->show(); + break; } - break; - } - case 4:{ - EmitSignalDeactivateDialog(); - SMESHGUI_TransparencyDlg *aDlg = new SMESHGUI_TransparencyDlg(QAD_Application::getDesktop(),"",false); - break; - } - } - UpdateView(); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESHGUI::UpdateView(){ - ::RepaintCurrentView(); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESHGUI::DisplayActor(SMESH_Actor * theActor, bool theVisibility){ - theActor->SetVisibility(theVisibility); - ::DisplayActor(myActiveStudy->getActiveStudyFrame(),theActor); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESHGUI::EraseActor(SMESH_Actor * theActor){ - theActor->SetVisibility(false); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -bool SMESHGUI::AddActorInSelection(SMESH_Actor * ac) -{ - SALOME_Selection *Sel = - SALOME_Selection::Selection(myActiveStudy->getSelection()); - Sel->ClearIObjects(); - if (ac->hasIO()) - return Sel->AddIObject(ac->getIO()); - else - return -1; -} -//============================================================================= -/*! - * - */ -//============================================================================= -QString SMESHGUI::CheckHomogeneousSelection() -{ - SALOME_Selection *Sel = - SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - /* copy the list */ - SALOME_ListIO List; - SALOME_ListIteratorOfListIO Itinit(Sel->StoredIObjects()); - for (; Itinit.More(); Itinit.Next()) - { - List.Append(Itinit.Value()); + case 802: // CONSTRUCT GROUP + { + if(checkLock(aStudy)) break; + EmitSignalDeactivateDialog(); + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + int nbSel = Sel->IObjectCount(); + if (nbSel == 1) { + // check if submesh is selected + Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); + if (IObject->hasEntry()) { + SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(IObject->getEntry()); + if(!aSObj->_is_nil()) { + SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(aSObj->GetObject()); + if (!aSubMesh->_is_nil()) { + try { + SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather(); + // get submesh elements list by types + SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE); + SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE); + SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE); + SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME); + // create group for each type o elements + QString aName = IObject->getName(); + if (aNodes->length() > 0) { + SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::NODE, aName); + aGroup->Add(aNodes.inout()); + } + if (aEdges->length() > 0) { + SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::EDGE, aName); + aGroup->Add(aEdges.inout()); + } + if (aFaces->length() > 0) { + SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::FACE, aName); + aGroup->Add(aFaces.inout()); + } + if (aVolumes->length() > 0) { + SMESH::SMESH_Group_var aGroup = SMESH::AddGroup(aMesh, SMESH::VOLUME, aName); + aGroup->Add(aVolumes.inout()); + } + myActiveStudy->updateObjBrowser(true); + }catch(const SALOME::SALOME_Exception & S_ex){ + QtCatchCorbaException(S_ex); + } + } + } } + } + break; + } - QString RefType = CheckTypeObject(Sel->firstIObject()); - SALOME_ListIteratorOfListIO It(List); - for (; It.More(); It.Next()) - { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - QString Type = CheckTypeObject(IObject); - if (Type.compare(RefType) != 0) - return "Heterogeneous Selection"; + case 803: // EDIT GROUP + { + if(checkLock(aStudy)) break; + EmitSignalDeactivateDialog(); + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy + SALOME_ListIteratorOfListIO It (IOs); + int nbSelectedGroups = 0; + for ( ; It.More(); It.Next() ) + { + SMESH::SMESH_Group_var aGroup = + SMESH::IObjectToInterface(It.Value()); + if (!aGroup->_is_nil()) { + nbSelectedGroups++; + SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, aGroup); + aDlg->show(); } - - Sel->ClearIObjects(); - SALOME_ListIteratorOfListIO It1(List); - for (; It1.More(); It1.Next()) + } + if (nbSelectedGroups == 0) { - int res = Sel->AddIObject(It1.Value()); - if (res == -1) - myActiveStudy->highlight(It1.Value(), false); - if (res == 0) - myActiveStudy->highlight(It1.Value(), true); + SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, SMESH::SMESH_Group::_nil()); + aDlg->show(); } - return RefType; -} + break; + } -//============================================================================= -/*! - * - */ -//============================================================================= -QString SMESHGUI::CheckTypeObject(const Handle(SALOME_InteractiveObject) & IO) -{ - SALOMEDS::SObject_var sobj = smeshGUI->myActiveStudy->getStudyDocument()->FindObjectID(IO->getEntry()); - if (!sobj->_is_nil()) { - SALOMEDS::SComponent_var scomp = sobj->GetFatherComponent(); - if (strcmp(scomp->GetID(), IO->getEntry()) == 0) - { // component is selected - return "Component"; + case 804: // Add elements to group + { + if(checkLock(aStudy)) break; + if (myState == 800) { + SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox; + if (aDlg) aDlg->onAdd(); } - } + break; + } - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - Sel->ClearIObjects(); - - Handle(SMESH_TypeFilter) aHypFilter = new SMESH_TypeFilter(HYPOTHESIS); - Handle(SMESH_TypeFilter) anAlgoFilter = new SMESH_TypeFilter(ALGORITHM); - Handle(SMESH_TypeFilter) aMeshFilter = new SMESH_TypeFilter(MESH); - Handle(SMESH_TypeFilter) aSubMeshFilter = new SMESH_TypeFilter(SUBMESH); - Handle(SMESH_TypeFilter) aGroupFilter = new SMESH_TypeFilter(GROUP); - Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter(MESHorSUBMESH); - Handle(SMESH_TypeFilter) aSubMeshVextexFilter = new SMESH_TypeFilter(SUBMESH_VERTEX); - Handle(SMESH_TypeFilter) aSubMeshEdgeFilter = new SMESH_TypeFilter(SUBMESH_EDGE); - Handle(SMESH_TypeFilter) aSubMeshFaceFilter = new SMESH_TypeFilter(SUBMESH_FACE); - Handle(SMESH_TypeFilter) aSubMeshSolidFilter = new SMESH_TypeFilter(SUBMESH_SOLID); - Handle(SMESH_TypeFilter) aSubMeshCompoundFilter = new SMESH_TypeFilter(SUBMESH_COMPOUND); - - Sel->AddFilter(aHypFilter); - if (Sel->AddIObject(IO) != -1) { - Sel->ClearFilters(); - return "Hypothesis"; - } + case 805: // Remove elements from group + { + if(checkLock(aStudy)) break; + if (myState == 800) { + SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) myActiveDialogBox; + if (aDlg) aDlg->onRemove(); + } + break; + } - Sel->ClearFilters(); - Sel->AddFilter(anAlgoFilter); - if (Sel->AddIObject(IO) != -1) { - Sel->ClearFilters(); - return "Algorithm"; - } + case 810: // Union Groups + case 811: // Intersect groups + case 812: // Cut groups + { + if ( checkLock( aStudy ) ) + break; - Sel->ClearFilters(); - Sel->AddFilter(aMeshFilter); - if (Sel->AddIObject(IO) != -1) { - Sel->ClearFilters(); - return "Mesh"; - } + EmitSignalDeactivateDialog(); + SALOME_Selection *Sel = SALOME_Selection::Selection( + myActiveStudy->getSelection() ); - Sel->ClearFilters(); - Sel->AddFilter(aSubMeshFilter); - if (Sel->AddIObject(IO) != -1) { - Sel->ClearFilters(); - return "SubMesh"; - } + int aMode; + if ( theCommandID == 810 ) aMode = SMESHGUI_GroupOpDlg::UNION; + else if ( theCommandID == 811 ) aMode = SMESHGUI_GroupOpDlg::INTERSECT; + else aMode = SMESHGUI_GroupOpDlg::CUT; - Sel->ClearFilters(); - Sel->AddFilter(aGroupFilter); - if (Sel->AddIObject(IO) != -1) { - Sel->ClearFilters(); - return "Group"; - } + ( new SMESHGUI_GroupOpDlg( parent, Sel, aMode ) )->show(); + break; + } - Sel->ClearFilters(); - Sel->AddFilter(aSubMeshVextexFilter); - if (Sel->AddIObject(IO) != -1) { - Sel->ClearFilters(); - return "SubMeshVertex"; - } + case 813: // Delete groups with their contents + { + if ( checkLock( aStudy ) ) + break; - Sel->ClearFilters(); - Sel->AddFilter(aSubMeshEdgeFilter); - if (Sel->AddIObject(IO) != -1) { - Sel->ClearFilters(); - return "SubMeshEdge"; - } + EmitSignalDeactivateDialog(); + SALOME_Selection *Sel = SALOME_Selection::Selection( + myActiveStudy->getSelection() ); - Sel->ClearFilters(); - Sel->AddFilter(aSubMeshFaceFilter); - if (Sel->AddIObject(IO) != -1) { - Sel->ClearFilters(); - return "SubMeshFace"; - } + ( new SMESHGUI_DeleteGroupDlg( parent, Sel ) )->show(); + break; + } - Sel->ClearFilters(); - Sel->AddFilter(aSubMeshSolidFilter); - if (Sel->AddIObject(IO) != -1) { - Sel->ClearFilters(); - return "SubMeshSolid"; - } + case 900: // MESH INFOS + { + EmitSignalDeactivateDialog(); + SALOME_Selection *Sel = + SALOME_Selection::Selection(myActiveStudy->getSelection()); + if ( Sel->IObjectCount() > 1 ) { // a dlg for each IO + SALOME_ListIO IOs; IOs = Sel->StoredIObjects(); // list copy + SALOME_ListIteratorOfListIO It (IOs); + for ( ; It.More(); It.Next() ) { + Sel->ClearIObjects(); + Sel->AddIObject( It.Value() ); + SMESHGUI_MeshInfosDlg *aDlg = new SMESHGUI_MeshInfosDlg(parent, "", false); + } + // restore selection + Sel->ClearIObjects(); + for (It.Initialize( IOs ) ; It.More(); It.Next() ) + Sel->AddIObject( It.Value() ); + } + else + SMESHGUI_MeshInfosDlg *aDlg = new SMESHGUI_MeshInfosDlg(parent, "", false); + break; + } - Sel->ClearFilters(); - Sel->AddFilter(aSubMeshCompoundFilter); - if (Sel->AddIObject(IO) != -1) { - Sel->ClearFilters(); - return "SubMeshCompound"; - } + case 1001: // AUTOMATIC UPDATE PREFERENCES + { + parent->menuBar()->setItemChecked(1001, !parent->menuBar()->isItemChecked(1001)); + if (parent->menuBar()->isItemChecked(1001)) { + QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "true"); + myAutomaticUpdate = true; + } + else { + QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "false"); + myAutomaticUpdate = false; + } + break; + } - Sel->ClearFilters(); - Sel->AddIObject(IO); - return "NoType"; -} + case 1003: // MESH PREFERENCES + { + ::SetDisplaySettings(); + break; + } + case 1005: + { + SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( parent ); + break; + } -static int isStudyLocked(const SALOMEDS::Study_var& theStudy){ - return theStudy->GetProperties()->IsLocked(); -} + case 1007: + { + ( new SMESHGUI_PrecisionDlg( parent ) )->exec(); + break; + } -static int checkLock(const SALOMEDS::Study_var& theStudy) { - if (isStudyLocked(theStudy)) { - QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(), - QObject::tr("WRN_WARNING"), - QObject::tr("WRN_STUDY_LOCKED"), - QObject::tr("BUT_OK") ); - return true; - } - return false; -} + case 1006: + { + SMESHGUI_Preferences_SelectionDlg* aDlg = + new SMESHGUI_Preferences_SelectionDlg(parent); -//============================================================================= -/*! - * - */ -//============================================================================= -bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) -{ - SALOMEDS::Study_var aStudy = smeshGUI->myActiveStudy->getStudyDocument(); //Document OCAF de l'etude active - // QAD_Viewer3d* v3d; - OCCViewer_Viewer3d *v3d; - - Handle(AIS_InteractiveContext) ic; - vtkRenderer *Renderer; - vtkRenderWindow *RenWin; - - if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_OCC) { - v3d = ((OCCViewer_ViewFrame *) smeshGUI->myActiveStudy-> - getActiveStudyFrame()->getRightFrame()->getViewFrame())->getViewer(); - ic = v3d->getAISContext(); - } - else if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - Renderer = ((VTKViewer_ViewFrame *) smeshGUI->myActiveStudy-> - getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - RenWin = Renderer->GetRenderWindow(); - } + QColor aColor; + QString SCr, SCg, SCb; + SCr = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorRed"); + SCg = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorGreen"); + SCb = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorBlue"); + if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) + aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); + else aColor = Qt::cyan; + aDlg->SetColor(1, aColor); - switch (theCommandID) { - case 33: // DELETE - if(checkLock(aStudy)) break; - smeshGUI->OnEditDelete(); - break; - - case 113: // IMPORT - case 112: - case 111: - { - if(checkLock(aStudy)) break; - //Import_Document(parent, theCommandID); //NBU - Import_Mesh(parent,theCommandID); - break; - } + SCr = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorRed"); + SCg = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorGreen"); + SCb = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorBlue"); + if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) + aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); + else aColor = Qt::yellow; + aDlg->SetColor(2, aColor); - case 122: // EXPORT MED - case 121: - case 123: - { - Export_Mesh(parent, theCommandID); - break; - } + SCr = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorRed"); + SCg = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorGreen"); + SCb = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorBlue"); + if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) + aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); + else aColor = Qt::white; + aDlg->SetColor(3, aColor); - case 200: // SCALAR BAR - { - SALOME_Selection *Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); - if( Sel && Sel->IObjectCount() ) { - Handle(SALOME_InteractiveObject) anIO = Sel->firstIObject(); - if( anIO->hasEntry() ) { - if( SMESH_Actor* anActor = ::FindActorByEntry( anIO->getEntry() ) ) { - anActor->SetControlMode( SMESH_Actor::eNone ); + QString SW1 = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectWidth"); + if (SW1.isEmpty()) SW1 = "5"; + aDlg->SetWidth(1, SW1.toInt()); + + QString SW2 = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectWidth"); + if (SW2.isEmpty()) SW2 = "5"; + aDlg->SetWidth(2, SW2.toInt()); + + QString SP1 = QAD_CONFIG->getSetting("SMESH:SettingsNodeSelectTol"); + if (SP1.isEmpty()) SP1 = "0.025"; + aDlg->SetPrecision(1, SP1.toDouble()); + + QString SP2 = QAD_CONFIG->getSetting("SMESH:SettingsElementsSelectTol"); + if (SP2.isEmpty()) SP2 = "0.001"; + aDlg->SetPrecision(2, SP2.toDouble()); + + if (aDlg->exec()) { + QColor aPreColor = aDlg->GetColor(1); + QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorRed", aPreColor.red()); + QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorGreen", aPreColor.green()); + QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorBlue", aPreColor.blue()); + + QColor aSelColor = aDlg->GetColor(2); + QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorRed", aSelColor.red()); + QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorGreen", aSelColor.green()); + QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorBlue", aSelColor.blue()); + + QColor aHiColor = aDlg->GetColor(3); + QAD_CONFIG->addSetting("SMESH:SettingsSelectColorRed", aHiColor.red()); + QAD_CONFIG->addSetting("SMESH:SettingsSelectColorGreen", aHiColor.green()); + QAD_CONFIG->addSetting("SMESH:SettingsSelectColorBlue", aHiColor.blue()); + + int aPreWidth = aDlg->GetWidth(1); + QAD_CONFIG->addSetting("SMESH:SettingsPreSelectWidth", aPreWidth); + int aSelWidth = aDlg->GetWidth(2); + QAD_CONFIG->addSetting("SMESH:SettingsItemSelectWidth", aSelWidth); + + double aTolNodes = aDlg->GetPrecision(1); + QAD_CONFIG->addSetting("SMESH:SettingsNodeSelectTol", aTolNodes); + double aTolItems = aDlg->GetPrecision(2); + QAD_CONFIG->addSetting("SMESH:SettingsElementsSelectTol", aTolItems); + + // update current study settings + SMESH::UpdateSelectionProp(); + + QAD_StudyFrame* studyFrame = myActiveStudy->getActiveStudyFrame(); + if (studyFrame->getTypeView() == VIEW_VTK) { + VTKViewer_ViewFrame* aViewFrame = SMESH::GetVtkViewFrame(studyFrame); + // update VTK viewer properties + VTKViewer_RenderWindowInteractor* anInteractor = aViewFrame->getRWInteractor(); + if (anInteractor) { + anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255., + aSelColor.blue()/255., aSelWidth); + anInteractor->SetSelectionTolerance(aTolNodes, aTolItems); + VTKViewer_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME(); + if (aStyle) + aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255., + aPreColor.blue()/255., aPreWidth); + } + // update actors + vtkRenderer* aRenderer = aViewFrame->getRenderer(); + vtkActorCollection *aCollection = aRenderer->GetActors(); + aCollection->InitTraversal(); + while(vtkActor *anAct = aCollection->GetNextActor()){ + if(SMESH_Actor *anActor = dynamic_cast(anAct)){ + anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255., + aHiColor.blue()/255.); + anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255., + aPreColor.blue()/255.); + } } } } + break; } - case 201: + + case 1100: // EDIT HYPOTHESIS { - SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); - SMESHGUI_Preferences_ScalarBarDlg::ScalarBarProperties( parent, Sel ); + if(checkLock(aStudy)) break; + SALOME_Selection *Sel = + SALOME_Selection::Selection(myActiveStudy->getSelection()); + int nbSel = Sel->IObjectCount(); + + if (nbSel == 1) { + SMESH::SMESH_Hypothesis_var Hyp = SMESH::IObjectToInterface(Sel->firstIObject()); + + /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */ + /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */ + /* Warning : however by internal mechanism all subMeshes icons are changed ! */ + if ( !Hyp->_is_nil() ) + { + char* sName = Hyp->GetName(); + SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator(sName); + if (aCreator) + { + aCreator->EditHypothesis(Hyp); + } + else + { + // report error + } + } + } break; } - case 1133: // DISPLAY MODE : WireFrame, Surface, Shrink - case 1132: - case 215: - case 213: - case 212: - case 211: + case 1101: // RENAME { - smeshGUI->SetViewMode(theCommandID); + if ( checkLock( aStudy ) ) + break; + + SALOME_Selection *Sel = + SALOME_Selection::Selection( myActiveStudy->getSelection() ); + + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + for ( ; It.More(); It.Next() ) + { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + SALOMEDS::SObject_var obj = aStudy->FindObjectID( IObject->getEntry() ); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + if ( !obj->_is_nil() ) + { + if ( obj->FindAttribute(anAttr, "AttributeName") ) + { + aName = SALOMEDS::AttributeName::_narrow( anAttr ); + QString newName = QString(aName->Value()); + newName = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), newName ); + if ( !newName.isEmpty() ) + { + myActiveStudy->renameIObject( IObject, newName ); + + // if current object is group update group's name + SMESH::SMESH_GroupBase_var aGroup = + SMESH::IObjectToInterface(IObject); + if (!aGroup->_is_nil() ) + aGroup->SetName( newName.latin1() ); + } + } + } + } break; } - - case 214: // UPDATE + + case 1102: // REMOVE HYPOTHESIS / ALGORITHMS { if(checkLock(aStudy)) break; - smeshGUI->Update(); + QAD_WaitCursor wc; + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); + for (int i = 0; It.More(); It.Next(), i++) { + Handle(SALOME_InteractiveObject) IObject = It.Value(); + SMESH::RemoveHypothesisOrAlgorithmOnMesh(IObject); + } + Sel->ClearIObjects(); + myActiveStudy->updateObjBrowser(true); break; } - case 300: // ERASE - case 301: // DISPLAY - case 302: // DISPLAY ONLY + case 401: // GEOM::EDGE + case 4021: // TRIANGLE + case 4022: // QUAD + case 4031: // TETRA + case 4032: // HEXA { - EDisplaing anAction; - switch(theCommandID){ - case 300: anAction = eErase; break; - case 301: anAction = eDisplay; break; - case 302: anAction = eDisplayOnly; break; + if(checkLock(aStudy)) break; + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + EmitSignalDeactivateDialog(); + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + SMDSAbs_ElementType type = SMDSAbs_Edge; + int nbNodes = 2; + switch (theCommandID) { + case 4021: // TRIANGLE + type = SMDSAbs_Face; nbNodes = 3; break; + case 4022: // QUAD + type = SMDSAbs_Face; nbNodes = 4; break; + case 4031: // TETRA + type = SMDSAbs_Volume; nbNodes = 4; break; + case 4032: // HEXA + type = SMDSAbs_Volume; nbNodes = 8; break; + default:; + } + SMESHGUI_AddMeshElementDlg *aDlg = + new SMESHGUI_AddMeshElementDlg(parent, "", Sel, type, nbNodes); } - - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - for (; It.More(); It.Next()) { - Handle(SALOME_InteractiveObject) IOS = It.Value(); - if (IOS->hasEntry()) { - ::UpdateView(anAction,IOS->getEntry()); - } - } + else { + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), + tr("SMESH_BUT_OK")); } - Sel->ClearIObjects(); break; } - case 400: // NODES + case 4041: // REMOVES NODES { if(checkLock(aStudy)) break; - if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - smeshGUI->EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - Sel->ClearIObjects(); - smeshGUI->myDesktop->SetSelectionMode(NodeSelection, true); - smeshGUI->ViewNodes(); - SMESHGUI_NodesDlg *aDlg = new SMESHGUI_NodesDlg(parent, "", Sel); + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + EmitSignalDeactivateDialog(); + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + SMESHGUI_RemoveNodesDlg *aDlg = new SMESHGUI_RemoveNodesDlg(parent, "", Sel); } else { QAD_MessageBox::warn1(QAD_Application::getDesktop(), - tr("SMESH_WRN_WARNING"), - tr("SMESH_WRN_VIEWER_VTK"), + tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), tr("SMESH_BUT_OK")); } break; } - - case 2151: // FILTER - { - if ( smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) + case 4042: // REMOVES ELEMENTS { - smeshGUI->EmitSignalDeactivateDialog(); - SMESHGUI_FilterDlg *aDlg = new SMESHGUI_FilterDlg( parent, SMESH::EDGE ); + if(checkLock(aStudy)) break; + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + EmitSignalDeactivateDialog(); + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + SMESHGUI_RemoveElementsDlg *aDlg = new SMESHGUI_RemoveElementsDlg(parent, "", Sel); + } + else + { + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), + tr("SMESH_BUT_OK")); + } + break; } - break; - } - - case 405: // MOVE NODE + case 4051: // RENUMBERING NODES { if(checkLock(aStudy)) break; - smeshGUI->myDesktop->SetSelectionMode(NodeSelection, true); - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - SMESHGUI_MoveNodesDlg *aDlg = new SMESHGUI_MoveNodesDlg(parent, "", Sel); + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + EmitSignalDeactivateDialog(); + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + SMESHGUI_RenumberingDlg *aDlg = new SMESHGUI_RenumberingDlg(parent, "", Sel, 0); + } + else + { + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), + tr("SMESH_BUT_OK")); + } break; } - - case 701: // COMPUTE MESH + case 4052: // RENUMBERING ELEMENTS { if(checkLock(aStudy)) break; - if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - int nbSel = Sel->IObjectCount(); - if (nbSel != 1){ - break; + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + EmitSignalDeactivateDialog(); + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + SMESHGUI_RenumberingDlg *aDlg = new SMESHGUI_RenumberingDlg(parent, "", Sel, 1); + } + else + { + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), + tr("SMESH_BUT_OK")); } - - SMESH::SMESH_Mesh_var aMesh; - SMESH::SMESH_subMesh_var aSubMesh; - Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); - if (IObject->hasEntry()){ - SALOMEDS::SObject_var aMeshSObj = smeshGUI->myStudy->FindObjectID(IObject->getEntry()); - GEOM::GEOM_Shape_var aShape = smeshGUI->myStudyAPI.GetShapeOnMeshOrSubMesh( aMeshSObj ); - if ( aShape->_is_nil() ) { - // imported mesh - break; - } - SALOMEDS::GenericAttribute_var anAttr; - if(!aMeshSObj->_is_nil() && aMeshSObj->FindAttribute(anAttr, "AttributeIOR")){ - SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - MESSAGE("SMESHGUI::OnGUIEvent - Compute mesh : IOR = "<< anIOR->Value()); - CORBA::Object_var anObj; - try{ - anObj = _orb->string_to_object(anIOR->Value()); - if (CORBA::is_nil(anObj)){ - MESSAGE("SMESHGUI::OnGUIEvent - Compute mesh : nil object"); - } - }catch(CORBA::COMM_FAILURE & ex){ - INFOS("SMESHGUI::OnGUIEvent - Compute mesh : exception (1)"); - } - aMesh = SMESH::SMESH_Mesh::_narrow(anObj); - aSubMesh = SMESH::SMESH_subMesh::_narrow(anObj); - if (!aMesh->_is_nil()){ - GEOM::GEOM_Shape_var refShape = smeshGUI->myStudyAPI.GetShapeOnMeshOrSubMesh(aMeshSObj); - if (!refShape->_is_nil()) { - if(!smeshGUI->myComponentMesh->IsReadyToCompute(aMesh,refShape)){ - QAD_MessageBox::warn1(QAD_Application::getDesktop(), - tr("SMESH_WRN_WARNING"), - tr("SMESH_WRN_MISSING_PARAMETERS"), - tr("SMESH_BUT_OK")); - break; - } - try{ - if (smeshGUI->myComponentMesh->Compute(aMesh,refShape)) - smeshGUI->myStudyAPI.ModifiedMesh(aMeshSObj,true); - // TO Do : change icon of all submeshes - } - catch(const SALOME::SALOME_Exception & S_ex){ - QtCatchCorbaException(S_ex); - } - } - }else if(!aSubMesh->_is_nil()){ - aMesh = aSubMesh->GetFather(); - GEOM::GEOM_Shape_var refShape = smeshGUI->myStudyAPI.GetShapeOnMeshOrSubMesh(aMeshSObj); - if(!refShape->_is_nil()){ - bool compute = smeshGUI->myComponentMesh->IsReadyToCompute(aMesh,refShape); - if(!compute){ - QAD_MessageBox::warn1(QAD_Application::getDesktop(), - tr("SMESH_WRN_WARNING"), - tr("SMESH_WRN_MISSING_PARAMETERS"), - tr("SMESH_BUT_OK")); - break; - } - try{ - if ( smeshGUI->myComponentMesh->Compute(aMesh,refShape) ) - smeshGUI->myStudyAPI.ModifiedMesh(aMeshSObj,true); - // TO Do : change icon of all submeshes - }catch(const SALOME::SALOME_Exception & S_ex){ - QtCatchCorbaException(S_ex); - } - } - } - } - } - CORBA::Long anId = smeshGUI->myStudy->StudyId(); - TVisualObjPtr aVisualObj = GetVisualObj(anId,IObject->getEntry()); - if(smeshGUI->myAutomaticUpdate && aVisualObj){ - aVisualObj->Update(); - SMESH_Actor* anActor = ::FindActorByEntry(IObject->getEntry()); - if(!anActor){ - anActor = ::CreateActor(smeshGUI->myStudy,IObject->getEntry()); - if(anActor){ - ::DisplayActor(smeshGUI->myActiveStudy->getActiveStudyFrame(),anActor); //apo - ::FitAll(); - } - } - } - }else{ - QAD_MessageBox::warn1(QAD_Application::getDesktop(), - tr("SMESH_WRN_WARNING"), - tr("SMESH_WRN_VIEWER_VTK"), - tr("SMESH_BUT_OK")); - } break; } - - case 702: // ADD SUB MESH + case 4061: // TRANSLATION { if(checkLock(aStudy)) break; - if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - smeshGUI->EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - SMESHGUI_AddSubMeshDlg *aDlg = new SMESHGUI_AddSubMeshDlg(parent, "", Sel); + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + EmitSignalDeactivateDialog(); + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + SMESHGUI_TranslationDlg *aDlg = new SMESHGUI_TranslationDlg(parent, "", Sel); } else { QAD_MessageBox::warn1(QAD_Application::getDesktop(), @@ -2423,1873 +1877,200 @@ bool SMESHGUI::OnGUIEvent(int theCommandID, QAD_Desktop * parent) } break; } - - case 703: // INIT MESH - { - if(checkLock(aStudy)) break; - smeshGUI->EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - SMESHGUI_InitMeshDlg *aDlg = new SMESHGUI_InitMeshDlg(parent, "", Sel); - break; - } - - case 704: // EDIT Hypothesis - { - if(checkLock(aStudy)) break; - smeshGUI->EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - SMESHGUI_EditHypothesesDlg *aDlg = new SMESHGUI_EditHypothesesDlg(parent, "", Sel); - break; - } - - case 705: // EDIT Global Hypothesis - { - if(checkLock(aStudy)) break; - smeshGUI->EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - SMESHGUI_EditHypothesesDlg *aDlg = new SMESHGUI_EditHypothesesDlg(parent, "", Sel); - break; - } - - case 706: // EDIT Local Hypothesis - { - if(checkLock(aStudy)) break; - smeshGUI->EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - SMESHGUI_EditHypothesesDlg *aDlg = new SMESHGUI_EditHypothesesDlg(parent, "", Sel); - break; - } - - case 406: // ORIENTATION ELEMENTS - { - if(checkLock(aStudy)) break; - smeshGUI->EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - smeshGUI->myDesktop->SetSelectionMode(FaceSelection, true); - SMESHGUI_OrientationElementsDlg *aDlg = new SMESHGUI_OrientationElementsDlg(parent, "", Sel); - break; - } - - case 407: // DIAGONAL INVERSION + case 4062: // ROTATION { if(checkLock(aStudy)) break; - smeshGUI->EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - Sel->ClearIObjects(); - smeshGUI->myDesktop->SetSelectionMode(EdgeOfCellSelection, true); - SMESHGUI_DiagonalInversionDlg *aDlg = new SMESHGUI_DiagonalInversionDlg(parent, "", Sel); + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + EmitSignalDeactivateDialog(); + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + SMESHGUI_RotationDlg *aDlg = new SMESHGUI_RotationDlg(parent, "", Sel); + } + else { + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), + tr("SMESH_BUT_OK")); + } break; } - - case 801: // CREATE GROUP + case 4063: // SYMMETRY { if(checkLock(aStudy)) break; - smeshGUI->EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - int nbSel = Sel->IObjectCount(); - if (nbSel == 1) { - // check if mesh is selected - Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); - if (IObject->hasEntry()) { - SALOMEDS::SObject_var aMeshSObj = smeshGUI->myStudy->FindObjectID(IObject->getEntry()); - if (!aMeshSObj->_is_nil()) { - CORBA::Object_var anObj = aMeshSObj->GetObject(); - SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(anObj); - SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(anObj); - if (aMesh->_is_nil() && !aSubMesh->_is_nil()) { - aMesh = aSubMesh->GetFather(); - } - if (!aMesh->_is_nil()) { - SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, aMesh); - aDlg->show(); - } - } - } + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + EmitSignalDeactivateDialog(); + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + SMESHGUI_SymmetryDlg *aDlg = new SMESHGUI_SymmetryDlg(parent, "", Sel); + } + else { + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), + tr("SMESH_BUT_OK")); } break; } - - case 802: // CONSTRUCT GROUP + case 4064: // SEWING { if(checkLock(aStudy)) break; - smeshGUI->EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - int nbSel = Sel->IObjectCount(); - if (nbSel == 1) { - // check if submesh is selected - Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); - if (IObject->hasEntry()) { - SALOMEDS::SObject_var aSObj = smeshGUI->myStudy->FindObjectID(IObject->getEntry()); - if(!aSObj->_is_nil()) { - SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(aSObj->GetObject()); - if (!aSubMesh->_is_nil()) { - try { - SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather(); - // get submesh elements list by types - SMESH::long_array_var aNodes = aSubMesh->GetElementsByType(SMESH::NODE); - SMESH::long_array_var aEdges = aSubMesh->GetElementsByType(SMESH::EDGE); - SMESH::long_array_var aFaces = aSubMesh->GetElementsByType(SMESH::FACE); - SMESH::long_array_var aVolumes = aSubMesh->GetElementsByType(SMESH::VOLUME); - // create group for each type o elements - QString aName = IObject->getName(); - MESSAGE("SMESHGUI::OnGUIEvent - Construct group on submesh : "<length() << ", edges " << aEdges->length() - << ", faces " << aFaces->length() << ", volumes " << aVolumes->length()); - if (aNodes->length() > 0) { - SMESH::SMESH_Group_var aGroup = smeshGUI->AddGroup(aMesh, SMESH::NODE, aName); - aGroup->Add(aNodes); - } - if (aEdges->length() > 0) { - SMESH::SMESH_Group_var aGroup = smeshGUI->AddGroup(aMesh, SMESH::EDGE, aName); - aGroup->Add(aEdges); - } - if (aFaces->length() > 0) { - SMESH::SMESH_Group_var aGroup = smeshGUI->AddGroup(aMesh, SMESH::FACE, aName); - aGroup->Add(aFaces); - } - if (aVolumes->length() > 0) { - SMESH::SMESH_Group_var aGroup = smeshGUI->AddGroup(aMesh, SMESH::VOLUME, aName); - aGroup->Add(aVolumes); - } - smeshGUI->myActiveStudy->updateObjBrowser(true); - }catch(const SALOME::SALOME_Exception & S_ex){ - QtCatchCorbaException(S_ex); - } - } - } - } + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + EmitSignalDeactivateDialog(); + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + SMESHGUI_SewingDlg *aDlg = new SMESHGUI_SewingDlg(parent, "", Sel); + } + else { + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), + tr("SMESH_BUT_OK")); } break; } - - case 803: // EDIT GROUP + case 4065: // MERGE NODES { if(checkLock(aStudy)) break; - smeshGUI->EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - int nbSel = Sel->IObjectCount(); - if (nbSel == 1) { - // check if group is selected - Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); - if (IObject->hasEntry()) { - SALOMEDS::SObject_var aSObj = smeshGUI->myStudy->FindObjectID(IObject->getEntry()); - if(!aSObj->_is_nil()) { - SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_narrow(aSObj->GetObject()); - if (!aGroup->_is_nil()) { - SMESHGUI_GroupDlg *aDlg = new SMESHGUI_GroupDlg(parent, "", Sel, aGroup); - aDlg->show(); - } - } - } + if (myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { + EmitSignalDeactivateDialog(); + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + SMESHGUI_MergeNodesDlg *aDlg = new SMESHGUI_MergeNodesDlg(parent, "", Sel); + } + else { + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), + tr("SMESH_BUT_OK")); } break; } + - case 804: // Add elements to group + case 5000: // HYPOTHESIS { if(checkLock(aStudy)) break; - if (smeshGUI->myState == 800) { - SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) smeshGUI->myActiveDialogBox; - if (aDlg) aDlg->onAdd(); - } + EmitSignalDeactivateDialog(); + SMESHGUI_CreateHypothesesDlg *aDlg = + new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, false); break; } - - case 805: // Remove elements from group + case 5010: // ALGO { if(checkLock(aStudy)) break; - if (smeshGUI->myState == 800) { - SMESHGUI_GroupDlg *aDlg = (SMESHGUI_GroupDlg*) smeshGUI->myActiveDialogBox; - if (aDlg) aDlg->onRemove(); - } + EmitSignalDeactivateDialog(); + SMESHGUI_CreateHypothesesDlg *aDlg = + new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, true); break; } - case 900: // MESH INFOS + case 5105: // Library of selection filters + { + static QValueList aTypes; + if ( aTypes.isEmpty() ) { - smeshGUI->EmitSignalDeactivateDialog(); - SMESHGUI_MeshInfosDlg *aDlg = new SMESHGUI_MeshInfosDlg(parent, "", false); - break; + aTypes.append( SMESH::NODE ); + aTypes.append( SMESH::EDGE ); + aTypes.append( SMESH::FACE ); + aTypes.append( SMESH::VOLUME ); } + new SMESHGUI_FilterLibraryDlg( parent, aTypes, SMESHGUI_FilterLibraryDlg::EDIT ); + } + break; - case 1001: // AUTOMATIC UPDATE PREFERENCES - { - parent->menuBar()->setItemChecked(1001, !parent->menuBar()->isItemChecked(1001)); - if (parent->menuBar()->isItemChecked(1001)) { - QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "true"); - smeshGUI->myAutomaticUpdate = true; - } - else { - QAD_CONFIG->addSetting("SMESH:AutomaticUpdate", "false"); - smeshGUI->myAutomaticUpdate = false; + case 6016: // CONTROLS + case 6015: + case 6014: + case 6013: + case 6012: + case 6011: + case 6001: + case 6002: + case 6003: + case 6004: + if ( myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + if ( Sel->IObjectCount() == 1 && Sel->firstIObject()->hasEntry() ) { + SALOMEDS::SObject_var SO = aStudy->FindObjectID( Sel->firstIObject()->getEntry() ); + if ( !SO->_is_nil() ) { + CORBA::Object_var aObject = SO->GetObject(); + SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject ); + SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject ); + SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( aObject ); + if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) { + ::Control( theCommandID ); + break; + } + } } - break; - } - - case 1003: // MESH PREFERENCES - { - smeshGUI->SetDisplaySettings(); - break; - } - - case 1005: - { - SMESHGUI_Preferences_ScalarBarDlg::ScalarBarPreferences( parent ); - break; - } - - case 1006: - { - SMESHGUI_Preferences_SelectionDlg* aDlg = - new SMESHGUI_Preferences_SelectionDlg(parent); - - QColor aColor; - QString SCr, SCg, SCb; - SCr = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorRed"); - SCg = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorGreen"); - SCb = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorBlue"); - if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) - aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); - else aColor = Qt::cyan; - aDlg->SetColor(1, aColor); - - SCr = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorRed"); - SCg = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorGreen"); - SCb = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorBlue"); - if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) - aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); - else aColor = Qt::yellow; - aDlg->SetColor(2, aColor); - - SCr = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorRed"); - SCg = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorGreen"); - SCb = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorBlue"); - if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) - aColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); - else aColor = Qt::white; - aDlg->SetColor(3, aColor); - - QString SW1 = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectWidth"); - if (SW1.isEmpty()) SW1 = "5"; - aDlg->SetWidth(1, SW1.toInt()); - - QString SW2 = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectWidth"); - if (SW2.isEmpty()) SW2 = "5"; - aDlg->SetWidth(2, SW2.toInt()); - - QString SP1 = QAD_CONFIG->getSetting("SMESH:SettingsNodeSelectTol"); - if (SP1.isEmpty()) SP1 = "0.025"; - aDlg->SetPrecision(1, SP1.toDouble()); - - QString SP2 = QAD_CONFIG->getSetting("SMESH:SettingsElementsSelectTol"); - if (SP2.isEmpty()) SP2 = "0.001"; - aDlg->SetPrecision(2, SP2.toDouble()); - - if (aDlg->exec()) { - QColor aPreColor = aDlg->GetColor(1); - QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorRed", aPreColor.red()); - QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorGreen", aPreColor.green()); - QAD_CONFIG->addSetting("SMESH:SettingsPreSelectColorBlue", aPreColor.blue()); - - QColor aSelColor = aDlg->GetColor(2); - QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorRed", aSelColor.red()); - QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorGreen", aSelColor.green()); - QAD_CONFIG->addSetting("SMESH:SettingsItemSelectColorBlue", aSelColor.blue()); - - QColor aHiColor = aDlg->GetColor(3); - QAD_CONFIG->addSetting("SMESH:SettingsSelectColorRed", aHiColor.red()); - QAD_CONFIG->addSetting("SMESH:SettingsSelectColorGreen", aHiColor.green()); - QAD_CONFIG->addSetting("SMESH:SettingsSelectColorBlue", aHiColor.blue()); - - int aPreWidth = aDlg->GetWidth(1); - QAD_CONFIG->addSetting("SMESH:SettingsPreSelectWidth", aPreWidth); - int aSelWidth = aDlg->GetWidth(2); - QAD_CONFIG->addSetting("SMESH:SettingsItemSelectWidth", aSelWidth); - - double aTolNodes = aDlg->GetPrecision(1); - QAD_CONFIG->addSetting("SMESH:SettingsNodeSelectTol", aTolNodes); - double aTolItems = aDlg->GetPrecision(2); - QAD_CONFIG->addSetting("SMESH:SettingsElementsSelectTol", aTolItems); - - // update current study settings - ::UpdateSelectionProp(); - - QAD_StudyFrame* studyFrame = smeshGUI->myActiveStudy->getActiveStudyFrame(); - if (studyFrame->getTypeView() == VIEW_VTK) { - VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(studyFrame); - // update VTK viewer properties - VTKViewer_RenderWindowInteractor* anInteractor = aViewFrame->getRWInteractor(); - if (anInteractor) { - anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255., - aSelColor.blue()/255., aSelWidth); - anInteractor->SetSelectionTolerance(aTolNodes, aTolItems); - VTKViewer_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME(); - if (aStyle) - aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255., - aPreColor.blue()/255., aPreWidth); - } - // update actors - vtkRenderer* aRenderer = aViewFrame->getRenderer(); - vtkActorCollection *aCollection = aRenderer->GetActors(); - aCollection->InitTraversal(); - while(vtkActor *anAct = aCollection->GetNextActor()){ - if(SMESH_Actor *anActor = dynamic_cast(anAct)){ - anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255., - aHiColor.blue()/255.); - anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255., - aPreColor.blue()/255.); - } - } - } - } - - break; - } - - case 1100: // EDIT HYPOTHESIS - { - if(checkLock(aStudy)) break; - SALOME_Selection *Sel = - SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - int nbSel = Sel->IObjectCount(); - - if (nbSel == 1) { - Standard_Boolean res; - SMESH::SMESH_Hypothesis_var Hyp = - smeshGUI->ConvertIOinSMESHHypothesis(Sel->firstIObject(), res); - - /* Look for all mesh objects that have this hypothesis affected in order to flag as ModifiedMesh */ - /* At end below '...->updateObjBrowser(true)' will change icon of mesh objects */ - /* Warning : however by internal mechanism all subMeshes icons are changed ! */ - if ( res ) - { - char* sName = Hyp->GetName(); - SMESHGUI_GenericHypothesisCreator* aCreator = smeshGUI->GetHypothesisCreator(sName); - if (aCreator) - { - aCreator->EditHypothesis(Hyp); - } - else - { - // report error - } - } - } - break; - } - - case 1101: // RENAME - { - if(checkLock(aStudy)) break; - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - for (; It.More(); It.Next()) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - - SALOMEDS::SObject_var obj = smeshGUI->myStudy->FindObjectID(IObject->getEntry()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - if (!obj->_is_nil()) { - if (obj->FindAttribute(anAttr, "AttributeName")) { - aName = SALOMEDS::AttributeName::_narrow(anAttr); - QString newName = QString(aName->Value()); - newName = SALOMEGUI_NameDlg::getName(QAD_Application::getDesktop(), newName); - if (!newName.isEmpty()) { - smeshGUI->myActiveStudy->renameIObject(IObject, newName); - } - } - } - } - break; - } - - case 1102: // REMOVE HYPOTHESIS / ALGORITHMS - { - if(checkLock(aStudy)) break; - QAD_WaitCursor wc; - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - for (int i = 0; It.More(); It.Next(), i++) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - smeshGUI->RemoveHypothesisOrAlgorithmOnMesh(IObject); - } - Sel->ClearIObjects(); - smeshGUI->myActiveStudy->updateObjBrowser(true); - break; - } - - case 401: // GEOM::EDGE - { - if(checkLock(aStudy)) break; - if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - smeshGUI->EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - Sel->ClearIObjects(); - smeshGUI->myDesktop->SetSelectionMode(NodeSelection, true); - smeshGUI->ViewNodes(); - SMESHGUI_AddEdgeDlg *aDlg = new SMESHGUI_AddEdgeDlg(parent, "", Sel); - } - else { - QAD_MessageBox::warn1(QAD_Application::getDesktop(), - tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), - tr("SMESH_BUT_OK")); - } - break; - } - case 4021: // TRIANGLE - { - if(checkLock(aStudy)) break; - if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - smeshGUI->EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - Sel->ClearIObjects(); - smeshGUI->myDesktop->SetSelectionMode(NodeSelection, true); - smeshGUI->ViewNodes(); - SMESHGUI_AddFaceDlg *aDlg = new SMESHGUI_AddFaceDlg(parent, "", Sel, 3); - } - else { - QAD_MessageBox::warn1(QAD_Application::getDesktop(), - tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), - tr("SMESH_BUT_OK")); - } - break; - } - case 4022: // QUAD - { - if(checkLock(aStudy)) break; - if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - smeshGUI->EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - Sel->ClearIObjects(); - smeshGUI->myDesktop->SetSelectionMode(NodeSelection, true); - smeshGUI->ViewNodes(); - SMESHGUI_AddFaceDlg *aDlg = new SMESHGUI_AddFaceDlg(parent, "", Sel, 4); - } - else - { - QAD_MessageBox::warn1(QAD_Application::getDesktop(), - tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), - tr("SMESH_BUT_OK")); - } - break; - } - case 4031: // TETRA - { - if(checkLock(aStudy)) break; - if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - smeshGUI->EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - Sel->ClearIObjects(); - smeshGUI->myDesktop->SetSelectionMode(NodeSelection, true); - smeshGUI->ViewNodes(); - SMESHGUI_AddVolumeDlg *aDlg = new SMESHGUI_AddVolumeDlg(parent, "", Sel, 4); - } - else { - QAD_MessageBox::warn1(QAD_Application::getDesktop(), - tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), - tr("SMESH_BUT_OK")); - } - break; - } - case 4032: // HEXA - { - if(checkLock(aStudy)) break; - if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - smeshGUI->EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - Sel->ClearIObjects(); - smeshGUI->myDesktop->SetSelectionMode(NodeSelection, true); - smeshGUI->ViewNodes(); - SMESHGUI_AddVolumeDlg *aDlg = new SMESHGUI_AddVolumeDlg(parent, "", Sel, 8); - } - else { - QAD_MessageBox::warn1(QAD_Application::getDesktop(), - tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), - tr("SMESH_BUT_OK")); - } - break; - } - - case 4041: // REMOVES NODES - { - if(checkLock(aStudy)) break; - if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - smeshGUI->EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - Sel->ClearIObjects(); - smeshGUI->myDesktop->SetSelectionMode(NodeSelection, true); - smeshGUI->ViewNodes(); - SMESHGUI_RemoveNodesDlg *aDlg = new SMESHGUI_RemoveNodesDlg(parent, "", Sel); - } - else { - QAD_MessageBox::warn1(QAD_Application::getDesktop(), - tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), - tr("SMESH_BUT_OK")); - } - break; - } - case 4042: // REMOVES ELEMENTS - { - if(checkLock(aStudy)) break; - if (smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) { - smeshGUI->EmitSignalDeactivateDialog(); - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - Sel->ClearIObjects(); - smeshGUI->myDesktop->SetSelectionMode(CellSelection, true); - SMESHGUI_RemoveElementsDlg *aDlg = new SMESHGUI_RemoveElementsDlg(parent, "", Sel); - } - else - { - QAD_MessageBox::warn1(QAD_Application::getDesktop(), - tr("SMESH_WRN_WARNING"), tr("SMESH_WRN_VIEWER_VTK"), - tr("SMESH_BUT_OK")); - } - break; - } - - case 5000: // HYPOTHESIS - { - if(checkLock(aStudy)) break; - smeshGUI->EmitSignalDeactivateDialog(); - SMESHGUI_CreateHypothesesDlg *aDlg = - new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, false); - break; - } - case 5010: // ALGO - { - if(checkLock(aStudy)) break; - smeshGUI->EmitSignalDeactivateDialog(); - SMESHGUI_CreateHypothesesDlg *aDlg = - new SMESHGUI_CreateHypothesesDlg (parent, "", FALSE, true); - break; - } - - case 6016: // CONTROLS - case 6015: - case 6014: - case 6013: - case 6012: - case 6011: - case 6001: - case 6003: - case 6004: - if ( smeshGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - if ( Sel->IObjectCount() == 1 && Sel->firstIObject()->hasEntry() ) { - SALOMEDS::SObject_var SO = smeshGUI->myStudy->FindObjectID( Sel->firstIObject()->getEntry() ); - if ( !SO->_is_nil() ) { - CORBA::Object_var aObject = SO->GetObject(); - SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( aObject ); - SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( aObject ); - SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_narrow( aObject ); - if ( !aMesh->_is_nil() || !aSubMesh->_is_nil() || !aGroup->_is_nil() ) { - smeshGUI->Control( theCommandID ); - break; - } - } - } - QAD_MessageBox::warn1(smeshGUI->GetDesktop(), - tr( "SMESH_WRN_WARNING" ), - tr( "SMESH_BAD_SELECTION" ), - tr( "SMESH_BUT_OK" ) ); + QAD_MessageBox::warn1(GetDesktop(), + tr( "SMESH_WRN_WARNING" ), + tr( "SMESH_BAD_SELECTION" ), + tr( "SMESH_BUT_OK" ) ); break; } else { - QAD_MessageBox::warn1(smeshGUI->GetDesktop(), + QAD_MessageBox::warn1(GetDesktop(), tr( "SMESH_WRN_WARNING" ), tr( "NOT_A_VTK_VIEWER" ), - tr( "SMESH_BUT_OK" ) ); - } - break; - case 9010: - { - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - if (Sel->IObjectCount() == 1) { - Handle(SALOME_InteractiveObject) anIObject = Sel->firstIObject(); - if(anIObject->hasEntry()) - if(SMESH_Actor *anActor = ::FindActorByEntry(anIObject->getEntry())){ - anActor->SetPointsLabeled( !anActor->GetPointsLabeled() ); - } - } - break; - } - case 9011: - { - SALOME_Selection *Sel = SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - if (Sel->IObjectCount() == 1) { - Handle(SALOME_InteractiveObject) anIObject = Sel->firstIObject(); - if(anIObject->hasEntry()) - if(SMESH_Actor *anActor = ::FindActorByEntry(anIObject->getEntry())){ - anActor->SetCellsLabeled( !anActor->GetCellsLabeled() ); - } - } - break; - } - case 10001: // DISPLAY MODE PREFERENCE - { - // Wireframe - parent->menuBar()->setItemChecked(10001, true); - parent->menuBar()->setItemChecked(10002, false); - parent->menuBar()->setItemChecked(10004, false); - parent->menuBar()->setItemEnabled(10003, true); - QAD_CONFIG->addSetting("SMESH:DisplayMode", "Wireframe"); - break; - } - case 10002: - { - parent->menuBar()->setItemChecked(10002, true); - parent->menuBar()->setItemChecked(10001, false); - parent->menuBar()->setItemChecked(10004, false); - parent->menuBar()->setItemEnabled(10003, true); - QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading"); - break; - } - case 10003: - { - parent->menuBar()->setItemChecked(10003,!parent->menuBar()->isItemChecked(10003)); - QAD_CONFIG->addSetting("SMESH:Shrink", parent->menuBar()->isItemChecked(10003) ? "yes" : "no"); - break; - } - case 10004: - { - parent->menuBar()->setItemChecked(10001, false); - parent->menuBar()->setItemChecked(10004, true); - parent->menuBar()->setItemChecked(10002, false); - parent->menuBar()->setItemEnabled(10003, false); - QAD_CONFIG->addSetting("SMESH:DisplayMode", "Nodes"); - break; - } - - } - - smeshGUI->myActiveStudy->updateObjBrowser(true); - return true; -} - -//============================================================================= -/*! function : GetMeshesUsingAlgoOrHypothesis() - * purpose : return a list of Study objects (mesh kind) that have 'AlgoOrHyp' affected. - * : However is supposed here that father of father of an hypothesis is a Mesh Object. - */ -//============================================================================= -SALOMEDS::Study::ListOfSObject * - SMESHGUI::GetMeshesUsingAlgoOrHypothesis(SMESH:: - SMESH_Hypothesis_ptr AlgoOrHyp) -{ - SALOMEDS::Study::ListOfSObject_var listSOmesh = - new SALOMEDS::Study::ListOfSObject; - listSOmesh->length(0); - unsigned int index = 0; - if (!AlgoOrHyp->_is_nil()) { - SALOMEDS::SObject_var SO_Hypothesis = - smeshGUI->GetStudyAPI().FindObject(AlgoOrHyp); - if (!SO_Hypothesis->_is_nil()) { - SALOMEDS::Study::ListOfSObject_var listSO = - smeshGUI->myStudy->FindDependances(SO_Hypothesis); - MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency number ="<length()); - for (unsigned int i = 0; i < listSO->length(); i++) { - SALOMEDS::SObject_ptr SO = listSO[i]; - if (!SO->_is_nil()) { - SALOMEDS::SObject_var aFather = SO->GetFather(); - if (!aFather->_is_nil()) { - SALOMEDS::SObject_var SOfatherFather = aFather->GetFather(); - if (!SOfatherFather->_is_nil()) { - MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency added to list"); - index++; - listSOmesh->length(index); - listSOmesh[index - 1] = SOfatherFather; - } - } - } - } - } - } - MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): completed"); - return listSOmesh._retn(); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESHGUI::Import_Mesh(QAD_Desktop * parent, int theCommandID){ - QString filter; - string myExtension; - - if(theCommandID == 113){ - filter = tr("MED files (*.med)"); - }else if (theCommandID == 112){ - filter = tr("IDEAS files (*.unv)"); - }else if (theCommandID == 111){ - filter = tr("DAT files (*.dat)"); - } - QString filename = QAD_FileDlg::getFileName(parent, - "", - filter, - tr("Import mesh"), - true); - if(!filename.isEmpty()){ - QAD_WaitCursor wc; - SMESH::mesh_array_var aMeshes; - try { - SMESH::DriverMED_ReadStatus res; - aMeshes = smeshGUI->myComponentMesh->CreateMeshesFromMED(filename.latin1(), - res); - if ( res > SMESH::DRS_OK ) { - wc.stop(); - QAD_MessageBox::warn1(QAD_Application::getDesktop(), - tr("SMESH_WRN_WARNING"), - tr(QString("SMESH_DRS_%1").arg(res)), - tr("SMESH_BUT_OK")); - wc.start(); - - } - } - catch (const SALOME::SALOME_Exception& S_ex) - { - wc.stop(); - QtCatchCorbaException(S_ex); - wc.start(); - } - for ( int i = 0, n = aMeshes->length(); i < n; i++ ) { - SALOMEDS::SObject_var aMeshSO = smeshGUI->myStudyAPI.FindObject( aMeshes[i] ); - if ( !aMeshSO->_is_nil() ) { - SALOMEDS::StudyBuilder_var aBuilder = smeshGUI->myStudy->NewBuilder(); - SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow( aBuilder->FindOrCreateAttribute( aMeshSO, "AttributePixMap" ) ); - aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_IMPORTED" ); - } - } - } -} - -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESHGUI::Export_Mesh(QAD_Desktop * parent, int theCommandID) -{ - SALOME_Selection *Sel = - SALOME_Selection::Selection(smeshGUI->myActiveStudy->getSelection()); - int nbSel = Sel->IObjectCount(); - if ( !nbSel ) - return; - Standard_Boolean res; - Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); - SMESH::SMESH_Mesh_var aMesh = smeshGUI->ConvertIOinMesh(IObject, res); - if ( res && ( nbSel == 1 || theCommandID == 122 ) ) {// MED export supports multiple meshes - QString aFilter, aTitle = tr("Export mesh"); - switch ( theCommandID ) { - case 122: - aFilter = tr("MED files (*.med)"); - break; - case 121: - aFilter = tr("DAT files (*.dat)"); - break; - case 123: - aFilter = tr("IDEAS files (*.unv)"); - break; - default: - break; - } - - QString filename = QAD_FileDlg::getFileName(parent, "", aFilter, aTitle, false); - - if ( !filename.isEmpty() ) { - // Check whether the file already exists and delete it if yes - QFile aFile( filename ); - if ( aFile.exists() ) - aFile.remove(); - - QAD_WaitCursor wc; - for ( SALOME_ListIteratorOfListIO it( Sel->StoredIObjects() ); it.More(); it.Next() ) { - aMesh = smeshGUI->ConvertIOinMesh( it.Value(), res ); - if ( res ) { - switch ( theCommandID ) { - case 122: - aMesh->ExportMED( filename.latin1(), true ); // currently, automatic groups are always created - break; - case 121: - aMesh->ExportDAT( filename.latin1() ); - break; - case 123: - aMesh->ExportUNV( filename.latin1() ); - break; - default: - break; - } - } - } - } - } -} - -//============================================================================= -/*! - * - */ -//============================================================================= -bool SMESHGUI::OnMousePress(QMouseEvent * pe, QAD_Desktop * parent, - QAD_StudyFrame * studyFrame) -{ - return false; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -bool SMESHGUI::OnMouseMove(QMouseEvent * pe, QAD_Desktop * parent, - QAD_StudyFrame * studyFrame) -{ - return true; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -bool SMESHGUI::OnKeyPress(QKeyEvent * pe, QAD_Desktop * parent, - QAD_StudyFrame * studyFrame) -{ - return true; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -bool SMESHGUI::SetSettings(QAD_Desktop * parent) -{ - MESSAGE("SMESHGUI::SetSettings."); - SMESHGUI::GetOrCreateSMESHGUI(parent); - - /* Display mode */ - QString DisplayMode = "Shading"; - if ( QAD_CONFIG->hasSetting("SMESH:DisplayMode") ) - DisplayMode = QAD_CONFIG->getSetting("SMESH:DisplayMode"); - else - QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading"); - - bool Shrink = false; - if ( QAD_CONFIG->hasSetting("SMESH:Shrink") ) - Shrink = QAD_CONFIG->getSetting("SMESH:Shrink") == "yes"; - - if (DisplayMode == "Wireframe") { - // wireframe - parent->menuBar()->setItemChecked(10004, false); - parent->menuBar()->setItemChecked(10002, false); - parent->menuBar()->setItemChecked(10001, true); - parent->menuBar()->setItemEnabled(10003, true); - } - else if (DisplayMode == "Nodes") { - // poins - parent->menuBar()->setItemChecked(10004, true); - parent->menuBar()->setItemChecked(10002, false); - parent->menuBar()->setItemChecked(10001, false); - parent->menuBar()->setItemEnabled(10003, false); - } - else { - // default is shading - parent->menuBar()->setItemChecked(10004, false); - parent->menuBar()->setItemChecked(10002, true); - parent->menuBar()->setItemChecked(10001, false); - parent->menuBar()->setItemEnabled(10003, true); - } - parent->menuBar()->setItemChecked(10003, Shrink); - - /* Automatic Update */ - QString AutoUpdate = QAD_CONFIG->getSetting("SMESH:AutomaticUpdate"); - if (AutoUpdate.compare("true") == 0) { - parent->menuBar()->setItemChecked(1001, true); - smeshGUI->myAutomaticUpdate = true; - } - else { - parent->menuBar()->setItemChecked(1001, false); - smeshGUI->myAutomaticUpdate = false; - } - - /* Selection */ - ::UpdateSelectionProp(); - - /* menus disable */ - parent->menuBar()->setItemEnabled(111, false); // IMPORT DAT - parent->menuBar()->setItemEnabled(112, false); // IMPORT UNV - - return true; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESHGUI::DefinePopup(QString & theContext, QString & theParent, QString & theObject) -{ - // NRI : Temporary added - // if ( smeshGUI->myStudy->GetProperties()->IsLocked() ) { - // theObject = "NothingSelected"; - // theContext = "NothingSelected"; - // } - // NRI - - SALOME_Selection *Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); - int nbSel = Sel->IObjectCount(); - switch ( nbSel ) { - case 0: - theObject = "NothingSelected"; - theContext = "NothingSelected"; - break; - case 1: - if ( smeshGUI->myState == 800 && Sel->HasIndex( Sel->firstIObject() ) ) - theObject = "Elements"; - else - theObject = smeshGUI->CheckTypeObject( Sel->firstIObject() ); - theContext = ""; - break; - default: - theObject = smeshGUI->CheckHomogeneousSelection(); - theContext = ""; - } -} - -//============================================================================= -/*! - * - */ -//============================================================================= -bool SMESHGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext, - const QString& theParent, const QString& theObject) -{ - // get active study frame - QAD_StudyFrame* studyFrame = smeshGUI->myActiveStudy->getActiveStudyFrame(); - - // get parent component which selected object(s) belongs to - QString parentComp = ( (SALOMEGUI_Desktop*)parent )->getComponentFromSelection(); - - // get selection - SALOME_Selection* Sel = SALOME_Selection::Selection( smeshGUI->myActiveStudy->getSelection() ); - int nbSel = Sel->IObjectCount(); - - if ( nbSel == 0 ) { - popup->clear(); - } - else if ( nbSel == 1 ) { - if ( parentComp != parent->getActiveComponent() ) { - // object not belongs to SMESH module - remove all commands except common Display/Erase... - while ( 1 ) { - int id = popup->idAt( 0 ); - if ( id <= QAD_TopLabel_Popup_ID ) - popup->removeItemAt( 0 ); - else - break; - } - } - else { - // get selected interactive object - Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); - SALOMEDS::SObject_var SO = smeshGUI->myStudy->FindObjectID( IObject->getEntry() ); - // find popup menu's TopLabel item - int topItem = popup->indexOf( QAD_TopLabel_Popup_ID ); - if ( topItem >= 0 ) { - if ( theParent == "Viewer" ) { - // set bold font for popup menu's TopLabel item (Viewer popup) - QFont fnt = QApplication::font(); fnt.setBold( TRUE ); - popup->removeItem( QAD_TopLabel_Popup_ID ); - popup->insertItem( new CustomItem( QString( IObject->getName() ), fnt ), QAD_TopLabel_Popup_ID, topItem ); - } - else if ( theParent == "ObjectBrowser" ) { - // remove popup menu's TopLabel item (Object Browser popup) - popup->removeItem( QAD_TopLabel_Popup_ID ); - } - } - - // remove "Display only" command for component object - if ( theObject.compare( "Component" ) == 0 ) { - popup->removeItem( QAD_DisplayOnly_Popup_ID ); - } - else if ( theObject == "Hypothesis" || theObject == "Algorithm" ) { - // remove Display/Erase commands - popup->removeItem( QAD_Display_Popup_ID ); - popup->removeItem( QAD_DisplayOnly_Popup_ID ); - popup->removeItem( QAD_Erase_Popup_ID ); - // remove "Unassign ..." command if hyp/algo is not assigned - if ( SO->_is_nil() || !IObject->hasReference()/* !IsReferencedObject( SO ) */) - popup->removeItem( 1102 ); - } - else if ( theObject == "Mesh" || theObject == "SubMesh" || theObject == "Group" ) { - // get actor - GEOM::GEOM_Shape_var aShape = GetSMESHGUI()->GetStudyAPI().GetShapeOnMeshOrSubMesh( SO ); - if ( aShape->_is_nil() ) { - // imported mesh - popup->removeItem( 701 ); // Compute - popup->removeItem( 705 ); // Edit hypothesis - popup->removeItem( 706 ); // ... - } - SMESH_Actor* ac = ::FindActorByEntry(IObject->getEntry()); - // if object has actor - if ( ac && studyFrame->getTypeView() == VIEW_VTK ) { - VTKViewer_RenderWindowInteractor* myRenderInter = - ( ( VTKViewer_ViewFrame* ) studyFrame->getRightFrame()->getViewFrame() )->getRWInteractor(); - if ( myRenderInter->isVisible( IObject ) ) { - popup->removeItem( QAD_Display_Popup_ID ); - popup->setItemChecked( 9010, ac->GetPointsLabeled() ); // Numbering / Display Nodes # - popup->setItemChecked( 9011, ac->GetCellsLabeled() ); // Numbering / Display Elements # - TVisualObjPtr aVisualObj = ac->GetObject(); - int aNbEdges = aVisualObj->GetNbEntities(SMESH::EDGE); - int aNbFaces = aVisualObj->GetNbEntities(SMESH::FACE); - int aNbVolumes = aVisualObj->GetNbEntities(SMESH::VOLUME); - QMenuItem* mi = popup->findItem( 1131 ); - if ( mi && mi->popup() ) { - int prType = ac->GetRepresentation(); - // Display Mode / Wireframe - if(!aNbFaces && !aNbVolumes && !aNbEdges){ - mi->popup()->removeItem( 211 ); - }else{ - mi->popup()->setItemChecked( 211, prType == SMESH_Actor::eEdge ); - } - // Display Mode / Shading - if(!aNbFaces && !aNbVolumes){ - mi->popup()->removeItem( 212 ); - }else{ - mi->popup()->setItemChecked( 212, prType == SMESH_Actor::eSurface ); - } - // Display Mode / Points - mi->popup()->setItemChecked( 215, prType == SMESH_Actor::ePoint ); - // Display Mode / Shrink - bool isShrunk = ac->IsShrunk(); - bool isShrunkable = ac->IsShrunkable(); - mi->popup()->setItemChecked( 213, isShrunk ); - mi->popup()->setItemEnabled( 213, prType != SMESH_Actor::ePoint && isShrunkable); - } - // Scalar Bar - mi = popup->findItem( 2000 ); - if ( mi && mi->popup() ) { - SMESH_Actor::eControl cMode = ac->GetControlMode(); - switch ( cMode ) { - case SMESH_Actor::eLengthEdges: - mi->popup()->setItemChecked( 6001, true ); break; - case SMESH_Actor::eFreeBorders: - mi->popup()->setItemChecked( 6003, true ); - mi->popup()->removeItem( 201 ); - break; - case SMESH_Actor::eMultiConnection: - mi->popup()->setItemChecked( 6004, true ); break; - case SMESH_Actor::eArea: - mi->popup()->setItemChecked( 6011, true ); break; - case SMESH_Actor::eTaper: - mi->popup()->setItemChecked( 6012, true ); break; - case SMESH_Actor::eAspectRatio: - mi->popup()->setItemChecked( 6013, true ); break; - case SMESH_Actor::eMinimumAngle: - mi->popup()->setItemChecked( 6014, true ); break; - case SMESH_Actor::eWarping: - mi->popup()->setItemChecked( 6015, true ); break; - case SMESH_Actor::eSkew: - mi->popup()->setItemChecked( 6016, true ); break; - case SMESH_Actor::eNone: - default: - mi->popup()->removeItem( 200 ); - mi->popup()->removeItem( 201 ); - break; - } - TVisualObjPtr aVisualObj = ac->GetObject(); - SMESH::ElementType aType; - if(!aNbEdges){ - mi->popup()->removeItem( 6001 ); - mi->popup()->removeItem( 6003 ); - mi->popup()->removeItem( 6004 ); - } - if(!aNbFaces){ - mi->popup()->removeItem( 6011 ); - mi->popup()->removeItem( 6012 ); - mi->popup()->removeItem( 6013 ); - mi->popup()->removeItem( 6014 ); - mi->popup()->removeItem( 6015 ); - mi->popup()->removeItem( 6016 ); - } - if(!aNbFaces && !aNbEdges) - popup->removeItem( 2000 ); // Scalar Bar - } - } - else { - popup->removeItem( QAD_Erase_Popup_ID ); - popup->removeItem( 114 ); // Numbering popup menu - popup->removeItem( 1131 ); // Display mode - popup->removeItem( 1132 ); // Color / size - popup->removeItem( 1133 ); // Transparency - popup->removeItem( 2000 ); // Scalar Bar - } - } - else { - // object doesn't have actor - CORBA::Object_var anObject = SO->GetObject(); - bool bDisplay = false; - if ( !CORBA::is_nil( anObject ) ) { - SMESH::SMESH_Mesh_var aMeshObj = SMESH::SMESH_Mesh::_narrow( anObject ); - if ( !aMeshObj->_is_nil() && ( aMeshObj->NbNodes() > 0 || aMeshObj->NbFaces() > 0 || aMeshObj->NbVolumes() > 0 ) ) - bDisplay = true; - SMESH::SMESH_subMesh_var aSubMeshObj = SMESH::SMESH_subMesh::_narrow( anObject ); - if ( !aSubMeshObj->_is_nil() && ( aSubMeshObj->GetNumberOfNodes() > 0 || aSubMeshObj->GetNumberOfElements() > 0 ) ) - bDisplay = true; - SMESH::SMESH_Group_var aGroupObj = SMESH::SMESH_Group::_narrow( anObject ); - if ( !aGroupObj->_is_nil() && aGroupObj->Size() > 0 ) - bDisplay = true; - } - if ( !bDisplay ) { - popup->removeItem( QAD_Display_Popup_ID ); - popup->removeItem( QAD_DisplayOnly_Popup_ID ); - } - popup->removeItem( QAD_Erase_Popup_ID ); - popup->removeItem( 114 ); // Numbering popup menu - popup->removeItem( 1131 ); // Display mode - popup->removeItem( 1132 ); // Color / size - popup->removeItem( 1133 ); // Transparency - popup->removeItem( 2000 ); // Scalar Bar - } - } - else { - // another SMESH object - popup->removeItem( QAD_Display_Popup_ID ); - popup->removeItem( QAD_DisplayOnly_Popup_ID ); - popup->removeItem( QAD_Erase_Popup_ID ); - } - } - } - else { - // multiple selection - if ( parentComp != parent->getActiveComponent() ) { - // object not belongs to SMESH module - remove all commands except common Display/Erase... - while ( 1 ) { - int id = popup->idAt( 0 ); - if ( id <= QAD_TopLabel_Popup_ID ) - popup->removeItemAt( 0 ); - else - break; - } - if ( parentComp.isNull() ) { - // objects from different components are selected - popup->removeItem( QAD_DisplayOnly_Popup_ID ); - popup->removeItem( QAD_Display_Popup_ID ); - popup->removeItem( QAD_Erase_Popup_ID ); - } - } - else { - QString type = smeshGUI->CheckHomogeneousSelection(); - if ( type != "Heterogeneous Selection" ) { - int topItem = popup->indexOf( QAD_TopLabel_Popup_ID ); - if ( topItem >= 0 ) { - // set bold font for popup menu's TopLabel item - QFont fnt = QApplication::font(); fnt.setBold( TRUE ); - popup->removeItem( QAD_TopLabel_Popup_ID ); - popup->insertItem( new CustomItem( QString("%1 ").arg( nbSel ) + type + "(s) ", fnt ), QAD_TopLabel_Popup_ID, topItem ); - } - } - } - } - return false; -} - -//============================================================================= -/*! Method: BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO) - * Purpose: ensures that the actor for the given exists in the active VTK view - */ -//============================================================================= -void SMESHGUI::BuildPresentation(const Handle(SALOME_InteractiveObject) & theIO) -{ - if(theIO->hasEntry()){ - QAD_Study* aStudy = SMESHGUI::GetSMESHGUI()->GetActiveStudy(); - QAD_StudyFrame *aStudyFrame = aStudy->getActiveStudyFrame(); - ::UpdateView(aStudyFrame,eDisplay,theIO->getEntry()); - } -} - -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESHGUI::setOrb() -{ - try - { - ORB_INIT & init = *SINGLETON_ < ORB_INIT >::Instance(); - ASSERT(SINGLETON_ < ORB_INIT >::IsAlreadyExisting()); - _orb = init(0, 0); - } catch(...) - { - INFOS("internal error : orb not found"); - _orb = 0; - } - ASSERT(!CORBA::is_nil(_orb)); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -SMESH_Actor *SMESHGUI::ReadScript(SMESH::SMESH_Mesh_ptr theMesh){} - -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESHGUI::Dump(SMESH_Actor * Mactor) -{ - vtkUnstructuredGrid *ugrid = Mactor->GetUnstructuredGrid(); - vtkPoints *Pts = ugrid->GetPoints(); - int nbPts = Pts->GetNumberOfPoints(); - int nbCells = ugrid->GetNumberOfCells(); - - FILE *In; - int i, j; - In = fopen("/tmp/dumpMesh", "w+"); - fprintf(In, "%d %d\n", nbPts, nbCells); - for (int i = 0; i < nbPts; i++) - { - float *p = ugrid->GetPoint(i); - fprintf(In, "%d %e %e %e\n", i, p[0], p[1], p[2]); - } - - for (int i = 0; i < nbCells; i++) - { - fprintf(In, "%d %d", i, ugrid->GetCell(i)->GetCellType()); - vtkIdList *Id = ugrid->GetCell(i)->GetPointIds(); - for (j = 0; j < Id->GetNumberOfIds(); j++) - { - fprintf(In, " %d", Id->GetId(j)); - } - fprintf(In, "\n"); - } - fclose(In); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESHGUI::RemoveNodes(SMESH::SMESH_Mesh_ptr theMesh, - const TColStd_MapOfInteger & MapIndex) -{ - QAD_WaitCursor wc; - try{ - SALOMEDS::SObject_var aSobj = myStudyAPI.FindObject(theMesh); - CORBA::String_var anEntry = aSobj->GetID(); - if(SMESH_Actor* anActor = ::FindActorByEntry(anEntry.in())){ - SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array; - anArrayOfIdeces->length(MapIndex.Extent()); - TColStd_MapIteratorOfMapOfInteger ite(MapIndex); - for(int i = 0; ite.More(); ite.Next(), i++){ - anArrayOfIdeces[i] = anActor->GetNodeObjId(ite.Key()); - } - SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor(); - aMeshEditor->RemoveNodes(anArrayOfIdeces); - if(myAutomaticUpdate){ - CORBA::Long anId = smeshGUI->myStudy->StudyId(); - if(TVisualObjPtr aVisualObj = GetVisualObj(anId,anEntry.in())){ - aVisualObj->Update(true); - } - } - } - }catch(SALOME::SALOME_Exception& exc) { - INFOS("Follow exception was cought:\n\t"<GetID(); - if(SMESH_Actor* anActor = ::FindActorByEntry(anEntry.in())){ - SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array; - anArrayOfIdeces->length(MapIndex.Extent()); - TColStd_MapIteratorOfMapOfInteger ite(MapIndex); - for(int i = 0; ite.More(); ite.Next(), i++){ - anArrayOfIdeces[i] = anActor->GetElemObjId(ite.Key()); - } - SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor(); - aMeshEditor->RemoveElements(anArrayOfIdeces); - if(myAutomaticUpdate){ - CORBA::Long anId = smeshGUI->myStudy->StudyId(); - if(TVisualObjPtr aVisualObj = GetVisualObj(anId,anEntry.in())){ - aVisualObj->Update(true); - } - } - } - }catch(SALOME::SALOME_Exception& exc) { - INFOS("Follow exception was cought:\n\t"<EmitSignalCloseAllDialogs(); - } -} - - -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESHGUI::SetPickable(SMESH_Actor* theActor){ - if(VTKViewer_ViewFrame* aViewFrame = GetCurrentVtkView()){ - int anIsAllPickable = (theActor == NULL); - vtkRenderer *aRenderer = aViewFrame->getRenderer(); - vtkActorCollection *aCollection = aRenderer->GetActors(); - aCollection->InitTraversal(); - while(vtkActor *anAct = aCollection->GetNextActor()){ - if(SALOME_Actor *anActor = dynamic_cast(anAct)){ - if(anActor->GetVisibility()){ - anActor->SetPickable(anIsAllPickable); - } - } - } - if(theActor) - theActor->SetPickable(!anIsAllPickable); - RepaintCurrentView(); - } -} - - -void SMESHGUI::ViewNodes(){ - EraseSimulationActors(); - ::SetPointRepresentation(true); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESHGUI::Control( int theCommandID ){ - SALOME_Selection *Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); - if(Sel){ - Handle(SALOME_InteractiveObject) anIO = Sel->firstIObject(); - if(!anIO.IsNull()){ - QString aTitle; - SMESH_Actor::eControl aControl = SMESH_Actor::eNone; - if(SMESH_Actor *anActor = ::FindActorByEntry(anIO->getEntry())){ - switch ( theCommandID ){ - case 6001: - aTitle = tr( "LENGTH_EDGES" ); - aControl = SMESH_Actor::eLengthEdges; - break; - case 6003: - aTitle = tr( "FREE_BORDERS" ); - aControl = SMESH_Actor::eFreeBorders; - break; - case 6004: - aTitle = tr( "MULTI_BORDERS" ); - aControl = SMESH_Actor::eMultiConnection; - break; - case 6011: - aTitle = tr( "AREA_ELEMENTS" ); - aControl = SMESH_Actor::eArea; - break; - case 6012: - aTitle = tr( "TAPER_ELEMENTS" ); - aControl = SMESH_Actor::eTaper; - break; - case 6013: - aTitle = tr( "ASPECTRATIO_ELEMENTS" ); - aControl = SMESH_Actor::eAspectRatio; - break; - case 6014: - aTitle = tr( "MINIMUMANGLE_ELEMENTS" ); - aControl = SMESH_Actor::eMinimumAngle; - break; - case 6015: - aTitle = tr( "WARP_ELEMENTS" ); - aControl = SMESH_Actor::eWarping; - break; - case 6016: - aTitle = tr( "SKEW_ELEMENTS" ); - aControl = SMESH_Actor::eSkew; - break; - } - anActor->SetControlMode(aControl); - anActor->GetScalarBarActor()->SetTitle(aTitle.latin1()); - } - } - } -} - -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESHGUI::SetSettingsScalarBar(vtkScalarBarActor * theScalarBar, - QString Bold, - QString Italic, - QString Shadow, - QString FontFamily, - QString Orientation, - float Width, - float Height, - int NbColors, - int NbLabels) -{ - if (Bold.isNull() || Bold.isEmpty() || (Bold.compare("true") == 0)) - theScalarBar->BoldOn(); - else - theScalarBar->BoldOff(); - - if (Italic.isNull() || Italic.isEmpty() || (Italic.compare("true") == 0)) - theScalarBar->ItalicOn(); - else - theScalarBar->ItalicOff(); - - if (Shadow.isNull() || Shadow.isEmpty() || (Shadow.compare("true") == 0)) - theScalarBar->ShadowOn(); - else - theScalarBar->ShadowOff(); - - if (FontFamily.compare("Arial") == 0) - theScalarBar->SetFontFamilyToArial(); - else if (FontFamily.compare("Courier") == 0) - theScalarBar->SetFontFamilyToCourier(); - else if (FontFamily.compare("Times") == 0) - theScalarBar->SetFontFamilyToTimes(); - else - theScalarBar->SetFontFamilyToArial(); - - if (Orientation.isNull() || Orientation.isEmpty() || - (Orientation.compare("Vertical") == 0)) - theScalarBar->SetOrientationToVertical(); - else - theScalarBar->SetOrientationToHorizontal(); - - theScalarBar->SetWidth((Width == 0) ? 0.17 : Width); - theScalarBar->SetHeight((Height == 0) ? 0.8 : Height); - - theScalarBar->SetNumberOfLabels((NbLabels == 0) ? 5 : NbLabels); - theScalarBar->SetMaximumNumberOfColors((NbColors == 0) ? 64 : NbColors); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESHGUI::SetDisplaySettings() -{ - EmitSignalDeactivateDialog(); - SMESHGUI_Preferences_ColorDlg *aDlg = - new SMESHGUI_Preferences_ColorDlg(QAD_Application::getDesktop(), ""); - - QColor color; - QString SCr, SCg, SCb; - SCr = QAD_CONFIG->getSetting("SMESH:SettingsFillColorRed"); - SCg = QAD_CONFIG->getSetting("SMESH:SettingsFillColorGreen"); - SCb = QAD_CONFIG->getSetting("SMESH:SettingsFillColorBlue"); - if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) - color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); - else color = QColor(0, 170, 255); - aDlg->SetColor(1, color); - - SCr = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorRed"); - SCg = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorGreen"); - SCb = QAD_CONFIG->getSetting("SMESH:SettingsOutlineColorBlue"); - if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) - color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); - else color = QColor(0, 170, 255); - aDlg->SetColor(2, color); - - SCr = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorRed"); - SCg = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorGreen"); - SCb = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorBlue"); - if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) - color = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); - else color = Qt::red; - aDlg->SetColor(3, color); - - QString SBr = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorRed"); - QString SBg = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorGreen"); - QString SBb = QAD_CONFIG->getSetting("SMESH:SettingsBackFaceColorBlue"); - if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) - color = QColor(SBr.toInt(), SBg.toInt(), SBb.toInt()); - else color = Qt::blue; - aDlg->SetColor(4, color); - - QString intValue = QAD_CONFIG->getSetting("SMESH:SettingsWidth"); - if (intValue.isEmpty()) intValue = "1"; - aDlg->SetIntValue(1, intValue.toInt()); - intValue = QAD_CONFIG->getSetting("SMESH:SettingsNodesSize"); - if (intValue.isEmpty()) intValue = "3"; - aDlg->SetIntValue(2, intValue.toInt()); - intValue = QAD_CONFIG->getSetting("SMESH:SettingsShrinkCoeff"); - if (intValue.isEmpty()) intValue = "75"; - aDlg->SetIntValue(3, intValue.toInt()); - - if (aDlg->exec()) { - QColor colorFill = aDlg->GetColor(1); - QAD_CONFIG->addSetting("SMESH:SettingsFillColorRed", colorFill.red()); - QAD_CONFIG->addSetting("SMESH:SettingsFillColorGreen", colorFill.green()); - QAD_CONFIG->addSetting("SMESH:SettingsFillColorBlue", colorFill.blue()); - - QColor colorOutline = aDlg->GetColor(2); - QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorRed", colorOutline.red()); - QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorGreen", colorOutline.green()); - QAD_CONFIG->addSetting("SMESH:SettingsOutlineColorBlue", colorOutline.blue()); - - QColor colorNode = aDlg->GetColor(3); - QAD_CONFIG->addSetting("SMESH:SettingsNodeColorRed", colorNode.red()); - QAD_CONFIG->addSetting("SMESH:SettingsNodeColorGreen", colorNode.green()); - QAD_CONFIG->addSetting("SMESH:SettingsNodeColorBlue", colorNode.blue()); - - QColor colorBackFace = aDlg->GetColor(4); - QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorRed", colorBackFace.red()); - QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorGreen", colorBackFace.green()); - QAD_CONFIG->addSetting("SMESH:SettingsBackFaceColorBlue", colorBackFace.blue()); - - int width = aDlg->GetIntValue(1); - QAD_CONFIG->addSetting("SMESH:SettingsWidth", width); - - int nodes_size = aDlg->GetIntValue(2); - QAD_CONFIG->addSetting("SMESH:SettingsNodesSize", nodes_size); - - int shrink_coeff = aDlg->GetIntValue(3); - QAD_CONFIG->addSetting("SMESH:SettingsShrinkCoeff", shrink_coeff); - } - - delete aDlg; -} - -//======================================================================= -// function : Parameter() -// purpose : return a parameter (double) from a dialog box -// -// aValue : is a double used as a default value displayed -// aLabel : is the title for aValue1 -// aTitle : is the main title -// bottom : maximum value to be entered -// top : minimum value to be entered -// decimals : number of decimals -//======================================================================= -double SMESHGUI::Parameter(Standard_Boolean & res, - const double aValue, - const char *aLabel, - const char *aTitle, - const double bottom, const double top, const int decimals) -{ - SMESHGUI_aParameterDlg *Dialog = - new SMESHGUI_aParameterDlg(QAD_Application::getDesktop(), - aTitle, - aLabel, - bottom, top, decimals, - TRUE); - Dialog->setValue(aValue); - double X = 0.0; - res = (Dialog->exec() == QDialog::Accepted); - if (res) - X = Dialog->getDblValue(); - return X; -} - -//======================================================================= -// function : Parameter() -// purpose : return a parameter (int) from a dialog box -// -// aValue : is a int used as a default value displayed -// aLabel : is the title for aValue1 -// aTitle : is the main title -// bottom : maximum value to be entered -// top : minimum value to be entered -//======================================================================= -int SMESHGUI::Parameter(Standard_Boolean & res, - const int aValue, - const char *aLabel, const char *aTitle, const int bottom, const int top) -{ - SMESHGUI_aParameterDlg *Dialog = - new SMESHGUI_aParameterDlg(QAD_Application::getDesktop(), - aTitle, - aLabel, - bottom, top, - TRUE); - Dialog->setValue(aValue); - int X = 0; - res = (Dialog->exec() == QDialog::Accepted); - if (res) - X = Dialog->getIntValue(); - return X; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESHGUI::DisplayEdges(SMESH_Actor * ac, bool visibility){} - -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESHGUI::InitActor(SMESH::SMESH_Mesh_ptr aMesh){} - -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESHGUI::Update(){ - if(VTKViewer_ViewFrame* aViewFrame = GetCurrentVtkView()){ - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - if(Sel->IObjectCount() == 0){ - vtkRenderer* aRenderer = aViewFrame->getRenderer(); - vtkActorCollection *aCollection = aRenderer->GetActors(); - aCollection->InitTraversal(); - while(vtkActor *anAct = aCollection->GetNextActor()){ - if(SMESH_Actor *anActor = dynamic_cast(anAct)){ - if(anActor->hasIO()){ - Update(anActor->getIO()); + tr( "SMESH_BUT_OK" ) ); + } + break; + case 9010: + { + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + if (Sel->IObjectCount() == 1) { + Handle(SALOME_InteractiveObject) anIObject = Sel->firstIObject(); + if(anIObject->hasEntry()) + if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){ + anActor->SetPointsLabeled( !anActor->GetPointsLabeled() ); } - } } - }else{ - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - for(; It.More(); It.Next()){ - Handle(SALOME_InteractiveObject) IO = It.Value(); - Update(IO); + break; + } + case 9011: + { + SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); + if (Sel->IObjectCount() == 1) { + Handle(SALOME_InteractiveObject) anIObject = Sel->firstIObject(); + if(anIObject->hasEntry()) + if(SMESH_Actor *anActor = SMESH::FindActorByEntry(anIObject->getEntry())){ + anActor->SetCellsLabeled( !anActor->GetCellsLabeled() ); + } } + break; + } + case 10001: // DISPLAY MODE PREFERENCE + { + // Wireframe + parent->menuBar()->setItemChecked(10001, true); + parent->menuBar()->setItemChecked(10002, false); + parent->menuBar()->setItemChecked(10004, false); + parent->menuBar()->setItemEnabled(10003, true); + QAD_CONFIG->addSetting("SMESH:DisplayMode", "Wireframe"); + break; } - ::RepaintCurrentView(); + case 10002: + { + parent->menuBar()->setItemChecked(10002, true); + parent->menuBar()->setItemChecked(10001, false); + parent->menuBar()->setItemChecked(10004, false); + parent->menuBar()->setItemEnabled(10003, true); + QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading"); + break; + } + case 10003: + { + parent->menuBar()->setItemChecked(10003,!parent->menuBar()->isItemChecked(10003)); + QAD_CONFIG->addSetting("SMESH:Shrink", parent->menuBar()->isItemChecked(10003) ? "yes" : "no"); + break; + } + case 10004: + { + parent->menuBar()->setItemChecked(10001, false); + parent->menuBar()->setItemChecked(10004, true); + parent->menuBar()->setItemChecked(10002, false); + parent->menuBar()->setItemEnabled(10003, false); + QAD_CONFIG->addSetting("SMESH:DisplayMode", "Nodes"); + break; + } + } -} - -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESHGUI::Update(const Handle(SALOME_InteractiveObject) & theIO){ - CORBA::Long anId = smeshGUI->myStudy->StudyId(); - TVisualObjPtr aVisualObj = ::GetVisualObj(anId,theIO->getEntry()); - aVisualObj->Update(); - ::UpdateView(eDisplay,theIO->getEntry()); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -vtkActor *SMESHGUI::SimulationMoveNode(SMESH_Actor * Mactor, int idnode) -{ - if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) - return NULL; - - mySimulationActors = vtkActorCollection::New(); - vtkRenderer *theRenderer = - ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()-> - getRightFrame()->getViewFrame())->getRenderer(); - - vtkUnstructuredGrid *ugrid = - vtkUnstructuredGrid::SafeDownCast(Mactor->GetUnstructuredGrid()); - vtkIdList *IdCells = vtkIdList::New(); - ugrid->GetPointCells(idnode, IdCells); - - vtkPoints *Pts = vtkPoints::New(); - Pts = ugrid->GetPoints(); - - vtkUnstructuredGrid *ugridSimulation = vtkUnstructuredGrid::New(); - ugridSimulation->SetPoints(Pts); - vtkIdList *IdPts = vtkIdList::New(); - for (int j = 0; j < IdCells->GetNumberOfIds(); j++) - { - ugrid->GetCellPoints(IdCells->GetId(j), IdPts); - ugridSimulation->InsertNextCell(ugrid->GetCellType(IdCells->GetId(j)), - IdPts); - } - - vtkProperty *prop = vtkProperty::New(); - prop->SetColor(1., 0., 0.); - prop->SetRepresentationToWireframe(); - - int Edgewidth = (int)Mactor->GetLineWidth(); - if (Edgewidth == 0) - Edgewidth = 1; - prop->SetLineWidth(Edgewidth + 1); - - vtkDataSetMapper *Mapper = vtkDataSetMapper::New(); - Mapper->SetInput(ugridSimulation); - vtkActor *ac = vtkActor::New(); - ac->SetMapper(Mapper); - ac->SetProperty(prop); - - ac->GetMapper()->SetResolveCoincidentTopologyToShiftZBuffer(); - ac->GetMapper()->SetResolveCoincidentTopologyZShift(0.02); - - mySimulationActors->AddItem(ac); - theRenderer->AddActor(ac); - - vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); - renWin->Render(); - - return ac; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESHGUI::DisplaySimulationNode(SMESH::SMESH_Mesh_ptr aMesh, float x, - float y, float z) -{ - if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) - return; - - EraseSimulationActors(); - mySimulationActors = vtkActorCollection::New(); - vtkRenderer *theRenderer = - ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()-> - getRightFrame()->getViewFrame())->getRenderer(); - Standard_Boolean result; - SMESH_Actor *ac = FindActor(aMesh, result, true); - - if (result) - { - vtkUnstructuredGrid *ugrid = - vtkUnstructuredGrid::SafeDownCast(ac->GetUnstructuredGrid()); - vtkUnstructuredGrid *newugrid = vtkUnstructuredGrid::New(); - - vtkPoints *Pts = ugrid->GetPoints(); - vtkPoints *newPts = vtkPoints::New(); - int nbPts = Pts->GetNumberOfPoints(); - for (int i = 0; i < nbPts; i++) - { - newPts->InsertPoint(i, Pts->GetPoint(i)); - } - - newugrid->SetPoints(newPts); - newugrid->GetPoints()->InsertNextPoint(x, y, z); - - vtkMaskPoints *verts = vtkMaskPoints::New(); - verts->SetInput(newugrid); - verts->SetGenerateVertices(1); - verts->SetOnRatio(1); - - vtkPolyDataMapper *vertMapper = vtkPolyDataMapper::New(); - vertMapper->SetInput(verts->GetOutput()); - vertMapper->ScalarVisibilityOff(); - - vtkActor *node = vtkActor::New(); - node->SetMapper(vertMapper); - QString SCr = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorRed"); - QString SCg = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorGreen"); - QString SCb = QAD_CONFIG->getSetting("SMESH:SettingsNodeColorBlue"); - QColor nodecolor(SCr.toInt(), SCg.toInt(), SCb.toInt()); - if (!nodecolor.isValid()) -// nodecolor = QColor(0.,1.,0.); - nodecolor = QColor(0, 1, 0); - - node->GetProperty()->SetColor(float (nodecolor.red()) / 255., - float (nodecolor.green()) / 255., float (nodecolor.blue()) / 255.); - - int intValue = - QAD_CONFIG->getSetting("SMESH:SettingsNodesSize").toInt(); - if (intValue < 1) - intValue == 1; - - node->GetProperty()->SetPointSize(intValue); - - node->VisibilityOn(); - - mySimulationActors->AddItem(node); - theRenderer->AddActor(node); - } - - vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); - renWin->Render(); -} - -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESHGUI::DisplaySimulationMoveNode(vtkActor * ac, int idnode, float x, - float y, float z) -{ - if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) - return; - - vtkRenderer *theRenderer = - ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()-> - getRightFrame()->getViewFrame())->getRenderer(); - float *pt = ac->GetMapper()->GetInput()->GetPoint(idnode); - pt[0] = x; - pt[1] = y; - pt[2] = z; - - ac->GetMapper()->ImmediateModeRenderingOn(); - ac->GetProperty()->SetRepresentationToWireframe(); - - vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); - - renWin->Render(); + myActiveStudy->updateObjBrowser(true); + return true; } //============================================================================= @@ -4297,33 +2078,10 @@ void SMESHGUI::DisplaySimulationMoveNode(vtkActor * ac, int idnode, float x, * */ //============================================================================= -void SMESHGUI::MoveNode(SMESH::SMESH_Mesh_ptr aMesh, int idnode, float x, - float y, float z) +bool SMESHGUI::OnMousePress(QMouseEvent * pe, QAD_Desktop * parent, + QAD_StudyFrame * studyFrame) { - Standard_Boolean result; - - SMESH_Actor *MeshActor = FindActor(aMesh, result, true); - if (result) - { - } -} - -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESHGUI::ScalarVisibilityOff(){ - if(vtkRenderer *aRenderer = ::GetCurrentRenderer()){ - vtkActorCollection *actorList = aRenderer->GetActors(); - actorList->InitTraversal(); - while(vtkActor *ac = actorList->GetNextActor()){ - if(SMESH_Actor *anActor = SMESH_Actor::SafeDownCast(ac)){ - anActor->GetMapper()->ScalarVisibilityOff(); - } - } - ::RepaintCurrentView(); - } + return false; } //============================================================================= @@ -4331,58 +2089,10 @@ void SMESHGUI::ScalarVisibilityOff(){ * */ //============================================================================= -void SMESHGUI::DisplaySimulationEdge(SMESH::SMESH_Mesh_ptr aMesh, - const TColStd_MapOfInteger & MapIndex) +bool SMESHGUI::OnMouseMove(QMouseEvent * pe, QAD_Desktop * parent, + QAD_StudyFrame * studyFrame) { - if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) - return; - - EraseSimulationActors(); - mySimulationActors = vtkActorCollection::New(); - vtkRenderer *theRenderer = - ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()-> - getRightFrame()->getViewFrame())->getRenderer(); - Standard_Boolean result; - SMESH_Actor *ac = FindActor(aMesh, result, true); - if (result) - { - TColStd_MapIteratorOfMapOfInteger ite(MapIndex); - int idNodes[2]; - int pts[2]; - int i = 0; - vtkIdList *Ids = vtkIdList::New(); - for (; ite.More(); ite.Next()) - { - idNodes[i] = ite.Key(); - i++; - } - - Ids->InsertId(0, idNodes[0]); - pts[0] = idNodes[0]; - Ids->InsertId(1, idNodes[1]); - pts[1] = idNodes[1]; - - vtkUnstructuredGrid *ugrid = - vtkUnstructuredGrid::SafeDownCast(ac->GetUnstructuredGrid()); - vtkUnstructuredGrid *newugrid = vtkUnstructuredGrid::New(); - newugrid->SetPoints(ugrid->GetPoints()); - newugrid->InsertNextCell(VTK_LINE, 2, pts); - - vtkDataSetMapper *Mapper = vtkDataSetMapper::New(); - Mapper->SetInput(newugrid); - Mapper->Update(); - - vtkActor *edge = vtkActor::New(); - edge->SetMapper(Mapper); - edge->SetProperty(ac->GetProperty()); - edge->SetBackfaceProperty(ac->GetBackfaceProperty()); - edge->VisibilityOn(); - mySimulationActors->AddItem(edge); - theRenderer->AddActor(edge); - } - - vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); - renWin->Render(); + return true; } //============================================================================= @@ -4390,71 +2100,10 @@ void SMESHGUI::DisplaySimulationEdge(SMESH::SMESH_Mesh_ptr aMesh, * */ //============================================================================= -void SMESHGUI::DisplaySimulationTriangle(SMESH::SMESH_Mesh_ptr aMesh, - const TColStd_MapOfInteger & MapIndex, bool reverse) +bool SMESHGUI::OnKeyPress(QKeyEvent * pe, QAD_Desktop * parent, + QAD_StudyFrame * studyFrame) { - if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) - return; - - EraseSimulationActors(); - mySimulationActors = vtkActorCollection::New(); - vtkRenderer *theRenderer = - ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()-> - getRightFrame()->getViewFrame())->getRenderer(); - Standard_Boolean result; - SMESH_Actor *ac = FindActor(aMesh, result, true); - if (result) - { - TColStd_MapIteratorOfMapOfInteger ite(MapIndex); - int idNodes[3]; - int pts[3]; - int i = 0; - vtkIdList *Ids = vtkIdList::New(); - for (; ite.More(); ite.Next()) - { - idNodes[i] = ite.Key(); - i++; - } - - if (reverse) - { - Ids->InsertId(0, idNodes[2]); - pts[0] = idNodes[2]; - Ids->InsertId(1, idNodes[1]); - pts[1] = idNodes[1]; - Ids->InsertId(2, idNodes[0]); - pts[2] = idNodes[0]; - } - else - { - Ids->InsertId(0, idNodes[0]); - pts[0] = idNodes[0]; - Ids->InsertId(1, idNodes[1]); - pts[1] = idNodes[1]; - Ids->InsertId(2, idNodes[2]); - pts[2] = idNodes[2]; - } - vtkUnstructuredGrid *ugrid = - vtkUnstructuredGrid::SafeDownCast(ac->GetUnstructuredGrid()); - vtkUnstructuredGrid *newugrid = vtkUnstructuredGrid::New(); - newugrid->SetPoints(ugrid->GetPoints()); - newugrid->InsertNextCell(VTK_TRIANGLE, 3, pts); - - vtkDataSetMapper *Mapper = vtkDataSetMapper::New(); - Mapper->SetInput(newugrid); - Mapper->Update(); - - vtkActor *tri = vtkActor::New(); - tri->SetMapper(Mapper); - tri->SetProperty(ac->GetProperty()); - tri->SetBackfaceProperty(ac->GetBackfaceProperty()); - tri->VisibilityOn(); - mySimulationActors->AddItem(tri); - theRenderer->AddActor(tri); - } - - vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); - renWin->Render(); + return true; } //============================================================================= @@ -4462,162 +2111,64 @@ void SMESHGUI::DisplaySimulationTriangle(SMESH::SMESH_Mesh_ptr aMesh, * */ //============================================================================= -void SMESHGUI::DisplaySimulationQuadrangle(SMESH::SMESH_Mesh_ptr aMesh, - const TColStd_MapOfInteger & MapIndex, bool reverse) +bool SMESHGUI::SetSettings(QAD_Desktop * parent) { - if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) - return; - - EraseSimulationActors(); - mySimulationActors = vtkActorCollection::New(); - vtkRenderer *theRenderer = - ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()-> - getRightFrame()->getViewFrame())->getRenderer(); - Standard_Boolean result; - SMESH_Actor *ac = FindActor(aMesh, result, true); + MESSAGE("SMESHGUI::SetSettings."); + SMESHGUI::GetSMESHGUI(); - vtkUnstructuredGrid *ugrid = - vtkUnstructuredGrid::SafeDownCast(ac->GetUnstructuredGrid()); + /* Display mode */ + QString DisplayMode = "Shading"; + if ( QAD_CONFIG->hasSetting("SMESH:DisplayMode") ) + DisplayMode = QAD_CONFIG->getSetting("SMESH:DisplayMode"); + else + QAD_CONFIG->addSetting("SMESH:DisplayMode", "Shading"); - if (result) - { - TColStd_MapIteratorOfMapOfInteger ite(MapIndex); - int i = 0; - int idNodes[4]; - vtkIdList *Ids = vtkIdList::New(); - for (; ite.More(); ite.Next()) - { - idNodes[i] = ite.Key(); - i++; - } + bool Shrink = false; + if ( QAD_CONFIG->hasSetting("SMESH:Shrink") ) + Shrink = QAD_CONFIG->getSetting("SMESH:Shrink") == "yes"; - float *p0 = ugrid->GetPoint(idNodes[0]); - float *p1 = ugrid->GetPoint(idNodes[1]); - float *p2 = ugrid->GetPoint(idNodes[2]); - float *p3 = ugrid->GetPoint(idNodes[3]); - - gp_Pnt P0(p0[0], p0[1], p0[2]); - - gp_Vec V1(P0, gp_Pnt(p1[0], p1[1], p1[2])); - gp_Vec V2(P0, gp_Pnt(p2[0], p2[1], p2[2])); - gp_Vec V3(P0, gp_Pnt(p3[0], p3[1], p3[2])); - - gp_Vec Cross1 = V1 ^ V2; - gp_Vec Cross2 = V2 ^ V3; - - int tmp; - if (Cross1.Dot(Cross2) < 0) - { - V1 = gp_Vec(P0, gp_Pnt(p2[0], p2[1], p2[2])); - V2 = gp_Vec(P0, gp_Pnt(p1[0], p1[1], p1[2])); - Cross1 = V1 ^ V2; - Cross2 = V2 ^ V3; - - if (Cross1.Dot(Cross2) < 0) - { - tmp = idNodes[2]; - idNodes[2] = idNodes[3]; - idNodes[3] = tmp; - } - else - { - tmp = idNodes[1]; - idNodes[1] = idNodes[2]; - idNodes[2] = tmp; - } - } + if (DisplayMode == "Wireframe") { + // wireframe + parent->menuBar()->setItemChecked(10004, false); + parent->menuBar()->setItemChecked(10002, false); + parent->menuBar()->setItemChecked(10001, true); + parent->menuBar()->setItemEnabled(10003, true); + } + else if (DisplayMode == "Nodes") { + // poins + parent->menuBar()->setItemChecked(10004, true); + parent->menuBar()->setItemChecked(10002, false); + parent->menuBar()->setItemChecked(10001, false); + parent->menuBar()->setItemEnabled(10003, false); + } + else { + // default is shading + parent->menuBar()->setItemChecked(10004, false); + parent->menuBar()->setItemChecked(10002, true); + parent->menuBar()->setItemChecked(10001, false); + parent->menuBar()->setItemEnabled(10003, true); + } + parent->menuBar()->setItemChecked(10003, Shrink); - if (reverse) - { - Ids->InsertId(0, idNodes[3]); - Ids->InsertId(1, idNodes[2]); - Ids->InsertId(2, idNodes[1]); - Ids->InsertId(3, idNodes[0]); - } - else - { - Ids->InsertId(0, idNodes[0]); - Ids->InsertId(1, idNodes[1]); - Ids->InsertId(2, idNodes[2]); - Ids->InsertId(3, idNodes[3]); - } + /* Automatic Update */ + QString AutoUpdate = QAD_CONFIG->getSetting("SMESH:AutomaticUpdate"); + if (AutoUpdate.compare("true") == 0) { + parent->menuBar()->setItemChecked(1001, true); + myAutomaticUpdate = true; + } + else { + parent->menuBar()->setItemChecked(1001, false); + myAutomaticUpdate = false; + } - // vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( ac->GetUnstructuredGrid() ); - vtkUnstructuredGrid *newugrid = vtkUnstructuredGrid::New(); - newugrid->SetPoints(ugrid->GetPoints()); - newugrid->InsertNextCell(VTK_QUAD, Ids); - - vtkDataSetMapper *Mapper = vtkDataSetMapper::New(); - Mapper->SetInput(newugrid); - Mapper->Update(); - - vtkActor *quad = vtkActor::New(); - quad->SetMapper(Mapper); - quad->SetProperty(ac->GetProperty()); - quad->SetBackfaceProperty(ac->GetBackfaceProperty()); - quad->VisibilityOn(); - mySimulationActors->AddItem(quad); - theRenderer->AddActor(quad); - } - vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); - renWin->Render(); -} + /* Selection */ + SMESH::UpdateSelectionProp(); -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESHGUI::DisplaySimulationTetra(SMESH::SMESH_Mesh_ptr aMesh, - const TColStd_MapOfInteger & MapIndex) -{ - if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) - return; - - EraseSimulationActors(); - mySimulationActors = vtkActorCollection::New(); - vtkRenderer *theRenderer = - ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()-> - getRightFrame()->getViewFrame())->getRenderer(); - Standard_Boolean result; - SMESH_Actor *ac = FindActor(aMesh, result, true); - if (result) - { - TColStd_MapIteratorOfMapOfInteger ite(MapIndex); - int i = 0; - int idNodes[4]; - vtkIdList *Ids = vtkIdList::New(); - for (; ite.More(); ite.Next()) - { - idNodes[i] = ite.Key(); - i++; - } + /* menus disable */ + parent->menuBar()->setItemEnabled(111, false); // IMPORT DAT + //parent->menuBar()->setItemEnabled(112, false); // IMPORT UNV - Ids->InsertId(0, idNodes[0]); - Ids->InsertId(1, idNodes[1]); - Ids->InsertId(2, idNodes[2]); - Ids->InsertId(3, idNodes[3]); - - vtkUnstructuredGrid *ugrid = - vtkUnstructuredGrid::SafeDownCast(ac->GetUnstructuredGrid()); - vtkUnstructuredGrid *newugrid = vtkUnstructuredGrid::New(); - newugrid->SetPoints(ugrid->GetPoints()); - newugrid->InsertNextCell(VTK_TETRA, Ids); - - vtkDataSetMapper *Mapper = vtkDataSetMapper::New(); - Mapper->SetInput(newugrid); - Mapper->Update(); - - vtkActor *tetra = vtkActor::New(); - tetra->SetMapper(Mapper); - tetra->SetProperty(ac->GetProperty()); - tetra->SetBackfaceProperty(ac->GetBackfaceProperty()); - tetra->VisibilityOn(); - mySimulationActors->AddItem(tetra); - theRenderer->AddActor(tetra); - } - vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); - renWin->Render(); + return true; } //============================================================================= @@ -4625,144 +2176,32 @@ void SMESHGUI::DisplaySimulationTetra(SMESH::SMESH_Mesh_ptr aMesh, * */ //============================================================================= -void SMESHGUI::DisplaySimulationHexa(SMESH::SMESH_Mesh_ptr aMesh, - const TColStd_MapOfInteger & MapIndex) +void SMESHGUI::DefinePopup(QString & theContext, QString & theParent, QString & theObject) { - if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) - return; - - EraseSimulationActors(); - mySimulationActors = vtkActorCollection::New(); - vtkRenderer *theRenderer = - ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()-> - getRightFrame()->getViewFrame())->getRenderer(); - Standard_Boolean result; - SMESH_Actor *ac = FindActor(aMesh, result, true); - if (result) - { - TColStd_MapIteratorOfMapOfInteger ite(MapIndex); - int i = 0; - int idNodes[8]; - vtkIdList *Ids = vtkIdList::New(); - for (; ite.More(); ite.Next()) - { - idNodes[i] = ite.Key(); - i++; - } - - Ids->InsertId(0, idNodes[0]); - Ids->InsertId(1, idNodes[1]); - Ids->InsertId(2, idNodes[2]); - Ids->InsertId(3, idNodes[3]); - Ids->InsertId(4, idNodes[4]); - Ids->InsertId(5, idNodes[5]); - Ids->InsertId(6, idNodes[6]); - Ids->InsertId(7, idNodes[7]); - - vtkUnstructuredGrid *ugrid = - vtkUnstructuredGrid::SafeDownCast(ac->GetUnstructuredGrid()); - vtkUnstructuredGrid *newugrid = vtkUnstructuredGrid::New(); - newugrid->SetPoints(ugrid->GetPoints()); - newugrid->InsertNextCell(VTK_HEXAHEDRON, Ids); - - vtkDataSetMapper *Mapper = vtkDataSetMapper::New(); - Mapper->SetInput(newugrid); - Mapper->Update(); - - vtkActor *hexa = vtkActor::New(); - hexa->SetMapper(Mapper); - hexa->SetProperty(ac->GetProperty()); - hexa->SetBackfaceProperty(ac->GetBackfaceProperty()); - hexa->VisibilityOn(); - mySimulationActors->AddItem(hexa); - theRenderer->AddActor(hexa); - } - vtkRenderWindow *renWin = theRenderer->GetRenderWindow(); - renWin->Render(); -} + // NRI : Temporary added + // if ( myStudy->GetProperties()->IsLocked() ) { + // theObject = "NothingSelected"; + // theContext = "NothingSelected"; + // } + // NRI -//============================================================================= -/*! - * - */ -//============================================================================= -void SMESHGUI::AddFace(SMESH::SMESH_Mesh_ptr theMesh, - const TColStd_MapOfInteger & MapIndex, - bool reverse) -{ - QAD_WaitCursor wc; - try{ - SALOMEDS::SObject_var aSobj = myStudyAPI.FindObject(theMesh); - CORBA::String_var anEntry = aSobj->GetID(); - if(SMESH_Actor* anActor = ::FindActorByEntry(anEntry.in())){ - SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array; - anArrayOfIdeces->length(MapIndex.Extent()); - TColStd_MapIteratorOfMapOfInteger ite(MapIndex); - for(int i = 0; ite.More(); ite.Next(), i++){ - anArrayOfIdeces[i] = anActor->GetNodeObjId(ite.Key()); - } - int tmp; - if(MapIndex.Extent() == 4){ - int idNodes[4]; - TColStd_MapIteratorOfMapOfInteger ite1(MapIndex); - for(int i = 0; ite1.More(); ite1.Next(), i++){ - idNodes[i] = ite1.Key(); - } - vtkUnstructuredGrid *ugrid = anActor->GetUnstructuredGrid(); - float *p0 = ugrid->GetPoint(idNodes[0]); - float *p1 = ugrid->GetPoint(idNodes[1]); - float *p2 = ugrid->GetPoint(idNodes[2]); - float *p3 = ugrid->GetPoint(idNodes[3]); - - gp_Pnt P0(p0[0], p0[1], p0[2]); - - gp_Vec V1(P0, gp_Pnt(p1[0], p1[1], p1[2])); - gp_Vec V2(P0, gp_Pnt(p2[0], p2[1], p2[2])); - gp_Vec V3(P0, gp_Pnt(p3[0], p3[1], p3[2])); - - gp_Vec Cross1 = V1 ^ V2; - gp_Vec Cross2 = V2 ^ V3; - - if(Cross1.Dot(Cross2) < 0){ - V1 = gp_Vec(P0, gp_Pnt(p2[0], p2[1], p2[2])); - V2 = gp_Vec(P0, gp_Pnt(p1[0], p1[1], p1[2])); - Cross1 = V1 ^ V2; - Cross2 = V2 ^ V3; - - if(Cross1.Dot(Cross2) < 0){ - tmp = anArrayOfIdeces[2]; - anArrayOfIdeces[2] = anArrayOfIdeces[3]; - anArrayOfIdeces[3] = tmp; - }else{ - tmp = anArrayOfIdeces[1]; - anArrayOfIdeces[1] = anArrayOfIdeces[2]; - anArrayOfIdeces[2] = tmp; - } - } - } - if(reverse){ - for(int i = 0; i < (MapIndex.Extent() / 2); i++){ - tmp = anArrayOfIdeces[i]; - anArrayOfIdeces[i] = anArrayOfIdeces[MapIndex.Extent() - i - 1]; - anArrayOfIdeces[MapIndex.Extent() - i - 1] = tmp; - } - } - SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor(); - aMeshEditor->AddFace(anArrayOfIdeces); - if(myAutomaticUpdate){ - CORBA::Long anId = smeshGUI->myStudy->StudyId(); - if(TVisualObjPtr aVisualObj = GetVisualObj(anId,anEntry.in())){ - aVisualObj->Update(true); - } - AddActorInSelection(anActor); - } - } - }catch(SALOME::SALOME_Exception& exc) { - INFOS("Follow exception was cought:\n\t"<getSelection() ); + int nbSel = Sel->IObjectCount(); + switch ( nbSel ) { + case 0: + theObject = "NothingSelected"; + theContext = "NothingSelected"; + break; + case 1: + if ( myState == 800 && Sel->HasIndex( Sel->firstIObject() ) ) + theObject = "Elements"; + else + theObject = ::CheckTypeObject( Sel->firstIObject() ); + theContext = ""; + break; + default: + theObject = ::CheckHomogeneousSelection(); + theContext = ""; } } @@ -4771,244 +2210,269 @@ void SMESHGUI::AddFace(SMESH::SMESH_Mesh_ptr theMesh, * */ //============================================================================= -void SMESHGUI::AddVolume(SMESH::SMESH_Mesh_ptr theMesh, - const TColStd_MapOfInteger & MapIndex) +bool SMESHGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* popup, const QString& theContext, + const QString& theParent, const QString& theObject) { - QAD_WaitCursor wc; - try{ - SALOMEDS::SObject_var aSobj = myStudyAPI.FindObject(theMesh); - CORBA::String_var anEntry = aSobj->GetID(); - if(SMESH_Actor* anActor = ::FindActorByEntry(anEntry.in())){ - SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array; - anArrayOfIdeces->length(MapIndex.Extent()); - TColStd_MapIteratorOfMapOfInteger ite(MapIndex); - for(int i = 0; ite.More(); ite.Next(), i++){ - anArrayOfIdeces[i] = anActor->GetNodeObjId(ite.Key()); + // get active study frame + QAD_StudyFrame* studyFrame = myActiveStudy->getActiveStudyFrame(); + + // get parent component which selected object(s) belongs to + QString parentComp = ( (SALOMEGUI_Desktop*)parent )->getComponentFromSelection(); + + // get selection + SALOME_Selection* Sel = SALOME_Selection::Selection( myActiveStudy->getSelection() ); + int nbSel = Sel->IObjectCount(); + + if ( nbSel == 0 ) { + popup->clear(); + } + else if ( nbSel == 1 ) { + if ( parentComp != parent->getActiveComponent() ) { + // object not belongs to SMESH module - remove all commands except common Display/Erase... + while ( 1 ) { + int id = popup->idAt( 0 ); + if ( id <= QAD_TopLabel_Popup_ID ) + popup->removeItemAt( 0 ); + else + break; } - SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor(); - aMeshEditor->AddVolume(anArrayOfIdeces); - if(myAutomaticUpdate){ - CORBA::Long anId = smeshGUI->myStudy->StudyId(); - if(TVisualObjPtr aVisualObj = GetVisualObj(anId,anEntry.in())){ - aVisualObj->Update(true); + } + else { + // get selected interactive object + Handle(SALOME_InteractiveObject) IObject = Sel->firstIObject(); + SALOMEDS::SObject_var SO = SMESH::GetActiveStudyDocument()->FindObjectID( IObject->getEntry() ); + // find popup menu's TopLabel item + int topItem = popup->indexOf( QAD_TopLabel_Popup_ID ); + if ( topItem >= 0 ) { + if ( theParent == "Viewer" ) { + // set bold font for popup menu's TopLabel item (Viewer popup) + QFont fnt = QApplication::font(); fnt.setBold( TRUE ); + popup->removeItem( QAD_TopLabel_Popup_ID ); + popup->insertItem( new CustomItem( QString( IObject->getName() ), fnt ), QAD_TopLabel_Popup_ID, topItem ); + } + else if ( theParent == "ObjectBrowser" ) { + // remove popup menu's TopLabel item (Object Browser popup) + popup->removeItem( QAD_TopLabel_Popup_ID ); } } - } - }catch(SALOME::SALOME_Exception& exc) { - INFOS("Follow exception was cought:\n\t"<GetID(); - if(SMESH_Actor* anActor = ::FindActorByEntry(anEntry.in())){ - SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array; - anArrayOfIdeces->length(MapIndex.Extent()); - TColStd_MapIteratorOfMapOfInteger ite(MapIndex); - for(int i = 0; ite.More(); ite.Next(), i++){ - anArrayOfIdeces[i] = anActor->GetNodeObjId(ite.Key()); + + if ( theObject == "Hypothesis" || theObject == "Algorithm" ) { + // remove Display/Erase commands + popup->removeItem( QAD_Display_Popup_ID ); + popup->removeItem( QAD_DisplayOnly_Popup_ID ); + popup->removeItem( QAD_Erase_Popup_ID ); + // remove "Unassign ..." command if hyp/algo is not assigned + if ( SO->_is_nil() || !IObject->hasReference()/* !IsReferencedObject( SO ) */) + popup->removeItem( 1102 ); } - SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor(); - aMeshEditor->AddEdge(anArrayOfIdeces); - if(myAutomaticUpdate){ - CORBA::Long anId = smeshGUI->myStudy->StudyId(); - if(TVisualObjPtr aVisualObj = GetVisualObj(anId,anEntry.in())){ - aVisualObj->Update(true); + else if ( theObject == "Mesh" || theObject == "SubMesh" || theObject == "Group" ) { + // get actor + GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( SO ); + if ( aShapeObject->_is_nil() ) { + // imported mesh + popup->removeItem( 701 ); // Compute + popup->removeItem( 705 ); // Edit hypothesis + popup->removeItem( 706 ); // ... + } + SMESH::SMESH_GroupOnGeom_var aGeomGroup = + SMESH::SMESH_GroupOnGeom::_narrow( SO->GetObject() ); + if ( !aGeomGroup->_is_nil() ) // group linked on geometry + popup->removeItem( 803 ); // EDIT GROUP + + SMESH_Actor* ac = SMESH::FindActorByEntry(IObject->getEntry()); + // if object has actor + if ( ac && studyFrame->getTypeView() == VIEW_VTK ) { + VTKViewer_RenderWindowInteractor* myRenderInter = SMESH::GetCurrentVtkView()->getRWInteractor(); + if ( myRenderInter->isVisible( IObject ) ) { + popup->removeItem( QAD_Display_Popup_ID ); + popup->setItemChecked( 9010, ac->GetPointsLabeled() ); // Numbering / Display Nodes # + popup->setItemChecked( 9011, ac->GetCellsLabeled() ); // Numbering / Display Elements # + TVisualObjPtr aVisualObj = ac->GetObject(); + int aNbEdges = aVisualObj->GetNbEntities(SMESH::EDGE); + int aNbFaces = aVisualObj->GetNbEntities(SMESH::FACE); + int aNbVolumes = aVisualObj->GetNbEntities(SMESH::VOLUME); + QMenuItem* mi = popup->findItem( 1131 ); + if ( mi && mi->popup() ) { + int prType = ac->GetRepresentation(); + // Display Mode / Wireframe + if(!aNbFaces && !aNbVolumes && !aNbEdges){ + mi->popup()->removeItem( 211 ); + }else{ + mi->popup()->setItemChecked( 211, prType == SMESH_Actor::eEdge ); + } + // Display Mode / Shading + if(!aNbFaces && !aNbVolumes){ + mi->popup()->removeItem( 212 ); + }else{ + mi->popup()->setItemChecked( 212, prType == SMESH_Actor::eSurface ); + } + // Display Mode / Points + mi->popup()->setItemChecked( 215, prType == SMESH_Actor::ePoint ); + // Display Mode / Shrink + bool isShrunk = ac->IsShrunk(); + bool isShrunkable = ac->IsShrunkable(); + mi->popup()->setItemChecked( 213, isShrunk ); + mi->popup()->setItemEnabled( 213, prType != SMESH_Actor::ePoint && isShrunkable); + } + // Scalar Bar + mi = popup->findItem( 2000 ); + if ( mi && mi->popup() ) { + SMESH_Actor::eControl cMode = ac->GetControlMode(); + switch ( cMode ) { + case SMESH_Actor::eLengthEdges: + mi->popup()->setItemChecked( 6001, true ); break; + case SMESH_Actor::eFreeEdges: + mi->popup()->setItemChecked( 6002, true ); + mi->popup()->removeItem( 201 ); + break; + case SMESH_Actor::eFreeBorders: + mi->popup()->setItemChecked( 6003, true ); + mi->popup()->removeItem( 201 ); + break; + case SMESH_Actor::eMultiConnection: + mi->popup()->setItemChecked( 6004, true ); break; + case SMESH_Actor::eArea: + mi->popup()->setItemChecked( 6011, true ); break; + case SMESH_Actor::eTaper: + mi->popup()->setItemChecked( 6012, true ); break; + case SMESH_Actor::eAspectRatio: + mi->popup()->setItemChecked( 6013, true ); break; + case SMESH_Actor::eMinimumAngle: + mi->popup()->setItemChecked( 6014, true ); break; + case SMESH_Actor::eWarping: + mi->popup()->setItemChecked( 6015, true ); break; + case SMESH_Actor::eSkew: + mi->popup()->setItemChecked( 6016, true ); break; + case SMESH_Actor::eNone: + default: + mi->popup()->removeItem( 200 ); + mi->popup()->removeItem( 201 ); + break; + } + TVisualObjPtr aVisualObj = ac->GetObject(); + if(!aNbEdges){ + mi->popup()->removeItem( 6001 ); + mi->popup()->removeItem( 6003 ); + mi->popup()->removeItem( 6004 ); + } + if(!aNbFaces){ + mi->popup()->removeItem( 6002 ); + mi->popup()->removeItem( 6011 ); + mi->popup()->removeItem( 6012 ); + mi->popup()->removeItem( 6013 ); + mi->popup()->removeItem( 6014 ); + mi->popup()->removeItem( 6015 ); + mi->popup()->removeItem( 6016 ); + } + if(!aNbFaces && !aNbEdges) + popup->removeItem( 2000 ); // Scalar Bar + } + } + else { + popup->removeItem( QAD_Erase_Popup_ID ); + popup->removeItem( 114 ); // Numbering popup menu + popup->removeItem( 1131 ); // Display mode + popup->removeItem( 1132 ); // Color / size + popup->removeItem( 1133 ); // Transparency + popup->removeItem( 1134 ); // Clipping + popup->removeItem( 2000 ); // Scalar Bar + } + } + else { + // object doesn't have actor + CORBA::Object_var anObject = SO->GetObject(); + bool bDisplay = false; + if ( !CORBA::is_nil( anObject ) ) { + SMESH::SMESH_Mesh_var aMeshObj = SMESH::SMESH_Mesh::_narrow( anObject ); + if ( !aMeshObj->_is_nil() && ( aMeshObj->NbNodes() > 0 || aMeshObj->NbFaces() > 0 || aMeshObj->NbVolumes() > 0 ) ) + bDisplay = true; + SMESH::SMESH_subMesh_var aSubMeshObj = SMESH::SMESH_subMesh::_narrow( anObject ); + if ( !aSubMeshObj->_is_nil() && ( aSubMeshObj->GetNumberOfNodes(false) > 0 || aSubMeshObj->GetNumberOfElements() > 0 ) ) + bDisplay = true; + SMESH::SMESH_GroupBase_var aGroupObj = SMESH::SMESH_GroupBase::_narrow( anObject ); + if ( !aGroupObj->_is_nil() && aGroupObj->Size() > 0 ) + bDisplay = true; + } + if ( !bDisplay ) { + popup->removeItem( QAD_Display_Popup_ID ); + popup->removeItem( QAD_DisplayOnly_Popup_ID ); + } + popup->removeItem( QAD_Erase_Popup_ID ); + popup->removeItem( 114 ); // Numbering popup menu + popup->removeItem( 1131 ); // Display mode + popup->removeItem( 1132 ); // Color / size + popup->removeItem( 1133 ); // Transparency + popup->removeItem( 1134 ); // Clipping + popup->removeItem( 2000 ); // Scalar Bar } } + else if( theObject!="Component" ) { + // another SMESH object + popup->removeItem( QAD_Display_Popup_ID ); + popup->removeItem( QAD_DisplayOnly_Popup_ID ); + popup->removeItem( QAD_Erase_Popup_ID ); + } } - }catch(SALOME::SALOME_Exception& exc) { - INFOS("Follow exception was cought:\n\t"<GetID(); - if(SMESH_Actor* anActor = ::FindActorByEntry(anEntry.in())){ - SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor(); - aMeshEditor->AddNode(x, y, z); - if(myAutomaticUpdate){ - CORBA::Long anId = smeshGUI->myStudy->StudyId(); - if(TVisualObjPtr aVisualObj = GetVisualObj(anId,anEntry.in())){ - aVisualObj->Update(true); + else { + // multiple selection + if ( parentComp != parent->getActiveComponent() ) { + // object not belongs to SMESH module - remove all commands except common Display/Erase... + while ( 1 ) { + int id = popup->idAt( 0 ); + if ( id <= QAD_TopLabel_Popup_ID ) + popup->removeItemAt( 0 ); + else + break; + } + if ( parentComp.isNull() ) { + // objects from different components are selected + popup->removeItem( QAD_DisplayOnly_Popup_ID ); + popup->removeItem( QAD_Display_Popup_ID ); + popup->removeItem( QAD_Erase_Popup_ID ); + } + } + else { + QString type = ::CheckHomogeneousSelection(); + if ( type != "Heterogeneous Selection" ) { + int topItem = popup->indexOf( QAD_TopLabel_Popup_ID ); + if ( topItem >= 0 ) { + // set bold font for popup menu's TopLabel item + QFont fnt = QApplication::font(); fnt.setBold( TRUE ); + popup->removeItem( QAD_TopLabel_Popup_ID ); + popup->insertItem( new CustomItem( QString("%1 ").arg( nbSel ) + type + "(s) ", fnt ), QAD_TopLabel_Popup_ID, topItem ); } } } - }catch(SALOME::SALOME_Exception& exc) { - INFOS("Follow exception was cought:\n\t"< exists in the active VTK view */ //============================================================================= -void SMESHGUI::DisplayEdgesConnectivityLegendBox(vtkActor * ac) +void SMESHGUI::BuildPresentation( const Handle(SALOME_InteractiveObject) & theIO, + QAD_ViewFrame* ) { - if (myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) - return; - - EraseSimulationActors(); - mySimulationActors2D = vtkActor2DCollection::New(); - - vtkRenderer *theRenderer = - ((VTKViewer_ViewFrame *) myActiveStudy->getActiveStudyFrame()-> - getRightFrame()->getViewFrame())->getRenderer(); - - vtkGlyphSource2D *gs2 = vtkGlyphSource2D::New(); - gs2->SetGlyphTypeToTriangle(); - gs2->FilledOff(); - - vtkLegendBoxActor *legend = vtkLegendBoxActor::New(); - legend->GetPositionCoordinate()->SetValue(0.025, 0.025, 0.); - legend->GetPosition2Coordinate()->SetValue(0.3, 0.3, 0.); //relative to Position - - legend->SetNumberOfEntries(4); - legend->SetEntryString(0, tr("SMESH_BOUNDARYEDGES")); - legend->SetEntrySymbol(0, gs2->GetOutput()); - legend->SetEntryColor(0, ac->GetMapper()->GetLookupTable()->GetColor(0.)); - legend->SetEntryString(1, tr("SMESH_MANIFOLDEDGES")); - legend->SetEntrySymbol(1, gs2->GetOutput()); - legend->SetEntryColor(1, - ac->GetMapper()->GetLookupTable()->GetColor(0.666667)); - legend->SetEntryString(2, tr("SMESH_NONMANIFOLDEDGES")); - legend->SetEntrySymbol(2, gs2->GetOutput()); - legend->SetEntryColor(2, - ac->GetMapper()->GetLookupTable()->GetColor(0.222222)); - legend->SetEntryString(3, tr("SMESH_FEATUREEDGES")); - legend->SetEntrySymbol(3, gs2->GetOutput()); - legend->SetEntryColor(3, - ac->GetMapper()->GetLookupTable()->GetColor(0.444444)); - legend->SetPadding(5); - // legend->GetProperty()->SetColor(); - - mySimulationActors2D->AddItem(legend); - theRenderer->AddActor2D(legend); - - // Update the view - myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()-> - Repaint(); + if(theIO->hasEntry()){ + QAD_Study* aStudy = SMESHGUI::GetSMESHGUI()->GetActiveStudy(); + QAD_StudyFrame *aStudyFrame = aStudy->getActiveStudyFrame(); + SMESH::UpdateView(aStudyFrame,SMESH::eDisplay,theIO->getEntry()); + } } -//=============================================================================== -// function : OnEditDelete() -// purpose : -//=============================================================================== -void SMESHGUI::OnEditDelete() +void SMESHGUI::SupportedViewType(int *buffer, int bufferSize) { - if (QAD_MessageBox::warn2 - (QAD_Application::getDesktop(), - tr("SMESH_WRN_WARNING"), - tr("SMESH_REALLY_DELETE"), - tr("SMESH_BUT_YES"), tr("SMESH_BUT_NO"), 1, 0, 0) != 1) + if (!buffer || !bufferSize) return; - - int nbSf = myActiveStudy->getStudyFramesCount(); - - Standard_Boolean found; - SALOMEDS::Study_var aStudy = myActiveStudy->getStudyDocument(); - SALOMEDS::StudyBuilder_var aStudyBuilder = myStudy->NewBuilder(); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - - SALOME_Selection *Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - for(; It.More(); It.Next()){ - Handle(SALOME_InteractiveObject) IObject = It.Value(); - if(IObject->hasEntry()){ - SALOMEDS::SObject_var SO = myStudy->FindObjectID(IObject->getEntry()); - - /* Erase child graphical objects */ - SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(SO); - for(; it->More(); it->Next()){ - SALOMEDS::SObject_var CSO = it->Value(); - if(CSO->FindAttribute(anAttr, "AttributeIOR")){ - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - - for(int i = 0; i < nbSf; i++){ - QAD_StudyFrame *sf = myActiveStudy->getStudyFrame(i); - CORBA::String_var anEntry = CSO->GetID(); - if(SMESH_Actor* anActor = ::FindActorByEntry(sf,anEntry.in())){ - RemoveActor(sf,anActor); - } - } - } - } - - /* Erase main graphical object */ - for(int i = 0; i < nbSf; i++){ - QAD_StudyFrame *sf = myActiveStudy->getStudyFrame(i); - if(SMESH_Actor* anActor = ::FindActorByEntry(sf,IObject->getEntry())){ - RemoveActor(sf,anActor); - } - } - - // Remove object(s) from data structures - SALOMEDS::SObject_var obj = myStudy->FindObjectID(IObject->getEntry()); - if(!obj->_is_nil()){ - SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group ::_narrow(obj->GetObject()); - SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(obj->GetObject()); - - if ( !aGroup->_is_nil() ) { // DELETE GROUP - SMESH::SMESH_Mesh_var aMesh = aGroup->GetMesh(); - aMesh->RemoveGroup( aGroup ); - } - else if ( !aSubMesh->_is_nil() ) { // DELETE SUBMESH - SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather(); - aMesh->RemoveSubMesh( aSubMesh ); - } - else {// default action: remove SObject from the study - // san - it's no use opening a transaction here until UNDO/REDO is provided in SMESH - //QAD_Operation *op = new SALOMEGUI_ImportOperation(myActiveStudy); - //op->start(); - aStudyBuilder->RemoveObjectWithChildren( obj ); - //op->finish(); - } - } - - } /* IObject->hasEntry() */ - } /* more/next */ - - /* Clear any previous selection */ - Sel->ClearIObjects(); - myActiveStudy->updateObjBrowser(); + buffer[0] = (int)VIEW_VTK; } -//======================================================================= -// name : SMESHGUI::GetFilterMgr -// Purpose : Get filter manager -//======================================================================= -SMESH::FilterManager_ptr SMESHGUI::GetFilterMgr() +void SMESHGUI::Deactivate() { - return myFilterMgr; + if ( SMESHGUI::GetSMESHGUI() ) { + SMESHGUI::GetSMESHGUI()->EmitSignalCloseAllDialogs(); + } } diff --git a/src/SMESHGUI/SMESHGUI.h b/src/SMESHGUI/SMESHGUI.h index 4c17a2cb6..4905f783f 100644 --- a/src/SMESHGUI/SMESHGUI.h +++ b/src/SMESHGUI/SMESHGUI.h @@ -29,41 +29,15 @@ #ifndef SMESHGUI_HeaderFile #define SMESHGUI_HeaderFile -#include "TColStd_MapOfInteger.hxx" -#include - -#include "SMESHDS_Document.hxx" - // SALOME Includes #include "SALOMEGUI.h" -#include "QAD_Desktop.h" -#include "SALOME_Selection.h" #include "SALOME_InteractiveObject.hxx" -#include "SMESHGUI_StudyAPI.h" -#include "SMESHGUI_Hypotheses.h" - -// IDL Headers -#include -#include CORBA_SERVER_HEADER(SMESH_Gen) -#include CORBA_SERVER_HEADER(SMESH_Mesh) -#include CORBA_SERVER_HEADER(SMESH_Group) -#include CORBA_SERVER_HEADER(SMESH_Hypothesis) -#include CORBA_SERVER_HEADER(GEOM_Gen) -#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) -#include CORBA_SERVER_HEADER(SMESH_Filter) - -// QT Includes -#include +class QAD_Desktop; +class QAD_Study; -// VTK Inlcludes +class QDialog; -class vtkActorCollection; -class vtkActor2DCollection; -class vtkScalarBarActor; -class vtkActor; - -class SMESH_Actor; //================================================================================= // class : SMESHGUI @@ -71,63 +45,32 @@ class SMESH_Actor; //================================================================================= class SMESHGUI : public SALOMEGUI { - Q_OBJECT + Q_OBJECT; private : - - QAD_Desktop* myDesktop; - QAD_Study* myActiveStudy; - SMESH::SMESH_Gen_var myComponentMesh; - GEOM::GEOM_Gen_var myComponentGeom; - - QDialog* myActiveDialogBox; - int myNbMesh ; - int myState ; - - vtkActorCollection* mySimulationActors; - vtkActor2DCollection* mySimulationActors2D; - - SMESH_Actor* myCurrentMesh; + QAD_Desktop* myDesktop; + QAD_Study* myActiveStudy; + QDialog* myActiveDialogBox; - SALOMEDS::Study_var myStudy; - int myStudyId; - - SMESHGUI_StudyAPI myStudyAPI; - - // vtkScalarBarActor* myScalarBar; - - SMESHDS_Document * myDocument;//NBU - - bool myAutomaticUpdate; - - SMESH::FilterManager_var myFilterMgr; - - // Hypotheses/algorithms from plugin libraries - map myHypothesesMap; - map myAlgorithmsMap; - map myHypCreatorMap; + int myState; + bool myAutomaticUpdate; public : - SMESHGUI( const QString& name = "", QObject* parent = 0 ); - ~SMESHGUI(); - - static SMESHGUI* GetOrCreateSMESHGUI( QAD_Desktop* desktop ); static SMESHGUI* GetSMESHGUI() ; + ~SMESHGUI(); - QAD_Study* GetActiveStudy() ; QAD_Desktop* GetDesktop() ; - SALOMEDS::Study_ptr GetStudy(); - SMESHGUI_StudyAPI GetStudyAPI(); + QAD_Study* GetActiveStudy() ; + bool ActiveStudyLocked(); QDialog* GetActiveDialogBox() ; void SetActiveDialogBox(QDialog* aDlg) ; - void SetState(int aState) ; void ResetState() ; + void SetState(int aState) ; bool DefineDlgPosition(QWidget* aDlg, int& x, int& y) ; - virtual bool OnGUIEvent (int theCommandID, QAD_Desktop* parent); virtual bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame); virtual bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame); @@ -137,163 +80,22 @@ public : virtual void DefinePopup ( QString & theContext, QString & theParent, QString & theObject ); virtual bool CustomPopup ( QAD_Desktop* parent, QPopupMenu* popup, const QString & theContext, const QString & theParent, const QString & theObject ); - virtual void BuildPresentation ( const Handle(SALOME_InteractiveObject)& theIO ); + virtual void BuildPresentation ( const Handle(SALOME_InteractiveObject)& theIO, + QAD_ViewFrame* = 0 ); virtual void SupportedViewType (int* buffer, int bufferSize); virtual void Deactivate (); - void OnEditDelete(); - - /* Mesh Management */ - SMESH::SMESH_Mesh_ptr InitMesh( GEOM::GEOM_Shape_ptr aShape, QString NameMesh ); - SMESH::SMESH_subMesh_ptr AddSubMesh( SMESH::SMESH_Mesh_ptr aMesh, GEOM::GEOM_Shape_ptr aShape, QString NameMesh ); - SMESH::SMESH_Group_ptr AddGroup( SMESH::SMESH_Mesh_ptr aMesh, SMESH::ElementType aType, QString aName ); - - /* Hypotheses and Algorithms Management */ - void InitAvailableHypotheses (); - QStringList GetAvailableHypotheses (const bool isAlgo); - HypothesisData* GetHypothesisData (const char* aHypType); - SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator (const QString& aHypType); - - SMESH::SMESH_Hypothesis_ptr CreateHypothesis (const QString& aHypType, - const QString& aHypName, - const bool isAlgo = false); - - bool AddHypothesisOnMesh (SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp); - bool AddAlgorithmOnMesh (SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp); - - bool AddHypothesisOnSubMesh (SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp); - bool AddAlgorithmOnSubMesh (SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp); - - bool RemoveHypothesisOrAlgorithmOnMesh (const Handle(SALOME_InteractiveObject)& IObject); - bool RemoveHypothesisOrAlgorithmOnMesh (SALOMEDS::SObject_ptr MorSM, - SMESH::SMESH_Hypothesis_ptr anHyp); - - void SetPickable(SMESH_Actor* theActor = NULL); - - /* NODES */ - void ViewNodes(); - vtkActor* SimulationMoveNode(SMESH_Actor* Mactor, int idnode); - void MoveNode( SMESH::SMESH_Mesh_ptr aMesh, int idnode, float x, float y, float z); - - void DisplaySimulationNode( SMESH::SMESH_Mesh_ptr aMesh, float x, float y, float z); - void DisplaySimulationMoveNode( vtkActor* ac, int idnode, float x, float y, float z); - - void RemoveNodes(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex) ; - - /* EDGES */ - void DisplayEdges(SMESH_Actor* ac, bool visibility = true); - void DisplayEdgesConnectivityLegendBox(vtkActor *ac); - void DisplaySimulationEdge( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex ); - - /* TRIANGLES */ - void DisplaySimulationTriangle( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse ); - - /* QUADRANGLES */ - void DisplaySimulationQuadrangle( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse ); - - /* VOLUMES */ - void DisplaySimulationTetra( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex ); - void DisplaySimulationHexa( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex ); - - /* ELEMENTS */ - void RemoveElements(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex) ; - void OrientationElements(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex); - void DiagonalInversion(SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex); - - void AddFace( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex, bool reverse ); - void AddEdge( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex ); - void AddVolume( SMESH::SMESH_Mesh_ptr aMesh, const TColStd_MapOfInteger& MapIndex ); - void AddNode( SMESH::SMESH_Mesh_ptr aMesh, float x, float y, float z); - - /* Simulation management */ - void EraseSimulationActors() ; - /* Non modal dialog boxes magement */ void EmitSignalDeactivateDialog() ; + void EmitSignalStudyFrameChanged() ; void EmitSignalCloseAllDialogs() ; - /* Selection management */ - int GetNameOfSelectedIObjects( SALOME_Selection* Sel, QString& aName ) ; - int GetNameOfSelectedNodes( SALOME_Selection* Sel, QString& aName ) ; - int GetNameOfSelectedElements( SALOME_Selection* Sel, QString& aName ) ; - int GetNameOfSelectedEdges( SALOME_Selection* Sel, QString& aName ) ; - - SMESH::SMESH_Hypothesis_ptr ConvertIOinSMESHHypothesis( const Handle(SALOME_InteractiveObject)& IO, - Standard_Boolean& testResult ) ; - - SMESH::SMESH_Mesh_ptr ConvertIOinMesh(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) ; - SMESH::SMESH_subMesh_ptr ConvertIOinSubMesh(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) ; - SMESH::SMESH_Group_ptr ConvertIOinSMESHGroup(const Handle(SALOME_InteractiveObject)& IO, Standard_Boolean& testResult) ; - - /* Geometry Client */ - GEOM::GEOM_Shape_ptr ConvertIOinGEOMShape( const Handle(SALOME_InteractiveObject)& IO, - Standard_Boolean& testResult ) ; - - /* Popup management */ - QString CheckTypeObject(const Handle(SALOME_InteractiveObject)& IO); - QString CheckHomogeneousSelection(); - - /* Scripts management */ - SMESH_Actor* ReadScript(SMESH::SMESH_Mesh_ptr aMesh); - - /* Actors management */ - void Dump(SMESH_Actor* Mactor); - - void SetViewMode(int commandId); - void ChangeRepresentation( SMESH_Actor* ac, int type ); - - SMESH_Actor* FindActor(CORBA::Object_ptr theObj, - Standard_Boolean& testResult, - bool onlyInActiveView); - SMESH_Actor* FindActorByEntry(QString entry, - Standard_Boolean& testResult, - bool onlyInActiveView); - - void InitActor(SMESH::SMESH_Mesh_ptr aMesh); - void DisplayActor(SMESH_Actor* ac, bool visibility = true); - void EraseActor(SMESH_Actor* ac); - bool AddActorInSelection(SMESH_Actor* ac); - - void UpdateView(); - - void Update(); - void Update(const Handle(SALOME_InteractiveObject)& IO); - - void ScalarVisibilityOff(); - - - /* Settings management */ - void SetSettingsScalarBar(vtkScalarBarActor* theScalarBar, - QString Bold, QString Italic, QString Shadow, QString Font, - QString Orientation, float Width, float Height, - int NbColors, int NbLabels); - void SetDisplaySettings(); - - SALOMEDS::Study::ListOfSObject* GetMeshesUsingAlgoOrHypothesis( SMESH::SMESH_Hypothesis_ptr AlgoOrHyp ) ; - - /* Control management */ - void Control(int theCommandID); - - /* Parameter functions */ - double Parameter( Standard_Boolean& res, const double aValue, - const char* aLabel, const char* aTitle, - const double bottom, const double top, const int decimals ) ; - int Parameter( Standard_Boolean& res, const int aValue, - const char* aLabel, const char* aTitle, - const int bottom, const int top ) ; - - static void setOrb(); - - /* Import/Export */ //NBU - static void Import_Mesh(QAD_Desktop* parent, int theCommandID); - static void Export_Mesh(QAD_Desktop* parent, int theCommandID); - - /* Filter manager */ - SMESH::FilterManager_ptr GetFilterMgr(); - signals: void SignalDeactivateActiveDialog() ; + void SignalStudyFrameChanged() ; void SignalCloseAllDialogs() ; + }; + #endif diff --git a/src/SMESHGUI/SMESHGUI_AddAlgorithmDlg.cxx b/src/SMESHGUI/SMESHGUI_AddAlgorithmDlg.cxx deleted file mode 100644 index 634e437d7..000000000 --- a/src/SMESHGUI/SMESHGUI_AddAlgorithmDlg.cxx +++ /dev/null @@ -1,466 +0,0 @@ -// SMESH SMESHGUI : GUI for SMESH component -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMESHGUI_AddAlgorithmDlg.cxx -// Author : Nicolas REJNERI -// Module : SMESH -// $Header$ - -using namespace std; -#include "SMESHGUI_AddAlgorithmDlg.h" -#include "SALOME_ListIteratorOfListIO.hxx" - -#include "SMESHGUI.h" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "utilities.h" - -// QT Includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -//================================================================================= -// class : SMESHGUI_AddAlgorithmDlg() -// purpose : Constructs a SMESHGUI_AddAlgorithmDlg which is a child of 'parent', with the -// name 'name' and widget flags set to 'f'. -// The dialog will by default be modeless, unless you set 'modal' to -// TRUE to construct a modal dialog. -//================================================================================= -SMESHGUI_AddAlgorithmDlg::SMESHGUI_AddAlgorithmDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) -{ - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_ADD_ALGORITHM"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); - - if ( !name ) - setName( "SMESHGUI_AddAlgorithmDlg" ); - resize( 322, 220 ); - setCaption( tr( "SMESH_ADD_ALGORITHM_TITLE" ) ); - setSizeGripEnabled( TRUE ); - - SMESHGUI_AddAlgorithmDlgLayout = new QGridLayout( this ); - SMESHGUI_AddAlgorithmDlgLayout->setSpacing( 6 ); - SMESHGUI_AddAlgorithmDlgLayout->setMargin( 11 ); - - /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( tr( "SMESH_ADD_ALGORITHM" ) ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer, 0, 1 ); - Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); - Constructor1->setText( tr( "" ) ); - Constructor1->setPixmap( image0 ); - Constructor1->setChecked( TRUE ); - Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); - GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); - SMESHGUI_AddAlgorithmDlgLayout->addWidget( GroupConstructors, 0, 0 ); - - /***************************************************************/ - GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" ); - GroupConstructor1->setTitle( tr( "SMESH_ARGUMENTS" ) ); - GroupConstructor1->setColumnLayout(0, Qt::Vertical ); - GroupConstructor1->layout()->setSpacing( 0 ); - GroupConstructor1->layout()->setMargin( 0 ); - GroupConstructor1Layout = new QGridLayout( GroupConstructor1->layout() ); - GroupConstructor1Layout->setAlignment( Qt::AlignTop ); - GroupConstructor1Layout->setSpacing( 6 ); - GroupConstructor1Layout->setMargin( 11 ); - LineEditC1A2Mesh = new QLineEdit( GroupConstructor1, "LineEditC1A2Mesh" ); - LineEditC1A2Mesh->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2Mesh->sizePolicy().hasHeightForWidth() ) ); - GroupConstructor1Layout->addWidget( LineEditC1A2Mesh, 1, 2 ); - LineEditC1A1Hyp = new QLineEdit( GroupConstructor1, "LineEditC1A1Hyp" ); - LineEditC1A1Hyp->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Hyp->sizePolicy().hasHeightForWidth() ) ); - GroupConstructor1Layout->addWidget( LineEditC1A1Hyp, 0, 2 ); - SelectButtonC1A1Hyp = new QPushButton( GroupConstructor1, "SelectButtonC1A1Hyp" ); - SelectButtonC1A1Hyp->setText( tr( "" ) ); - SelectButtonC1A1Hyp->setPixmap( image1 ); - GroupConstructor1Layout->addWidget( SelectButtonC1A1Hyp, 0, 1 ); - SelectButtonC1A2Mesh = new QPushButton( GroupConstructor1, "SelectButtonC1A2Mesh" ); - SelectButtonC1A2Mesh->setText( tr( "" ) ); - SelectButtonC1A2Mesh->setPixmap( image1 ); - GroupConstructor1Layout->addWidget( SelectButtonC1A2Mesh, 1, 1 ); - TextLabelC1A2Mesh = new QLabel( GroupConstructor1, "TextLabelC1A2Mesh" ); - TextLabelC1A2Mesh->setText( tr( "SMESH_OBJECT_MESHorSUBMESH" ) ); - TextLabelC1A2Mesh->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A2Mesh->setFrameShape( QLabel::NoFrame ); - TextLabelC1A2Mesh->setFrameShadow( QLabel::Plain ); - GroupConstructor1Layout->addWidget( TextLabelC1A2Mesh, 1, 0 ); - TextLabelC1A1Hyp = new QLabel( GroupConstructor1, "TextLabelC1A1Hyp" ); - TextLabelC1A1Hyp->setText( tr( "SMESH_OBJECT_ALGORITHM" ) ); - TextLabelC1A1Hyp->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A1Hyp->setFrameShape( QLabel::NoFrame ); - TextLabelC1A1Hyp->setFrameShadow( QLabel::Plain ); - GroupConstructor1Layout->addWidget( TextLabelC1A1Hyp, 0, 0 ); - SMESHGUI_AddAlgorithmDlgLayout->addWidget( GroupConstructor1, 1, 0 ); - - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_1 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_1, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - SMESHGUI_AddAlgorithmDlgLayout->addWidget( GroupButtons, 2, 0 ); - - /* Initialisation */ - Init( Sel ) ; -} - - -//================================================================================= -// function : ~SMESHGUI_AddAlgorithmDlg() -// purpose : Destroys the object and frees any allocated resources -//================================================================================= -SMESHGUI_AddAlgorithmDlg::~SMESHGUI_AddAlgorithmDlg() -{ - /* no need to delete child widgets, Qt does it all for us */ - this->destroy(TRUE, TRUE) ; -} - - - -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void SMESHGUI_AddAlgorithmDlg::Init( SALOME_Selection* Sel ) -{ - mySelection = Sel ; - myConstructorId = 0 ; - - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - - GroupConstructor1->show(); - myConstructorId = 0 ; - myEditCurrentArgument = LineEditC1A1Hyp ; - Constructor1->setChecked( TRUE ); - myOkMesh = myOkSubMesh = myOkAlgorithm = false ; - - myAlgorithmFilter = new SMESH_TypeFilter( ALGORITHM ); - myMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); - - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; - - /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); - connect( SelectButtonC1A1Hyp, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectButtonC1A2Mesh, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - /* to close dialog if study change */ - connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - - /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* Displays Dialog */ - - return ; -} - - - -//================================================================================= -// function : ConstructorsClicked() -// purpose : Radio button management -//================================================================================= -void SMESHGUI_AddAlgorithmDlg::ConstructorsClicked(int constructorId) -{ - switch (constructorId) - { - case 0: - { - GroupConstructor1->show(); - myConstructorId = constructorId ; - myEditCurrentArgument = LineEditC1A1Hyp ; - LineEditC1A2Mesh->setText(tr("")) ; - Constructor1->setChecked( TRUE ); - myOkMesh = myOkSubMesh = myOkAlgorithm = false ; - break; - } - } - return ; -} - -//================================================================================= -// function : ClickOnOk() -// purpose : -//================================================================================= -void SMESHGUI_AddAlgorithmDlg::ClickOnOk() -{ - this->ClickOnApply() ; - this->ClickOnCancel() ; - - return ; -} - -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -void SMESHGUI_AddAlgorithmDlg::ClickOnApply() -{ - switch(myConstructorId) - { - case 0 : - { - if(myOkMesh && myOkAlgorithm ) { - SALOME_ListIteratorOfListIO It( AlgoList ); - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - Standard_Boolean testResult; - myAlgorithm = mySMESHGUI->ConvertIOinSMESHHypothesis(IObject, testResult) ; - if( testResult ) - mySMESHGUI->AddAlgorithmOnMesh(myMesh, myAlgorithm) ; - } - } else if ( myOkSubMesh && myOkAlgorithm ) { - SALOME_ListIteratorOfListIO It( AlgoList ); - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - Standard_Boolean testResult; - myAlgorithm = mySMESHGUI->ConvertIOinSMESHHypothesis(IObject, testResult) ; - if( testResult ) - mySMESHGUI->AddAlgorithmOnSubMesh(mySubMesh, myAlgorithm) ; - } - } - break ; - } - } -} - -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void SMESHGUI_AddAlgorithmDlg::ClickOnCancel() -{ - mySelection->ClearFilters() ; - disconnect( mySelection, 0, this, 0 ); - mySMESHGUI->ResetState() ; - reject() ; - return ; -} - - - -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection has changed -//================================================================================= -void SMESHGUI_AddAlgorithmDlg::SelectionIntoArgument() -{ - myEditCurrentArgument->setText("") ; - QString aString = ""; - - int nbSel = mySMESHGUI->GetNameOfSelectedIObjects(mySelection, aString) ; - - if ( myEditCurrentArgument == LineEditC1A2Mesh ) { - if ( nbSel == 1 ) { - Handle(SALOME_InteractiveObject) IObject = mySelection->firstIObject(); - QString aName = IObject->getName(); - Standard_Boolean testResult; - myOkMesh = true ; - myMesh = mySMESHGUI->ConvertIOinMesh(IObject, testResult) ; - if( !testResult ) { - myOkMesh = false; - myOkSubMesh = true; - mySubMesh = mySMESHGUI->ConvertIOinSubMesh(IObject, testResult) ; - if( !testResult ) { - myOkSubMesh = false; - return ; - } - } - LineEditC1A2Mesh->setText(aString) ; - } - else { - myOkMesh = myOkSubMesh = false ; - return ; - } - } - else if ( myEditCurrentArgument == LineEditC1A1Hyp ) { - if ( nbSel >= 1 ) { - AlgoList.Clear(); // = mySelection->StoredIObjects() ; - SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() ); - for (; Itinit.More(); Itinit.Next()) { - AlgoList.Append(Itinit.Value()); - } - myOkAlgorithm = true ; - if (nbSel > 1) - aString = tr("%1 Algorithms").arg(nbSel) ; - LineEditC1A1Hyp->setText(aString) ; - } - else { - myOkAlgorithm = false ; - return ; - } - } - - return ; -} - - -//================================================================================= -// function : SetEditCurrentArgument() -// purpose : -//================================================================================= -void SMESHGUI_AddAlgorithmDlg::SetEditCurrentArgument() -{ - QPushButton* send = (QPushButton*)sender(); - - switch (myConstructorId) - { - case 0: /* default constructor */ - { - if( send == SelectButtonC1A1Hyp ) { - LineEditC1A1Hyp->setFocus() ; - myEditCurrentArgument = LineEditC1A1Hyp ; - mySelection->ClearFilters() ; - mySelection->AddFilter(myAlgorithmFilter) ; - } - else if(send == SelectButtonC1A2Mesh) { - LineEditC1A2Mesh->setFocus() ; - myEditCurrentArgument = LineEditC1A2Mesh; - mySelection->ClearFilters() ; - mySelection->AddFilter(myMeshOrSubMeshFilter) ; - } - SelectionIntoArgument() ; - break; - } - } - return ; -} - - - -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void SMESHGUI_AddAlgorithmDlg::LineEditReturnPressed() -{ - - return ; -} - - - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void SMESHGUI_AddAlgorithmDlg::DeactivateActiveDialog() -{ - if ( GroupConstructors->isEnabled() ) { - - GroupConstructors->setEnabled(false) ; - GroupConstructor1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - disconnect( mySelection, 0, this, 0 ); - } - return ; -} - - - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void SMESHGUI_AddAlgorithmDlg::closeEvent( QCloseEvent* e ) -{ - this->ClickOnCancel() ; /* same than click on cancel button */ -} - - -//================================================================================= -// function : enterEvent() -// purpose : when mouse enter onto the QWidget -//================================================================================= -void SMESHGUI_AddAlgorithmDlg::enterEvent( QEvent * ) -{ - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; -} - - - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void SMESHGUI_AddAlgorithmDlg::ActivateThisDialog() -{ - /* Emit a signal to deactivate any active dialog */ - mySMESHGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupConstructor1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - - connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - return ; -} diff --git a/src/SMESHGUI/SMESHGUI_AddAlgorithmDlg.h b/src/SMESHGUI/SMESHGUI_AddAlgorithmDlg.h deleted file mode 100644 index 785703010..000000000 --- a/src/SMESHGUI/SMESHGUI_AddAlgorithmDlg.h +++ /dev/null @@ -1,130 +0,0 @@ -// SMESH SMESHGUI : GUI for SMESH component -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMESHGUI_AddAlgorithmDlg.h -// Author : Nicolas REJNERI -// Module : SMESH -// $Header$ - -#ifndef DIALOGBOX_ADD_ALGORITHM_H -#define DIALOGBOX_ADD_ALGORITHM_H - -#include "SALOME_Selection.h" -#include "SMESH_TypeFilter.hxx" -#include "SALOME_ListIO.hxx" - -// IDL Headers -#include -#include CORBA_SERVER_HEADER(SMESH_Gen) - -// QT Includes -#include -#include - -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QButtonGroup; -class QFrame; -class QGroupBox; -class QLabel; -class QLineEdit; -class QPushButton; -class QRadioButton; -class SMESHGUI; - - -//================================================================================= -// class : SMESHGUI_AddAlgorithmDlg -// purpose : -//================================================================================= -class SMESHGUI_AddAlgorithmDlg : public QDialog -{ - Q_OBJECT - -public: - SMESHGUI_AddAlgorithmDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); - ~SMESHGUI_AddAlgorithmDlg(); - -private: - - void Init( SALOME_Selection* Sel ) ; - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ - - SMESH::SMESH_Gen_var myCompMesh ; - SMESHGUI* mySMESHGUI ; - SALOME_Selection* mySelection ; - - SMESH::SMESH_Mesh_var myMesh; - SMESH::SMESH_subMesh_var mySubMesh; - SMESH::SMESH_Hypothesis_var myAlgorithm; - - Handle(SMESH_TypeFilter) myAlgorithmFilter; - Handle(SMESH_TypeFilter) myMeshOrSubMeshFilter; - - bool myOkMesh ; - bool myOkSubMesh ; - bool myOkAlgorithm; - - int myConstructorId ; /* Current constructor id = radio button id */ - QLineEdit* myEditCurrentArgument; /* Current LineEdit */ - - SALOME_ListIO AlgoList; - - QButtonGroup* GroupConstructors; - QRadioButton* Constructor1; - - QGroupBox* GroupConstructor1; - QLineEdit* LineEditC1A1Hyp; - QLineEdit* LineEditC1A2Mesh; - QPushButton* SelectButtonC1A1Hyp; - QPushButton* SelectButtonC1A2Mesh; - QLabel* TextLabelC1A2Mesh; - QLabel* TextLabelC1A1Hyp; - - QGroupBox* GroupButtons; - QPushButton* buttonApply; - QPushButton* buttonOk; - QPushButton* buttonCancel; - -private slots: - - void ConstructorsClicked(int constructorId); - void ClickOnOk(); - void ClickOnCancel(); - void ClickOnApply(); - void SetEditCurrentArgument() ; - void SelectionIntoArgument() ; - void LineEditReturnPressed() ; - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; - -protected: - QGridLayout* SMESHGUI_AddAlgorithmDlgLayout; - QGridLayout* GroupConstructorsLayout; - QGridLayout* GroupButtonsLayout; - QGridLayout* GroupConstructor1Layout; -}; - -#endif // DIALOGBOX_ADD_ALGORITHM_H diff --git a/src/SMESHGUI/SMESHGUI_AddEdgeDlg.cxx b/src/SMESHGUI/SMESHGUI_AddEdgeDlg.cxx deleted file mode 100644 index 2b40287d0..000000000 --- a/src/SMESHGUI/SMESHGUI_AddEdgeDlg.cxx +++ /dev/null @@ -1,388 +0,0 @@ -// SMESH SMESHGUI : GUI for SMESH component -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMESHGUI_AddEdgeDlg.cxx -// Author : Nicolas REJNERI -// Module : SMESH -// $Header$ - -using namespace std; -#include "SMESHGUI_AddEdgeDlg.h" - -#include "SMESHGUI.h" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_MessageBox.h" -#include "utilities.h" - -// QT Includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -//================================================================================= -// class : SMESHGUI_AddEdgeDlg() -// purpose : -//================================================================================= -SMESHGUI_AddEdgeDlg::SMESHGUI_AddEdgeDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, - bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) -{ - myNodes = 2; - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_LINE"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); - - if ( !name ) - setName( "SMESHGUI_AddEdgeDlg" ); - resize( 303, 185 ); - setCaption( tr( "SMESH_ADD_EDGE_TITLE" ) ); - setSizeGripEnabled( TRUE ); - SMESHGUI_AddEdgeDlgLayout = new QGridLayout( this ); - SMESHGUI_AddEdgeDlgLayout->setSpacing( 6 ); - SMESHGUI_AddEdgeDlgLayout->setMargin( 11 ); - - /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( tr( "SMESH_EDGE" ) ); - - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); - Constructor1->setText( tr( "" ) ); - Constructor1->setPixmap( image0 ); - Constructor1->setChecked( TRUE ); - Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); - Constructor1->setMinimumSize( QSize( 50, 0 ) ); - GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer, 0, 1 ); - SMESHGUI_AddEdgeDlgLayout->addWidget( GroupConstructors, 0, 0 ); - - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_9, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - SMESHGUI_AddEdgeDlgLayout->addWidget( GroupButtons, 2, 0 ); - - /***************************************************************/ - GroupC1 = new QGroupBox( this, "GroupC1" ); - GroupC1->setTitle( tr( "SMESH_ADD_EDGE" ) ); - - GroupC1->setMinimumSize( QSize( 0, 0 ) ); - GroupC1->setFrameShape( QGroupBox::Box ); - GroupC1->setFrameShadow( QGroupBox::Sunken ); - GroupC1->setColumnLayout(0, Qt::Vertical ); - GroupC1->layout()->setSpacing( 0 ); - GroupC1->layout()->setMargin( 0 ); - GroupC1Layout = new QGridLayout( GroupC1->layout() ); - GroupC1Layout->setAlignment( Qt::AlignTop ); - GroupC1Layout->setSpacing( 6 ); - GroupC1Layout->setMargin( 11 ); - TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); - TextLabelC1A1->setText( tr( "SMESH_ID_NODES" ) ); - TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A1->setFrameShape( QLabel::NoFrame ); - TextLabelC1A1->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); - SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); - SelectButtonC1A1->setText( tr( "" ) ); - SelectButtonC1A1->setPixmap( image1 ); - SelectButtonC1A1->setToggleButton( FALSE ); - GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); - LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); - GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); - - SMESHGUI_AddEdgeDlgLayout->addWidget( GroupC1, 1, 0 ); - - Init(Sel) ; /* Initialisations */ -} - -//================================================================================= -// function : ~SMESHGUI_AddEdgeDlg() -// purpose : Destroys the object and frees any allocated resources -//================================================================================= -SMESHGUI_AddEdgeDlg::~SMESHGUI_AddEdgeDlg() -{ - // no need to delete child widgets, Qt does it all for us -} - - -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void SMESHGUI_AddEdgeDlg::Init( SALOME_Selection* Sel ) -{ - - GroupC1->show(); - myConstructorId = 0 ; - Constructor1->setChecked( TRUE ); - myEditCurrentArgument = LineEditC1A1 ; - mySelection = Sel; - this->myOkNodes = false ; - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; - - /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); - - connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - /* to close dialog if study change */ - connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - - /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ - - SelectionIntoArgument(); - - return ; -} - - -//================================================================================= -// function : ConstructorsClicked() -// purpose : Radio button management -//================================================================================= -void SMESHGUI_AddEdgeDlg::ConstructorsClicked(int constructorId) -{ - return ; -} - - -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -void SMESHGUI_AddEdgeDlg::ClickOnApply() -{ - switch(myConstructorId) - { - case 0 : - { - if(myOkNodes) { - mySMESHGUI->EraseSimulationActors(); - mySMESHGUI->AddEdge( myMesh, myMapIndex ) ; - mySMESHGUI->ViewNodes(); - mySelection->ClearIObjects(); - } - break ; - } - } - return ; -} - -//================================================================================= -// function : ClickOnOk() -// purpose : -//================================================================================= -void SMESHGUI_AddEdgeDlg::ClickOnOk() -{ - this->ClickOnApply() ; - this->ClickOnCancel() ; - return ; -} - -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void SMESHGUI_AddEdgeDlg::ClickOnCancel() -{ - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - disconnect( mySelection, 0, this, 0 ); - mySMESHGUI->ResetState() ; - mySMESHGUI->EraseSimulationActors(); - reject() ; - return ; -} - - -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection as changed or other case -//================================================================================= -void SMESHGUI_AddEdgeDlg::SelectionIntoArgument() -{ - myEditCurrentArgument->setText("") ; - myOkNodes = false; - QString aString = ""; - - int nbSel = mySelection->IObjectCount(); - if(nbSel != 1) - return; - - int nbNodes = mySMESHGUI->GetNameOfSelectedNodes(mySelection, aString) ; - if(nbNodes < 1) - return ; - - if ( mySelection->SelectionMode() != NodeSelection ) { - QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), - tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_OK") ); - return; - } - - myEditCurrentArgument->setText(aString) ; - Standard_Boolean res; - myMesh = mySMESHGUI->ConvertIOinMesh( mySelection->firstIObject(), res ); - if (!res) - return ; - - mySelection->GetIndex( mySelection->firstIObject(), myMapIndex); - - if ( myNodes == 2 && nbNodes == 2 ) { - mySMESHGUI->DisplaySimulationEdge(myMesh, myMapIndex); - myOkNodes = true ; - } else { - // mySMESHGUI->EraseSimulationActors(); - myOkNodes = false ; - } - return ; -} - - -//================================================================================= -// function : SetEditCurrentArgument() -// purpose : -//================================================================================= -void SMESHGUI_AddEdgeDlg::SetEditCurrentArgument() -{ - QPushButton* send = (QPushButton*)sender(); - switch (myConstructorId) - { - case 0: /* default constructor */ - { - if(send == SelectButtonC1A1) { - LineEditC1A1->setFocus() ; - myEditCurrentArgument = LineEditC1A1; - } - SelectionIntoArgument() ; - break; - } - } - return ; -} - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void SMESHGUI_AddEdgeDlg::DeactivateActiveDialog() -{ - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupC1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - mySMESHGUI->EraseSimulationActors() ; - mySMESHGUI->ResetState() ; - mySMESHGUI->SetActiveDialogBox(0) ; - } - return ; -} - - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void SMESHGUI_AddEdgeDlg::ActivateThisDialog() -{ - /* Emit a signal to deactivate the active dialog */ - mySMESHGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupC1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - return ; -} - - -//================================================================================= -// function : enterEvent() -// purpose : -//================================================================================= -void SMESHGUI_AddEdgeDlg::enterEvent(QEvent* e) -{ - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; - return ; -} - - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void SMESHGUI_AddEdgeDlg::closeEvent( QCloseEvent* e ) -{ - /* same than click on cancel button */ - this->ClickOnCancel() ; - return ; -} - diff --git a/src/SMESHGUI/SMESHGUI_AddHypothesisDlg.cxx b/src/SMESHGUI/SMESHGUI_AddHypothesisDlg.cxx deleted file mode 100644 index 75b489604..000000000 --- a/src/SMESHGUI/SMESHGUI_AddHypothesisDlg.cxx +++ /dev/null @@ -1,467 +0,0 @@ -// SMESH SMESHGUI : GUI for SMESH component -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMESHGUI_AddHypothesisDlg.cxx -// Author : Nicolas REJNERI -// Module : SMESH -// $Header$ - -using namespace std; -#include "SMESHGUI_AddHypothesisDlg.h" -#include "SALOME_ListIteratorOfListIO.hxx" - -#include "SMESHGUI.h" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "utilities.h" - -// QT Includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -//================================================================================= -// class : SMESHGUI_AddHypothesisDlg() -// purpose : Constructs a SMESHGUI_AddHypothesisDlg which is a child of 'parent', with the -// name 'name' and widget flags set to 'f'. -// The dialog will by default be modeless, unless you set 'modal' to -// TRUE to construct a modal dialog. -//================================================================================= -SMESHGUI_AddHypothesisDlg::SMESHGUI_AddHypothesisDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) -{ - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_ADD_HYPOTHESIS"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); - - if ( !name ) - setName( "SMESHGUI_AddHypothesisDlg" ); - resize( 322, 220 ); - setCaption( tr( "SMESH_ADD_HYPOTHESIS_TITLE" ) ); - setSizeGripEnabled( TRUE ); - - SMESHGUI_AddHypothesisDlgLayout = new QGridLayout( this ); - SMESHGUI_AddHypothesisDlgLayout->setSpacing( 6 ); - SMESHGUI_AddHypothesisDlgLayout->setMargin( 11 ); - - /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( tr( "SMESH_ADD_HYPOTHESIS" ) ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer, 0, 1 ); - Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); - Constructor1->setText( tr( "" ) ); - Constructor1->setPixmap( image0 ); - Constructor1->setChecked( TRUE ); - Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); - GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); - SMESHGUI_AddHypothesisDlgLayout->addWidget( GroupConstructors, 0, 0 ); - - /***************************************************************/ - GroupConstructor1 = new QGroupBox( this, "GroupConstructor1" ); - GroupConstructor1->setTitle( tr( "SMESH_ARGUMENTS" ) ); - GroupConstructor1->setColumnLayout(0, Qt::Vertical ); - GroupConstructor1->layout()->setSpacing( 0 ); - GroupConstructor1->layout()->setMargin( 0 ); - GroupConstructor1Layout = new QGridLayout( GroupConstructor1->layout() ); - GroupConstructor1Layout->setAlignment( Qt::AlignTop ); - GroupConstructor1Layout->setSpacing( 6 ); - GroupConstructor1Layout->setMargin( 11 ); - LineEditC1A2Mesh = new QLineEdit( GroupConstructor1, "LineEditC1A2Mesh" ); - LineEditC1A2Mesh->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A2Mesh->sizePolicy().hasHeightForWidth() ) ); - GroupConstructor1Layout->addWidget( LineEditC1A2Mesh, 1, 2 ); - LineEditC1A1Hyp = new QLineEdit( GroupConstructor1, "LineEditC1A1Hyp" ); - LineEditC1A1Hyp->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)0, LineEditC1A1Hyp->sizePolicy().hasHeightForWidth() ) ); - GroupConstructor1Layout->addWidget( LineEditC1A1Hyp, 0, 2 ); - SelectButtonC1A1Hyp = new QPushButton( GroupConstructor1, "SelectButtonC1A1Hyp" ); - SelectButtonC1A1Hyp->setText( tr( "" ) ); - SelectButtonC1A1Hyp->setPixmap( image1 ); - GroupConstructor1Layout->addWidget( SelectButtonC1A1Hyp, 0, 1 ); - SelectButtonC1A2Mesh = new QPushButton( GroupConstructor1, "SelectButtonC1A2Mesh" ); - SelectButtonC1A2Mesh->setText( tr( "" ) ); - SelectButtonC1A2Mesh->setPixmap( image1 ); - GroupConstructor1Layout->addWidget( SelectButtonC1A2Mesh, 1, 1 ); - TextLabelC1A2Mesh = new QLabel( GroupConstructor1, "TextLabelC1A2Mesh" ); - TextLabelC1A2Mesh->setText( tr( "SMESH_OBJECT_MESHorSUBMESH" ) ); - TextLabelC1A2Mesh->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A2Mesh->setFrameShape( QLabel::NoFrame ); - TextLabelC1A2Mesh->setFrameShadow( QLabel::Plain ); - GroupConstructor1Layout->addWidget( TextLabelC1A2Mesh, 1, 0 ); - TextLabelC1A1Hyp = new QLabel( GroupConstructor1, "TextLabelC1A1Hyp" ); - TextLabelC1A1Hyp->setText( tr( "SMESH_OBJECT_HYPOTHESIS" ) ); - TextLabelC1A1Hyp->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A1Hyp->setFrameShape( QLabel::NoFrame ); - TextLabelC1A1Hyp->setFrameShadow( QLabel::Plain ); - GroupConstructor1Layout->addWidget( TextLabelC1A1Hyp, 0, 0 ); - SMESHGUI_AddHypothesisDlgLayout->addWidget( GroupConstructor1, 1, 0 ); - - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_1 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_1, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - SMESHGUI_AddHypothesisDlgLayout->addWidget( GroupButtons, 2, 0 ); - - /* Initialisation */ - Init( Sel ) ; -} - - -//================================================================================= -// function : ~SMESHGUI_AddHypothesisDlg() -// purpose : Destroys the object and frees any allocated resources -//================================================================================= -SMESHGUI_AddHypothesisDlg::~SMESHGUI_AddHypothesisDlg() -{ - /* no need to delete child widgets, Qt does it all for us */ - this->destroy(TRUE, TRUE) ; -} - - - -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void SMESHGUI_AddHypothesisDlg::Init( SALOME_Selection* Sel ) -{ - mySelection = Sel ; - myConstructorId = 0 ; - - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - - GroupConstructor1->show(); - myConstructorId = 0 ; - myEditCurrentArgument = LineEditC1A1Hyp ; - Constructor1->setChecked( TRUE ); - myOkMesh = myOkSubMesh = myOkHypothesis = false ; - - myHypothesisFilter = new SMESH_TypeFilter( HYPOTHESIS ); - myMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); - - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; - - /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); - connect( SelectButtonC1A1Hyp, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( SelectButtonC1A2Mesh, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - /* to close dialog if study change */ - connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - - /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* Displays Dialog */ - - return ; -} - - - -//================================================================================= -// function : ConstructorsClicked() -// purpose : Radio button management -//================================================================================= -void SMESHGUI_AddHypothesisDlg::ConstructorsClicked(int constructorId) -{ - switch (constructorId) - { - case 0: - { - GroupConstructor1->show(); - myConstructorId = constructorId ; - myEditCurrentArgument = LineEditC1A1Hyp ; - LineEditC1A2Mesh->setText(tr("")) ; - Constructor1->setChecked( TRUE ); - myOkMesh = myOkSubMesh = myOkHypothesis = false ; - break; - } - } - return ; -} - -//================================================================================= -// function : ClickOnOk() -// purpose : -//================================================================================= -void SMESHGUI_AddHypothesisDlg::ClickOnOk() -{ - this->ClickOnApply() ; - this->ClickOnCancel() ; - - return ; -} - -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -void SMESHGUI_AddHypothesisDlg::ClickOnApply() -{ - switch(myConstructorId) - { - case 0 : - { - if(myOkMesh && myOkHypothesis ) { - SALOME_ListIteratorOfListIO It( HypoList ); - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - Standard_Boolean testResult; - myHypothesis = mySMESHGUI->ConvertIOinSMESHHypothesis(IObject, testResult) ; - if( testResult ) - mySMESHGUI->AddHypothesisOnMesh(myMesh, myHypothesis) ; - } - } else if( myOkSubMesh && myOkHypothesis ) { - SALOME_ListIteratorOfListIO It( HypoList ); - for(;It.More();It.Next()) { - Handle(SALOME_InteractiveObject) IObject = It.Value(); - Standard_Boolean testResult; - myHypothesis = mySMESHGUI->ConvertIOinSMESHHypothesis(IObject, testResult) ; - if( testResult ) - mySMESHGUI->AddHypothesisOnSubMesh(mySubMesh, myHypothesis) ; - } - } - break ; - } - } -} - - -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void SMESHGUI_AddHypothesisDlg::ClickOnCancel() -{ - mySelection->ClearFilters() ; - disconnect( mySelection, 0, this, 0 ); - mySMESHGUI->ResetState() ; - reject() ; - return ; -} - - - -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection has changed -//================================================================================= -void SMESHGUI_AddHypothesisDlg::SelectionIntoArgument() -{ - myEditCurrentArgument->setText("") ; - QString aString = ""; - - int nbSel = mySMESHGUI->GetNameOfSelectedIObjects(mySelection, aString) ; - - if ( myEditCurrentArgument == LineEditC1A2Mesh ) { - if ( nbSel == 1 ) { - Handle(SALOME_InteractiveObject) IObject = mySelection->firstIObject(); - QString aName = IObject->getName(); - Standard_Boolean testResult; - myOkMesh = true ; - myMesh = mySMESHGUI->ConvertIOinMesh(IObject, testResult) ; - if( !testResult ) { - myOkMesh = false; - myOkSubMesh = true; - mySubMesh = mySMESHGUI->ConvertIOinSubMesh(IObject, testResult) ; - if( !testResult ) { - myOkSubMesh = false; - return ; - } - } - LineEditC1A2Mesh->setText(aString) ; - } - else { - myOkMesh = myOkSubMesh = false ; - return ; - } - } - else if ( myEditCurrentArgument == LineEditC1A1Hyp ) { - if ( nbSel >= 1 ) { - HypoList.Clear(); // = mySelection->StoredIObjects() ; - SALOME_ListIteratorOfListIO Itinit( mySelection->StoredIObjects() ); - for (; Itinit.More(); Itinit.Next()) { - HypoList.Append(Itinit.Value()); - } - myOkHypothesis = true ; - if (nbSel > 1) - aString = tr("%1 Hypothesis").arg(nbSel) ; - LineEditC1A1Hyp->setText(aString) ; - } - else { - myOkHypothesis = false ; - return ; - } - } - - return ; -} - - -//================================================================================= -// function : SetEditCurrentArgument() -// purpose : -//================================================================================= -void SMESHGUI_AddHypothesisDlg::SetEditCurrentArgument() -{ - QPushButton* send = (QPushButton*)sender(); - - switch (myConstructorId) - { - case 0: /* default constructor */ - { - if( send == SelectButtonC1A1Hyp ) { - myEditCurrentArgument = LineEditC1A1Hyp ; - LineEditC1A1Hyp->setFocus() ; - mySelection->ClearFilters() ; - mySelection->AddFilter(myHypothesisFilter) ; - } - else if(send == SelectButtonC1A2Mesh) { - myEditCurrentArgument = LineEditC1A2Mesh; - LineEditC1A2Mesh->setFocus() ; - mySelection->ClearFilters() ; - mySelection->AddFilter(myMeshOrSubMeshFilter) ; - } - SelectionIntoArgument() ; - break; - } - } - return ; -} - - - -//================================================================================= -// function : LineEditReturnPressed() -// purpose : -//================================================================================= -void SMESHGUI_AddHypothesisDlg::LineEditReturnPressed() -{ - - return ; -} - - - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void SMESHGUI_AddHypothesisDlg::DeactivateActiveDialog() -{ - if ( GroupConstructors->isEnabled() ) { - - GroupConstructors->setEnabled(false) ; - GroupConstructor1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - disconnect( mySelection, 0, this, 0 ); - } - return ; -} - - - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void SMESHGUI_AddHypothesisDlg::closeEvent( QCloseEvent* e ) -{ - this->ClickOnCancel() ; /* same than click on cancel button */ -} - - -//================================================================================= -// function : enterEvent() -// purpose : when mouse enter onto the QWidget -//================================================================================= -void SMESHGUI_AddHypothesisDlg::enterEvent( QEvent * ) -{ - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; -} - - - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void SMESHGUI_AddHypothesisDlg::ActivateThisDialog() -{ - /* Emit a signal to deactivate any active dialog */ - mySMESHGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupConstructor1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - - connect ( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - return ; -} diff --git a/src/SMESHGUI/SMESHGUI_AddHypothesisDlg.h b/src/SMESHGUI/SMESHGUI_AddHypothesisDlg.h deleted file mode 100644 index 1b165d030..000000000 --- a/src/SMESHGUI/SMESHGUI_AddHypothesisDlg.h +++ /dev/null @@ -1,132 +0,0 @@ -// SMESH SMESHGUI : GUI for SMESH component -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMESHGUI_AddHypothesisDlg.h -// Author : Nicolas REJNERI -// Module : SMESH -// $Header$ - -#ifndef DIALOGBOX_ADD_HYPOTHESIS_H -#define DIALOGBOX_ADD_HYPOTHESIS_H - -#include "SALOME_Selection.h" -#include "SALOME_TypeFilter.hxx" -#include "SMESH_TypeFilter.hxx" -#include "SALOME_ListIO.hxx" - -// IDL Headers -#include -#include CORBA_SERVER_HEADER(SMESH_Gen) - -// QT Includes -#include -#include - -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QButtonGroup; -class QFrame; -class QGroupBox; -class QLabel; -class QLineEdit; -class QPushButton; -class QRadioButton; -class SMESHGUI; - - -//================================================================================= -// class : SMESHGUI_AddHypothesisDlg -// purpose : -//================================================================================= -class SMESHGUI_AddHypothesisDlg : public QDialog -{ - Q_OBJECT - -public: - SMESHGUI_AddHypothesisDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); - ~SMESHGUI_AddHypothesisDlg(); - -private: - - void Init( SALOME_Selection* Sel ) ; - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ - - SMESH::SMESH_Gen_var myCompMesh ; - SMESHGUI* mySMESHGUI ; - SALOME_Selection* mySelection ; - - SMESH::SMESH_Mesh_var myMesh; - SMESH::SMESH_subMesh_var mySubMesh; - - SMESH::SMESH_Hypothesis_var myHypothesis; - - Handle(SMESH_TypeFilter) myHypothesisFilter; - Handle(SMESH_TypeFilter) myMeshOrSubMeshFilter; - - bool myOkMesh ; - bool myOkSubMesh ; - bool myOkHypothesis; - - int myConstructorId ; /* Current constructor id = radio button id */ - QLineEdit* myEditCurrentArgument; /* Current LineEdit */ - - SALOME_ListIO HypoList; - - QButtonGroup* GroupConstructors; - QRadioButton* Constructor1; - - QGroupBox* GroupConstructor1; - QLineEdit* LineEditC1A1Hyp; - QLineEdit* LineEditC1A2Mesh; - QPushButton* SelectButtonC1A1Hyp; - QPushButton* SelectButtonC1A2Mesh; - QLabel* TextLabelC1A2Mesh; - QLabel* TextLabelC1A1Hyp; - - QGroupBox* GroupButtons; - QPushButton* buttonApply; - QPushButton* buttonOk; - QPushButton* buttonCancel; - -private slots: - - void ConstructorsClicked(int constructorId); - void ClickOnOk(); - void ClickOnCancel(); - void ClickOnApply(); - void SetEditCurrentArgument() ; - void SelectionIntoArgument() ; - void LineEditReturnPressed() ; - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; - -protected: - QGridLayout* SMESHGUI_AddHypothesisDlgLayout; - QGridLayout* GroupConstructorsLayout; - QGridLayout* GroupButtonsLayout; - QGridLayout* GroupConstructor1Layout; -}; - -#endif // DIALOGBOX_ADD_HYPOTHESIS_H diff --git a/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx new file mode 100644 index 000000000..fad8aa4e5 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.cxx @@ -0,0 +1,696 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_AddMeshElementDlg.cxx +// Author : Nicolas REJNERI +// Module : SMESH +// $Header$ + +#include "SMESHGUI_AddMeshElementDlg.h" + +#include "SMESHGUI.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_MeshUtils.h" +#include "SMESHGUI_IdValidator.h" +#include "SMESH_ActorUtils.h" + +#include "VTKViewer_ViewFrame.h" +#include "SMDS_Mesh.hxx" +#include "SMESH_Actor.h" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" + +#include "utilities.h" + +#include +#include +#include +#include +#include +#include +#include + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +using namespace std; + +namespace SMESH{ + + class TElementSimulation{ + QAD_Study* myStudy; + QAD_StudyFrame* myStudyFrame; + VTKViewer_ViewFrame* myViewFrame; + + SALOME_Actor *myPreviewActor; + vtkDataSetMapper* myMapper; + vtkUnstructuredGrid* myGrid; + + public: + + TElementSimulation(QAD_Study* theStudy): + myStudy(theStudy), + myStudyFrame(theStudy->getActiveStudyFrame()), + myViewFrame(GetVtkViewFrame(theStudy->getActiveStudyFrame())) + { + myGrid = vtkUnstructuredGrid::New(); + + // Create and display actor + myMapper = vtkDataSetMapper::New(); + myMapper->SetInput( myGrid ); + + myPreviewActor = SALOME_Actor::New(); + myPreviewActor->PickableOff(); + myPreviewActor->VisibilityOff(); + myPreviewActor->SetMapper( myMapper ); + + vtkProperty* aProp = vtkProperty::New(); + float anRGB[3]; + anRGB[0] = GetFloat("SMESH:SettingsFillColorRed", 0)/255.; + anRGB[1] = GetFloat("SMESH:SettingsFillColorGreen", 170)/255.; + anRGB[2] = GetFloat("SMESH:SettingsFillColorBlue", 255)/255.; + aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); + myPreviewActor->SetProperty( aProp ); + aProp->Delete(); + + vtkProperty* aBackProp = vtkProperty::New(); + anRGB[0] = GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.; + anRGB[1] = GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.; + anRGB[2] = GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.; + aBackProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); + myPreviewActor->SetBackfaceProperty( aBackProp ); + aBackProp->Delete(); + + myViewFrame->AddActor( myPreviewActor ); + + } + + + typedef list TVTKIds; + void SetPosition(SMESH_Actor* theActor, + vtkIdType theType, + const TVTKIds& theIds) + { + vtkUnstructuredGrid *aGrid = theActor->GetUnstructuredGrid(); + myGrid->SetPoints(aGrid->GetPoints()); + + myGrid->Reset(); + vtkIdList *anIds = vtkIdList::New(); + TVTKIds::const_iterator anIt = theIds.begin(); + for (int i = 0; anIt != theIds.end(); anIt++,i++) + anIds->InsertId(i, *anIt); + myGrid->InsertNextCell(theType,anIds); + anIds->Delete(); + + myGrid->Modified(); + + SetVisibility(true); + } + + + void SetVisibility(bool theVisibility){ + myPreviewActor->SetVisibility(theVisibility); + RepaintCurrentView(); + } + + + ~TElementSimulation(){ + if(FindVtkViewFrame(myStudy,myStudyFrame)){ + myViewFrame->RemoveActor(myPreviewActor); + } + myPreviewActor->Delete(); + + myMapper->RemoveAllInputs(); + myMapper->Delete(); + + myGrid->Delete(); + } + + }; + +} + +//================================================================================= +// class : SMESHGUI_AddMeshElementDlg() +// purpose : +//================================================================================= +SMESHGUI_AddMeshElementDlg::SMESHGUI_AddMeshElementDlg( QWidget* parent, const char* name, + SALOME_Selection* Sel, + SMDSAbs_ElementType ElementType, int nbNodes, + bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | + Qt::WDestructiveClose) +{ + mySimulation = new SMESH::TElementSimulation(SMESH::GetActiveStudy()); + + // verify nb nodes and type + myNbNodes = nbNodes; + myElementType = ElementType; + switch ( ElementType ) { + case SMDSAbs_Face: + if ( myNbNodes != 3 && myNbNodes != 4 ) + myNbNodes = 3; + break; + case SMDSAbs_Volume: + if ( myNbNodes != 4 && myNbNodes != 8 ) //(nbNodes < 4 || nbNodes > 8 || nbNodes == 7) + myNbNodes = 4; + break; + default: + myElementType = SMDSAbs_Edge; + myNbNodes = 2; + } + + QString elemName; + switch ( myNbNodes ) { + case 2: elemName = "EDGE"; break; + case 3: elemName = "TRIANGLE"; break; + case 4: elemName = + myElementType == SMDSAbs_Face ? elemName = "QUADRANGLE" : elemName = "TETRAS"; break; +// case 5: +// case 6: + default: // 8 + elemName = "HEXAS"; + } + QString iconName = tr( QString("ICON_DLG_%1").arg(elemName) ); + QString buttonGrTitle = tr( QString("SMESH_%1").arg(elemName) ); + QString caption = tr( QString("SMESH_ADD_%1_TITLE").arg(elemName) ); + QString grBoxTitle = tr( QString("SMESH_ADD_%1").arg(elemName) ); + + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", iconName )); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr("ICON_SELECT"))); + + if ( !name ) + setName( "SMESHGUI_AddMeshElementDlg" ); + resize( 303, 185 ); + setCaption( caption ); + + setSizeGripEnabled( TRUE ); + SMESHGUI_AddMeshElementDlgLayout = new QGridLayout( this ); + SMESHGUI_AddMeshElementDlgLayout->setSpacing( 6 ); + SMESHGUI_AddMeshElementDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( buttonGrTitle ); + + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); + Constructor1->setText( tr( "" ) ); + Constructor1->setPixmap( image0 ); + Constructor1->setChecked( TRUE ); + Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); + Constructor1->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer, 0, 1 ); + SMESHGUI_AddMeshElementDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_AddMeshElementDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( grBoxTitle ); + + GroupC1->setMinimumSize( QSize( 0, 0 ) ); + GroupC1->setFrameShape( QGroupBox::Box ); + GroupC1->setFrameShadow( QGroupBox::Sunken ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); + TextLabelC1A1->setText( tr( "SMESH_ID_NODES" ) ); + TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); + TextLabelC1A1->setFrameShape( QLabel::NoFrame ); + TextLabelC1A1->setFrameShadow( QLabel::Plain ); + GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); + SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); + SelectButtonC1A1->setText( tr( "" ) ); + SelectButtonC1A1->setPixmap( image1 ); + SelectButtonC1A1->setToggleButton( FALSE ); + GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); + LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); +// LineEditC1A1->setReadOnly( TRUE ); + LineEditC1A1->setValidator( new SMESHGUI_IdValidator( this, "validator", myNbNodes )); + GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); + + if ( myElementType == SMDSAbs_Face ) { + Reverse = new QCheckBox( GroupC1, "Reverse" ); + Reverse->setText( tr( "SMESH_REVERSE" ) ); + GroupC1Layout->addWidget( Reverse, 1, 0 ); + } + else + Reverse = 0; + + SMESHGUI_AddMeshElementDlgLayout->addWidget( GroupC1, 1, 0 ); + + Init(Sel) ; /* Initialisations */ +} + +//================================================================================= +// function : ~SMESHGUI_AddMeshElementDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_AddMeshElementDlg::~SMESHGUI_AddMeshElementDlg() +{ + // no need to delete child widgets, Qt does it all for us + delete mySimulation; +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_AddMeshElementDlg::Init( SALOME_Selection* Sel ) +{ + + GroupC1->show(); + Constructor1->setChecked( TRUE ); + myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + myOkNodes = false ; + myActor = 0; + + /* signals and slots connections */ + connect(buttonOk, SIGNAL( clicked() ), SLOT( ClickOnOk() ) ); + connect(buttonCancel, SIGNAL( clicked() ), SLOT( ClickOnCancel() ) ) ; + connect(buttonApply, SIGNAL( clicked() ), SLOT(ClickOnApply() ) ); + + connect(SelectButtonC1A1, SIGNAL( clicked() ), SLOT( SetEditCurrentArgument() ) ) ; + connect(LineEditC1A1, SIGNAL( textChanged(const QString&) ), SLOT(onTextChange(const QString&))); + connect(mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), SLOT( DeactivateActiveDialog())); + connect(mySelection, SIGNAL( currentSelectionChanged() ), SLOT( SelectionIntoArgument() ) ); + /* to close dialog if study frame change */ + connect( mySMESHGUI, SIGNAL ( SignalStudyFrameChanged() ), SLOT( ClickOnCancel() ) ) ; + + if ( Reverse ) + connect( Reverse, SIGNAL(stateChanged(int)), SLOT(CheckBox(int)) ); + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + // set selection mode + SMESH::SetPointRepresentation(true); + QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + + SelectionIntoArgument(); + + myBusy = false; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_AddMeshElementDlg::ClickOnApply() +{ + if ( myOkNodes && !mySMESHGUI->ActiveStudyLocked() ) { + + myBusy = true; + SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array; + anArrayOfIdeces->length( myNbNodes ); + bool reverse = ( Reverse && Reverse->isChecked() ); + QStringList aListId = QStringList::split( " ", myEditCurrentArgument->text(), false); + for ( int i = 0; i < aListId.count(); i++ ) + if ( reverse ) + anArrayOfIdeces[i] = aListId[ myNbNodes - i - 1 ].toInt(); + else + anArrayOfIdeces[i] = aListId[ i ].toInt(); + + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + switch ( myElementType ) { + case SMDSAbs_Edge: + aMeshEditor->AddEdge(anArrayOfIdeces.inout()); break; + case SMDSAbs_Face: + aMeshEditor->AddFace(anArrayOfIdeces.inout()); break; + case SMDSAbs_Volume: + aMeshEditor->AddVolume(anArrayOfIdeces.inout()); break; + default:; + } + + mySelection->ClearIObjects(); + mySelection->AddIObject( myActor->getIO(), false ); + + SMESH::UpdateView(); + mySimulation->SetVisibility(false); + + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + + myEditCurrentArgument->setText(""); + + myBusy = false; + } +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_AddMeshElementDlg::ClickOnOk() +{ + this->ClickOnApply() ; + this->ClickOnCancel() ; + return ; +} + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_AddMeshElementDlg::ClickOnCancel() +{ + mySelection->ClearIObjects(); + mySimulation->SetVisibility(false); + SMESH::SetPointRepresentation(false); + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + reject() ; + return ; +} + +//======================================================================= +//function : onTextChange +//purpose : +//======================================================================= + +void SMESHGUI_AddMeshElementDlg::onTextChange(const QString& theNewText) +{ + if ( myBusy ) return; + myBusy = true; + + myOkNodes = false; + + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + + mySimulation->SetVisibility(false); + + // hilight entered nodes + SMDS_Mesh* aMesh = 0; + if ( myActor ) + aMesh = myActor->GetObject()->GetMesh(); + if ( aMesh ) { + + mySelection->ClearIObjects(); + mySelection->AddIObject( myActor->getIO() ); + + QStringList aListId = QStringList::split( " ", theNewText, false); + bool allOk = true; + for ( int i = 0; i < aListId.count(); i++ ) { + const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ); + if ( n ) { + if ( mySelection->IsIndexSelected( myActor->getIO(), n->GetID() )) + allOk = false; + else + mySelection->AddOrRemoveIndex (myActor->getIO(), n->GetID(), true); + } + else + allOk = false; + } + myOkNodes = (allOk && myNbNodes == aListId.count() ); + + if ( myOkNodes ) { + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); + displaySimulation(); + } + } + + myBusy = false; +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection has changed +//================================================================================= +void SMESHGUI_AddMeshElementDlg::SelectionIntoArgument() +{ + if ( myBusy ) return; + + // clear + + myOkNodes = false; + myActor = 0; + + myBusy = true; + myEditCurrentArgument->setText( "" ); + myBusy = false; + + if ( !GroupButtons->isEnabled() ) // inactive + return; + + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + + mySimulation->SetVisibility(false); +// SMESH::SetPointRepresentation(true); + + // get selected mesh + + int nbSel = mySelection->IObjectCount(); + if(nbSel != 1) + return; + + myMesh = SMESH::GetMeshByIO( mySelection->firstIObject() ); + if ( myMesh->_is_nil() ) + return; + + myActor = SMESH::FindActorByEntry( mySelection->firstIObject()->getEntry() ); + if ( !myActor ) + return; + + // get selected nodes + + QString aString = ""; + int nbNodes = SMESH::GetNameOfSelectedNodes(mySelection, aString) ; + myBusy = true; + myEditCurrentArgument->setText( aString ); + myBusy = false; + if ( myNbNodes != nbNodes ) + return; + + // OK + + myOkNodes = true; + + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); + + displaySimulation(); +} + +//======================================================================= +//function : displaySimulation +//purpose : +//======================================================================= + +void SMESHGUI_AddMeshElementDlg::displaySimulation() +{ + if ( myOkNodes && GroupButtons->isEnabled() ) + { + SMESH::TElementSimulation::TVTKIds anIds; + QStringList aListId = QStringList::split( " ", myEditCurrentArgument->text(), false); + for ( int i = 0; i < aListId.count(); i++ ) + anIds.push_back( myActor->GetObject()->GetNodeVTKId( aListId[ i ].toInt() )); + + if ( Reverse && Reverse->isChecked() ) + anIds.reverse(); + + vtkIdType aType = 0; + switch ( myNbNodes ) { + case 2: aType = VTK_LINE; break; + case 3: aType = VTK_TRIANGLE; break; + case 4: aType = myElementType == SMDSAbs_Face ? VTK_QUAD : VTK_TETRA; break; + case 8: aType = VTK_HEXAHEDRON; break; + default: return; + } + + mySimulation->SetPosition(myActor,aType,anIds); + } +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void SMESHGUI_AddMeshElementDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + if(send == SelectButtonC1A1) { + LineEditC1A1->setFocus() ; + myEditCurrentArgument = LineEditC1A1; + } + SelectionIntoArgument() ; +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_AddMeshElementDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupC1->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + mySimulation->SetVisibility(false); + mySMESHGUI->ResetState() ; + mySMESHGUI->SetActiveDialogBox(0) ; + } + return ; +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_AddMeshElementDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + mySMESHGUI->EmitSignalDeactivateDialog() ; + + GroupConstructors->setEnabled(true) ; + GroupC1->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + + SMESH::SetPointRepresentation(true); + QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + + SelectionIntoArgument(); +} + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_AddMeshElementDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; + return ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_AddMeshElementDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} +//======================================================================= +//function : hideEvent +//purpose : caused by ESC key +//======================================================================= + +void SMESHGUI_AddMeshElementDlg::hideEvent ( QHideEvent * e ) +{ + if ( !isMinimized() ) + ClickOnCancel() ; +} + +//======================================================================= +//function : CheckBox +//purpose : +//======================================================================= + +void SMESHGUI_AddMeshElementDlg::CheckBox( int state ) +{ + if ( !myOkNodes ) + return; + + if ( state >= 0 ) { + mySimulation->SetVisibility(false); + displaySimulation(); + } +} diff --git a/src/SMESHGUI/SMESHGUI_OrientationElementsDlg.h b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.h similarity index 53% rename from src/SMESHGUI/SMESHGUI_OrientationElementsDlg.h rename to src/SMESHGUI/SMESHGUI_AddMeshElementDlg.h index 9e4e268a9..4a785bbc5 100644 --- a/src/SMESHGUI/SMESHGUI_OrientationElementsDlg.h +++ b/src/SMESHGUI/SMESHGUI_AddMeshElementDlg.h @@ -21,23 +21,23 @@ // // // -// File : SMESHGUI_OrientationElementsDlg.h +// File : SMESHGUI_AddMeshElementDlg.h // Author : Nicolas REJNERI // Module : SMESH // $Header$ -#ifndef DIALOGBOX_ORIENTATION_ELEMENTS_H -#define DIALOGBOX_ORIENTATION_ELEMENTS_H +#ifndef DIALOGBOX_ADD_FACE_H +#define DIALOGBOX_ADD_FACE_H #include "SALOME_Selection.h" +#include "SMDSAbs_ElementType.hxx" + + // QT Includes #include #include -// Open CASCADE Includes -#include - class QVBoxLayout; class QHBoxLayout; class QGridLayout; @@ -47,53 +47,71 @@ class QLabel; class QLineEdit; class QPushButton; class QRadioButton; +class QCheckBox; class SMESHGUI; +class SMESH_Actor; +class SMDS_Mesh; + +namespace SMESH{ + struct TElementSimulation; +} // IDL Headers #include #include CORBA_SERVER_HEADER(SMESH_Mesh) //================================================================================= -// class : SMESHGUI_OrientationElementsDlg +// class : SMESHGUI_AddMeshElementDlg // purpose : //================================================================================= -class SMESHGUI_OrientationElementsDlg : public QDialog +class SMESHGUI_AddMeshElementDlg : public QDialog { Q_OBJECT public: - SMESHGUI_OrientationElementsDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); - ~SMESHGUI_OrientationElementsDlg(); + SMESHGUI_AddMeshElementDlg( QWidget* parent = 0, const char* name = 0, + SALOME_Selection* Sel = 0, + SMDSAbs_ElementType ElementType = SMDSAbs_Edge, + int nbNodes = 2, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_AddMeshElementDlg(); private: void Init( SALOME_Selection* Sel ) ; void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void hideEvent ( QHideEvent * ); /* ESC key */ + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void displaySimulation(); - SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ - SALOME_Selection* mySelection ; /* User shape selection */ - bool myOkElements ; /* to check when arguments is defined */ - int myConstructorId ; /* Current constructor id = radio button id */ - QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + bool myOkNodes ; /* to check when arguments is defined */ + bool myBusy; - SMESH::SMESH_Mesh_var myMesh; - TColStd_MapOfInteger myMapIndex; + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + + int myElementType ; + int myNbNodes; + + SMESH::SMESH_Mesh_var myMesh; + SMESH_Actor* myActor; + SMESH::TElementSimulation* mySimulation; QButtonGroup* GroupConstructors; QRadioButton* Constructor1; - QGroupBox* GroupButtons; - QPushButton* buttonOk; - QPushButton* buttonCancel; - QPushButton* buttonApply; - QGroupBox* GroupC1; - QLabel* TextLabelC1A1; - QPushButton* SelectButtonC1A1; - QLineEdit* LineEditC1A1; + QGroupBox * GroupButtons; + QPushButton * buttonOk; + QPushButton * buttonCancel; + QPushButton * buttonApply; + QGroupBox * GroupC1; + QLabel * TextLabelC1A1; + QPushButton * SelectButtonC1A1; + QLineEdit * LineEditC1A1; + + QCheckBox * Reverse; private slots: - void ConstructorsClicked(int constructorId); void ClickOnOk(); void ClickOnCancel(); void ClickOnApply(); @@ -101,12 +119,14 @@ private slots: void SelectionIntoArgument() ; void DeactivateActiveDialog() ; void ActivateThisDialog() ; + void CheckBox( int ); + void onTextChange(const QString&); protected: - QGridLayout* SMESHGUI_OrientationElementsDlgLayout; + QGridLayout* SMESHGUI_AddMeshElementDlgLayout; QGridLayout* GroupConstructorsLayout; QGridLayout* GroupButtonsLayout; QGridLayout* GroupC1Layout; }; -#endif // DIALOGBOX_ORIENTATION_ELEMENTS_H +#endif // DIALOGBOX_ADD_FACE_H diff --git a/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx b/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx index b3ab63dfc..250323da7 100644 --- a/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.cxx @@ -26,10 +26,14 @@ // Module : SMESH // $Header$ -using namespace std; #include "SMESHGUI_AddSubMeshDlg.h" + #include "SMESHGUI.h" -#include "SALOME_ListIteratorOfListIO.hxx" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_GEOMGenUtils.h" +#include "SMESHGUI_HypothesesUtils.h" + +#include "GEOMBase.h" #include "QAD_Application.h" #include "QAD_Desktop.h" @@ -37,6 +41,9 @@ using namespace std; #include "QAD_WaitCursor.h" #include "QAD_Operation.h" +#include "SALOME_ListIteratorOfListIO.hxx" +#include "SALOMEGUI_QtCatchCorbaException.hxx" + #include "utilities.h" // QT Includes @@ -47,6 +54,25 @@ using namespace std; #include #include +using namespace std; + +namespace SMESH{ + SMESH::SMESH_subMesh_var AddSubMesh(SMESH::SMESH_Mesh_ptr theMesh, + GEOM::GEOM_Object_ptr theShapeObject, + const char* theMeshName ) + { + SMESH::SMESH_subMesh_var aSubMesh; + try { + if ( !theMesh->_is_nil() && !theShapeObject->_is_nil() ) + aSubMesh = theMesh->GetSubMesh( theShapeObject, theMeshName ); + } + catch( const SALOME::SALOME_Exception& S_ex ) { + QtCatchCorbaException( S_ex ); + } + return aSubMesh._retn(); + } +} + //================================================================================= // class : SMESHGUI_AddSubMeshDlg() // purpose : Constructs a SMESHGUI_AddSubMeshDlg which is a child of 'parent', with the @@ -88,6 +114,7 @@ SMESHGUI_AddSubMeshDlg::SMESHGUI_AddSubMeshDlg( QWidget* parent, const char* nam SelectButtonC1A1->setToggleButton( FALSE ); GroupC1Layout->addWidget( SelectButtonC1A1, 1, 1 ); LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + LineEditC1A1->setReadOnly( true ); GroupC1Layout->addWidget( LineEditC1A1, 1, 2 ); TextLabelC1A2 = new QLabel( tr( "SMESH_OBJECT_GEOM" ), GroupC1, "TextLabelC1A2" ); @@ -97,6 +124,7 @@ SMESHGUI_AddSubMeshDlg::SMESHGUI_AddSubMeshDlg( QWidget* parent, const char* nam SelectButtonC1A2->setToggleButton( FALSE ); GroupC1Layout->addWidget( SelectButtonC1A2, 2, 1 ); LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" ); + LineEditC1A2->setReadOnly( true ); GroupC1Layout->addWidget( LineEditC1A2, 2, 2 ); TextLabelC1A1Hyp = new QLabel( tr( "SMESH_OBJECT_HYPOTHESIS" ), GroupC1, "TextLabelC1A1Hyp" ); @@ -105,6 +133,7 @@ SMESHGUI_AddSubMeshDlg::SMESHGUI_AddSubMeshDlg( QWidget* parent, const char* nam SelectButtonC1A1Hyp->setPixmap( image0 ); GroupC1Layout->addWidget( SelectButtonC1A1Hyp, 3, 1 ); LineEditC1A1Hyp = new QLineEdit( GroupC1, "LineEditC1A1Hyp" ); + LineEditC1A1Hyp->setReadOnly( true ); GroupC1Layout->addWidget( LineEditC1A1Hyp, 3, 2 ); TextLabelC1A1Algo = new QLabel( tr( "SMESH_OBJECT_ALGORITHM" ), GroupC1, "TextLabelC1A1Algo" ); @@ -113,6 +142,7 @@ SMESHGUI_AddSubMeshDlg::SMESHGUI_AddSubMeshDlg( QWidget* parent, const char* nam SelectButtonC1A1Algo->setPixmap( image0 ); GroupC1Layout->addWidget( SelectButtonC1A1Algo, 4, 1 ); LineEditC1A1Algo = new QLineEdit( GroupC1, "LineEditC1A1Algo" ); + LineEditC1A1Algo->setReadOnly( true ); GroupC1Layout->addWidget( LineEditC1A1Algo, 4, 2 ); SMESHGUI_AddSubMeshDlgLayout->addWidget( GroupC1, 1, 0 ); @@ -218,6 +248,9 @@ void SMESHGUI_AddSubMeshDlg::ClickOnOk() //================================================================================= bool SMESHGUI_AddSubMeshDlg::ClickOnApply() { + if (mySMESHGUI->ActiveStudyLocked()) + return false; + QString myNameSubMesh = LineEdit_NameMesh->text().stripWhiteSpace(); if ( myNameSubMesh.isEmpty() ) { QAD_MessageBox::warn1( this, tr( "SMESH_WRN_WARNING" ), tr( "SMESH_WRN_EMPTY_NAME" ), tr( "SMESH_BUT_OK" ) ); @@ -227,8 +260,8 @@ bool SMESHGUI_AddSubMeshDlg::ClickOnApply() if ( myMesh->_is_nil() || myGeomShape->_is_nil() || ( !HypoList.count() && !AlgoList.count() ) ) return false; - SALOMEDS::SObject_var aMeshSO = mySMESHGUI->GetStudyAPI().FindObject( myMesh ); - GEOM::GEOM_Shape_var myMainShape = mySMESHGUI->GetStudyAPI().GetShapeOnMeshOrSubMesh( aMeshSO ); + SALOMEDS::SObject_var aMeshSO = SMESH::FindSObject( myMesh ); + GEOM::GEOM_Object_var myMainShape = SMESH::GetShapeOnMeshOrSubMesh( aMeshSO ); if ( myMainShape->_is_nil() ) return false; @@ -240,45 +273,40 @@ bool SMESHGUI_AddSubMeshDlg::ClickOnApply() op->start(); // create submesh - SMESH::SMESH_subMesh_var aSubMesh = mySMESHGUI->AddSubMesh( myMesh, myGeomShape, myNameSubMesh ) ; + SMESH::SMESH_subMesh_var aSubMesh = SMESH::AddSubMesh( myMesh, myGeomShape, myNameSubMesh ) ; + int nbSuccess = 0; if ( !aSubMesh->_is_nil() ) { // assign hypotheses - for( int i = 0; i < HypoList.count(); i++ ) { - SALOMEDS::SObject_var aHypSO = mySMESHGUI->GetStudy()->FindObjectID( HypoList[i] ); + int nbAlgo = AlgoList.count(); + int nbHyps = HypoList.count() + nbAlgo; + for( int i = 0; i < nbHyps; i++ ) { + SALOMEDS::SObject_var aHypSO = SMESH::GetActiveStudyDocument()->FindObjectID + ( i < nbAlgo ? AlgoList[i] : HypoList[i-nbAlgo] ); if ( !aHypSO->_is_nil() ) { CORBA::Object_var anObject = aHypSO->GetObject(); if ( !CORBA::is_nil( anObject ) ) { SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject ); if ( !aHyp->_is_nil() ) - if ( !mySMESHGUI->AddHypothesisOnSubMesh( aSubMesh, aHyp ) ) { - // abort transaction - op->abort(); - return false; - } + if ( SMESH::AddHypothesisOnSubMesh( aSubMesh, aHyp ) ) + nbSuccess++; } + else { + SCRUTE( CORBA::is_nil( anObject )); + } } - } - // assign algorithms - for( int i = 0; i < AlgoList.count(); i++ ) { - SALOMEDS::SObject_var aHypSO = mySMESHGUI->GetStudy()->FindObjectID( AlgoList[i] ); - if ( !aHypSO->_is_nil() ) { - CORBA::Object_var anObject = aHypSO->GetObject(); - if ( !CORBA::is_nil( anObject ) ) { - SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject ); - if ( !aHyp->_is_nil() ) - if ( !mySMESHGUI->AddAlgorithmOnSubMesh( aSubMesh, aHyp ) ) { - // abort transaction - op->abort(); - return false; - } - } + else { + SCRUTE( aHypSO->_is_nil() ); } } } + else { + SCRUTE( aSubMesh->_is_nil() ); + } + // commit transaction op->finish(); - return true; + return ( nbSuccess > 0 ); } @@ -291,6 +319,11 @@ void SMESHGUI_AddSubMeshDlg::ClickOnCancel() close(); } +//======================================================================= +//function : IsFatherOf +//purpose : +//======================================================================= + static bool IsFatherOf( SALOMEDS::SObject_ptr SO, SALOMEDS::SObject_ptr fatherSO ) { if ( !SO->_is_nil() && !fatherSO->_is_nil() ) { SALOMEDS::SObject_var aSO = SO->GetFather(); @@ -309,10 +342,8 @@ static bool IsFatherOf( SALOMEDS::SObject_ptr SO, SALOMEDS::SObject_ptr fatherSO //================================================================================= void SMESHGUI_AddSubMeshDlg::SelectionIntoArgument() { - SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI(); QString aString = ""; - - int nbSel = mySMESHGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + int nbSel = SMESH::GetNameOfSelectedIObjects(mySelection, aString) ; if ( myEditCurrentArgument == LineEditC1A1 ) { // mesh @@ -321,37 +352,35 @@ void SMESHGUI_AddSubMeshDlg::SelectionIntoArgument() aString = ""; } else { - Standard_Boolean testResult ; Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; - myMesh = mySMESHGUI->ConvertIOinMesh(IO, testResult) ; - if( !testResult ) { - myMesh = SMESH::SMESH_Mesh::_nil(); + myMesh = SMESH::IObjectToInterface(IO) ; + if( myMesh->_is_nil() ) { aString = ""; } } - myGeomShape = GEOM::GEOM_Shape::_nil(); + myGeomShape = GEOM::GEOM_Object::_nil(); LineEditC1A2->setText( "" ); } else if ( myEditCurrentArgument == LineEditC1A2 ) { // geom shape if ( nbSel != 1 ) { - myGeomShape = GEOM::GEOM_Shape::_nil(); + myGeomShape = GEOM::GEOM_Object::_nil(); aString = ""; } else { - Standard_Boolean testResult ; Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; - myGeomShape = mySMESHGUI->ConvertIOinGEOMShape(IO, testResult) ; - if( !testResult ) { - myGeomShape = GEOM::GEOM_Shape::_nil(); - aString = ""; + myGeomShape = SMESH::IObjectToInterface(IO) ; + if( myGeomShape->_is_nil() || !GEOMBase::IsShape( myGeomShape ) ) + { + myGeomShape = GEOM::GEOM_Object::_nil(); + aString = ""; } if ( !myMesh->_is_nil() ) { - SALOMEDS::SObject_var aMeshSO = myStudyAPI.FindObject( myMesh ); - GEOM::GEOM_Shape_var aMainGeomShape = myStudyAPI.GetShapeOnMeshOrSubMesh( aMeshSO ); - SALOMEDS::SObject_var aMainGeomShapeSO = myStudyAPI.FindObject( aMainGeomShape ); - if ( aMainGeomShapeSO->_is_nil() || !IsFatherOf( mySMESHGUI->GetStudy()->FindObjectID( IO->getEntry() ), aMainGeomShapeSO ) ) { - myGeomShape = GEOM::GEOM_Shape::_nil(); + SALOMEDS::SObject_var aMeshSO = SMESH::FindSObject( myMesh ); + GEOM::GEOM_Object_var aMainGeomShape = SMESH::GetShapeOnMeshOrSubMesh( aMeshSO ); + SALOMEDS::SObject_var aMainGeomShapeSO = SMESH::FindSObject( aMainGeomShape ); + if ( aMainGeomShapeSO->_is_nil() || !IsFatherOf( SMESH::GetActiveStudyDocument()->FindObjectID( IO->getEntry() ), aMainGeomShapeSO ) ) { + myGeomShape = GEOM::GEOM_Object::_nil(); aString = ""; } } @@ -484,16 +513,11 @@ void SMESHGUI_AddSubMeshDlg::UpdateControlState() bool isEnabled = ( !myMesh->_is_nil() && !myGeomShape->_is_nil() && ( HypoList.count() || AlgoList.count() ) ); bool isImportedMesh = false; if ( !myMesh->_is_nil() ) { - SALOMEDS::SObject_var aMeshSO = mySMESHGUI->GetStudyAPI().FindObject( myMesh ); - GEOM::GEOM_Shape_var myGeomShape = mySMESHGUI->GetStudyAPI().GetShapeOnMeshOrSubMesh( aMeshSO ); + SALOMEDS::SObject_var aMeshSO = SMESH::FindSObject( myMesh ); + GEOM::GEOM_Object_var myGeomShape = SMESH::GetShapeOnMeshOrSubMesh( aMeshSO ); isImportedMesh = myGeomShape->_is_nil(); } buttonOk ->setEnabled( isEnabled && !isImportedMesh ); buttonApply->setEnabled( isEnabled && !isImportedMesh ); } - - - - - diff --git a/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.h b/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.h index a9e8d3efa..3ede5c043 100644 --- a/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.h +++ b/src/SMESHGUI/SMESHGUI_AddSubMeshDlg.h @@ -40,7 +40,6 @@ // IDL Headers #include #include CORBA_SERVER_HEADER(GEOM_Gen) -#include CORBA_SERVER_HEADER(GEOM_Shape) #include CORBA_SERVER_HEADER(SMESH_Mesh) class QGroupBox; @@ -75,7 +74,7 @@ private: SALOME_Selection* mySelection ; SMESH::SMESH_Mesh_var myMesh; - GEOM::GEOM_Shape_var myGeomShape ; + GEOM::GEOM_Object_var myGeomShape ; QLineEdit* myEditCurrentArgument; Handle(SALOME_TypeFilter) myGeomFilter; diff --git a/src/SMESHGUI/SMESHGUI_AddVolumeDlg.cxx b/src/SMESHGUI/SMESHGUI_AddVolumeDlg.cxx deleted file mode 100644 index 8953903d5..000000000 --- a/src/SMESHGUI/SMESHGUI_AddVolumeDlg.cxx +++ /dev/null @@ -1,406 +0,0 @@ -// SMESH SMESHGUI : GUI for SMESH component -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMESHGUI_AddVolumeDlg.cxx -// Author : Nicolas REJNERI -// Module : SMESH -// $Header$ - -using namespace std; -#include "SMESHGUI_AddVolumeDlg.h" - -#include "SMESHGUI.h" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_MessageBox.h" -#include "utilities.h" - -// QT Includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -//================================================================================= -// class : SMESHGUI_AddVolumeDlg() -// purpose : -//================================================================================= -SMESHGUI_AddVolumeDlg::SMESHGUI_AddVolumeDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, - int nbNodes, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) -{ - myNodes = nbNodes; - QPixmap image0; - if ( myNodes == 4 ) - image0 = QPixmap(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_TETRAS"))); - else if ( myNodes == 8 ) - image0 = QPixmap(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_HEXAS"))); - - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); - - if ( !name ) - setName( "SMESHGUI_AddVolumeDlg" ); - resize( 303, 185 ); - if ( myNodes == 4 ) - setCaption( tr( "SMESH_ADD_TETRAS_TITLE" ) ); - else if ( myNodes == 8 ) - setCaption( tr( "SMESH_ADD_HEXAS_TITLE" ) ); - - setSizeGripEnabled( TRUE ); - SMESHGUI_AddVolumeDlgLayout = new QGridLayout( this ); - SMESHGUI_AddVolumeDlgLayout->setSpacing( 6 ); - SMESHGUI_AddVolumeDlgLayout->setMargin( 11 ); - - /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - if ( myNodes == 4 ) - GroupConstructors->setTitle( tr( "SMESH_TETRAS" ) ); - else if ( myNodes == 8 ) - GroupConstructors->setTitle( tr( "SMESH_HEXAS" ) ); - - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); - Constructor1->setText( tr( "" ) ); - Constructor1->setPixmap( image0 ); - Constructor1->setChecked( TRUE ); - Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); - Constructor1->setMinimumSize( QSize( 50, 0 ) ); - GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer, 0, 1 ); - SMESHGUI_AddVolumeDlgLayout->addWidget( GroupConstructors, 0, 0 ); - - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_9, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - SMESHGUI_AddVolumeDlgLayout->addWidget( GroupButtons, 2, 0 ); - - /***************************************************************/ - GroupC1 = new QGroupBox( this, "GroupC1" ); - if ( myNodes == 4 ) - GroupC1->setTitle( tr( "SMESH_ADD_TETRAS" ) ); - else if ( myNodes == 8 ) - GroupC1->setTitle( tr( "SMESH_ADD_HEXAS" ) ); - - GroupC1->setMinimumSize( QSize( 0, 0 ) ); - GroupC1->setFrameShape( QGroupBox::Box ); - GroupC1->setFrameShadow( QGroupBox::Sunken ); - GroupC1->setColumnLayout(0, Qt::Vertical ); - GroupC1->layout()->setSpacing( 0 ); - GroupC1->layout()->setMargin( 0 ); - GroupC1Layout = new QGridLayout( GroupC1->layout() ); - GroupC1Layout->setAlignment( Qt::AlignTop ); - GroupC1Layout->setSpacing( 6 ); - GroupC1Layout->setMargin( 11 ); - TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); - TextLabelC1A1->setText( tr( "SMESH_ID_NODES" ) ); - TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A1->setFrameShape( QLabel::NoFrame ); - TextLabelC1A1->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); - SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); - SelectButtonC1A1->setText( tr( "" ) ); - SelectButtonC1A1->setPixmap( image1 ); - SelectButtonC1A1->setToggleButton( FALSE ); - GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); - LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); - GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); - - SMESHGUI_AddVolumeDlgLayout->addWidget( GroupC1, 1, 0 ); - - Init(Sel) ; /* Initialisations */ -} - -//================================================================================= -// function : ~SMESHGUI_AddVolumeDlg() -// purpose : Destroys the object and frees any allocated resources -//================================================================================= -SMESHGUI_AddVolumeDlg::~SMESHGUI_AddVolumeDlg() -{ - // no need to delete child widgets, Qt does it all for us -} - - -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void SMESHGUI_AddVolumeDlg::Init( SALOME_Selection* Sel ) -{ - - GroupC1->show(); - myConstructorId = 0 ; - Constructor1->setChecked( TRUE ); - myEditCurrentArgument = LineEditC1A1 ; - mySelection = Sel; - this->myOkNodes = false ; - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; - - /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); - - connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - /* to close dialog if study change */ - connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - - /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ - - SelectionIntoArgument(); - - return ; -} - - -//================================================================================= -// function : ConstructorsClicked() -// purpose : Radio button management -//================================================================================= -void SMESHGUI_AddVolumeDlg::ConstructorsClicked(int constructorId) -{ - return ; -} - - -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -void SMESHGUI_AddVolumeDlg::ClickOnApply() -{ - switch(myConstructorId) - { - case 0 : - { - if(myOkNodes) { - mySMESHGUI->EraseSimulationActors(); - mySMESHGUI->AddVolume( myMesh, myMapIndex ) ; - mySMESHGUI->ViewNodes(); - mySelection->ClearIObjects(); - } - break ; - } - } - return ; -} - -//================================================================================= -// function : ClickOnOk() -// purpose : -//================================================================================= -void SMESHGUI_AddVolumeDlg::ClickOnOk() -{ - this->ClickOnApply() ; - this->ClickOnCancel() ; - return ; -} - -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void SMESHGUI_AddVolumeDlg::ClickOnCancel() -{ - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - disconnect( mySelection, 0, this, 0 ); - mySMESHGUI->ResetState() ; - mySMESHGUI->EraseSimulationActors(); - reject() ; - return ; -} - - -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection as changed or other case -//================================================================================= -void SMESHGUI_AddVolumeDlg::SelectionIntoArgument() -{ - myEditCurrentArgument->setText("") ; - myOkNodes = false; - QString aString = ""; - - int nbSel = mySelection->IObjectCount(); - if(nbSel != 1) - return; - - int nbNodes = mySMESHGUI->GetNameOfSelectedNodes(mySelection, aString) ; - if(nbNodes < 1) - return ; - - if ( mySelection->SelectionMode() != NodeSelection ) { - QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), - tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_OK") ); - return; - } - - myEditCurrentArgument->setText(aString) ; - Standard_Boolean res; - myMesh = mySMESHGUI->ConvertIOinMesh( mySelection->firstIObject(), res ); - if (!res) - return ; - - mySelection->GetIndex( mySelection->firstIObject(), myMapIndex); - - if ( myNodes == 4 && nbNodes == 4 ) { - mySMESHGUI->DisplaySimulationTetra(myMesh, myMapIndex); - myOkNodes = true ; - } else if ( myNodes == 8 && nbNodes == 8 ) { - mySMESHGUI->DisplaySimulationHexa(myMesh, myMapIndex); - myOkNodes = true ; - } else { - // mySMESHGUI->EraseSimulationActors(); - myOkNodes = false ; - } - return ; -} - - -//================================================================================= -// function : SetEditCurrentArgument() -// purpose : -//================================================================================= -void SMESHGUI_AddVolumeDlg::SetEditCurrentArgument() -{ - QPushButton* send = (QPushButton*)sender(); - switch (myConstructorId) - { - case 0: /* default constructor */ - { - if(send == SelectButtonC1A1) { - LineEditC1A1->setFocus() ; - myEditCurrentArgument = LineEditC1A1; - } - SelectionIntoArgument() ; - break; - } - } - return ; -} - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void SMESHGUI_AddVolumeDlg::DeactivateActiveDialog() -{ - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupC1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - mySMESHGUI->EraseSimulationActors() ; - mySMESHGUI->ResetState() ; - mySMESHGUI->SetActiveDialogBox(0) ; - } - return ; -} - - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void SMESHGUI_AddVolumeDlg::ActivateThisDialog() -{ - /* Emit a signal to deactivate the active dialog */ - mySMESHGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupC1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - return ; -} - - -//================================================================================= -// function : enterEvent() -// purpose : -//================================================================================= -void SMESHGUI_AddVolumeDlg::enterEvent(QEvent* e) -{ - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; - return ; -} - - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void SMESHGUI_AddVolumeDlg::closeEvent( QCloseEvent* e ) -{ - /* same than click on cancel button */ - this->ClickOnCancel() ; - return ; -} - diff --git a/src/SMESHGUI/SMESHGUI_ClippingDlg.cxx b/src/SMESHGUI/SMESHGUI_ClippingDlg.cxx new file mode 100644 index 000000000..d98228dde --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_ClippingDlg.cxx @@ -0,0 +1,756 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_ClippingDlg.cxx +// Author : Nicolas REJNERI +// Module : SMESH +// $Header$ + +#include "SMESHGUI_ClippingDlg.h" + +#include "SMESHGUI.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" + +#include + +// QT Includes +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include "VTKViewer_ViewFrame.h" +#include "QAD_RightFrame.h" +#include "QAD_WaitCursor.h" +#include "SALOME_ListIteratorOfListIO.hxx" +#include "SMESH_Actor.h" +#include "SALOME_Selection.h" +#include "SALOME_InteractiveObject.hxx" +#include "SMESH_ActorUtils.h" + +using namespace std; + + +class OrientedPlane: public vtkPlane +{ + QAD_Study* myStudy; + QAD_StudyFrame* myStudyFrame; + VTKViewer_ViewFrame* myViewFrame; + + vtkDataSetMapper* myMapper; + + +public: + static OrientedPlane *New(){ + return new OrientedPlane(); + } + static OrientedPlane *New(QAD_Study* theStudy){ + return new OrientedPlane(theStudy); + } + vtkTypeMacro(OrientedPlane, vtkPlane); + + + SMESH::Orientation myOrientation; + float myDistance; + double myAngle[2]; + + vtkPlaneSource* myPlaneSource; + SALOME_Actor *myActor; + + void SetOrientation(SMESH::Orientation theOrientation) {myOrientation = theOrientation;} + SMESH::Orientation GetOrientation() {return myOrientation;} + + void SetDistance(float theDistance) {myDistance = theDistance;} + float GetDistance() {return myDistance;} + + void ShallowCopy(OrientedPlane* theOrientedPlane){ + SetNormal(theOrientedPlane->GetNormal()); + SetOrigin(theOrientedPlane->GetOrigin()); + + myOrientation = theOrientedPlane->GetOrientation(); + myDistance = theOrientedPlane->GetDistance(); + + myAngle[0] = theOrientedPlane->myAngle[0]; + myAngle[1] = theOrientedPlane->myAngle[1]; + + myPlaneSource->SetNormal(theOrientedPlane->myPlaneSource->GetNormal()); + myPlaneSource->SetOrigin(theOrientedPlane->myPlaneSource->GetOrigin()); + myPlaneSource->SetPoint1(theOrientedPlane->myPlaneSource->GetPoint1()); + myPlaneSource->SetPoint2(theOrientedPlane->myPlaneSource->GetPoint2()); + } + +protected: + OrientedPlane(QAD_Study* theStudy): + myOrientation(SMESH::XY), + myDistance(0.5), + myStudy(theStudy), + myStudyFrame(theStudy->getActiveStudyFrame()), + myViewFrame(SMESH::GetVtkViewFrame(theStudy->getActiveStudyFrame())) + { + Init(); + myViewFrame->AddActor( myActor ); + } + + OrientedPlane(): + myOrientation(SMESH::XY), + myDistance(0.5), + myStudy(NULL), + myStudyFrame(NULL), + myViewFrame(NULL) + { + Init(); + } + + void Init(){ + myPlaneSource = vtkPlaneSource::New(); + + myAngle[0] = myAngle[1] = 0.0; + + // Create and display actor + myMapper = vtkDataSetMapper::New(); + myMapper->SetInput( myPlaneSource->GetOutput() ); + + myActor = SALOME_Actor::New(); + myActor->VisibilityOff(); + myActor->PickableOff(); + myActor->SetInfinitive(true); + myActor->SetMapper( myMapper ); + + static float anOpacity = 0.75; + + vtkProperty* aProp = vtkProperty::New(); + float anRGB[3]; + anRGB[0] = SMESH::GetFloat("SMESH:SettingsFillColorRed", 0)/255.; + anRGB[1] = SMESH::GetFloat("SMESH:SettingsFillColorGreen", 170)/255.; + anRGB[2] = SMESH::GetFloat("SMESH:SettingsFillColorBlue", 255)/255.; + aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); + aProp->SetOpacity(0.75); + myActor->SetProperty( aProp ); + aProp->Delete(); + + vtkProperty* aBackProp = vtkProperty::New(); + anRGB[0] = SMESH::GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.; + anRGB[1] = SMESH::GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.; + anRGB[2] = SMESH::GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.; + aBackProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); + aBackProp->SetOpacity(0.75); + myActor->SetBackfaceProperty( aBackProp ); + aBackProp->Delete(); + } + + ~OrientedPlane(){ + if(myStudy && SMESH::FindVtkViewFrame(myStudy,myStudyFrame)){ + myViewFrame->RemoveActor(myActor); + } + myActor->Delete(); + + myMapper->RemoveAllInputs(); + myMapper->Delete(); + + myPlaneSource->UnRegisterAllOutputs(); + myPlaneSource->Delete(); + }; + +private: + // Not implemented. + OrientedPlane(const OrientedPlane&); + void operator=(const OrientedPlane&); + +}; + +struct TSetVisiblity{ + TSetVisiblity(int theIsVisible): myIsVisible(theIsVisible){} + void operator()(SMESH::TVTKPlane& theOrientedPlane){ + theOrientedPlane->myActor->SetVisibility(myIsVisible); + } + int myIsVisible; +}; + + +//================================================================================= +// class : SMESHGUI_ClippingDlg() +// purpose : +// +//================================================================================= +SMESHGUI_ClippingDlg::SMESHGUI_ClippingDlg( QWidget* parent, + const char* name, + bool modal, + WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose ) +{ + if ( !name ) + setName( "SMESHGUI_ClippingDlg" ); + setCaption( tr( "SMESH_CLIPPING_TITLE" ) ); + setSizeGripEnabled( TRUE ); + QGridLayout* SMESHGUI_ClippingDlgLayout = new QGridLayout( this ); + SMESHGUI_ClippingDlgLayout->setSpacing( 6 ); + SMESHGUI_ClippingDlgLayout->setMargin( 11 ); + + // Controls for selecting, creating, deleting planes + QGroupBox* GroupPlanes = new QGroupBox( this, "GroupPlanes" ); + GroupPlanes->setTitle( tr("Clipping planes") ); + GroupPlanes->setColumnLayout(0, Qt::Vertical); + GroupPlanes->layout()->setSpacing( 0 ); + GroupPlanes->layout()->setMargin( 0 ); + QGridLayout* GroupPlanesLayout = new QGridLayout( GroupPlanes->layout() ); + GroupPlanesLayout->setAlignment( Qt::AlignTop ); + GroupPlanesLayout->setSpacing( 6 ); + GroupPlanesLayout->setMargin( 11 ); + + ComboBoxPlanes = new QComboBox(GroupPlanes, "ComboBoxPlanes"); + GroupPlanesLayout->addWidget( ComboBoxPlanes, 0, 0 ); + + QSpacerItem* spacerGP = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupPlanesLayout->addItem( spacerGP, 0, 1 ); + + buttonNew = new QPushButton( GroupPlanes, "buttonNew" ); + buttonNew->setText( tr( "SMESH_BUT_NEW" ) ); + GroupPlanesLayout->addWidget( buttonNew, 0, 2 ); + + buttonDelete = new QPushButton( GroupPlanes, "buttonDelete" ); + buttonDelete->setText( tr( "SMESH_BUT_DELETE" ) ); + GroupPlanesLayout->addWidget( buttonDelete, 0, 3 ); + + // Controls for defining plane parameters + QGroupBox* GroupParameters = new QGroupBox( this, "GroupParameters" ); + GroupParameters->setTitle( tr("SMESH_PARAMETERS") ); + GroupParameters->setColumnLayout(0, Qt::Vertical); + GroupParameters->layout()->setSpacing( 0 ); + GroupParameters->layout()->setMargin( 0 ); + QGridLayout* GroupParametersLayout = new QGridLayout( GroupParameters->layout() ); + GroupParametersLayout->setAlignment( Qt::AlignTop ); + GroupParametersLayout->setSpacing( 6 ); + GroupParametersLayout->setMargin( 11 ); + + TextLabelOrientation = new QLabel( GroupParameters, "TextLabelOrientation" ); + TextLabelOrientation->setText( tr("SMESH_ORIENTATION") ); + GroupParametersLayout->addWidget( TextLabelOrientation, 0, 0 ); + + ComboBoxOrientation = new QComboBox(GroupParameters, "ComboBoxOrientation"); + GroupParametersLayout->addWidget( ComboBoxOrientation, 0, 1 ); + + TextLabelDistance = new QLabel( GroupParameters, "TextLabelDistance" ); + TextLabelDistance->setText( tr("SMESH_DISTANCE") ); + GroupParametersLayout->addWidget( TextLabelDistance, 1, 0 ); + + SpinBoxDistance = new SMESHGUI_SpinBox( GroupParameters, "SpinBoxDistance" ); + GroupParametersLayout->addWidget( SpinBoxDistance, 1, 1 ); + + TextLabelRot1 = new QLabel( GroupParameters, "TextLabelRot1" ); + TextLabelRot1->setText( tr("Rotation around X (Y to Z):") ); + GroupParametersLayout->addWidget( TextLabelRot1, 2, 0 ); + + SpinBoxRot1 = new SMESHGUI_SpinBox( GroupParameters, "SpinBoxRot1" ); + GroupParametersLayout->addWidget( SpinBoxRot1, 2, 1 ); + + TextLabelRot2 = new QLabel( GroupParameters, "TextLabelRot2" ); + TextLabelRot2->setText( tr("Rotation around Y (X to Z):") ); + GroupParametersLayout->addWidget( TextLabelRot2, 3, 0 ); + + SpinBoxRot2 = new SMESHGUI_SpinBox( GroupParameters, "SpinBoxRot2" ); + GroupParametersLayout->addWidget( SpinBoxRot2, 3, 1 ); + + PreviewCheckBox = new QCheckBox(tr("Show preview"), GroupParameters); + PreviewCheckBox->setChecked(true); + GroupParametersLayout->addWidget( PreviewCheckBox, 4, 0 ); + + AutoApplyCheckBox = new QCheckBox(tr("Auto Apply"), GroupParameters); + AutoApplyCheckBox->setChecked(false); + GroupParametersLayout->addWidget( AutoApplyCheckBox, 4, 1 ); + + // Controls for "Ok", "Apply" and "Close" button + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + + SMESHGUI_ClippingDlgLayout->addWidget( GroupPlanes, 0, 0 ); + SMESHGUI_ClippingDlgLayout->addWidget( GroupParameters, 1, 0 ); + SMESHGUI_ClippingDlgLayout->addWidget( GroupButtons, 2, 0 ); + + mySelection = SALOME_Selection::Selection( SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getSelection()); + + // Initial state + SpinBoxDistance->RangeStepAndValidator( 0.0, 1.0, 0.01, 3 ); + SpinBoxRot1->RangeStepAndValidator( -180.0, 180.0, 1, 3 ); + SpinBoxRot2->RangeStepAndValidator( -180.0, 180.0, 1, 3 ); + + ComboBoxOrientation->insertItem( tr("|| X-Y") ); + ComboBoxOrientation->insertItem( tr("|| Y-Z") ); + ComboBoxOrientation->insertItem( tr("|| Z-X") ); + + SpinBoxDistance->SetValue(0.5); + + myActor = 0; + myIsSelectPlane = false; + onSelectionChanged(); + + // signals and slots connections : + connect( ComboBoxPlanes, SIGNAL( activated( int )), this, SLOT( onSelectPlane( int ) ) ); + connect( buttonNew, SIGNAL( clicked() ), this, SLOT( ClickOnNew() ) ); + connect( buttonDelete, SIGNAL( clicked() ), this, SLOT( ClickOnDelete() ) ); + connect( ComboBoxOrientation, SIGNAL( activated( int )), this, SLOT( onSelectOrientation( int ) ) ); + connect( SpinBoxDistance, SIGNAL( valueChanged( double )), this, SLOT( SetCurrentPlaneParam() ) ); + connect( SpinBoxRot1, SIGNAL( valueChanged( double )), this, SLOT( SetCurrentPlaneParam() ) ); + connect( SpinBoxRot2, SIGNAL( valueChanged( double )), this, SLOT( SetCurrentPlaneParam() ) ); + connect( PreviewCheckBox, SIGNAL( toggled( bool )), this, SLOT( OnPreviewToggle( bool ) ) ); + connect( AutoApplyCheckBox, SIGNAL( toggled( bool )), this, SLOT( ClickOnApply() ) ); + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( SMESHGUI::GetSMESHGUI(), SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnOk() ) ) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionChanged() ) ); + /* to close dialog if study frame change */ + connect( SMESHGUI::GetSMESHGUI(), SIGNAL ( SignalStudyFrameChanged() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + SMESHGUI::GetSMESHGUI()->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show(); +} + + +//================================================================================= +// function : ~SMESHGUI_ClippingDlg() +// purpose : +//================================================================================= +SMESHGUI_ClippingDlg::~SMESHGUI_ClippingDlg() +{ + // no need to delete child widgets, Qt does it all for us + //cout<<"SMESHGUI_ClippingDlg::~SMESHGUI_ClippingDlg\n"; + std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(false)); + SMESH::GetCurrentVtkView()->Repaint(); +} + + +//======================================================================= +// function : ClickOnApply() +// purpose : +//======================================================================= +void SMESHGUI_ClippingDlg::ClickOnApply() +{ + if (!myActor) + return; + + if ( SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + QAD_WaitCursor wc; + + vtkImplicitBoolean* aBoolean = myActor->GetPlaneContainer(); + vtkImplicitFunctionCollection* aCollection = aBoolean->GetFunction(); + aCollection->RemoveAllItems(); + aBoolean->Modified(); // VTK bug + aCollection->InitTraversal(); + + SMESH::TPlanes::iterator anIter = myPlanes.begin(); + for (;anIter != myPlanes.end();anIter++){ + OrientedPlane* anOrientedPlane = OrientedPlane::New(); + anOrientedPlane->ShallowCopy(anIter->GetPointer()); + aCollection->AddItem(anOrientedPlane); + anOrientedPlane->Delete(); + } + + myActor->SetVisibility(myActor->GetVisibility()); + + SMESH::GetCurrentVtkView()->Repaint(); + } +} + + +//======================================================================= +// function : ClickOnOk() +// purpose : +//======================================================================= +void SMESHGUI_ClippingDlg::ClickOnOk() +{ + ClickOnApply() ; + ClickOnCancel() ; +} + + +//======================================================================= +// function : ClickOnCancel() +// purpose : +//======================================================================= +void SMESHGUI_ClippingDlg::ClickOnCancel() +{ + close(); +} + + +//================================================================================= +// function : onSelectionChanged() +// purpose : Called when selection is changed +//================================================================================= +void SMESHGUI_ClippingDlg::onSelectionChanged() +{ + if ( SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + if ( mySelection->IObjectCount() ) { + Handle(SALOME_InteractiveObject) IOS = mySelection->firstIObject(); + myActor = SMESH::FindActorByEntry(IOS->getEntry()); + if ( myActor ){ + vtkImplicitBoolean* aBoolean = myActor->GetPlaneContainer(); + vtkImplicitFunctionCollection* aCollection = aBoolean->GetFunction(); + aCollection->InitTraversal(); + std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(false)); + myPlanes.clear(); + while(vtkImplicitFunction* aFunction = aCollection->GetNextItem()){ + if(OrientedPlane* aPlane = OrientedPlane::SafeDownCast(aFunction)){ + OrientedPlane* anOrientedPlane = OrientedPlane::New(SMESH::GetActiveStudy()); + SMESH::TVTKPlane aTVTKPlane(anOrientedPlane); + anOrientedPlane->Delete(); + aTVTKPlane->ShallowCopy(aPlane); + myPlanes.push_back(aTVTKPlane); + } + } + std::for_each(myPlanes.begin(),myPlanes.end(), + TSetVisiblity(PreviewCheckBox->isChecked())); + } + } + } + Sinchronize(); + SMESH::GetCurrentVtkView()->Repaint(); +} + + +//======================================================================= +// function : onSelectPlane() +// purpose : +//======================================================================= +void SMESHGUI_ClippingDlg::onSelectPlane(int theIndex) +{ + if (!myActor || myPlanes.empty()) + return; + + OrientedPlane* aPlane = myPlanes[theIndex].GetPointer(); + + // Orientation + SMESH::Orientation anOrientation = aPlane->GetOrientation(); + + // Distance and Rotations + float aDistance; + double aRot[2] = {aPlane->myAngle[0], aPlane->myAngle[1]}; + + // Set plane parameters in the dialog + myIsSelectPlane = true; + setDistance(aPlane->GetDistance()); + setRotation(aRot[0], aRot[1]); + switch (anOrientation) { + case SMESH::XY: + ComboBoxOrientation->setCurrentItem(0); + onSelectOrientation(0); + break; + case SMESH::YZ: + ComboBoxOrientation->setCurrentItem(1); + onSelectOrientation(1); + break; + case SMESH::ZX: + ComboBoxOrientation->setCurrentItem(2); + onSelectOrientation(2); + break; + } + myIsSelectPlane = false; +} + + +//======================================================================= +// function : ClickOnNew() +// purpose : +//======================================================================= +void SMESHGUI_ClippingDlg::ClickOnNew() +{ + if (!myActor) + return; + + OrientedPlane* aPlane = OrientedPlane::New(SMESH::GetActiveStudy()); + SMESH::TVTKPlane aTVTKPlane(aPlane); + myPlanes.push_back(aTVTKPlane); + + if(PreviewCheckBox->isChecked()) + aTVTKPlane->myActor->VisibilityOn(); + + Sinchronize(); + SetCurrentPlaneParam(); +} + + +//======================================================================= +// function : ClickOnDelete() +// purpose : +//======================================================================= +void SMESHGUI_ClippingDlg::ClickOnDelete() +{ + if (!myActor || myPlanes.empty()) + return; + + int aPlaneIndex = ComboBoxPlanes->currentItem(); + + SMESH::TPlanes::iterator anIter = myPlanes.begin() + aPlaneIndex; + anIter->GetPointer()->myActor->SetVisibility(false); + myPlanes.erase(anIter); + + if(AutoApplyCheckBox->isChecked()) + ClickOnApply(); + + Sinchronize(); + SMESH::GetCurrentVtkView()->Repaint(); +} + + +//======================================================================= +// function : onSelectOrientation() +// purpose : +//======================================================================= +void SMESHGUI_ClippingDlg::onSelectOrientation(int theItem) +{ + if (myPlanes.empty()) + return; + + if (theItem == 0) { + TextLabelRot1->setText( tr( "Rotation around X (Y to Z):") ); + TextLabelRot2->setText( tr( "Rotation around Y (X to Z):" ) ); + } + else if (theItem == 1) { + TextLabelRot1->setText( tr( "Rotation around Y (Z to X):" ) ); + TextLabelRot2->setText( tr( "Rotation around Z (Y to X):" ) ); + } + else if (theItem == 2) { + TextLabelRot1->setText( tr( "Rotation around Z (X to Y):" ) ); + TextLabelRot2->setText( tr( "Rotation around X (Z to Y):" ) ); + } + + if((QComboBox*)sender() == ComboBoxOrientation) + SetCurrentPlaneParam(); +} + + +//======================================================================= +// function : Sinchronize() +// purpose : +//======================================================================= +void SMESHGUI_ClippingDlg::Sinchronize() +{ + int aNbPlanes = myPlanes.size(); + ComboBoxPlanes->clear(); + + QString aName; + for(int i = 1; i<=aNbPlanes ; i++){ + aName = QString(tr("Plane# %1")).arg(i); + ComboBoxPlanes->insertItem(aName); + } + + int aPos = ComboBoxPlanes->count() - 1; + ComboBoxPlanes->setCurrentItem(aPos); + + bool anIsControlsEnable = (aPos >= 0); + if(anIsControlsEnable){ + onSelectPlane(aPos); + }else{ + ComboBoxPlanes->insertItem( tr("No planes") ); + SpinBoxRot1->SetValue(0.0); + SpinBoxRot2->SetValue(0.0); + SpinBoxDistance->SetValue(0.5); + } + + buttonDelete->setEnabled(anIsControlsEnable); + buttonApply->setEnabled(anIsControlsEnable); + PreviewCheckBox->setEnabled(anIsControlsEnable); + AutoApplyCheckBox->setEnabled(anIsControlsEnable); + ComboBoxOrientation->setEnabled(anIsControlsEnable); + SpinBoxDistance->setEnabled(anIsControlsEnable); + SpinBoxRot1->setEnabled(anIsControlsEnable); + SpinBoxRot2->setEnabled(anIsControlsEnable); +} + + +//======================================================================= +// function : setRotation() +// purpose : +//======================================================================= +void SMESHGUI_ClippingDlg::setRotation( const double theRot1, const double theRot2 ) +{ + SpinBoxRot1->SetValue(theRot1); + SpinBoxRot2->SetValue(theRot2); +} + + +//======================================================================= +// function : SetCurrentPlaneParam +// purpose : +//======================================================================= +void SMESHGUI_ClippingDlg::SetCurrentPlaneParam() +{ + if(myPlanes.empty() || myIsSelectPlane) + return; + + int aCurPlaneIndex = ComboBoxPlanes->currentItem(); + + OrientedPlane* aPlane = myPlanes[aCurPlaneIndex].GetPointer(); + + float aNormal[3]; + SMESH::Orientation anOrientation; + float aDir[3][3] = {{0, 0, 0}, {0, 0, 0}}; + { + static double aCoeff = vtkMath::Pi()/180.0; + + float aRot[2] = {getRotation1(), getRotation2()}; + aPlane->myAngle[0] = aRot[0]; + aPlane->myAngle[1] = aRot[1]; + + float anU[2] = {cos(aCoeff*aRot[0]), cos(aCoeff*aRot[1])}; + float aV[2] = {sqrt(1.0-anU[0]*anU[0]), sqrt(1.0-anU[1]*anU[1])}; + aV[0] = aRot[0] > 0? aV[0]: -aV[0]; + aV[1] = aRot[1] > 0? aV[1]: -aV[1]; + + switch (ComboBoxOrientation->currentItem()) { + case 0: + anOrientation = SMESH::XY; + + aDir[0][1] = anU[0]; + aDir[0][2] = aV[0]; + + aDir[1][0] = anU[1]; + aDir[1][2] = aV[1]; + + break; + case 1: + anOrientation = SMESH::YZ; + + aDir[0][2] = anU[0]; + aDir[0][0] = aV[0]; + + aDir[1][1] = anU[1]; + aDir[1][0] = aV[1]; + + break; + case 2: + anOrientation = SMESH::ZX; + + aDir[0][0] = anU[0]; + aDir[0][1] = aV[0]; + + aDir[1][2] = anU[1]; + aDir[1][1] = aV[1]; + + break; + } + + vtkMath::Cross(aDir[1],aDir[0],aNormal); + vtkMath::Normalize(aNormal); + vtkMath::Cross(aNormal,aDir[1],aDir[0]); + } + + aPlane->SetOrientation(anOrientation); + aPlane->SetDistance(getDistance()); + + myActor->SetPlaneParam(aNormal, getDistance(), aPlane); + + float* anOrig = aPlane->GetOrigin(); + vtkDataSet* aDataSet = myActor->GetInput(); + float *aPnt = aDataSet->GetCenter(); + + float* anOrigin = aPlane->GetOrigin(); + float aDel = aDataSet->GetLength()/2.0; + + float aDelta[2][3] = {{aDir[0][0]*aDel, aDir[0][1]*aDel, aDir[0][2]*aDel}, + {aDir[1][0]*aDel, aDir[1][1]*aDel, aDir[1][2]*aDel}}; + float aParam, aPnt0[3], aPnt1[3], aPnt2[3]; + + float aPnt01[3] = {aPnt[0] - aDelta[0][0] - aDelta[1][0], + aPnt[1] - aDelta[0][1] - aDelta[1][1], + aPnt[2] - aDelta[0][2] - aDelta[1][2]}; + float aPnt02[3] = {aPnt01[0] + aNormal[0], + aPnt01[1] + aNormal[1], + aPnt01[2] + aNormal[2]}; + vtkPlane::IntersectWithLine(aPnt01,aPnt02,aNormal,anOrigin,aParam,aPnt0); + + float aPnt11[3] = {aPnt[0] - aDelta[0][0] + aDelta[1][0], + aPnt[1] - aDelta[0][1] + aDelta[1][1], + aPnt[2] - aDelta[0][2] + aDelta[1][2]}; + float aPnt12[3] = {aPnt11[0] + aNormal[0], + aPnt11[1] + aNormal[1], + aPnt11[2] + aNormal[2]}; + vtkPlane::IntersectWithLine(aPnt11,aPnt12,aNormal,anOrigin,aParam,aPnt1); + + float aPnt21[3] = {aPnt[0] + aDelta[0][0] - aDelta[1][0], + aPnt[1] + aDelta[0][1] - aDelta[1][1], + aPnt[2] + aDelta[0][2] - aDelta[1][2]}; + float aPnt22[3] = {aPnt21[0] + aNormal[0], + aPnt21[1] + aNormal[1], + aPnt21[2] + aNormal[2]}; + vtkPlane::IntersectWithLine(aPnt21,aPnt22,aNormal,anOrigin,aParam,aPnt2); + + vtkPlaneSource* aPlaneSource = aPlane->myPlaneSource; + aPlaneSource->SetNormal(aNormal[0],aNormal[1],aNormal[2]); + aPlaneSource->SetOrigin(aPnt0[0],aPnt0[1],aPnt0[2]); + aPlaneSource->SetPoint1(aPnt1[0],aPnt1[1],aPnt1[2]); + aPlaneSource->SetPoint2(aPnt2[0],aPnt2[1],aPnt2[2]); + + if(AutoApplyCheckBox->isChecked()) + ClickOnApply(); + + SMESH::GetCurrentVtkView()->Repaint(); +} + + +void SMESHGUI_ClippingDlg::OnPreviewToggle(bool theIsToggled){ + std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(theIsToggled)); + SMESH::GetCurrentVtkView()->Repaint(); +} diff --git a/src/SMESHGUI/SMESHGUI_ClippingDlg.h b/src/SMESHGUI/SMESHGUI_ClippingDlg.h new file mode 100644 index 000000000..6a2bb493f --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_ClippingDlg.h @@ -0,0 +1,126 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_TransparencyDlg.h +// Author : Nicolas REJNERI +// Module : SMESH +// $Header$ + +#ifndef DIALOGBOX_CLIPPING_H +#define DIALOGBOX_CLIPPING_H + +#include + +#include +#include + +#include + +// QT Includes +#include +#include + +class QLabel; +class QPushButton; +class QTable; +class QCheckBox; +class QComboBox; +class SALOME_Selection; +class SMESH_Actor; + +class OrientedPlane; + + +namespace SMESH{ + + typedef vtkSmartPointer TVTKPlane; + typedef std::vector TPlanes; + enum Orientation {XY, YZ, ZX}; + +}; + + +//================================================================================= +// class : SMESHGUI_ClippingDlg +// purpose : +//================================================================================= +class SMESHGUI_ClippingDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_ClippingDlg( QWidget* parent = 0, + const char* name = 0, + bool modal = false, + WFlags fl = 0 ); + + float getDistance() {return (float)SpinBoxDistance->GetValue();} + void setDistance( const float theDistance) {SpinBoxDistance->SetValue(theDistance);} + double getRotation1() {return SpinBoxRot1->GetValue();} + double getRotation2() {return SpinBoxRot2->GetValue();} + void setRotation( const double theRot1, const double theRot2 ); + void Sinchronize(); + + ~SMESHGUI_ClippingDlg(); + +private: + + SALOME_Selection* mySelection; + SMESH_Actor* myActor; + SMESH::TPlanes myPlanes; + + QComboBox* ComboBoxPlanes; + QPushButton* buttonNew; + QPushButton* buttonDelete; + QLabel* TextLabelOrientation; + QComboBox* ComboBoxOrientation; + QLabel* TextLabelDistance; + SMESHGUI_SpinBox* SpinBoxDistance; + QLabel* TextLabelRot1; + SMESHGUI_SpinBox* SpinBoxRot1; + QLabel* TextLabelRot2; + SMESHGUI_SpinBox* SpinBoxRot2; + QCheckBox* PreviewCheckBox; + QCheckBox* AutoApplyCheckBox; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + + bool myIsSelectPlane; + +public slots: + + void onSelectPlane(int theIndex); + void ClickOnNew(); + void ClickOnDelete(); + void onSelectOrientation(int theItem); + void SetCurrentPlaneParam(); + void onSelectionChanged(); + void OnPreviewToggle(bool theIsToggled); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); +}; + +#endif // DIALOGBOX_TRANSPARENCYDLG_H + diff --git a/src/SMESHGUI/SMESHGUI_ComputeScalarValue.cxx b/src/SMESHGUI/SMESHGUI_ComputeScalarValue.cxx deleted file mode 100644 index 87a0254ee..000000000 --- a/src/SMESHGUI/SMESHGUI_ComputeScalarValue.cxx +++ /dev/null @@ -1,425 +0,0 @@ -// SMESH SMESHGUI : GUI for SMESH component -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMESHGUI_ComputeScalarValue.cxx -// Author : Nicolas REJNERI -// Module : SMESH -// $Header$ - -using namespace std; -#include "SMESHGUI_ComputeScalarValue.h" -#include "utilities.h" -#include - -//============================================================================= -/*! - * - */ -//============================================================================= -static double ComputeLength(float* p1, float* p2) { - float a1,a2,a3,b1,b2,b3; - a1 = p1[0]; - a2 = p1[1]; - a3 = p1[2]; - b1 = p2[0]; - b2 = p2[1]; - b3 = p2[2]; - // MESSAGE( a1 << " "<< a2 << " "<< a3 << " " << b1 << " "<< b2 << " "<< b3 ); - float X1,Y1,Z1,X2,Z2,Y2; - X1 = b1 - a1; - Y1 = b2 - a2; - Z1 = b3 - a3; - // MESSAGE( X1 << " "<< Y1 << " "<< Z1 ); - float e1; - e1 = sqrt( X1*X1 + Y1*Y1 + Z1*Z1 ) ; - // MESSAGE( "Length = " << e1 ); - return e1; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -double SMESHGUI_ComputeScalarValue::LengthEdges(vtkCell* theCell) { - int num_points = theCell->GetNumberOfPoints (); - vtkPoints* points = theCell->GetPoints(); - if (num_points != 2 ) return 0; - float* pnt1 = points->GetPoint(0); - float* pnt2 = points->GetPoint(1); - return ComputeLength(pnt1,pnt2); -}; - -//============================================================================= -/*! - * - */ -//============================================================================= -static double ComputeAreaOfTriangle(float* p1, float* p2, float* p3) { - double a1,a2,a3,b1,b2,b3,c1,c2,c3; - a1 = p1[0]; - a2 = p1[1]; - a3 = p1[2]; - b1 = p2[0]; - b2 = p2[1]; - b3 = p2[2]; - c1 = p3[0]; - c2 = p3[1]; - c3 = p3[2]; - - float e1, e2, e3; - e1 = sqrt( (a1-b1)*(a1-b1) + (a2-b2)*(a2-b2) + (a3-b3)*(a3-b3) ) ; - e2 = sqrt( (b1-c1)*(b1-c1) + (b2-c2)*(b2-c2) + (b3-c3)*(b3-c3) ) ; - e3 = sqrt( (c1-a1)*(c1-a1) + (c2-a2)*(c2-a2) + (c3-a3)*(c3-a3) ) ; - - // MESSAGE( "e = " << e1 << " " << e2 <<" " << e3 ); - float s = (e1+e2+e3)/2; - double area = sqrt(s*(s-e1)*(s-e2)*(s-e3)); - // MESSAGE( "area = " << area ); - return area; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -double SMESHGUI_ComputeScalarValue::AreaElements(vtkCell* theCell){ - // MESSAGE ( " SMESHGUI_ComputeScalarValue::AreaElements " ) - int num_points = theCell->GetNumberOfPoints (); - vtkPoints* points = theCell->GetPoints(); - // MESSAGE( "num_points = "<< num_points ); - for (int j = 0; j < theCell->GetNumberOfPoints (); j++) { - float* pnt = points->GetPoint(j); - // MESSAGE( pnt[0] << " " << pnt[1] << " " << pnt[2] ); - } - if (num_points < 3 ) return 0; - if (num_points == 3) { - float* p1 = points->GetPoint(0); - float* p2 = points->GetPoint(1); - float* p3 = points->GetPoint(2); - double area = ComputeAreaOfTriangle(p1,p2,p3); - return area; - } else if (num_points == 4) { - float* p1 = points->GetPoint(0); - float* p2 = points->GetPoint(1); - float* p3 = points->GetPoint(2); - float* p4 = points->GetPoint(3); - double area1 = ComputeAreaOfTriangle(p1,p2,p3); - double area2 = ComputeAreaOfTriangle(p3,p4,p1); - return area1+area2; - } -}; - -//============================================================================= -/*! - * - */ -//============================================================================= -double SMESHGUI_ComputeScalarValue::Taper(vtkCell* theCell){ - int num_points = theCell->GetNumberOfPoints (); - vtkPoints* points = theCell->GetPoints(); - if (num_points != 4 ) return 0; - float* p1 = points->GetPoint(0); - float* p2 = points->GetPoint(1); - float* p3 = points->GetPoint(2); - float* p4 = points->GetPoint(3); - double A1 = ComputeAreaOfTriangle(p4,p1,p2); - double A2 = ComputeAreaOfTriangle(p3,p1,p2); - double A3 = ComputeAreaOfTriangle(p2,p3,p4); - double A4 = ComputeAreaOfTriangle(p3,p4,p1); - double JA = 0.25 * (A1 + A2 + A3 + A4); - double taper = fabs(A1/(JA-1)); - if (fabs(A2/(JA-1)) > taper) taper = fabs(A2/(JA-1)); - if (fabs(A3/(JA-1)) > taper) taper = fabs(A3/(JA-1)); - if (fabs(A4/(JA-1)) > taper) taper = fabs(A4/(JA-1)); - // MESSAGE( "Taper = " << taper); - return taper; -}; - -//============================================================================= -/*! - * - */ -//============================================================================= -double SMESHGUI_ComputeScalarValue::AspectRatio(vtkCell* theCell) { - int num_points = theCell->GetNumberOfPoints (); - vtkPoints* points = theCell->GetPoints(); - if (num_points < 3 ) return 0; - if (num_points == 3) { - float a1,a2,a3,b1,b2,b3,c1,c2,c3; - float* pnt = points->GetPoint(0); - a1 = pnt[0]; - a2 = pnt[1]; - a3 = pnt[2]; - pnt = points->GetPoint(1); - b1 = pnt[0]; - b2 = pnt[1]; - b3 = pnt[2]; - pnt = points->GetPoint(2); - c1 = pnt[0]; - c2 = pnt[1]; - c3 = pnt[2]; - - float e1, e2, e3; - e1 = sqrt( (a1-b1)*(a1-b1) + (a2-b2)*(a2-b2) + (a3-b3)*(a3-b3) ) ; - e2 = sqrt( (b1-c1)*(b1-c1) + (b2-c2)*(b2-c2) + (b3-c3)*(b3-c3) ) ; - e3 = sqrt( (c1-a1)*(c1-a1) + (c2-a2)*(c2-a2) + (c3-a3)*(c3-a3) ) ; - - float amax,p,s; - - amax=e1; - if (e2>amax) amax=e2; - if (e3>amax) amax=e3; - - p=(e1+e2+e3)/2; - s=AreaElements(theCell); - - double aspectRatio=amax*p*sqrt(double(3))/(s*6); - // MESSAGE( "aspectRatio = " << aspectRatio ); - return(aspectRatio); - } - else if (num_points == 4) { - float a1,a2,a3,b1,b2,b3,c1,c2,c3,d1,d2,d3; - float* pnt = points->GetPoint(0); - a1 = pnt[0]; - a2 = pnt[1]; - a3 = pnt[2]; - pnt = points->GetPoint(1); - b1 = pnt[0]; - b2 = pnt[1]; - b3 = pnt[2]; - pnt = points->GetPoint(2); - c1 = pnt[0]; - c2 = pnt[1]; - c3 = pnt[2]; - pnt = points->GetPoint(3); - d1 = pnt[0]; - d2 = pnt[1]; - d3 = pnt[2]; - - float e1, e2, e3, e4; - float len_min, len_max; - e1 = sqrt( (a1-b1)*(a1-b1) + (a2-b2)*(a2-b2) + (a3-b3)*(a3-b3) ) ; - e2 = sqrt( (b1-c1)*(b1-c1) + (b2-c2)*(b2-c2) + (b3-c3)*(b3-c3) ) ; - e3 = sqrt( (c1-d1)*(c1-d1) + (c2-d2)*(c2-d2) + (c3-d3)*(c3-d3) ) ; - e4 = sqrt( (d1-a1)*(d1-a1) + (d2-a2)*(d2-a2) + (d3-a3)*(d3-a3) ) ; - - len_min = e1; len_max = e1; - - if (e2 >len_max ) len_max = e2; - if (e3 >len_max ) len_max = e3; - if (e4 >len_max ) len_max = e4; - if (e2 GetNumberOfPoints (); - vtkPoints* points = theCell->GetPoints(); - if (num_points < 3 ) return 0; - float* pnt1 = points->GetPoint(0); - float* pnt2 = points->GetPoint(1); - float* pnt3 = points->GetPoint(2); - if (num_points == 3) { - double a1,a2,a3,amin; - a1=fabs(ComputeAngle(pnt1,pnt2,pnt3)); - amin=a1; - a2=fabs(ComputeAngle(pnt2,pnt3,pnt1)); - if (a2GetPoint(3); - double a1,a2,a3,a4,amin; - a1=fabs(ComputeAngle(pnt1,pnt2,pnt3)); - amin=a1; - a2=fabs(ComputeAngle(pnt2,pnt3,pnt4)); - if (a2GetNumberOfPoints (); - vtkPoints* points = theCell->GetPoints(); - if (num_points < 3 ) return 0; - //triangle case - if (num_points == 3) { - float* pnt1 = points->GetPoint(0); - float* pnt2 = points->GetPoint(1); - float* pnt3 = points->GetPoint(2); - double a1,a2,a3,amax; - a1=fabs(60 - fabs(ComputeAngle(pnt1,pnt2,pnt3))); - amax=a1; - a2=fabs(60 - fabs(ComputeAngle(pnt2,pnt3,pnt1))); - if (a2>amax) amax=a2; - a3=fabs(60 - fabs(ComputeAngle(pnt3,pnt1,pnt2))); - if (a3>amax) amax=a3; - // MESSAGE( "Skew = " << amax ); - return amax; - } - //quadrangle case - else if (num_points == 4) { - float* pnt1 = points->GetPoint(0); - float* pnt2 = points->GetPoint(1); - float* pnt3 = points->GetPoint(2); - float* pnt4 = points->GetPoint(3); - - double a1,a2,a3,a4,amax; - a1=fabs(90 - fabs(ComputeAngle(pnt1,pnt2,pnt3))); - amax=a1; - a2=fabs(90 - fabs(ComputeAngle(pnt2,pnt3,pnt4))); - if (a2>amax) amax=a2; - a3=fabs(90 - fabs(ComputeAngle(pnt3,pnt4,pnt1))); - if (a3>amax) amax=a3; - a4=fabs(90 - fabs(ComputeAngle(pnt4,pnt1,pnt2))); - if (a4>amax) amax=a4; - // MESSAGE( "Skew = " << amax ); - return amax; - } -}; - -//============================================================================= -/*! - * - */ -//============================================================================= -static double ComputeA(float* p1, float* p2, float* p3, float* G) { - double e1 = sqrt(pow(p2[0]-p1[0], 2)+pow(p2[1]-p1[1], 2)+pow(p2[2]-p1[2], 2)); - double e2 = sqrt(pow(p3[0]-p2[0], 2)+pow(p3[1]-p2[1], 2)+pow(p3[2]-p2[2], 2)); - double l; - if (e1 < e2) l = 0.5*e1; - else l = 0.5*e2; - float GI[3], GJ[3], N[3];; - GI[0] = (p2[0]-p1[0])/2-G[0]; - GI[1] = (p2[1]-p1[1])/2-G[1]; - GI[2] = (p2[2]-p1[2])/2-G[2]; - - GJ[0] = (p3[0]-p2[0])/2-G[0]; - GJ[1] = (p3[1]-p2[1])/2-G[1]; - GJ[2] = (p3[2]-p2[2])/2-G[2]; - - N[0] = GI[1]*GJ[2] - GI[2]*GJ[1]; - N[1] = GI[2]*GJ[0] - GI[0]*GJ[2]; - N[2] = GI[0]*GJ[1] - GI[1]*GJ[0]; - - double H; - float T[3]; - T[0] = (p1[0]-G[0])*N[0]; - T[1] = (p1[1]-G[1])*N[1]; - T[2] = (p1[2]-G[2])*N[2]; - - H = sqrt(pow(T[0],2)+pow(T[1],2)+pow(T[2],2))/sqrt(pow(N[0],2)+pow(N[1],2)+pow(N[2],2)); - double A = H/l; - return A; -} - -//============================================================================= -/*! - * - */ -//============================================================================= -double SMESHGUI_ComputeScalarValue::Warp(vtkCell* theCell) { - int num_points = theCell->GetNumberOfPoints (); - vtkPoints* points = theCell->GetPoints(); - if (num_points != 4 ) return 0; - float* p1 = points->GetPoint(0); - float* p2 = points->GetPoint(1); - float* p3 = points->GetPoint(2); - float* p4 = points->GetPoint(3); - double G1, G2, G3; - float G[3]; - G[0] = (p1[0]+p2[0]+p3[0]+p4[0])/4; - G[1] = (p1[1]+p2[1]+p3[1]+p4[1])/4; - G[2] = (p1[2]+p2[2]+p3[2]+p4[2])/4; - double amax = ComputeA(p1, p2, p3, G); - double nextA = ComputeA(p2, p3, p4, G); - if (nextA > amax) amax = nextA; - nextA = ComputeA(p3, p4, p1, G); - if (nextA > amax) amax = nextA; - nextA = ComputeA(p4, p1, p2, G); - if (nextA > amax) amax = nextA; - // MESSAGE( "Warp = " << amax ); - return amax; -} diff --git a/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.cxx b/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.cxx index fd494fb60..19d6b90fa 100644 --- a/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.cxx @@ -25,15 +25,6 @@ // Module : SMESH // $Header$ -using namespace std; -#include "SMESHGUI_CreateHypothesesDlg.h" -#include "SMESHGUI.h" -#include "SALOME_ListIteratorOfListIO.hxx" - -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "utilities.h" - // QT Includes #include #include @@ -42,6 +33,21 @@ using namespace std; #include #include +#include "QAD_Application.h" +#include "QAD_Desktop.h" + +#include "SALOME_ListIteratorOfListIO.hxx" + +#include "SMESHGUI_CreateHypothesesDlg.h" +#include "SMESHGUI_HypothesesUtils.h" +#include "SMESHGUI_Hypotheses.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI.h" + +#include "utilities.h" + +using namespace std; + //================================================================================= // class : SMESHGUI_CreateHypothesesDlg() // purpose : Constructs a SMESHGUI_CreateHypothesesDlg which is a child of 'parent', with the @@ -175,6 +181,8 @@ void SMESHGUI_CreateHypothesesDlg::ClickOnCancel() //================================================================================= void SMESHGUI_CreateHypothesesDlg::ClickOnApply() { + if (mySMESHGUI->ActiveStudyLocked()) + return; QListViewItem* item = ListAlgoDefinition->selectedItem(); if ( !item ) return; @@ -182,7 +190,7 @@ void SMESHGUI_CreateHypothesesDlg::ClickOnApply() MESSAGE("Apply " << aHypType); char* sHypType = (char*)aHypType.latin1(); - HypothesisData* aHypData = mySMESHGUI->GetHypothesisData(sHypType); + HypothesisData* aHypData = SMESH::GetHypothesisData(sHypType); if ( !aHypData ) return; QString aClientLibName = aHypData->ClientLibName; @@ -192,13 +200,13 @@ void SMESHGUI_CreateHypothesesDlg::ClickOnApply() { // Call hypothesis creation server method (without GUI) QString aHypName = aHypData->Label; - mySMESHGUI->CreateHypothesis(sHypType, aHypName, myIsAlgo); + SMESH::CreateHypothesis(sHypType, aHypName, myIsAlgo); } else { // Get hypotheses creator client (GUI) SMESHGUI_GenericHypothesisCreator* aCreator = - mySMESHGUI->GetHypothesisCreator(sHypType); + SMESH::GetHypothesisCreator(sHypType); // Create hypothesis/algorithm aCreator->CreateHypothesis(myIsAlgo, this); @@ -266,9 +274,9 @@ void SMESHGUI_CreateHypothesesDlg::onDoubleClicked(QListViewItem* i) void SMESHGUI_CreateHypothesesDlg::InitAlgoDefinition() { ListAlgoDefinition->clear(); - QStringList HypList = mySMESHGUI->GetAvailableHypotheses(myIsAlgo); + QStringList HypList = SMESH::GetAvailableHypotheses(myIsAlgo); for ( int i = 0; i < HypList.count(); ++i ) { - HypothesisData* aHypData = mySMESHGUI->GetHypothesisData( HypList[i] ); + HypothesisData* aHypData = SMESH::GetHypothesisData( HypList[i] ); QListViewItem* parentItem = 0; QListViewItem* childItem = ListAlgoDefinition->firstChild(); while ( childItem ) { diff --git a/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.h b/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.h index 4fa446d5c..e3ee5a9ce 100644 --- a/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.h +++ b/src/SMESHGUI/SMESHGUI_CreateHypothesesDlg.h @@ -36,14 +36,11 @@ // IDL Headers #include #include CORBA_SERVER_HEADER(GEOM_Gen) -#include CORBA_SERVER_HEADER(GEOM_Shape) #include CORBA_SERVER_HEADER(SMESH_Mesh) #include #include -using namespace std; - class QButtonGroup; class QGroupBox; class QPushButton; diff --git a/src/SMESHGUI/SMESHGUI_CreatePatternDlg.cxx b/src/SMESHGUI/SMESHGUI_CreatePatternDlg.cxx new file mode 100755 index 000000000..3e63d654f --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_CreatePatternDlg.cxx @@ -0,0 +1,797 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_CreatePatternDlg.cxx +// Author : Sergey LITONIN +// Module : SMESH + +#include "SMESHGUI_CreatePatternDlg.h" + +#include "QAD_Desktop.h" +#include "QAD_FileDlg.h" + +#include "SMESHGUI_PatternWidget.h" +#include "SMESHGUI_SpinBox.h" +#include "SMESHGUI.h" +#include "SALOME_Selection.h" +#include "SALOME_ListIteratorOfListOfFilter.hxx" +#include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "SMESH_NumberFilter.hxx" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_PatternUtils.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SPACING 5 +#define MARGIN 10 + +/* + Class : SMESHGUI_CreatePatternDlg + Description : Dialog to specify filters for VTK viewer +*/ + +//======================================================================= +// name : SMESHGUI_CreatePatternDlg::SMESHGUI_CreatePatternDlg +// Purpose : Constructor +//======================================================================= +SMESHGUI_CreatePatternDlg::SMESHGUI_CreatePatternDlg( QWidget* theParent, + SALOME_Selection* theSelection, + const int theType, + const char* theName ) +: QDialog( theParent, theName, false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + setCaption( tr( "CAPTION" ) ); + + QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); + + QFrame* aMainFrame = createMainFrame ( this ); + QFrame* aBtnFrame = createButtonFrame( this ); + + aDlgLay->addWidget( aMainFrame ); + aDlgLay->addWidget( aBtnFrame ); + + aDlgLay->setStretchFactor( aMainFrame, 1 ); + + Init( theSelection, theType ); +} + +//======================================================================= +// name : SMESHGUI_CreatePatternDlg::createMainFrame +// Purpose : Create frame containing dialog's input fields +//======================================================================= +QFrame* SMESHGUI_CreatePatternDlg::createMainFrame( QWidget* theParent ) +{ + QPixmap iconSlct( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_SELECT" ) ) ); + QPixmap icon2d ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_2d" ) ) ); + QPixmap icon3d ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_3d" ) ) ); + + QPixmap iconSample2d( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_SAMPLE_2D" ) ) ); + + QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Horizontal, theParent ); + aMainGrp->setFrameStyle( QFrame::NoFrame ); + aMainGrp->setInsideMargin( 0 ); + + // Pattern type group + + myTypeGrp = new QButtonGroup( 1, Qt::Vertical, tr( "PATTERN_TYPE" ), aMainGrp ); + mySwitch2d = new QRadioButton( myTypeGrp ); + mySwitch3d = new QRadioButton( myTypeGrp ); + mySwitch2d->setPixmap( icon2d ); + mySwitch3d->setPixmap( icon3d ); + myTypeGrp->insert( mySwitch2d, Type_2d ); + myTypeGrp->insert( mySwitch3d, Type_3d ); + + QGroupBox* aPatternGrp = new QGroupBox( 1, Qt::Horizontal, tr( "PATTERN" ), aMainGrp ); + + // Mesh and pattern name group + + QGroupBox* aMeshGrp = new QGroupBox( 1, Qt::Vertical, aPatternGrp ); + aMeshGrp->setFrameStyle( QFrame::NoFrame ); + aMeshGrp->setInsideMargin( 0 ); + + new QLabel( tr( "MESH_OR_SUBMESH" ), aMeshGrp ); + + QPushButton* aSelBtn = new QPushButton( aMeshGrp ); + aSelBtn->setPixmap( iconSlct ); + myMeshEdit = new QLineEdit( aMeshGrp ); + myMeshEdit->setReadOnly( true ); + + QGroupBox* aPattGrp = new QGroupBox( 1, Qt::Vertical, aPatternGrp ); + aPattGrp->setFrameStyle( QFrame::NoFrame ); + aPattGrp->setInsideMargin( 0 ); + + new QLabel( tr( "PATTERN_NAME" ), aPattGrp ); + myName = new QLineEdit( aPattGrp ); + + // Picture 2d + + myPicture2d = new SMESHGUI_PatternWidget( aPatternGrp ), + myPicture2d->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); + + // Project check box + + myProjectChk = new QCheckBox( tr( "PROJECT" ), aPatternGrp ); + + // Connect signals and slots + + connect( myTypeGrp, SIGNAL( clicked( int ) ), SLOT( onTypeChanged( int ) ) ); + connect( myProjectChk, SIGNAL( toggled( bool ) ), SLOT( onProject( bool ) ) ); + connect( aSelBtn, SIGNAL( clicked() ), SLOT( onSelBtnClicked() ) ); + + return aMainGrp; +} + +//======================================================================= +// name : SMESHGUI_CreatePatternDlg::createButtonFrame +// Purpose : Create frame containing buttons +//======================================================================= +QFrame* SMESHGUI_CreatePatternDlg::createButtonFrame( QWidget* theParent ) +{ + QFrame* aFrame = new QFrame( theParent ); + aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken ); + + myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), aFrame ); + mySaveBtn = new QPushButton( tr( "SAVE" ), aFrame ); + myCloseBtn = new QPushButton( tr( "SMESH_BUT_CANCEL" ), aFrame ); + + QSpacerItem* aSpacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); + + QHBoxLayout* aLay = new QHBoxLayout( aFrame, MARGIN, SPACING ); + + aLay->addWidget( myOkBtn ); + aLay->addWidget( mySaveBtn ); + aLay->addItem( aSpacer); + aLay->addWidget( myCloseBtn ); + + connect( myOkBtn, SIGNAL( clicked() ), SLOT( onOk() ) ); + connect( myCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ) ; + connect( mySaveBtn, SIGNAL( clicked() ), SLOT( onSave() ) ); + + return aFrame; +} + +//======================================================================= +// name : SMESHGUI_CreatePatternDlg::~SMESHGUI_CreatePatternDlg +// Purpose : Destructor +//======================================================================= +SMESHGUI_CreatePatternDlg::~SMESHGUI_CreatePatternDlg() +{ +} + +//======================================================================= +// name : SMESHGUI_CreatePatternDlg::onProject +// Purpose : SLOT. Called when state of "Project nodes on ther face" +// checkbox is changed +//======================================================================= +void SMESHGUI_CreatePatternDlg::onProject( bool ) +{ + loadFromObject( false ); + displayPreview(); +} + +//======================================================================= +// name : SMESHGUI_CreatePatternDlg::Init +// Purpose : Init dialog fields, connect signals and slots, show dialog +//======================================================================= +void SMESHGUI_CreatePatternDlg::Init( SALOME_Selection* theSelection, const int theType ) +{ + myIsLoaded = false; + myType = -1; + myNbPoints = -1; + mySelection = theSelection; + mySubMesh = SMESH::SMESH_subMesh::_nil(); + myMesh = SMESH::SMESH_Mesh::_nil(); + myGeomObj = GEOM::GEOM_Object::_nil(); + myPattern = SMESH::SMESH_Pattern::_nil(); + + erasePreview(); + + SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); + aSMESHGUI->SetActiveDialogBox( ( QDialog* )this ); + + // selection and SMESHGUI + connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); + connect( aSMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( onDeactivate() ) ); + connect( aSMESHGUI, SIGNAL( SignalCloseAllDialogs() ), SLOT( onClose() ) ); + + mySwitch2d->setEnabled( theType == Type_2d ); + mySwitch3d->setEnabled( theType == Type_3d ); + + if ( theType == Type_2d ) + myProjectChk->show(); + else + myProjectChk->hide(); + + myTypeGrp->setButton( theType ); + onTypeChanged( theType ); + + myName->setText( getDefaultName() ); + myMeshEdit->setText( "" ); + + setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding ) ); + qApp->processEvents(); + updateGeometry(); + myPicture2d->updateGeometry(); + adjustSize(); + resize( minimumSize() ); + + activateSelection(); + onSelectionDone(); + + int x, y ; + aSMESHGUI->DefineDlgPosition( this, x, y ); + this->move( x, y ); + this->show(); +} + +//======================================================================= +// name : SMESHGUI_CreatePatternDlg::SetMesh +// Purpose : Set mesh to dialog +//======================================================================= +void SMESHGUI_CreatePatternDlg::SetMesh( SMESH::SMESH_Mesh_ptr thePtr ) +{ + myMesh = SMESH::SMESH_Mesh::_duplicate( thePtr ); + mySubMesh = SMESH::SMESH_subMesh::_nil(); + + bool isValidMesh = false; + if ( !myMesh->_is_nil() ) + { + SALOMEDS::SObject_var aSobj = SMESH::FindSObject( thePtr ); + CORBA::String_var anEntry = aSobj->GetID(); + Handle(SALOME_InteractiveObject) anIObj = + new SALOME_InteractiveObject( anEntry.in(), "SMESH" ); + + const SALOME_ListOfFilter& aList = mySelection->StoredFilters(); + SALOME_ListIteratorOfListOfFilter anIter( aList ); + for ( ; anIter.More(); anIter.Next() ) + if ( !anIter.Value()->IsOk( anIObj ) ) + break; + + if ( !anIter.More() ) + isValidMesh = true; + } + + + if ( isValidMesh ) + { + SALOMEDS::SObject_var aSO = SMESH::FindSObject( myMesh.in() ); + myMeshEdit->setText( aSO->GetName() ); + myGeomObj = getGeom( aSO ); + } + else + { + myMeshEdit->setText( "" ); + myGeomObj = GEOM::GEOM_Object::_nil(); + } + + if ( myType == Type_2d ) + { + loadFromObject( false ); + displayPreview(); + } +} + +//======================================================================= +// name : SMESHGUI_CreatePatternDlg::isValid +// Purpose : Verify validity of entry data +//======================================================================= +bool SMESHGUI_CreatePatternDlg::isValid() +{ + if ( myGeomObj->_is_nil() ) + { + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_INSUFFICIENT_DATA" ), tr( "SMESHGUI_INVALID_PARAMETERS" ), QMessageBox::Ok ); + return false; + } + else + return true; +} + + + +//======================================================================= +// name : SMESHGUI_CreatePatternDlg::getDefaultName +// Purpose : Get default pattern name +//======================================================================= +QString SMESHGUI_CreatePatternDlg::getDefaultName() const +{ + return myType == Type_2d ? tr( "DEFAULT_2D" ) : tr( "DEFAULT_3D" ); +} + +//======================================================================= +// name : SMESHGUI_CreatePatternDlg::onSave +// Purpose : SLOT called when "Save" button pressed. Build pattern and + +// save it to disk +//======================================================================= +void SMESHGUI_CreatePatternDlg::onSave() +{ + try + { + if ( !isValid() ) + return; + + if ( !myIsLoaded ) + loadFromObject( true ); + + // Load pattern from object + if ( !myIsLoaded ) + return; + + /////////////////////////////////////////////////////// + QAD_FileDlg* aDlg = new QAD_FileDlg( this, false ); + aDlg->setCaption( tr( "SAVE_PATTERN" ) ); + aDlg->setMode( QFileDialogP::AnyFile ); + aDlg->setFilters( tr( "PATTERN_FILT" ) ); + if ( myName->text() != "" ) + aDlg->setSelection( myName->text() ); + + if ( aDlg->exec() != Accepted ) + return; + + QString fName = aDlg->selectedFile(); + if ( fName.isEmpty() ) + return; + + if ( QFileInfo( fName ).extension().isEmpty() ) + fName = autoExtension( fName ); + + fName = QDir::convertSeparators( fName ); + + QString aData( myPattern->GetString() ); + long aLen = aData.length(); + + QFile aFile( fName ); + aFile.open( IO_WriteOnly ); + long aWritten = aFile.writeBlock( aData, aLen ); + aFile.close(); + + if ( aWritten != aLen ) + { + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_ERROR" ), tr( "ERROR_OF_SAVING" ), QMessageBox::Ok ); + } + else + { + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + disconnect( mySelection, 0, this, 0 ); + disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); + SMESHGUI::GetSMESHGUI()->ResetState(); + accept(); + emit NewPattern(); + } + } + catch( const SALOME::SALOME_Exception& S_ex ) + { + QtCatchCorbaException( S_ex ); + } + catch( ... ) + { + } +} + +//======================================================================= +// name : SMESHGUI_CreatePatternDlg::GetPatternName +// Purpose : Get name of pattern +//======================================================================= +QString SMESHGUI_CreatePatternDlg::GetPatternName() const +{ + return myName->text(); +} + +//======================================================================= +// name : SMESHGUI_CreatePatternDlg::GetPattern +// Purpose : Get result pattern +//======================================================================= +SMESH::SMESH_Pattern_ptr SMESHGUI_CreatePatternDlg::GetPattern() +{ + return myPattern.in(); +} + +//======================================================================= +// name : SMESHGUI_CreatePatternDlg::onOk +// Purpose : SLOT called when "Ok" button pressed. +//======================================================================= +void SMESHGUI_CreatePatternDlg::onOk() +{ + try + { + if ( !isValid() ) + return; + + if ( !myIsLoaded ) + loadFromObject( true ); + + // Load pattern from object + if ( !myIsLoaded ) + return; + else + { + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + disconnect( mySelection, 0, this, 0 ); + disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); + SMESHGUI::GetSMESHGUI()->ResetState(); + accept(); + emit NewPattern(); + } + } + catch( const SALOME::SALOME_Exception& S_ex ) + { + QtCatchCorbaException( S_ex ); + } + catch( ... ) + { + } +} + +//======================================================================= +// name : SMESHGUI_CreatePatternDlg::onClose +// Purpose : SLOT called when "Close" button pressed. Close dialog +//======================================================================= +void SMESHGUI_CreatePatternDlg::onClose() +{ + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + disconnect( mySelection, 0, this, 0 ); + disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); + SMESHGUI::GetSMESHGUI()->ResetState(); + reject(); + emit Close(); +} + +//======================================================================= +// name : SMESHGUI_CreatePatternDlg::loadFromObject +// Purpose : Load pattern from geom object corresponding to the mesh/submesh +//======================================================================= +bool SMESHGUI_CreatePatternDlg::loadFromObject( const bool theMess ) +{ + try + { + myIsLoaded = false; + + if ( myPattern->_is_nil() ) + myPattern = SMESH::GetPattern(); + + if ( myMesh->_is_nil() && mySubMesh->_is_nil() || myGeomObj->_is_nil() ) + return false; + + SMESH::SMESH_Mesh_ptr aMesh = mySubMesh->_is_nil() ? myMesh.in() : mySubMesh->GetFather(); + + myIsLoaded = myType == Type_2d + ? myPattern->LoadFromFace( aMesh, myGeomObj, myProjectChk->isChecked() ) + : myPattern->LoadFrom3DBlock( aMesh, myGeomObj ); + + if ( !myIsLoaded && theMess ) + { + QString aMess; + SMESH::SMESH_Pattern::ErrorCode aCode = myPattern->GetErrorCode(); + + if ( aCode == SMESH::SMESH_Pattern::ERR_LOAD_EMPTY_SUBMESH ) aMess = tr( "ERR_LOAD_EMPTY_SUBMESH" ); + else if ( aCode == SMESH::SMESH_Pattern::ERR_LOADF_NARROW_FACE ) aMess = tr( "ERR_LOADF_NARROW_FACE" ); + else if ( aCode == SMESH::SMESH_Pattern::ERR_LOADF_CLOSED_FACE ) aMess = tr( "ERR_LOADF_CLOSED_FACE" ); + else if ( aCode == SMESH::SMESH_Pattern::ERR_LOADV_BAD_SHAPE ) aMess = tr( "ERR_LOADV_BAD_SHAPE" ); + else if ( aCode == SMESH::SMESH_Pattern::ERR_LOADV_COMPUTE_PARAMS ) aMess = tr( "ERR_LOADV_COMPUTE_PARAMS" ); + else aMess = tr( "ERROR_OF_CREATION" ); + + QMessageBox::information( + SMESHGUI::GetSMESHGUI()->GetDesktop(), tr( "SMESH_ERROR" ), aMess, QMessageBox::Ok ); + } + + } + catch( const SALOME::SALOME_Exception& S_ex ) + { + QtCatchCorbaException( S_ex ); + } + + return myIsLoaded; +} + +//======================================================================= +// name : SMESHGUI_CreatePatternDlg::getGeom +// Purpose : Retrieve geom object from SObject +//======================================================================= +GEOM::GEOM_Object_ptr SMESHGUI_CreatePatternDlg::getGeom( SALOMEDS::SObject_ptr theSO ) +{ + if ( theSO->_is_nil() ) + return GEOM::GEOM_Object::_nil(); + + SALOMEDS::Study_var aStudy = + SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getStudyDocument(); + + SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator( theSO ); + for( ; anIter->More(); anIter->Next() ) + { + SALOMEDS::SObject_var aSO = anIter->Value(); + SALOMEDS::SObject_var aRefSO; + + GEOM::GEOM_Object_var aMeshShape = GEOM::GEOM_Object::_narrow( + aSO->ReferencedObject( aRefSO )? aRefSO->GetObject() : aSO->GetObject() ); + + if ( !aMeshShape->_is_nil() ) + return aMeshShape._retn(); + } + return GEOM::GEOM_Object::_nil(); +} + +//======================================================================= +// name : SMESHGUI_CreatePatternDlg::onSelectionDone +// Purpose : SLOT called when selection changed +//======================================================================= +void SMESHGUI_CreatePatternDlg::onSelectionDone() +{ + try + { + if ( mySelection->IObjectCount() != 1 ) + return; + + // Get mesh or sub-mesh from selection + Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject(); + SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface( anIO ); + SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface( anIO ); + if ( aMesh->_is_nil() && aSubMesh->_is_nil() ) + return; + + // Get geom object corresponding to the mesh + SALOMEDS::SObject_var aSO; + if ( !aMesh->_is_nil() ) + aSO = SMESH::FindSObject( aMesh.in() ); + else + aSO = SMESH::FindSObject( aSubMesh.in() ); + + + GEOM::GEOM_Object_var aGeomObj = getGeom( aSO ); + if ( aGeomObj->_is_nil() ) + return; + + myGeomObj = aGeomObj; + + // init class fields + if ( !aMesh->_is_nil() ) + { + myMesh = aMesh; + mySubMesh = SMESH::SMESH_subMesh::_nil(); + } + else + { + mySubMesh = aSubMesh; + myMesh = SMESH::SMESH_Mesh::_nil(); + } + + QString aName; + SMESH::GetNameOfSelectedIObjects( mySelection, aName ); + myMeshEdit->setText( aName ); + + if ( myType == Type_2d ) + { + loadFromObject( true ); + displayPreview(); + } + } + catch( ... ) + { + myMesh = SMESH::SMESH_Mesh::_nil(); + mySubMesh = SMESH::SMESH_subMesh::_nil(); + myGeomObj = GEOM::GEOM_Object::_nil(); + erasePreview(); + } +} + +//======================================================================= +// name : SMESHGUI_CreatePatternDlg::onDeactivate +// Purpose : SLOT called when dialog must be deativated +//======================================================================= +void SMESHGUI_CreatePatternDlg::onDeactivate() +{ + disconnect( mySelection, 0, this, 0 ); + setEnabled( false ); +} + +//======================================================================= +// name : SMESHGUI_CreatePatternDlg::enterEvent +// Purpose : Event filter +//======================================================================= +void SMESHGUI_CreatePatternDlg::enterEvent( QEvent* ) +{ + SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); + setEnabled( true ); + activateSelection(); + connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); +} + + +//================================================================================= +// function : closeEvent() +// purpose : Close dialog box +//================================================================================= +void SMESHGUI_CreatePatternDlg::closeEvent( QCloseEvent* e ) +{ + onClose() ; +} + +//======================================================================= +// name : SMESHGUI_CreatePatternDlg::onSelBtnClicked +// Purpose : SLOT. Called when -> button clicked. +//======================================================================= +void SMESHGUI_CreatePatternDlg::onSelBtnClicked() +{ + onSelectionDone(); +} + +//================================================================ +// Function : SMESHGUI_CreatePatternDlg::autoExtension +// Purpose : Append extension to the file name +//================================================================ +QString SMESHGUI_CreatePatternDlg::autoExtension( const QString& theFileName ) const +{ + QString anExt = theFileName.section( '.', -1 ); + return anExt != "smp" && anExt != "SMP" ? theFileName + ".smp" : theFileName; +} + +//======================================================================= +// name : SMESHGUI_CreatePatternDlg::displayPreview +// Purpose : Display preview +//======================================================================= +void SMESHGUI_CreatePatternDlg::displayPreview() +{ + + // Redisplay preview in dialog + + try + { + if ( !myIsLoaded ) + erasePreview(); + else + { + SMESH::point_array_var pnts = myPattern->GetPoints(); + SMESH::long_array_var keyPoints = myPattern->GetKeyPoints(); + SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints(); + + if ( pnts->length() == 0 || + keyPoints->length() == 0 || + elemPoints->length() == 0 ) + { + myIsLoaded = false; + erasePreview(); + return; + } + + PointVector aPoints( pnts->length() ); + QValueVector aKeyPoints( keyPoints->length() ); + ConnectivityVector anElemPoints( elemPoints->length() ); + + for ( int i = 0, n = pnts->length(); i < n; i++ ) + aPoints[ i ] = pnts[ i ]; + + for ( int i2 = 0, n2 = keyPoints->length(); i2 < n2; i2++ ) + aKeyPoints[ i2 ] = keyPoints[ i2 ]; + + for ( int i3 = 0, n3 = elemPoints->length(); i3 < n3; i3++ ) + { + QValueVector aVec( elemPoints[ i3 ].length() ); + for ( int i4 = 0, n4 = elemPoints[ i3 ].length(); i4 < n4; i4++ ) + aVec[ i4 ] = elemPoints[ i3 ][ i4 ]; + + anElemPoints[ i3 ] = aVec; + } + + myPicture2d->SetPoints( aPoints, aKeyPoints, anElemPoints ); + } + + return; + } + catch( const SALOME::SALOME_Exception& S_ex ) + { + QtCatchCorbaException( S_ex ); + } + catch( ... ) + { + } + erasePreview(); +} + +//======================================================================= +// name : SMESHGUI_CreatePatternDlg::erasePreview +// Purpose : Erase preview +//======================================================================= +void SMESHGUI_CreatePatternDlg::erasePreview() + +{ + // Erase preview in 2D viewer + myPicture2d->SetPoints( PointVector(), QValueVector(), ConnectivityVector() ); +} + +//======================================================================= +// name : SMESHGUI_CreatePatternDlg::activateSelection +// Purpose : Activate selection in accordance with current pattern type +//======================================================================= +void SMESHGUI_CreatePatternDlg::activateSelection() +{ + mySelection->ClearFilters(); + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + + if ( myType == Type_2d ) + { + mySelection->AddFilter( + new SMESH_NumberFilter( "SMESH", TopAbs_SHAPE, -1, TopAbs_FACE ) ); + } + else + { + TColStd_MapOfInteger aTypes; + aTypes.Add( TopAbs_SHELL ); + aTypes.Add( TopAbs_SOLID ); + mySelection->AddFilter( new SMESH_NumberFilter( + "SMESH", TopAbs_FACE, 6, aTypes, GEOM::GEOM_Object::_nil(), true ) ); + } +} + +//======================================================================= +// name : SMESHGUI_CreatePatternDlg::onTypeChanged +// Purpose : SLOT. Called when pattern type changed. +// Change dialog's look and feel +//======================================================================= +void SMESHGUI_CreatePatternDlg::onTypeChanged( int theType ) +{ + if ( myType == theType ) + return; + + myType = theType; + + if ( theType == Type_2d ) + myPicture2d->show(); + else + myPicture2d->hide(); +} + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SMESHGUI/SMESHGUI_CreatePatternDlg.h b/src/SMESHGUI/SMESHGUI_CreatePatternDlg.h new file mode 100755 index 000000000..40fbfe1b7 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_CreatePatternDlg.h @@ -0,0 +1,158 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_CreatePatternDlg.h +// Author : Sergey LITONIN +// Module : SMESH + + +#ifndef SMESHGUI_CreatePatternDlg_H +#define SMESHGUI_CreatePatternDlg_H + +#include + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include CORBA_SERVER_HEADER(SMESH_Mesh) +#include CORBA_SERVER_HEADER(SMESH_Pattern) + +class SMESHGUI_PatternWidget; +class QCloseEvent; +class QFrame; +class QLineEdit; +class SMESHGUI_SpinBox; +class QPushButton; +class SALOME_Selection; +class QRadioButton; +class QCheckBox; +class QButtonGroup; +class QLabel; + +/* + Class : SMESHGUI_CreatePatternDlg + Description : Dialog to specify filters for VTK viewer +*/ + +class SMESHGUI_CreatePatternDlg : public QDialog +{ + Q_OBJECT + +public: + + enum { Type_2d, Type_3d }; + +public: + SMESHGUI_CreatePatternDlg( QWidget*, + SALOME_Selection*, + const int, + const char* = 0 ); + virtual ~SMESHGUI_CreatePatternDlg(); + + void Init( SALOME_Selection*, const int ); + QString GetPatternName() const; + SMESH::SMESH_Pattern_ptr GetPattern(); + void SetMesh( SMESH::SMESH_Mesh_ptr ); + +signals: + + void NewPattern(); + void Close(); + +private: + + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; + +private slots: + + void onOk(); + void onSave(); + void onClose(); + + void onDeactivate(); + + void onSelectionDone(); + void onTypeChanged( int ); + void onProject( bool ); + void onSelBtnClicked(); + +private: + + QFrame* createButtonFrame( QWidget* ); + QFrame* createMainFrame ( QWidget* ); + void displayPreview(); + void erasePreview(); + void activateSelection(); + QString autoExtension( const QString& theFileName ) const; + bool isValid(); + bool loadFromObject( const bool = true ); + QString getDefaultName() const; + GEOM::GEOM_Object_ptr getGeom( SALOMEDS::SObject_ptr ); + +private: + + QPushButton* myOkBtn; + QPushButton* mySaveBtn; + QPushButton* myCloseBtn; + + QButtonGroup* myTypeGrp; + QRadioButton* mySwitch2d; + QRadioButton* mySwitch3d; + QRadioButton* mySwitchSMESH_Pattern3d; + + QLineEdit* myMeshEdit; + QLineEdit* myName; + + SMESHGUI_PatternWidget* myPicture2d; + + QCheckBox* myProjectChk; + + SALOME_Selection* mySelection; + int myNbPoints; + int myType; + + SMESH::SMESH_Mesh_var myMesh; + SMESH::SMESH_subMesh_var mySubMesh; + GEOM::GEOM_Object_var myGeomObj; + + SMESH::SMESH_Pattern_var myPattern; + bool myIsLoaded; +}; + +#endif + + + + + + + + + + + + + + + + + diff --git a/src/SMESHGUI/SMESHGUI_DeleteGroupDlg.cxx b/src/SMESHGUI/SMESHGUI_DeleteGroupDlg.cxx new file mode 100644 index 000000000..07d3f87cd --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_DeleteGroupDlg.cxx @@ -0,0 +1,295 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_DeleteGroupDlg.cxx +// Author : Sergey LITONIN +// Module : SMESH + +#include "SMESHGUI_DeleteGroupDlg.h" + +#include "SMESHGUI.h" +#include "SMESH_TypeFilter.hxx" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" + +#include "QAD_Desktop.h" +#include "SALOME_Selection.h" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "SALOMEconfig.h" +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +#define SPACING 5 +#define MARGIN 10 + +/* + Class : SMESHGUI_DeleteGroupDlg + Description : Delete groups and their contents +*/ + +//======================================================================= +// name : SMESHGUI_DeleteGroupDlg::SMESHGUI_DeleteGroupDlg +// Purpose : Constructor +//======================================================================= +SMESHGUI_DeleteGroupDlg::SMESHGUI_DeleteGroupDlg( QWidget* theParent, + SALOME_Selection* theSelection ) +: QDialog( theParent, "SMESHGUI_DeleteGroupDlg", false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + setCaption( tr( "CAPTION" ) ); + + QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); + + QFrame* aMainFrame = createMainFrame ( this ); + QFrame* aBtnFrame = createButtonFrame( this ); + + aDlgLay->addWidget( aMainFrame ); + aDlgLay->addWidget( aBtnFrame ); + + aDlgLay->setStretchFactor( aMainFrame, 1 ); + + Init( theSelection ) ; +} + +//======================================================================= +// name : SMESHGUI_DeleteGroupDlg::createMainFrame +// Purpose : Create frame containing dialog's input fields +//======================================================================= +QFrame* SMESHGUI_DeleteGroupDlg::createMainFrame( QWidget* theParent ) +{ + QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Horizontal, tr( "SELECTED_GROUPS" ), theParent ); + + myListBox = new QListBox( aMainGrp ); + myListBox->setMinimumHeight( 100 ); + myListBox->setSelectionMode( QListBox::NoSelection ); + myListBox->setRowMode( QListBox::FitToWidth ); + + return aMainGrp; +} + +//======================================================================= +// name : SMESHGUI_DeleteGroupDlg::createButtonFrame +// Purpose : Create frame containing buttons +//======================================================================= +QFrame* SMESHGUI_DeleteGroupDlg::createButtonFrame( QWidget* theParent ) +{ + QFrame* aFrame = new QFrame( theParent ); + aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken ); + + myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), aFrame ); + myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), aFrame ); + myCloseBtn = new QPushButton( tr( "SMESH_BUT_CLOSE" ), aFrame ); + + QSpacerItem* aSpacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); + + QHBoxLayout* aLay = new QHBoxLayout( aFrame, MARGIN, SPACING ); + + aLay->addWidget( myOkBtn ); + aLay->addWidget( myApplyBtn ); + aLay->addItem( aSpacer); + aLay->addWidget( myCloseBtn ); + + // connect signals and slots + connect( myOkBtn, SIGNAL( clicked() ), SLOT( onOk() ) ); + connect( myCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ) ; + connect( myApplyBtn, SIGNAL( clicked() ), SLOT( onApply() ) ); + + return aFrame; +} + +//======================================================================= +// name : SMESHGUI_DeleteGroupDlg::~SMESHGUI_DeleteGroupDlg +// Purpose : Destructor +//======================================================================= +SMESHGUI_DeleteGroupDlg::~SMESHGUI_DeleteGroupDlg() +{ +} + +//======================================================================= +// name : SMESHGUI_DeleteGroupDlg::Init +// Purpose : Init dialog fields, connect signals and slots, show dialog +//======================================================================= +void SMESHGUI_DeleteGroupDlg::Init( SALOME_Selection* theSelection ) +{ + myBlockSelection = false; + mySelection = theSelection; + SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); + aSMESHGUI->SetActiveDialogBox( ( QDialog* )this ) ; + + // selection and SMESHGUI + connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); + connect( aSMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( onDeactivate() ) ); + connect( aSMESHGUI, SIGNAL( SignalCloseAllDialogs() ), SLOT( ClickOnClose() ) ); + + int x, y ; + aSMESHGUI->DefineDlgPosition( this, x, y ); + this->move( x, y ); + this->show(); + + // set selection mode + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection, true ); + mySelection->AddFilter( new SMESH_TypeFilter( GROUP ) ); + onSelectionDone(); + + return; +} + +//======================================================================= +// name : SMESHGUI_DeleteGroupDlg::isValid +// Purpose : Verify validity of input data +//======================================================================= +bool SMESHGUI_DeleteGroupDlg::isValid() +{ + if ( myListBox->count() == 0 ) + { + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_INSUFFICIENT_DATA" ), tr( "NO_SELECTED_GROUPS" ), QMessageBox::Ok ); + return false; + } + + return !SMESHGUI::GetSMESHGUI()->ActiveStudyLocked(); +} + +//======================================================================= +// name : SMESHGUI_DeleteGroupDlg::onApply +// Purpose : SLOT called when "Apply" button pressed. +//======================================================================= +bool SMESHGUI_DeleteGroupDlg::onApply() +{ + if ( !isValid() ) + return false; + + myBlockSelection = true; + + QValueList::iterator anIter; + for ( anIter = myListGrp.begin(); anIter != myListGrp.end(); ++anIter ) + { + SMESH::SMESH_Mesh_ptr aMesh = (*anIter)->GetMesh(); + if ( !aMesh->_is_nil() ) + aMesh->RemoveGroupWithContents( *anIter ); + } + + myListBox->clear(); + myListGrp.clear(); + mySelection->ClearIObjects(); + SMESH::UpdateView(); + SMESHGUI::GetSMESHGUI()->GetActiveStudy()->updateObjBrowser( true ); + + myBlockSelection = false; + return false; +} + +//======================================================================= +// name : SMESHGUI_DeleteGroupDlg::onOk +// Purpose : SLOT called when "Ok" button pressed. +//======================================================================= +void SMESHGUI_DeleteGroupDlg::onOk() +{ + if ( onApply() ) + onClose(); +} + +//======================================================================= +// name : SMESHGUI_DeleteGroupDlg::onClose +// Purpose : SLOT called when "Close" button pressed. Close dialog +//======================================================================= +void SMESHGUI_DeleteGroupDlg::onClose() +{ + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + disconnect( mySelection, 0, this, 0 ); + disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); + SMESHGUI::GetSMESHGUI()->ResetState() ; + mySelection->ClearFilters(); + reject(); +} + +//======================================================================= +// name : SMESHGUI_DeleteGroupDlg::onSelectionDone +// Purpose : SLOT called when selection changed +//======================================================================= +void SMESHGUI_DeleteGroupDlg::onSelectionDone() +{ + if ( myBlockSelection ) + return; + + myListGrp.clear(); + QStringList aNames; + + const SALOME_ListIO& aListIO = mySelection->StoredIObjects(); + SALOME_ListIteratorOfListIO anIter( aListIO ); + for( ; anIter.More(); anIter.Next() ) + { + SMESH::SMESH_GroupBase_var aGroup = + SMESH::IObjectToInterface( anIter.Value() ); + if ( !aGroup->_is_nil() ) + { + aNames.append( aGroup->GetName() ); + myListGrp.append( aGroup ); + } + } + + myListBox->clear(); + myListBox->insertStringList( aNames ); +} + +//======================================================================= +// name : SMESHGUI_DeleteGroupDlg::onDeactivate +// Purpose : SLOT called when dialog must be deativated +//======================================================================= +void SMESHGUI_DeleteGroupDlg::onDeactivate() +{ + mySelection->ClearFilters(); + setEnabled( false ); +} + +//======================================================================= +// name : SMESHGUI_DeleteGroupDlg::enterEvent +// Purpose : Event filter +//======================================================================= +void SMESHGUI_DeleteGroupDlg::enterEvent( QEvent* ) +{ + SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog() ; + setEnabled( true ); + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection, true ); + mySelection->AddFilter( new SMESH_TypeFilter( GROUP ) ); +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_DeleteGroupDlg::closeEvent( QCloseEvent* ) +{ + onClose() ; +} + diff --git a/src/SMESHGUI/SMESHGUI_DeleteGroupDlg.h b/src/SMESHGUI/SMESHGUI_DeleteGroupDlg.h new file mode 100644 index 000000000..1669dc705 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_DeleteGroupDlg.h @@ -0,0 +1,96 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_DeleteGroupDlg.h +// Author : Sergey LITONIN +// Module : SMESH + + +#ifndef SMESHGUI_DELETEGROUPDLG_H +#define SMESHGUI_DELETEGROUPDLG_H + +#include +#include + +#include +#include CORBA_SERVER_HEADER(SMESH_Group) + +class QCloseEvent; +class QFrame; +class QPushButton; +class SALOME_Selection; +class QListBox; + +/* + Class : SMESHGUI_DeleteGroupDlg + Description : Delete groups and their contents +*/ + +class SMESHGUI_DeleteGroupDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_DeleteGroupDlg( QWidget*, SALOME_Selection* ); + virtual ~SMESHGUI_DeleteGroupDlg(); + + void Init( SALOME_Selection* ) ; + +private: + + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; + +private slots: + + void onOk(); + bool onApply(); + void onClose(); + + void onDeactivate(); + + void onSelectionDone(); + +private: + + QFrame* createButtonFrame( QWidget* ); + QFrame* createMainFrame ( QWidget* ); + bool isValid(); + +private: + + QPushButton* myOkBtn; + QPushButton* myApplyBtn; + QPushButton* myCloseBtn; + QListBox* myListBox; + SALOME_Selection* mySelection; + + QValueList myListGrp; + bool myBlockSelection; + +}; + +#endif + + + + + diff --git a/src/SMESHGUI/SMESHGUI_DiagonalInversionDlg.cxx b/src/SMESHGUI/SMESHGUI_DiagonalInversionDlg.cxx deleted file mode 100644 index bc76e32fb..000000000 --- a/src/SMESHGUI/SMESHGUI_DiagonalInversionDlg.cxx +++ /dev/null @@ -1,369 +0,0 @@ -// SMESH SMESHGUI : GUI for SMESH component -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMESHGUI_DiagonalInversionDlg.cxx -// Author : Damien COQUERET -// Module : SMESH -// $Header$ - -using namespace std; -#include "SMESHGUI_DiagonalInversionDlg.h" - -#include "SMESHGUI.h" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_MessageBox.h" -#include "utilities.h" - -// QT Includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -//================================================================================= -// class : SMESHGUI_DiagonalInversionDlg() -// purpose : -//================================================================================= -SMESHGUI_DiagonalInversionDlg::SMESHGUI_DiagonalInversionDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, - bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) -{ - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_MESH_DIAGONAL"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); - - if ( !name ) - setName( "SMESHGUI_DiagonalInversionDlg" ); - resize( 303, 185 ); - setCaption( tr( "SMESH_DIAGONAL_INVERSION_TITLE" ) ); - setSizeGripEnabled( TRUE ); - SMESHGUI_DiagonalInversionDlgLayout = new QGridLayout( this ); - SMESHGUI_DiagonalInversionDlgLayout->setSpacing( 6 ); - SMESHGUI_DiagonalInversionDlgLayout->setMargin( 11 ); - - /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( tr( "SMESH_DIAGONAL" ) ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); - Constructor1->setText( tr( "" ) ); - Constructor1->setPixmap( image0 ); - Constructor1->setChecked( TRUE ); - Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); - Constructor1->setMinimumSize( QSize( 50, 0 ) ); - GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer, 0, 1 ); - SMESHGUI_DiagonalInversionDlgLayout->addWidget( GroupConstructors, 0, 0 ); - - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_9, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - SMESHGUI_DiagonalInversionDlgLayout->addWidget( GroupButtons, 2, 0 ); - - /***************************************************************/ - GroupC1 = new QGroupBox( this, "GroupC1" ); - GroupC1->setTitle( tr( "SMESH_DIAGONAL" ) ); - GroupC1->setMinimumSize( QSize( 0, 0 ) ); - GroupC1->setFrameShape( QGroupBox::Box ); - GroupC1->setFrameShadow( QGroupBox::Sunken ); - GroupC1->setColumnLayout(0, Qt::Vertical ); - GroupC1->layout()->setSpacing( 0 ); - GroupC1->layout()->setMargin( 0 ); - GroupC1Layout = new QGridLayout( GroupC1->layout() ); - GroupC1Layout->setAlignment( Qt::AlignTop ); - GroupC1Layout->setSpacing( 6 ); - GroupC1Layout->setMargin( 11 ); - TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); - TextLabelC1A1->setText( tr( "SMESH_ID_DIAGONAL" ) ); - TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A1->setFrameShape( QLabel::NoFrame ); - TextLabelC1A1->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); - SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); - SelectButtonC1A1->setText( tr( "" ) ); - SelectButtonC1A1->setPixmap( image1 ); - SelectButtonC1A1->setToggleButton( FALSE ); - GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); - LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); - GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); - SMESHGUI_DiagonalInversionDlgLayout->addWidget( GroupC1, 1, 0 ); - - Init(Sel) ; /* Initialisations */ -} - -//================================================================================= -// function : ~SMESHGUI_DiagonalInversionDlg() -// purpose : Destroys the object and frees any allocated resources -//================================================================================= -SMESHGUI_DiagonalInversionDlg::~SMESHGUI_DiagonalInversionDlg() -{ - // no need to delete child widgets, Qt does it all for us -} - - -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void SMESHGUI_DiagonalInversionDlg::Init( SALOME_Selection* Sel ) -{ - - GroupC1->show(); - myConstructorId = 0 ; - Constructor1->setChecked( TRUE ); - myEditCurrentArgument = LineEditC1A1 ; - mySelection = Sel; - this->myOkElements = false ; - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; - - /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); - - connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - /* to close dialog if study change */ - connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - - /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ - - return ; -} - - -//================================================================================= -// function : ConstructorsClicked() -// purpose : Radio button management -//================================================================================= -void SMESHGUI_DiagonalInversionDlg::ConstructorsClicked(int constructorId) -{ - return ; -} - - -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -void SMESHGUI_DiagonalInversionDlg::ClickOnApply() -{ - switch(myConstructorId) - { - case 0 : - { - if(myOkElements) { - mySMESHGUI->DiagonalInversion( myMesh, myMapIndex ) ; - mySelection->ClearIObjects(); - } - break ; - } - } - return ; -} - -//================================================================================= -// function : ClickOnOk() -// purpose : -//================================================================================= -void SMESHGUI_DiagonalInversionDlg::ClickOnOk() -{ - this->ClickOnApply() ; - this->ClickOnCancel() ; - - return ; -} - -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void SMESHGUI_DiagonalInversionDlg::ClickOnCancel() -{ - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - disconnect( mySelection, 0, this, 0 ); - mySMESHGUI->ResetState() ; - reject() ; - return ; -} - - -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection as changed or other case -//================================================================================= -void SMESHGUI_DiagonalInversionDlg::SelectionIntoArgument() -{ - myEditCurrentArgument->setText("") ; - myOkElements = false; - QString aString = ""; - - if ( mySelection->SelectionMode() != EdgeSelection ) { - return; - } - - int nbSel = mySelection->IObjectCount(); - if(nbSel != 1) - return; - - int nbElements = mySMESHGUI->GetNameOfSelectedEdges(mySelection, aString) ; - if(nbElements < 1) - return ; - MESSAGE( "DCQ : nb. elements = " << nbElements ) - - Standard_Boolean res; - myMesh = mySMESHGUI->ConvertIOinMesh( mySelection->firstIObject(), res ); - if (!res) - return ; - - mySelection->GetIndex( mySelection->firstIObject(), myMapIndex); - myOkElements = true ; - myEditCurrentArgument->setText(aString) ; - return ; -} - - -//================================================================================= -// function : SetEditCurrentArgument() -// purpose : -//================================================================================= -void SMESHGUI_DiagonalInversionDlg::SetEditCurrentArgument() -{ - QPushButton* send = (QPushButton*)sender(); - switch (myConstructorId) - { - case 0: /* default constructor */ - { - if(send == SelectButtonC1A1) { - LineEditC1A1->setFocus() ; - myEditCurrentArgument = LineEditC1A1; - } - SelectionIntoArgument() ; - break; - } - } - return ; -} - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void SMESHGUI_DiagonalInversionDlg::DeactivateActiveDialog() -{ - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupC1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - } - return ; -} - - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void SMESHGUI_DiagonalInversionDlg::ActivateThisDialog() -{ - /* Emit a signal to deactivate the active dialog */ - mySMESHGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupC1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - return ; -} - - -//================================================================================= -// function : enterEvent() -// purpose : -//================================================================================= -void SMESHGUI_DiagonalInversionDlg::enterEvent(QEvent* e) -{ - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; - return ; -} - - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void SMESHGUI_DiagonalInversionDlg::closeEvent( QCloseEvent* e ) -{ - /* same than click on cancel button */ - this->ClickOnCancel() ; - return ; -} - - diff --git a/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.cxx b/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.cxx index 7f8c99250..d6f2e1494 100644 --- a/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.cxx @@ -26,9 +26,13 @@ // Module : SMESH // $Header$ -using namespace std; #include "SMESHGUI_EditHypothesesDlg.h" + #include "SMESHGUI.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_GEOMGenUtils.h" +#include "SMESHGUI_HypothesesUtils.h" + #include "SALOME_ListIteratorOfListIO.hxx" #include "QAD_Application.h" @@ -36,6 +40,9 @@ using namespace std; #include "QAD_WaitCursor.h" #include "QAD_Operation.h" +#include "SALOMEconfig.h" +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) + #include "utilities.h" // QT Includes @@ -46,6 +53,8 @@ using namespace std; #include #include +using namespace std; + //VRV: porting on Qt 3.0.5 #if QT_VERSION >= 0x030005 #include @@ -120,6 +129,7 @@ SMESHGUI_EditHypothesesDlg::SMESHGUI_EditHypothesesDlg( QWidget* parent, const c SelectButtonC1A1->setPixmap( image0 ); GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + LineEditC1A1->setReadOnly( true ); GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); TextLabelC1A2 = new QLabel( tr( "SMESH_OBJECT_GEOM" ), GroupC1, "TextLabelC1A2" ); @@ -129,6 +139,7 @@ SMESHGUI_EditHypothesesDlg::SMESHGUI_EditHypothesesDlg( QWidget* parent, const c SelectButtonC1A2->setToggleButton( FALSE ); GroupC1Layout->addWidget( SelectButtonC1A2, 1, 1 ); LineEditC1A2 = new QLineEdit( GroupC1, "LineEditC1A2" ); + LineEditC1A2->setReadOnly( true ); GroupC1Layout->addWidget( LineEditC1A2, 1, 2 ); SMESHGUI_EditHypothesesDlgLayout->addWidget( GroupC1, 0, 0 ); @@ -246,7 +257,7 @@ void SMESHGUI_EditHypothesesDlg::Init( SALOME_Selection* Sel ) myGeomFilter = new SALOME_TypeFilter( "GEOM" ); myMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); - myGeomShape = GEOM::GEOM_Shape::_nil(); + myGeomShape = GEOM::GEOM_Object::_nil(); myMesh = SMESH::SMESH_Mesh::_nil(); mySubMesh = SMESH::SMESH_subMesh::_nil(); @@ -300,6 +311,9 @@ void SMESHGUI_EditHypothesesDlg::ClickOnOk() //================================================================================= bool SMESHGUI_EditHypothesesDlg::ClickOnApply() { + if (mySMESHGUI->ActiveStudyLocked()) + return false; + bool aRes = false; QAD_WaitCursor wc; @@ -314,13 +328,19 @@ bool SMESHGUI_EditHypothesesDlg::ClickOnApply() else if ( !mySubMesh->_is_nil() ) aRes = StoreSubMesh(); - if ( aRes ) + if ( true/*aRes*/ ) // abort desynchronizes contents of a Study and a mesh on server + { // commit transaction op->finish(); + InitHypAssignation(); + InitAlgoAssignation(); + } else // abort transaction op->abort(); + UpdateControlState(); + return aRes; } @@ -343,7 +363,7 @@ void SMESHGUI_EditHypothesesDlg::SelectionIntoArgument() { QString aString = ""; - int nbSel = mySMESHGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + int nbSel = SMESH::GetNameOfSelectedIObjects(mySelection, aString) ; if ( myEditCurrentArgument == LineEditC1A1 ) { if ( nbSel != 1 ) { @@ -351,37 +371,31 @@ void SMESHGUI_EditHypothesesDlg::SelectionIntoArgument() mySubMesh = SMESH::SMESH_subMesh::_nil(); aString = ""; } else { - Standard_Boolean testResult ; Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; - myMesh = mySMESHGUI->ConvertIOinMesh(IO, testResult) ; - if( !testResult ) { - myMesh = SMESH::SMESH_Mesh::_nil(); - mySubMesh = mySMESHGUI->ConvertIOinSubMesh(IO, testResult) ; - if( !testResult ) { - mySubMesh = SMESH::SMESH_subMesh::_nil(); + myMesh = SMESH::IObjectToInterface(IO) ; + if(myMesh->_is_nil()){ + mySubMesh = SMESH::IObjectToInterface(IO) ; + if(mySubMesh->_is_nil()){ aString = ""; } } } myEditCurrentArgument->setText( aString ); - myGeomShape = GEOM::GEOM_Shape::_nil(); // InitGeom() will try to retrieve a shape from myMesh or mySubMesh + myGeomShape = GEOM::GEOM_Object::_nil(); // InitGeom() will try to retrieve a shape from myMesh or mySubMesh InitGeom(); myImportedMesh = myGeomShape->_is_nil(); InitHypAssignation(); InitAlgoAssignation(); - } + } else if ( myEditCurrentArgument == LineEditC1A2 ) { if ( nbSel != 1 ) - myGeomShape = GEOM::GEOM_Shape::_nil(); + myGeomShape = GEOM::GEOM_Object::_nil(); else { - Standard_Boolean testResult ; Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; - myGeomShape = mySMESHGUI->ConvertIOinGEOMShape(IO, testResult) ; - if( !testResult ) - myGeomShape = GEOM::GEOM_Shape::_nil(); + myGeomShape = SMESH::IObjectToInterface(IO) ; } InitGeom(); } @@ -461,6 +475,21 @@ void SMESHGUI_EditHypothesesDlg::closeEvent( QCloseEvent* e ) QDialog::closeEvent( e ); } +//======================================================================= +//function : IsOld +//purpose : +//======================================================================= + +bool SMESHGUI_EditHypothesesDlg::IsOld(QListBoxItem* hypItem) +{ + if ( hypItem->rtti() == ListBoxIOR::RTTI_IOR ) { + ListBoxIOR* hyp = ( ListBoxIOR* ) hypItem; + return (myMapOldHypos.find( hyp->GetIOR() ) != myMapOldHypos.end() || + myMapOldAlgos.find( hyp->GetIOR() ) != myMapOldAlgos.end() ); + } + + return false; +} //================================================================================= // function : removeItem() @@ -473,12 +502,15 @@ void SMESHGUI_EditHypothesesDlg::removeItem(QListBoxItem* item) if (!item) return; if ( aSender == ListHypAssignation ) { + myNbModification += IsOld( item ) ? 1 : -1; ListHypAssignation->removeItem( ListHypAssignation->index( item ) ); } else if ( aSender == ListAlgoAssignation ) { + myNbModification += IsOld( item ) ? 1 : -1; ListAlgoAssignation->removeItem( ListAlgoAssignation->index( item ) ); } + UpdateControlState(); } @@ -509,8 +541,8 @@ void SMESHGUI_EditHypothesesDlg::addItem(QListBoxItem* item) } if ( !isFound ) ListBoxIOR* anItem = new ListBoxIOR( ListHypAssignation, - strdup( i->GetIOR() ), - strdup( i->text().latin1() ) ); + CORBA::string_dup( i->GetIOR() ), + CORBA::string_dup( i->text().latin1() ) ); } else if ( aSender == ListAlgoDefinition ) { for ( int j = 0, n = ListAlgoAssignation->count(); !isFound && j < n; j++ ) { @@ -521,10 +553,13 @@ void SMESHGUI_EditHypothesesDlg::addItem(QListBoxItem* item) } if ( !isFound ) ListBoxIOR* anItem = new ListBoxIOR( ListAlgoAssignation, - strdup( i->GetIOR() ), - strdup( i->text().latin1() ) ); + CORBA::string_dup( i->GetIOR() ), + CORBA::string_dup( i->text().latin1() ) ); } + if ( !isFound ) + myNbModification += IsOld( item ) ? -1 : 1; + UpdateControlState(); } @@ -537,7 +572,7 @@ void SMESHGUI_EditHypothesesDlg::InitHypDefinition() { ListHypDefinition->clear(); - SALOMEDS::SComponent_var father = mySMESHGUI->GetStudy()->FindComponent("MESH"); + SALOMEDS::SComponent_var father = SMESH::GetActiveStudyDocument()->FindComponent("SMESH"); if ( father->_is_nil() ) return; @@ -548,7 +583,7 @@ void SMESHGUI_EditHypothesesDlg::InitHypDefinition() int Tag_HypothesisRoot = 1; if (father->FindSubObject (1, HypothesisRoot)) { - SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(HypothesisRoot); + SALOMEDS::ChildIterator_var it = SMESH::GetActiveStudyDocument()->NewChildIterator(HypothesisRoot); for (; it->More();it->Next()) { SALOMEDS::SObject_var Obj = it->Value(); if (Obj->FindAttribute(anAttr, "AttributeName") ) { @@ -570,8 +605,9 @@ void SMESHGUI_EditHypothesesDlg::InitHypDefinition() //================================================================================= void SMESHGUI_EditHypothesesDlg::InitHypAssignation() { - MESSAGE ( " InitHypAssignation " << myMesh->_is_nil() ) - MESSAGE ( " InitHypAssignation " << mySubMesh->_is_nil() ) + myNbModification = 0; +// MESSAGE ( " InitHypAssignation " << myMesh->_is_nil() ) +// MESSAGE ( " InitHypAssignation " << mySubMesh->_is_nil() ) myMapOldHypos.clear(); ListHypAssignation->clear(); @@ -582,15 +618,14 @@ void SMESHGUI_EditHypothesesDlg::InitHypAssignation() SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeName_var aName; SALOMEDS::AttributeIOR_var anIOR; - SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI(); if ( !myMesh->_is_nil() ) - aMorSM = myStudyAPI.FindObject( myMesh ); + aMorSM = SMESH::FindSObject( myMesh ); else if ( !mySubMesh->_is_nil() ) - aMorSM = myStudyAPI.FindObject( mySubMesh ); + aMorSM = SMESH::FindSObject( mySubMesh ); if ( !aMorSM->_is_nil() && aMorSM->FindSubObject (2, AHR)) { - SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR); + SALOMEDS::ChildIterator_var it = SMESH::GetActiveStudyDocument()->NewChildIterator(AHR); for (; it->More();it->Next()) { SALOMEDS::SObject_var Obj = it->Value(); if ( Obj->ReferencedObject(aRef) ) { @@ -617,7 +652,7 @@ void SMESHGUI_EditHypothesesDlg::InitAlgoDefinition() { ListAlgoDefinition->clear(); - SALOMEDS::SComponent_var father = mySMESHGUI->GetStudy()->FindComponent("MESH"); + SALOMEDS::SComponent_var father = SMESH::GetActiveStudyDocument()->FindComponent("SMESH"); if ( father->_is_nil() ) return; @@ -627,7 +662,7 @@ void SMESHGUI_EditHypothesesDlg::InitAlgoDefinition() SALOMEDS::AttributeIOR_var anIOR; if (father->FindSubObject (2, AlgorithmsRoot)) { - SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AlgorithmsRoot); + SALOMEDS::ChildIterator_var it = SMESH::GetActiveStudyDocument()->NewChildIterator(AlgorithmsRoot); for (; it->More();it->Next()) { SALOMEDS::SObject_var Obj = it->Value(); if (Obj->FindAttribute(anAttr, "AttributeName") ) { @@ -662,15 +697,14 @@ void SMESHGUI_EditHypothesesDlg::InitAlgoAssignation() SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeName_var aName; SALOMEDS::AttributeIOR_var anIOR; - SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI(); if ( !myMesh->_is_nil() ) - aMorSM = myStudyAPI.FindObject( myMesh ); + aMorSM = SMESH::FindSObject( myMesh ); else if ( !mySubMesh->_is_nil() ) - aMorSM = myStudyAPI.FindObject( mySubMesh ); + aMorSM = SMESH::FindSObject( mySubMesh ); if ( !aMorSM->_is_nil() && aMorSM->FindSubObject (3, AHR)) { - SALOMEDS::ChildIterator_var it = mySMESHGUI->GetStudy()->NewChildIterator(AHR); + SALOMEDS::ChildIterator_var it = SMESH::GetActiveStudyDocument()->NewChildIterator(AHR); for (; it->More();it->Next()) { SALOMEDS::SObject_var Obj = it->Value(); if ( Obj->ReferencedObject(aRef) ) { @@ -696,27 +730,26 @@ void SMESHGUI_EditHypothesesDlg::InitAlgoAssignation() void SMESHGUI_EditHypothesesDlg::InitGeom() { LineEditC1A2->setText("") ; - SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI(); if ( myGeomShape->_is_nil() && !myMesh->_is_nil() ) { - SALOMEDS::SObject_var aMesh = myStudyAPI.FindObject( myMesh ); + SALOMEDS::SObject_var aMesh = SMESH::FindSObject( myMesh ); if ( !aMesh->_is_nil() ) - myGeomShape = myStudyAPI.GetShapeOnMeshOrSubMesh(aMesh); + myGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aMesh); } if ( myGeomShape->_is_nil() && !mySubMesh->_is_nil() ) { - SALOMEDS::SObject_var aSubMesh = myStudyAPI.FindObject( mySubMesh ); + SALOMEDS::SObject_var aSubMesh = SMESH::FindSObject( mySubMesh ); if ( !aSubMesh->_is_nil() ) - myGeomShape = myStudyAPI.GetShapeOnMeshOrSubMesh(aSubMesh); + myGeomShape = SMESH::GetShapeOnMeshOrSubMesh(aSubMesh); } SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeName_var aName; if ( !myGeomShape->_is_nil() && (!myMesh->_is_nil() || !mySubMesh->_is_nil()) ) { - SALOMEDS::SObject_var aSO = mySMESHGUI->GetStudy()->FindObjectIOR( myGeomShape->Name() ); + SALOMEDS::SObject_var aSO = SMESH::GetActiveStudyDocument()->FindObjectIOR( myGeomShape->GetName() ); if ( !aSO->_is_nil() ) { if (aSO->FindAttribute(anAttr, "AttributeName") ) { - aName = SALOMEDS::AttributeName::_narrow(anAttr); - LineEditC1A2->setText( QString(aName->Value()) ) ; + aName = SALOMEDS::AttributeName::_narrow(anAttr); + LineEditC1A2->setText( QString(aName->Value()) ) ; } } } @@ -731,8 +764,8 @@ void SMESHGUI_EditHypothesesDlg::UpdateControlState() bool isEnabled = ( !myMesh ->_is_nil() && !myGeomShape->_is_nil() && ListHypAssignation->count() && ListAlgoAssignation->count() ) || ( !mySubMesh->_is_nil() && !myGeomShape->_is_nil() && ( ListHypAssignation->count() || ListAlgoAssignation->count() ) ); - buttonOk ->setEnabled( isEnabled && !myImportedMesh ); - buttonApply->setEnabled( isEnabled && !myImportedMesh ); + buttonOk ->setEnabled( myNbModification && isEnabled && !myImportedMesh ); + buttonApply->setEnabled( myNbModification && isEnabled && !myImportedMesh ); SelectButtonC1A2 ->setEnabled( ALLOW_CHANGE_SHAPE && !myImportedMesh ); LineEditC1A2 ->setEnabled( ALLOW_CHANGE_SHAPE && !myImportedMesh ); @@ -748,31 +781,30 @@ void SMESHGUI_EditHypothesesDlg::UpdateControlState() //================================================================================= bool SMESHGUI_EditHypothesesDlg::StoreMesh() { - SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI(); MapIOR anOldHypos, aNewHypos; if ( myGeomShape->_is_nil() ) return false; // 1. Check whether the geometric shape has changed - SALOMEDS::SObject_var aMeshSO = myStudyAPI.FindObject( myMesh ); - GEOM::GEOM_Shape_var aIniGeomShape = myStudyAPI.GetShapeOnMeshOrSubMesh( aMeshSO ); + SALOMEDS::SObject_var aMeshSO = SMESH::FindSObject( myMesh ); + GEOM::GEOM_Object_var aIniGeomShape = SMESH::GetShapeOnMeshOrSubMesh( aMeshSO ); bool bShapeChanged = aIniGeomShape->_is_nil() || !aIniGeomShape->_is_equivalent( myGeomShape ); if ( bShapeChanged ) { // VSR : TODO : Set new shape - not supported yet by SMESH engine - // 1) remove all old hypotheses and algorithms and also submeshes - // 2) set new shape + // 1. remove all old hypotheses and algorithms and also submeshes + // 2. set new shape } + + int nbFail = 0; MapIOR::iterator it; // 2. remove not used hypotheses from the mesh for ( it = myMapOldHypos.begin(); it != myMapOldHypos.end(); ++it ) { string ior = it->first; int index = findItem( ListHypAssignation, ior ); if ( index < 0 ) { - CORBA::Object_var anObject = myStudyAPI.StringToIOR( ior.c_str() ); - if ( !CORBA::is_nil( anObject ) ) { - SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject ); - if ( !aHyp->_is_nil() ) - if ( !mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh( aMeshSO, aHyp ) ) - return false; + SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface(ior.c_str()); + if ( !aHyp->_is_nil() ){ + if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh( aMeshSO, aHyp )) + nbFail++; } } } @@ -781,52 +813,46 @@ bool SMESHGUI_EditHypothesesDlg::StoreMesh() string ior = it->first; int index = findItem( ListAlgoAssignation, ior ); if ( index < 0 ) { - CORBA::Object_var anObject = myStudyAPI.StringToIOR( ior.c_str() ); - if ( !CORBA::is_nil( anObject ) ) { - SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject ); - if ( !aHyp->_is_nil() ) - if ( !mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh( aMeshSO, aHyp ) ) - return false; + SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface(ior.c_str()); + if ( !aHyp->_is_nil() ){ + if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh( aMeshSO, aHyp )) + nbFail++; } } } - // 4. Add new hypotheses - for ( int i = 0; i < ListHypAssignation->count(); i++ ) { - if ( ListHypAssignation->item( i )->rtti() == ListBoxIOR::RTTI_IOR ) { - ListBoxIOR* anItem = ( ListBoxIOR* )( ListHypAssignation->item( i ) ); + // 4. Add new algorithms + for ( int i = 0; i < ListAlgoAssignation->count(); i++ ) { + if ( ListAlgoAssignation->item( i )->rtti() == ListBoxIOR::RTTI_IOR ) { + ListBoxIOR* anItem = ( ListBoxIOR* )( ListAlgoAssignation->item( i ) ); if ( anItem ) { string ior = anItem->GetIOR(); - if ( myMapOldHypos.find( ior ) == myMapOldHypos.end() ) { - CORBA::Object_var anObject = myStudyAPI.StringToIOR( ior.c_str() ); - if ( !CORBA::is_nil( anObject ) ) { - SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject ); - if ( !aHyp->_is_nil() ) - if ( !mySMESHGUI->AddHypothesisOnMesh( myMesh, aHyp ) ) - return false; + if ( myMapOldAlgos.find( ior ) == myMapOldAlgos.end() ) { + SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface(ior.c_str()); + if ( !aHyp->_is_nil() ){ + if (!SMESH::AddHypothesisOnMesh( myMesh, aHyp )) + nbFail++; } } } } } - // 4. Add new algorithms - for ( int i = 0; i < ListAlgoAssignation->count(); i++ ) { - if ( ListAlgoAssignation->item( i )->rtti() == ListBoxIOR::RTTI_IOR ) { - ListBoxIOR* anItem = ( ListBoxIOR* )( ListAlgoAssignation->item( i ) ); + // 5. Add new hypotheses + for ( int i = 0; i < ListHypAssignation->count(); i++ ) { + if ( ListHypAssignation->item( i )->rtti() == ListBoxIOR::RTTI_IOR ) { + ListBoxIOR* anItem = ( ListBoxIOR* )( ListHypAssignation->item( i ) ); if ( anItem ) { string ior = anItem->GetIOR(); - if ( myMapOldAlgos.find( ior ) == myMapOldAlgos.end() ) { - CORBA::Object_var anObject = myStudyAPI.StringToIOR( ior.c_str() ); - if ( !CORBA::is_nil( anObject ) ) { - SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject ); - if ( !aHyp->_is_nil() ) - if ( !mySMESHGUI->AddAlgorithmOnMesh( myMesh, aHyp ) ) - return false; + if ( myMapOldHypos.find( ior ) == myMapOldHypos.end() ) { + SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface(ior.c_str()); + if ( !aHyp->_is_nil() ){ + if (!SMESH::AddHypothesisOnMesh( myMesh, aHyp )) + nbFail++; } } } } } - return true; + return ( nbFail == 0 ); } //================================================================================= @@ -835,31 +861,29 @@ bool SMESHGUI_EditHypothesesDlg::StoreMesh() //================================================================================= bool SMESHGUI_EditHypothesesDlg::StoreSubMesh() { - SMESHGUI_StudyAPI myStudyAPI = mySMESHGUI->GetStudyAPI(); MapIOR anOldHypos, aNewHypos; if ( myGeomShape->_is_nil() ) return false; // 1. Check whether the geometric shape has changed - SALOMEDS::SObject_var aSubMeshSO = myStudyAPI.FindObject( mySubMesh ); - GEOM::GEOM_Shape_var aIniGeomShape = myStudyAPI.GetShapeOnMeshOrSubMesh( aSubMeshSO ); + SALOMEDS::SObject_var aSubMeshSO = SMESH::FindSObject( mySubMesh ); + GEOM::GEOM_Object_var aIniGeomShape = SMESH::GetShapeOnMeshOrSubMesh( aSubMeshSO ); bool bShapeChanged = aIniGeomShape->_is_nil() || !aIniGeomShape->_is_equivalent( myGeomShape ); if ( bShapeChanged ) { // VSR : TODO : Set new shape - not supported yet by engine - // 1) remove all old hypotheses and algorithms - // 2) set new shape + // 1. remove all old hypotheses and algorithms + // 2. set new shape } + int nbFail = 0; MapIOR::iterator it; // 2. remove not used hypotheses from the submesh for ( it = myMapOldHypos.begin(); it != myMapOldHypos.end(); ++it ) { string ior = it->first; int index = findItem( ListHypAssignation, ior ); if ( index < 0 ) { - CORBA::Object_var anObject = myStudyAPI.StringToIOR( ior.c_str() ); - if ( !CORBA::is_nil( anObject ) ) { - SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject ); - if ( !aHyp->_is_nil() ) - if ( !mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh( aSubMeshSO, aHyp ) ) - return false; + SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface(ior.c_str()); + if ( !aHyp->_is_nil() ){ + if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh( aSubMeshSO, aHyp )) + nbFail++; } } } @@ -868,50 +892,44 @@ bool SMESHGUI_EditHypothesesDlg::StoreSubMesh() string ior = it->first; int index = findItem( ListAlgoAssignation, ior ); if ( index < 0 ) { - CORBA::Object_var anObject = myStudyAPI.StringToIOR( ior.c_str() ); - if ( !CORBA::is_nil( anObject ) ) { - SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject ); - if ( !aHyp->_is_nil() ) - if ( !mySMESHGUI->RemoveHypothesisOrAlgorithmOnMesh( aSubMeshSO, aHyp ) ) - return false; + SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface(ior.c_str()); + if ( !aHyp->_is_nil() ){ + if (!SMESH::RemoveHypothesisOrAlgorithmOnMesh( aSubMeshSO, aHyp )) + nbFail++; } } } - // 4. Add new hypotheses - for ( int i = 0; i < ListHypAssignation->count(); i++ ) { - if ( ListHypAssignation->item( i )->rtti() == ListBoxIOR::RTTI_IOR ) { - ListBoxIOR* anItem = ( ListBoxIOR* )( ListHypAssignation->item( i ) ); + // 4. Add new algorithms + for ( int i = 0; i < ListAlgoAssignation->count(); i++ ) { + if ( ListAlgoAssignation->item( i )->rtti() == ListBoxIOR::RTTI_IOR ) { + ListBoxIOR* anItem = ( ListBoxIOR* )( ListAlgoAssignation->item( i ) ); if ( anItem ) { string ior = anItem->GetIOR(); - if ( myMapOldHypos.find( ior ) == myMapOldHypos.end() ) { - CORBA::Object_var anObject = myStudyAPI.StringToIOR( ior.c_str() ); - if ( !CORBA::is_nil( anObject ) ) { - SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject ); - if ( !aHyp->_is_nil() ) - if ( !mySMESHGUI->AddHypothesisOnSubMesh( mySubMesh, aHyp ) ) - return false; + if ( myMapOldAlgos.find( ior ) == myMapOldAlgos.end() ) { + SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface(ior.c_str()); + if ( !aHyp->_is_nil() ){ + if (!SMESH::AddHypothesisOnSubMesh( mySubMesh, aHyp )) + nbFail++; } } } } } - // 4. Add new algorithms - for ( int i = 0; i < ListAlgoAssignation->count(); i++ ) { - if ( ListAlgoAssignation->item( i )->rtti() == ListBoxIOR::RTTI_IOR ) { - ListBoxIOR* anItem = ( ListBoxIOR* )( ListAlgoAssignation->item( i ) ); + // 5. Add new hypotheses + for ( int i = 0; i < ListHypAssignation->count(); i++ ) { + if ( ListHypAssignation->item( i )->rtti() == ListBoxIOR::RTTI_IOR ) { + ListBoxIOR* anItem = ( ListBoxIOR* )( ListHypAssignation->item( i ) ); if ( anItem ) { string ior = anItem->GetIOR(); - if ( myMapOldAlgos.find( ior ) == myMapOldAlgos.end() ) { - CORBA::Object_var anObject = myStudyAPI.StringToIOR( ior.c_str() ); - if ( !CORBA::is_nil( anObject ) ) { - SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject ); - if ( !aHyp->_is_nil() ) - if ( !mySMESHGUI->AddAlgorithmOnSubMesh( mySubMesh, aHyp ) ) - return false; + if ( myMapOldHypos.find( ior ) == myMapOldHypos.end() ) { + SMESH::SMESH_Hypothesis_var aHyp = SMESH::IORToInterface(ior.c_str()); + if ( !aHyp->_is_nil() ){ + if (!SMESH::AddHypothesisOnSubMesh( mySubMesh, aHyp )) + nbFail++; } } } } } - return true; + return ( nbFail == 0 ); } diff --git a/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.h b/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.h index 2e707dd49..11ca8d494 100644 --- a/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.h +++ b/src/SMESHGUI/SMESHGUI_EditHypothesesDlg.h @@ -39,7 +39,6 @@ // IDL Headers #include #include CORBA_SERVER_HEADER(GEOM_Gen) -#include CORBA_SERVER_HEADER(GEOM_Shape) #include CORBA_SERVER_HEADER(SMESH_Mesh) #include @@ -86,11 +85,13 @@ private: bool StoreMesh(); bool StoreSubMesh(); + bool IsOld(QListBoxItem* hypItem); + private: SMESHGUI* mySMESHGUI ; SALOME_Selection* mySelection ; - GEOM::GEOM_Shape_var myGeomShape ; + GEOM::GEOM_Object_var myGeomShape ; QLineEdit* myEditCurrentArgument; SMESH::SMESH_Mesh_var myMesh; @@ -100,6 +101,7 @@ private: Handle(SMESH_TypeFilter) myMeshOrSubMeshFilter; MapIOR myMapOldHypos, myMapOldAlgos; + int myNbModification; bool myImportedMesh; diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx new file mode 100644 index 000000000..c47fa7a5b --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx @@ -0,0 +1,748 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_ExtrusionDlg.cxx +// Author : Michael ZORIN +// Module : SMESH +// $Header: + +#include "SMESHGUI_ExtrusionDlg.h" +#include "SMESHGUI.h" +#include "SMESHGUI_SpinBox.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_MeshUtils.h" +#include "SMESHGUI_IdValidator.h" +#include "SMESH_Actor.h" +#include "SMESH_TypeFilter.hxx" +#include "SMDS_Mesh.hxx" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +//================================================================================= +// class : SMESHGUI_ExtrusionDlg() +// purpose : +//================================================================================= +SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, + bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | + Qt::WDestructiveClose) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_EDGE"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_TRIANGLE"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); + + if ( !name ) + setName( "SMESHGUI_ExtrusionDlg" ); + resize( 303, 185 ); + setCaption( tr( "EXTRUSION_ALONG_LINE" ) ); + setSizeGripEnabled( TRUE ); + SMESHGUI_ExtrusionDlgLayout = new QGridLayout( this ); + SMESHGUI_ExtrusionDlgLayout->setSpacing( 6 ); + SMESHGUI_ExtrusionDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "SMESH_EXTRUSION" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" ); + RadioButton1->setText( tr( "" ) ); + RadioButton1->setPixmap( image0 ); + GroupConstructorsLayout->addWidget( RadioButton1, 0, 0 ); + RadioButton2= new QRadioButton( GroupConstructors, "RadioButton2" ); + RadioButton2->setText( tr( "" ) ); + RadioButton2->setPixmap( image1 ); + GroupConstructorsLayout->addWidget( RadioButton2, 0, 2 ); + SMESHGUI_ExtrusionDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_ExtrusionDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupArguments = new QGroupBox( this, "GroupArguments" ); + GroupArguments->setTitle( tr( "EXTRUSION_1D" ) ); + GroupArguments->setColumnLayout(0, Qt::Vertical ); + GroupArguments->layout()->setSpacing( 0 ); + GroupArguments->layout()->setMargin( 0 ); + GroupArgumentsLayout = new QGridLayout( GroupArguments->layout()); + GroupArgumentsLayout->setAlignment( Qt::AlignTop ); + GroupArgumentsLayout->setSpacing( 6 ); + GroupArgumentsLayout->setMargin( 11 ); + + // Controls for elements selection + TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" ); + TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) ); + TextLabelElements->setFixedWidth(74); + GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 ); + + SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" ); + SelectElementsButton->setText( tr( "" ) ); + SelectElementsButton->setPixmap( image2 ); + SelectElementsButton->setToggleButton( FALSE ); + GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 ); + + LineEditElements = new QLineEdit( GroupArguments, "LineEditElements" ); + LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" )); + GroupArgumentsLayout->addMultiCellWidget( LineEditElements, 0, 0, 2, 7 ); + + // Control for the whole mesh selection + CheckBoxMesh = new QCheckBox( GroupArguments, "CheckBoxMesh" ); + CheckBoxMesh->setText( tr( "SMESH_SELECT_WHOLE_MESH" ) ); + GroupArgumentsLayout->addMultiCellWidget( CheckBoxMesh, 1, 1, 0, 7 ); + + // Controls for vector selection + TextLabelVector = new QLabel( GroupArguments, "TextLabelVector" ); + TextLabelVector->setText( tr( "SMESH_VECTOR" ) ); + GroupArgumentsLayout->addWidget( TextLabelVector, 2, 0 ); + + TextLabelDx = new QLabel( GroupArguments, "TextLabelDx" ); + TextLabelDx->setText( tr( "SMESH_DX" ) ); + GroupArgumentsLayout->addWidget( TextLabelDx, 2, 2 ); + + SpinBox_Dx = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Dx"); + GroupArgumentsLayout->addWidget( SpinBox_Dx, 2, 3 ); + + TextLabelDy = new QLabel( GroupArguments, "TextLabelDy" ); + TextLabelDy->setText( tr( "SMESH_DY" ) ); + GroupArgumentsLayout->addWidget( TextLabelDy, 2, 4 ); + + SpinBox_Dy = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Dy"); + GroupArgumentsLayout->addWidget( SpinBox_Dy, 2, 5 ); + + TextLabelDz = new QLabel( GroupArguments, "TextLabelDz" ); + TextLabelDz->setText( tr( "SMESH_DZ" ) ); + GroupArgumentsLayout->addWidget( TextLabelDz, 2, 6 ); + + SpinBox_Dz = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Dz"); + GroupArgumentsLayout->addWidget( SpinBox_Dz, 2, 7 ); + + // Controls for nb. steps defining + TextLabelNbSteps = new QLabel( GroupArguments, "TextLabelNbSteps" ); + TextLabelNbSteps->setText( tr( "SMESH_NUMBEROFSTEPS" ) ); + GroupArgumentsLayout->addMultiCellWidget( TextLabelNbSteps, 3, 3, 0, 1 ); + + SpinBox_NbSteps = new QSpinBox(GroupArguments, "SpinBox_NbSteps"); + GroupArgumentsLayout->addMultiCellWidget( SpinBox_NbSteps, 3, 3, 2, 7 ); + + SMESHGUI_ExtrusionDlgLayout->addWidget( GroupArguments, 1, 0 ); + + /* Initialisations */ + SpinBox_Dx->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox_Dy->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox_Dz->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + + QIntValidator* anIntValidator = new QIntValidator(SpinBox_NbSteps); + SpinBox_NbSteps->setValidator(anIntValidator); + SpinBox_NbSteps->setRange( 1, 999999 ); + + GroupArguments->show(); + RadioButton1->setChecked( TRUE ); + mySelection = Sel; + + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + // Costruction of the logical filter + SMESH_ListOfFilter aListOfFilters; + Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); + if ( !aMeshOrSubMeshFilter.IsNull() ) + aListOfFilters.Append( aMeshOrSubMeshFilter ); + Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP ); + if ( !aSmeshGroupFilter.IsNull() ) + aListOfFilters.Append( aSmeshGroupFilter ); + + myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR ); + + Init(); + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + /* to close dialog if study change */ + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + connect( LineEditElements, SIGNAL( textChanged( const QString& )), + SLOT( onTextChange( const QString& ))); + connect( CheckBoxMesh, SIGNAL( toggled( bool )), + SLOT( onSelectMesh( bool ))); + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + ConstructorsClicked(0); +} + +//================================================================================= +// function : ~SMESHGUI_ExtrusionDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_ExtrusionDlg::~SMESHGUI_ExtrusionDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_ExtrusionDlg::Init( bool ResetControls ) +{ + myBusy = false; + + LineEditElements->clear(); + myElementsId = ""; + myNbOkElements = 0 ; + + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + + myActor = 0; + myMesh = SMESH::SMESH_Mesh::_nil(); + + if( ResetControls ) + { + SpinBox_NbSteps->setValue(1); + SpinBox_Dx->SetValue(0); + SpinBox_Dy->SetValue(0); + SpinBox_Dz->SetValue(0); + + CheckBoxMesh->setChecked(false); + onSelectMesh( false ); + } +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_ExtrusionDlg::ConstructorsClicked(int constructorId) +{ + disconnect(mySelection, 0, this, 0); + + switch(constructorId) + { + case 0 : + { + GroupArguments->setTitle( tr( "EXTRUSION_1D" ) ); + if ( !CheckBoxMesh->isChecked() ) + QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true ); + break; + } + case 1 : + { + GroupArguments->setTitle( tr( "EXTRUSION_2D" ) ); + if ( !CheckBoxMesh->isChecked() ) + QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true ); + break; + } + } + + myEditCurrentArgument = LineEditElements; + LineEditElements->setFocus(); + + if (CheckBoxMesh->isChecked()) + onSelectMesh(true); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_ExtrusionDlg::ClickOnApply() +{ + if (mySMESHGUI->ActiveStudyLocked()) + return; + + if ( myNbOkElements) + { + QStringList aListElementsId = QStringList::split( " ", myElementsId, false); + + SMESH::long_array_var anElementsId = new SMESH::long_array; + + anElementsId->length( aListElementsId.count() ); + for ( int i = 0; i < aListElementsId.count(); i++ ) + anElementsId[i] = aListElementsId[i].toInt(); + + SMESH::DirStruct aVector; + aVector.PS.x = SpinBox_Dx->GetValue(); + aVector.PS.y = SpinBox_Dy->GetValue(); + aVector.PS.z = SpinBox_Dz->GetValue(); + + long aNbSteps = (long)SpinBox_NbSteps->value(); + + try + { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + QApplication::setOverrideCursor(Qt::waitCursor); + aMeshEditor->ExtrusionSweep(anElementsId.inout(), aVector, aNbSteps); + QApplication::restoreOverrideCursor(); + } + catch( ... ) + { + } + + mySelection->ClearIObjects(); + SMESH::UpdateView(); + Init( false); + ConstructorsClicked( GetConstructorId() ); + } +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_ExtrusionDlg::ClickOnOk() +{ + ClickOnApply(); + ClickOnCancel(); +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_ExtrusionDlg::ClickOnCancel() +{ + mySelection->ClearFilters(); + mySelection->ClearIObjects(); + SMESH::SetPointRepresentation(false); + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + reject() ; +} + +//======================================================================= +//function : onTextChange +//purpose : +//======================================================================= +void SMESHGUI_ExtrusionDlg::onTextChange(const QString& theNewText) +{ + QLineEdit* send = (QLineEdit*)sender(); + + if ( myBusy ) return; + myBusy = true; + + if (send == LineEditElements) + myNbOkElements = 0; + + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + + // hilight entered elements/nodes + SMDS_Mesh* aMesh = 0; + if ( myActor ) + aMesh = myActor->GetObject()->GetMesh(); + + if ( aMesh ) { + mySelection->ClearIObjects(); + mySelection->AddIObject( myActor->getIO() ); + + QStringList aListId = QStringList::split( " ", theNewText, false); + + if (send == LineEditElements) { + for ( int i = 0; i < aListId.count(); i++ ) { + const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() ); + if ( e ) { + if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() )) + mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true); + myNbOkElements++; + } + } + myElementsId = theNewText; + } + } + + if ( myNbOkElements ) { + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); + } + + myBusy = false; +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void SMESHGUI_ExtrusionDlg::SelectionIntoArgument() +{ + if ( myBusy ) return; + + // clear + myActor = 0; + QString aString = ""; + + myBusy = true; + myEditCurrentArgument->setText( aString ); + myNbOkElements = 0; + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + myBusy = false; + + if ( !GroupButtons->isEnabled() ) // inactive + return; + + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + + // get selected mesh + + int nbSel = SMESH::GetNameOfSelectedIObjects(mySelection, aString); + if(nbSel != 1) + return; + + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + myMesh = SMESH::GetMeshByIO(IO); + if(myMesh->_is_nil()) + return; + myActor = SMESH::FindActorByObject(myMesh); + if (!myActor) + return; + + if (myEditCurrentArgument == LineEditElements) + { + int aNbElements = 0; + myElementsId = ""; + + if (CheckBoxMesh->isChecked()) + { + SMESH::GetNameOfSelectedIObjects(mySelection, aString); + + int aConstructorId = GetConstructorId(); + + if(!SMESH::IObjectToInterface(IO)->_is_nil()) //MESH + { + // get IDs from mesh + SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); + if (!aSMDSMesh) + return; + + if (aConstructorId == 0) + { + SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator(); + + while ( anIter->more() ) + { + const SMDS_MeshEdge * edge = anIter->next(); + if ( edge ) { + myElementsId += QString(" %1").arg(edge->GetID()); + aNbElements++; + } + } + } + else if (aConstructorId == 1) + { + SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator(); + while ( anIter->more() ) + { + const SMDS_MeshFace * face = anIter->next(); + if ( face ) { + myElementsId += QString(" %1").arg(face->GetID()); + aNbElements++; + } + } + } + } + else if (!SMESH::IObjectToInterface(IO)->_is_nil()) //SUBMESH + { + // get submesh + SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(IO) ; + + // get IDs from submesh + SMESH::long_array_var anElementsIds = new SMESH::long_array; + if (aConstructorId == 0) + anElementsIds = aSubMesh->GetElementsByType(SMESH::EDGE); + else if (aConstructorId == 1) + anElementsIds = aSubMesh->GetElementsByType(SMESH::FACE); + + for ( int i = 0; i < anElementsIds->length(); i++ ) + myElementsId += QString(" %1").arg(anElementsIds[i]); + aNbElements = anElementsIds->length(); + } + else // GROUP + { + // get smesh group + SMESH::SMESH_GroupBase_var aGroup = + SMESH::IObjectToInterface(IO); + if (aGroup->_is_nil()) + return; + + if ( (aConstructorId == 0 && aGroup->GetType()!= SMESH::EDGE) || + (aConstructorId == 1 && aGroup->GetType()!= SMESH::FACE) ) + return; + + // get IDs from smesh group + SMESH::long_array_var anElementsIds = new SMESH::long_array; + anElementsIds = aGroup->GetListOfID(); + for ( int i = 0; i < anElementsIds->length(); i++ ) + myElementsId += QString(" %1").arg(anElementsIds[i]); + aNbElements = anElementsIds->length(); + } + } + else + { + aNbElements = SMESH::GetNameOfSelectedElements(mySelection, aString) ; + myElementsId = aString; + } + + if(aNbElements < 1) + return ; + + myNbOkElements = true; + } + + myBusy = true; + myEditCurrentArgument->setText( aString ); + myBusy = false; + + // OK + + if(myNbOkElements) + { + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); + } +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void SMESHGUI_ExtrusionDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + disconnect( mySelection, 0, this, 0 ); + mySelection->ClearIObjects(); + mySelection->ClearFilters(); + + if(send == SelectElementsButton) { + myEditCurrentArgument = LineEditElements; + if (CheckBoxMesh->isChecked()) + { + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter); + } + else + { + int aConstructorId = GetConstructorId(); + if (aConstructorId == 0) + QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true ); + else if (aConstructorId == 1) + QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true ); + } + } + + myEditCurrentArgument->setFocus(); + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + SelectionIntoArgument() ; +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_ExtrusionDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupArguments->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + mySMESHGUI->ResetState() ; + mySMESHGUI->SetActiveDialogBox(0) ; + } +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_ExtrusionDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupArguments->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + ConstructorsClicked(GetConstructorId()); + SelectionIntoArgument(); +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_ExtrusionDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_ExtrusionDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; +} + + +//======================================================================= +//function : hideEvent +//purpose : caused by ESC key +//======================================================================= + +void SMESHGUI_ExtrusionDlg::hideEvent ( QHideEvent * e ) +{ + if ( !isMinimized() ) + ClickOnCancel(); +} + + +//======================================================================= +//function : onSelectMesh +//purpose : +//======================================================================= +void SMESHGUI_ExtrusionDlg::onSelectMesh ( bool toSelectMesh ) +{ + if (toSelectMesh) + TextLabelElements->setText( tr( "SMESH_NAME" ) ); + else + TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) ); + + if (myEditCurrentArgument != LineEditElements) + { + LineEditElements->clear(); + return; + } + + mySelection->ClearFilters() ; + + if (toSelectMesh) + { + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter); + LineEditElements->setReadOnly(true); + } + else + { + int aConstructorId = GetConstructorId(); + if (aConstructorId == 0) + QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true ); + else if (aConstructorId == 0) + QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true ); + + LineEditElements->setReadOnly(false); + onTextChange(LineEditElements->text()); + } + + SelectionIntoArgument(); +} + + +//================================================================================= +// function : GetConstructorId() +// purpose : +//================================================================================= +int SMESHGUI_ExtrusionDlg::GetConstructorId() +{ + if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL ) + return GroupConstructors->id( GroupConstructors->selected() ); + return -1; +} diff --git a/src/SMESHGUI/SMESHGUI_AddFaceDlg.h b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h similarity index 60% rename from src/SMESHGUI/SMESHGUI_AddFaceDlg.h rename to src/SMESHGUI/SMESHGUI_ExtrusionDlg.h index 1373926d7..c6f80f0e2 100644 --- a/src/SMESHGUI/SMESHGUI_AddFaceDlg.h +++ b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.h @@ -21,25 +21,20 @@ // // // -// File : SMESHGUI_AddFaceDlg.h -// Author : Nicolas REJNERI +// File : SMESHGUI_ExtrusionDlg.h +// Author : Michael ZORIN // Module : SMESH -// $Header$ +// $Header: -#ifndef DIALOGBOX_ADD_FACE_H -#define DIALOGBOX_ADD_FACE_H +#ifndef DIALOGBOX_EXTRUSION_H +#define DIALOGBOX_EXTRUSION_H #include "SALOME_Selection.h" +#include "SMESH_LogicalFilter.hxx" // QT Includes -#include #include -// Open CASCADE Includes -#include - -class QVBoxLayout; -class QHBoxLayout; class QGridLayout; class QButtonGroup; class QGroupBox; @@ -48,57 +43,71 @@ class QLineEdit; class QPushButton; class QRadioButton; class QCheckBox; +class QSpinBox; +class SMESHGUI_SpinBox; class SMESHGUI; +class SMESH_Actor; // IDL Headers #include #include CORBA_SERVER_HEADER(SMESH_Mesh) + //================================================================================= -// class : SMESHGUI_AddFaceDlg +// class : SMESHGUI_ExtrusionDlg // purpose : //================================================================================= -class SMESHGUI_AddFaceDlg : public QDialog +class SMESHGUI_ExtrusionDlg : public QDialog { Q_OBJECT public: - SMESHGUI_AddFaceDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, - int nbNode = 3, bool modal = FALSE, WFlags fl = 0 ); - ~SMESHGUI_AddFaceDlg(); + SMESHGUI_ExtrusionDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_ExtrusionDlg(); private: - void Init( SALOME_Selection* Sel ) ; + void Init( bool ResetControls = true ) ; void closeEvent( QCloseEvent* e ) ; void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void hideEvent ( QHideEvent * ); /* ESC key */ + int GetConstructorId(); SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ SALOME_Selection* mySelection ; /* User shape selection */ - bool myOkNodes ; /* to check when arguments is defined */ - - int myNodes ; - bool reverse ; - int myConstructorId ; /* Current constructor id = radio button id */ + QString myElementsId; + int myNbOkElements ; /* to check when elements are defined */ + QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + bool myBusy; SMESH::SMESH_Mesh_var myMesh; - TColStd_MapOfInteger myMapIndex; - + SMESH_Actor* myActor; + Handle(SMESH_LogicalFilter) myMeshOrSubMeshOrGroupFilter; + QButtonGroup* GroupConstructors; - QRadioButton* Constructor1; + QRadioButton* RadioButton1; + QRadioButton* RadioButton2; QGroupBox* GroupButtons; QPushButton* buttonOk; QPushButton* buttonCancel; QPushButton* buttonApply; - QGroupBox* GroupC1; - QLabel* TextLabelC1A1; - QPushButton* SelectButtonC1A1; - QLineEdit* LineEditC1A1; - - QCheckBox* Reverse; - -private slots: + QGroupBox* GroupArguments; + QLabel* TextLabelElements; + QPushButton* SelectElementsButton; + QLineEdit* LineEditElements; + QCheckBox* CheckBoxMesh; + QLabel* TextLabelVector; + QLabel* TextLabelDx; + SMESHGUI_SpinBox* SpinBox_Dx; + QLabel* TextLabelDy; + SMESHGUI_SpinBox* SpinBox_Dy; + QLabel* TextLabelDz; + SMESHGUI_SpinBox* SpinBox_Dz; + QLabel* TextLabelNbSteps; + QSpinBox* SpinBox_NbSteps; + + private slots: void ConstructorsClicked(int constructorId); void ClickOnOk(); @@ -108,13 +117,14 @@ private slots: void SelectionIntoArgument() ; void DeactivateActiveDialog() ; void ActivateThisDialog() ; - void CheckBox( int ); - + void onTextChange(const QString&); + void onSelectMesh(bool toSelectMesh); + protected: - QGridLayout* SMESHGUI_AddFaceDlgLayout; + QGridLayout* SMESHGUI_ExtrusionDlgLayout; QGridLayout* GroupConstructorsLayout; QGridLayout* GroupButtonsLayout; - QGridLayout* GroupC1Layout; + QGridLayout* GroupArgumentsLayout; }; -#endif // DIALOGBOX_ADD_FACE_H +#endif // DIALOGBOX_EXTRUSION_H diff --git a/src/SMESHGUI/SMESHGUI_Filter.cxx b/src/SMESHGUI/SMESHGUI_Filter.cxx index 22a2e8910..f6c4ae5b5 100755 --- a/src/SMESHGUI/SMESHGUI_Filter.cxx +++ b/src/SMESHGUI/SMESHGUI_Filter.cxx @@ -1,22 +1,22 @@ -// SMESHGUI_Filter : Filters for VTK viewer +// SMESHGUI_PredicateFilter : Filters for VTK viewer // // 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 -// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // @@ -26,6 +26,10 @@ // Module : SMESH #include "SMESHGUI_Filter.h" +#include "SMESHGUI_Utils.h" +#include "SMDS_Mesh.hxx" +#include "SMDS_MeshElement.hxx" +#include "SMDSAbs_ElementType.hxx" #include @@ -37,78 +41,302 @@ IMPLEMENT_STANDARD_HANDLE(SMESHGUI_Filter, VTKViewer_Filter) IMPLEMENT_STANDARD_RTTIEXT(SMESHGUI_Filter, VTKViewer_Filter) +IMPLEMENT_STANDARD_HANDLE(SMESHGUI_PredicateFilter, SMESHGUI_Filter) +IMPLEMENT_STANDARD_RTTIEXT(SMESHGUI_PredicateFilter, SMESHGUI_Filter) + +IMPLEMENT_STANDARD_HANDLE(SMESHGUI_QuadrangleFilter, SMESHGUI_Filter) +IMPLEMENT_STANDARD_RTTIEXT(SMESHGUI_QuadrangleFilter, SMESHGUI_Filter) + +IMPLEMENT_STANDARD_HANDLE(SMESHGUI_TriangleFilter, SMESHGUI_Filter) +IMPLEMENT_STANDARD_RTTIEXT(SMESHGUI_TriangleFilter, SMESHGUI_Filter) + /* - Class : SMESHGUI_Filter + Class : SMESHGUI_PredicateFilter Description : Selection filter for VTK viewer. This class aggregate object - of SMESH_Filter class and uses it for verification of criterion + of SMESH_Predicate class and uses it for verification of criterion */ //======================================================================= -// name : SMESHGUI_Filter::SMESHGUI_Filter +// name : SMESHGUI_PredicateFilter::SMESHGUI_PredicateFilter // Purpose : Constructor //======================================================================= -SMESHGUI_Filter::SMESHGUI_Filter() +SMESHGUI_PredicateFilter::SMESHGUI_PredicateFilter() { - myActor = 0; } -SMESHGUI_Filter::~SMESHGUI_Filter() +SMESHGUI_PredicateFilter::~SMESHGUI_PredicateFilter() { } //======================================================================= -// name : SMESHGUI_Filter::IsValid +// name : SMESHGUI_PredicateFilter::IsValid // Purpose : Verify whether entry id satisfies to criterion of the filter //======================================================================= -bool SMESHGUI_Filter::IsValid( const int theCellId ) const +bool SMESHGUI_PredicateFilter::IsValid( const int theCellId ) const { if ( myActor == 0 || myPred->_is_nil() ) return false; SMESH_Actor* anActor = ( SMESH_Actor* )myActor; + if ( anActor->GetObject() == 0 ) + return false; + + SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); + SMESH::ElementType anElemType = myPred->GetElementType(); + int aMeshId = anElemType == SMESH::NODE ? anActor->GetNodeObjId( theCellId ) + : anActor->GetElemObjId( theCellId ); - int aMeshId = 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; + return myPred->IsSatisfy( aMeshId ); } //======================================================================= -// name : SMESHGUI_Filter::SetPredicate -// Purpose : Set new pridicate to the filter +// name : SMESHGUI_PredicateFilter::IsValid +// Purpose : Verify whether entry id satisfies to criterion of the filter //======================================================================= -void SMESHGUI_Filter::SetPredicate( SMESH::Predicate_ptr thePred ) +bool SMESHGUI_PredicateFilter::IsObjValid( const int theObjId ) const { - myPred = thePred; + if ( myActor == 0 || myPred->_is_nil() ) + return false; + + SMESH_Actor* anActor = ( SMESH_Actor* )myActor; + if ( anActor->GetObject() == 0 ) + return false; + + SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); + SMESH::ElementType anElemType = 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; + + return myPred->IsSatisfy( theObjId ); } //======================================================================= -// name : SMESHGUI_Filter::GetActor -// Purpose : Get actor of the filter +// name : SMESHGUI_PredicateFilter::IsNodeFilter +// Purpose : Returns true if filter is intended for nodes //======================================================================= -SALOME_Actor* SMESHGUI_Filter::GetActor() const +bool SMESHGUI_PredicateFilter::IsNodeFilter() const { - return myActor; + return GetId() == SMESHGUI_NodeFilter; } //======================================================================= -// name : SMESHGUI_Filter::SetActor +// name : SMESHGUI_PredicateFilter::SetPredicate +// Purpose : Set new pridicate to the filter +//======================================================================= +void SMESHGUI_PredicateFilter::SetPredicate( SMESH::Predicate_ptr thePred ) +{ + myPred = SMESH::Predicate::_duplicate( thePred ); +} + +//======================================================================= +// name : SMESHGUI_PredicateFilter::SetActor // Purpose : Set new actor //======================================================================= -void SMESHGUI_Filter::SetActor( SALOME_Actor* theActor ) +void SMESHGUI_PredicateFilter::SetActor( SALOME_Actor* theActor ) { if ( myActor == theActor ) return; - VTKViewer_Filter::SetActor( theActor ); + SMESHGUI_Filter::SetActor( theActor ); if ( myActor != 0 && !myPred->_is_nil() ) { Handle(SALOME_InteractiveObject) anIO = myActor->getIO(); if ( !anIO.IsNull() ) { - Standard_Boolean aRes = false; - SMESH::SMESH_Mesh_ptr aMeshPtr = SMESHGUI::GetSMESHGUI()->ConvertIOinMesh( anIO, aRes ); - if ( aRes ) - myPred->SetMesh( aMeshPtr ); + SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface(anIO); + if(!aMesh->_is_nil()) + myPred->SetMesh(aMesh); } } } + +//======================================================================= +// name : SMESHGUI_PredicateFilter::SetActor +// Purpose : Get ID of the filter. Must return value from SMESHGUI_FilterType +// enumeration. All filters must have different ids +//======================================================================= +int SMESHGUI_PredicateFilter::GetId() const +{ + if ( myPred->GetElementType() == SMESH::NODE ) return SMESHGUI_NodeFilter; + else if ( myPred->GetElementType() == SMESH::EDGE ) return SMESHGUI_EdgeFilter; + else if ( myPred->GetElementType() == SMESH::FACE ) return SMESHGUI_FaceFilter; + else if ( myPred->GetElementType() == SMESH::VOLUME ) return SMESHGUI_VolumeFilter; + else if ( myPred->GetElementType() == SMESH::ALL ) return SMESHGUI_AllElementsFilter; + else return SMESHGUI_UnknownFilter; +} + + +/* + Class : SMESHGUI_QuadrangleFilter + Description : Verify whether selected cell is quadranle +*/ + +//======================================================================= +// name : SMESHGUI_QuadrangleFilter::SMESHGUI_QuadrangleFilter +// Purpose : Constructor +//======================================================================= +SMESHGUI_QuadrangleFilter::SMESHGUI_QuadrangleFilter() +: SMESHGUI_Filter() +{ +} + +SMESHGUI_QuadrangleFilter::~SMESHGUI_QuadrangleFilter() +{ +} + +//======================================================================= +// name : SMESHGUI_QuadrangleFilter::IsValid +// Purpose : Verify whether selected cell is quadranle +//======================================================================= +bool SMESHGUI_QuadrangleFilter::IsValid( const int theCellId ) const +{ + if ( myActor == 0 ) + return false; + + SMESH_Actor* anActor = ( SMESH_Actor* )myActor; + if ( anActor->GetObject() == 0 ) + return false; + + SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); + const SMDS_MeshElement* anElem = aMesh->FindElement( anActor->GetElemObjId( theCellId ) ); + + return anElem != 0 ? anElem->GetType() != SMDSAbs_Face || anElem->NbNodes() == 4 : false; +} + +//======================================================================= +// name : SMESHGUI_QuadrangleFilter::IsValid +// Purpose : Verify whether selected cell is quadranle +//======================================================================= +bool SMESHGUI_QuadrangleFilter::IsObjValid( const int theObjId ) const +{ + if ( myActor == 0 ) + return false; + + SMESH_Actor* anActor = ( SMESH_Actor* )myActor; + if ( anActor->GetObject() == 0 ) + return false; + + SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); + const SMDS_MeshElement* anElem = aMesh->FindElement( theObjId ); + + return anElem != 0 ? anElem->GetType() != SMDSAbs_Face || anElem->NbNodes() == 4 : false; +} + +//======================================================================= +// name : SMESHGUI_QuadrangleFilter::SetActor +// Purpose : Get ID of the filter. Must return value from SMESHGUI_FilterType +// enumeration. All filters must have different ids +//======================================================================= +int SMESHGUI_QuadrangleFilter::GetId() const +{ + return SMESHGUI_QuadFilter; +} + +//======================================================================= +// name : SMESHGUI_QuadrangleFilter::IsNodeFilter +// Purpose : Returns true if filter is intended for nodes +//======================================================================= +bool SMESHGUI_QuadrangleFilter::IsNodeFilter() const +{ + return false; +} + + +/* + Class : SMESHGUI_TriangleFilter + Description : Verify whether selected cell is triangle +*/ + + +//======================================================================= +// name : SMESHGUI_TriangleFilter::SMESHGUI_TriangleFilter +// Purpose : Constructor +//======================================================================= +SMESHGUI_TriangleFilter::SMESHGUI_TriangleFilter() +: SMESHGUI_Filter() +{ +} + +SMESHGUI_TriangleFilter::~SMESHGUI_TriangleFilter() +{ +} + +//======================================================================= +// name : SMESHGUI_TriangleFilter::IsValid +// Purpose : Verify whether selected cell is triangle +//======================================================================= +bool SMESHGUI_TriangleFilter::IsValid( const int theCellId ) const +{ + if ( myActor == 0 ) + return false; + + SMESH_Actor* anActor = ( SMESH_Actor* )myActor; + if ( anActor->GetObject() == 0 ) + return false; + + SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); + const SMDS_MeshElement* anElem = aMesh->FindElement( anActor->GetElemObjId( theCellId ) ); + + return anElem != 0 ? anElem->GetType() != SMDSAbs_Face || anElem->NbNodes() == 3 : false; +} + +//======================================================================= +// name : SMESHGUI_TriangleFilter::IsValid +// Purpose : Verify whether selected cell is triangle +//======================================================================= +bool SMESHGUI_TriangleFilter::IsObjValid( const int theObjId ) const +{ + if ( myActor == 0 ) + return false; + + SMESH_Actor* anActor = ( SMESH_Actor* )myActor; + if ( anActor->GetObject() == 0 ) + return false; + + SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh(); + const SMDS_MeshElement* anElem = aMesh->FindElement( theObjId ); + + return anElem != 0 ? anElem->GetType() != SMDSAbs_Face || anElem->NbNodes() == 3 : false; +} + +//======================================================================= +// name : SMESHGUI_TriangleFilter::SetActor +// Purpose : Get ID of the filter. Must return value from SMESHGUI_FilterType +// enumeration. All filters must have different ids +//======================================================================= +int SMESHGUI_TriangleFilter::GetId() const +{ + return SMESHGUI_TriaFilter; +} + +//======================================================================= +// name : SMESHGUI_TriangleFilter::IsNodeFilter +// Purpose : Returns true if filter is intended for nodes +//======================================================================= +bool SMESHGUI_TriangleFilter::IsNodeFilter() const +{ + return false; +} + + + + + + + + + + + diff --git a/src/SMESHGUI/SMESHGUI_Filter.h b/src/SMESHGUI/SMESHGUI_Filter.h index 91f3bd700..a3fcf83b3 100755 --- a/src/SMESHGUI/SMESHGUI_Filter.h +++ b/src/SMESHGUI/SMESHGUI_Filter.h @@ -28,41 +28,117 @@ #ifndef SMESHGUI_Filter_HeaderFile #define SMESHGUI_Filter_HeaderFile -#include "VTKViewer_Filter.h" - +#include "VTKViewer_Filter.h" + #include #include CORBA_SERVER_HEADER(SMESH_Filter) class SALOME_Actor; - -DEFINE_STANDARD_HANDLE(SMESHGUI_Filter, VTKViewer_Filter) +enum SMESHGUI_FilterType +{ + SMESHGUI_UnknownFilter = -1, + SMESHGUI_NodeFilter = 0, + SMESHGUI_EdgeFilter = 1, + SMESHGUI_FaceFilter = 2, + SMESHGUI_VolumeFilter = 3, + SMESHGUI_AllElementsFilter = 4, + SMESHGUI_QuadFilter = 5, + SMESHGUI_TriaFilter = 6 +}; /* Class : SMESHGUI_Filter - Description : Selection filter for VTK viewer + Description : Base class for SMESH selection filters for VTK viewer. */ +DEFINE_STANDARD_HANDLE(SMESHGUI_Filter, VTKViewer_Filter) + class SMESHGUI_Filter : public VTKViewer_Filter { public: - SMESHGUI_Filter(); - virtual ~SMESHGUI_Filter(); - virtual bool IsValid( const int theCellId ) const; + virtual bool IsObjValid( const int theObjId ) const = 0; +public: + DEFINE_STANDARD_RTTI(SMESHGUI_Filter) +}; + +/* + Class : SMESHGUI_PredicateFilter + Description : Selection filter for VTK viewer. This class aggregate object + of SMESH_Predicate class and uses it for verification of criterion +*/ + +DEFINE_STANDARD_HANDLE(SMESHGUI_PredicateFilter, SMESHGUI_Filter) + +class SMESHGUI_PredicateFilter : public SMESHGUI_Filter +{ - virtual void SetActor( SALOME_Actor* ); - SALOME_Actor* GetActor() const; - +public: + SMESHGUI_PredicateFilter(); + virtual ~SMESHGUI_PredicateFilter(); + + virtual bool IsValid( const int theCellId ) const; + virtual bool IsObjValid( const int theObjId ) const; + virtual int GetId() const; + virtual bool IsNodeFilter() const; void SetPredicate( SMESH::Predicate_ptr ); - + + void SetActor( SALOME_Actor* ); + private: - + SMESH::Predicate_var myPred; -public: - DEFINE_STANDARD_RTTI(SMESHGUI_Filter) +public: + DEFINE_STANDARD_RTTI(SMESHGUI_PredicateFilter) +}; + +/* + Class : SMESHGUI_QuadrangleFilter + Description : Verify whether selected cell is quadranle +*/ + +DEFINE_STANDARD_HANDLE(SMESHGUI_QuadrangleFilter, SMESHGUI_Filter) + +class SMESHGUI_QuadrangleFilter : public SMESHGUI_Filter +{ + +public: + SMESHGUI_QuadrangleFilter(); + virtual ~SMESHGUI_QuadrangleFilter(); + + virtual bool IsValid( const int theCellId ) const; + virtual bool IsObjValid( const int theObjId ) const; + virtual int GetId() const; + virtual bool IsNodeFilter() const; + +public: + DEFINE_STANDARD_RTTI(SMESHGUI_QuadrangleFilter) +}; + +/* + Class : SMESHGUI_TriangleFilter + Description : Verify whether selected cell is triangle +*/ + +DEFINE_STANDARD_HANDLE(SMESHGUI_TriangleFilter, SMESHGUI_Filter) + +class SMESHGUI_TriangleFilter : public SMESHGUI_Filter +{ + +public: + SMESHGUI_TriangleFilter(); + virtual ~SMESHGUI_TriangleFilter(); + + virtual bool IsValid( const int theCellId ) const; + virtual bool IsObjValid( const int theObjId ) const; + virtual int GetId() const; + virtual bool IsNodeFilter() const; + +public: + DEFINE_STANDARD_RTTI(SMESHGUI_TriangleFilter) }; #endif diff --git a/src/SMESHGUI/SMESHGUI_FilterDlg.cxx b/src/SMESHGUI/SMESHGUI_FilterDlg.cxx index 5995bd8ba..7aeb763d3 100755 --- a/src/SMESHGUI/SMESHGUI_FilterDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_FilterDlg.cxx @@ -25,18 +25,39 @@ // Author : Sergey LITONIN // Module : SMESH -#include "SMESHGUI.h" #include "SMESHGUI_FilterDlg.h" + +#include "SMESHGUI.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_FilterUtils.h" + #include "SMESHGUI_Filter.h" #include "SMESH_Actor.h" -#include "VTKViewer_InteractorStyleSALOME.h" #include "VTKViewer_ViewFrame.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" #include "QAD_RightFrame.h" +#include "QAD_Config.h" #include "SALOME_ListIteratorOfListIO.hxx" +#include "SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger.hxx" #include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "SMESHGUI_FilterLibraryDlg.h" +#include "SALOME_TypeFilter.hxx" +#include "GEOMBase.h" +#include "GEOM_FaceFilter.hxx" #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -57,741 +78,1911 @@ #include #include #include +#include +#include #define SPACING 5 #define MARGIN 10 -static int maxLength( const QStringList& theList, const QFontMetrics& theMetrics ) +using namespace SMESH; + +static int maxLength( const QMap theMap, const QFontMetrics& theMetrics ) { int aRes = 0; - QStringList::const_iterator anIter; - for ( anIter = theList.begin(); anIter != theList.end(); ++anIter ) - aRes = Max( aRes, theMetrics.width( *anIter ) ); + QMap::const_iterator anIter; + for ( anIter = theMap.begin(); anIter != theMap.end(); ++anIter ) + aRes = Max( aRes, theMetrics.width( anIter.data() ) ); return aRes; } +static int getFilterId( SMESH::ElementType theType ) +{ + switch ( theType ) + { + case SMESH::NODE : return SMESHGUI_NodeFilter; + case SMESH::EDGE : return SMESHGUI_EdgeFilter; + case SMESH::FACE : return SMESHGUI_FaceFilter; + case SMESH::VOLUME : return SMESHGUI_VolumeFilter; + case SMESH::ALL : return SMESHGUI_AllElementsFilter; + default : return SMESHGUI_UnknownFilter; + } +} + /* - Class : SMESHGUI_FilterDlg::Table - Description : Table used by this dialog + Class : SMESHGUI_FilterTable::AdditionalWidget + Description : Class for storing additional parameters of criterion */ -class SMESHGUI_FilterDlg::Table : public QTable +class SMESHGUI_FilterTable::AdditionalWidget : public QFrame { public: - Table( QWidget* parent = 0 ); - Table( int numRows, int numCols, QWidget* parent = 0 ); - virtual ~Table(); - - void SetEditable( const bool state, const int row, const int col ); - bool IsEditable( const int row, const int col ) const; + enum { Tolerance }; + +public: - virtual bool eventFilter( QObject *o, QEvent *e ); - virtual void insertRows( int row, int count = 1 ); - virtual QString text( int row, int col ) const; + AdditionalWidget( QWidget* theParent ); + virtual ~AdditionalWidget(); + + virtual void GetParameters( QValueList& ) const; + virtual bool IsValid( const bool theMsg = true ) const; + virtual double GetDouble( const int theId ) const; + virtual int GetInteger( const int theId ) const; + virtual QString GetString( const int theId ) const; + virtual void SetDouble( const int theId, const double theVal ); + virtual void SetInteger( const int theId, const int theVal ); + virtual void SetString( const int theId, const QString& theVal ); + void SetEditable( const int theId, const bool isEditable ); + void SetEditable( const bool isEditable ); + +private: + QMap< int, QLineEdit* > myLineEdits; }; -SMESHGUI_FilterDlg::Table::Table( QWidget* parent ) -: QTable( parent, "SMESHGUI_FilterDlg::Table" ) +SMESHGUI_FilterTable::AdditionalWidget::AdditionalWidget( QWidget* theParent ) +: QFrame( theParent ) { -} + QLabel* aLabel = new QLabel( tr( "SMESH_TOLERANCE" ), this ); + myLineEdits[ Tolerance ] = new QLineEdit( this ); + QDoubleValidator* aValidator = new QDoubleValidator( myLineEdits[ Tolerance ] ); + aValidator->setBottom( 0 ); + myLineEdits[ Tolerance ]->setValidator( aValidator ); + + QHBoxLayout* aLay = new QHBoxLayout( this, 0, SPACING ); + aLay->addWidget( aLabel ); + aLay->addWidget( myLineEdits[ Tolerance ] ); + + QSpacerItem* aSpacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); + aLay->addItem( aSpacer ); -SMESHGUI_FilterDlg::Table::Table( int numRows, int numCols, QWidget* parent ) -: QTable( numRows, numCols, parent, "SMESHGUI_FilterDlg::Table" ) + QString aText = QString( "%1" ).arg( Precision::Confusion() ); + myLineEdits[ Tolerance ]->setText( aText ); +} +SMESHGUI_FilterTable::AdditionalWidget::~AdditionalWidget() { } -SMESHGUI_FilterDlg::Table::~Table() +void SMESHGUI_FilterTable::AdditionalWidget::GetParameters( QValueList& theList ) const { + theList.clear(); + theList.append( Tolerance ); } -void SMESHGUI_FilterDlg::Table::SetEditable( const bool isEditable, const int row, const int col ) +bool SMESHGUI_FilterTable::AdditionalWidget::IsValid( const bool theMsg ) const { - QTableItem* anItem = item( row, col ); - if( anItem ) - takeItem( anItem ); + if ( !isEnabled() ) + return true; - if ( !isEditable ) - { - setItem( row, col, new QTableItem( this, QTableItem::Never, "" ) ); - } - else + QValueList aParams; + GetParameters( aParams ); + QValueList::const_iterator anIter; + for ( anIter = aParams.begin(); anIter != aParams.end(); ++anIter ) { - setItem( row, col, new QTableItem( this, QTableItem::OnTyping, "" ) ); + const QLineEdit* aWg = myLineEdits[ *anIter ]; + int p = 0; + QString aText = aWg->text(); + if ( aWg->isEnabled() && aWg->validator()->validate( aText, p ) != QValidator::Acceptable ) + { + if ( theMsg ) + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_INSUFFICIENT_DATA" ), tr( "SMESHGUI_INVALID_PARAMETERS" ), QMessageBox::Ok ); + return false; + } } + + return true; } -bool SMESHGUI_FilterDlg::Table::IsEditable( const int row, const int col ) const +double SMESHGUI_FilterTable::AdditionalWidget::GetDouble( const int theId ) const { - QTableItem* anItem = item( row, col ); - return anItem == 0 || anItem->editType() != QTableItem::Never; + return myLineEdits.contains( theId ) ? myLineEdits[ theId ]->text().toDouble() : 0; } -void SMESHGUI_FilterDlg::Table::insertRows( int row, int count ) +int SMESHGUI_FilterTable::AdditionalWidget::GetInteger( const int theId ) const { - int anEditRow = currEditRow(); - int anEditCol = currEditCol(); - -// printf( "sln: anEditRow = %d, anEditCol = %d\n", anEditRow, anEditCol ); + return myLineEdits.contains( theId ) ? myLineEdits[ theId ]->text().toInt() : 0; +} - if ( anEditRow >= 0 && anEditCol >= 0 ) - endEdit( anEditRow, anEditCol, true, false ); +QString SMESHGUI_FilterTable::AdditionalWidget::GetString( const int theId ) const +{ + return myLineEdits.contains( theId ) ? myLineEdits[ theId ]->text() : QString(""); +} - QTable::insertRows( row, count ); +void SMESHGUI_FilterTable::AdditionalWidget::SetDouble( const int theId, const double theVal ) +{ + if ( myLineEdits.contains( theId ) ) + myLineEdits[ theId ]->setText( QString( "%1" ).arg( theVal ) ); } -QString SMESHGUI_FilterDlg::Table::text( int row, int col ) const +void SMESHGUI_FilterTable::AdditionalWidget::SetInteger( const int theId, const int theVal ) { - int anEditRow = currEditRow(); - int anEditCol = currEditCol(); + if ( myLineEdits.contains( theId ) ) + myLineEdits[ theId ]->setText( QString( "%1" ).arg( theVal ) ); +} - if ( anEditRow >= 0 && anEditCol >= 0 && anEditRow == row && anEditCol == col ) - ((Table*)this)->endEdit( row, col, true, false ); +void SMESHGUI_FilterTable::AdditionalWidget::SetString( const int theId, const QString& theVal ) +{ + if ( myLineEdits.contains( theId ) ) + myLineEdits[ theId ]->setText( theVal ); +} - return QTable::text( row, col ); +void SMESHGUI_FilterTable::AdditionalWidget::SetEditable( const int theId, const bool isEditable ) +{ + if ( myLineEdits.contains( theId ) ) + myLineEdits[ theId ]->setEdited( isEditable ); } -bool SMESHGUI_FilterDlg::Table::eventFilter( QObject *o, QEvent *e ) +void SMESHGUI_FilterTable::AdditionalWidget::SetEditable( const bool isEditable ) { - return QTable::eventFilter( o, e ); + QValueList aParams; + GetParameters( aParams ); + QValueList::const_iterator anIter; + for ( anIter = aParams.begin(); anIter != aParams.end(); ++anIter ) + myLineEdits[ *anIter ]->setEdited( isEditable ); } /* - Class : SMESHGUI_FilterDlg - Description : Dialog to specify filters for VTK viewer + Class : SMESHGUI_FilterTable::ComboItem + Description : Combo table item. Identificator corresponding to string may be assigned */ +class SMESHGUI_FilterTable::ComboItem : public QComboTableItem -//======================================================================= -// name : SMESHGUI_FilterDlg::SMESHGUI_FilterDlg -// Purpose : Constructor -//======================================================================= -SMESHGUI_FilterDlg::SMESHGUI_FilterDlg( QWidget* theParent, - const int theType, - const bool theModal, - const char* theName ) -: QDialog( theParent, theName, theModal, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) { - myType = theType; +public: + ComboItem( QTable*, const QMap& ); + virtual ~ComboItem(); - setCaption( tr( "CAPTION" ) ); + virtual void setStringList ( const QStringList & l ); + void setStringList( const QMap& theIds ); - QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); + int GetValue() const; + void SetValue( const int ); + +private: + + QMap myNumToId; + QMap myIdToNum; +}; - myMainFrame = createMainFrame ( this ); - QFrame* aBtnFrame = createButtonFrame( this, theModal ); +SMESHGUI_FilterTable::ComboItem::ComboItem( QTable* theParent, + const QMap& theIds ) +: QComboTableItem( theParent, QStringList() ) +{ + setStringList( theIds ); +} - aDlgLay->addWidget( myMainFrame ); - aDlgLay->addWidget( aBtnFrame ); +void SMESHGUI_FilterTable::ComboItem::setStringList( const QStringList & l ) +{ + QComboTableItem::setStringList( l ); +} - aDlgLay->setStretchFactor( myMainFrame, 1 ); +void SMESHGUI_FilterTable::ComboItem::setStringList( const QMap& theIds ) +{ + int i = 0; + QStringList aList; + QMap::const_iterator anIter; + for ( anIter = theIds.begin(); anIter != theIds.end(); ++anIter ) + { + myNumToId[ i ] = anIter.key(); + myIdToNum[ anIter.key() ] = i; + aList.append( anIter.data() ); + i++; + } - Init( myType ); + setStringList( aList ); } - -//======================================================================= -// name : SMESHGUI_FilterDlg::createMainFrame -// Purpose : Create frame containing dialog's input fields -//======================================================================= -QFrame* SMESHGUI_FilterDlg::createMainFrame( QWidget* theParent ) +SMESHGUI_FilterTable::ComboItem::~ComboItem() { - QGroupBox* aMainFrame = new QGroupBox( 1, Qt::Horizontal, theParent ); - aMainFrame->setFrameStyle( QFrame::NoFrame ); - aMainFrame->setInsideMargin( 0 ); +} + +int SMESHGUI_FilterTable::ComboItem::GetValue() const +{ + return myNumToId[ currentItem() ]; +} - // filter frame +void SMESHGUI_FilterTable::ComboItem::SetValue( const int theVal ) +{ + setCurrentItem( myIdToNum[ theVal ] ); +} - QGroupBox* aFilterGrp = new QGroupBox( 1, Qt::Horizontal, tr ( "Filter" ), aMainFrame ); - QFrame* aFilterFrame = new QFrame( aFilterGrp ); - myTableGrp = new QGroupBox( 1, Qt::Horizontal, aFilterFrame ); - myTableGrp->setFrameStyle( QFrame::NoFrame ); - myTableGrp->setInsideMargin( 0 ); - - myTables[ myType ] = createTable( myTableGrp, myType ); - myAddBtn = new QPushButton( tr( "ADD" ), aFilterFrame ); - myRemoveBtn = new QPushButton( tr( "REMOVE" ), aFilterFrame ); - myClearBtn = new QPushButton( tr( "CLEAR" ), aFilterFrame ); +/* + Class : SMESHGUI_FilterTable::Table + Description : Table used by this widget +*/ - QGridLayout* aLay = new QGridLayout( aFilterFrame, 4, 2, 0, SPACING ); +class SMESHGUI_FilterTable::Table : public QTable +{ +public: + Table( QWidget* parent ); + Table( int numRows, int numCols, QWidget* parent = 0 ); + virtual ~Table(); - aLay->addMultiCellWidget( myTableGrp, 0, 3, 0, 0 ); - aLay->addWidget( myAddBtn, 0, 1 ); - aLay->addWidget( myRemoveBtn, 1, 1 ); - aLay->addWidget( myClearBtn, 2, 1 ); - aLay->setColStretch( 0, 1 ); - aLay->setColStretch( 1, 0 ); + void SetEditable( const bool state, const int row, const int col ); + bool IsEditable( const int row, const int col ) const; - mySetInViewer = new QCheckBox( tr( "SET_IN_VIEWER" ), aFilterGrp ); - mySetInViewer->setChecked( true ); + virtual void insertRows( int row, int count = 1 ); + virtual QString text( int row, int col ) const; +}; - QSpacerItem* aVSpacer = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ); - aLay->addItem( aVSpacer, 3, 1 ); +//======================================================================= +// name : SMESHGUI_FilterTable::Table::Table +// Purpose : Constructor +//======================================================================= +SMESHGUI_FilterTable::Table::Table( QWidget* parent ) +: QTable( parent, "SMESHGUI_FilterTable::Table" ) +{ +} - // other controls - mySourceGrp = createSourceGroup( aMainFrame ); - - // signals and slots - connect( myAddBtn, SIGNAL( clicked() ), this, SLOT( onAddBtn() ) ); - connect( myRemoveBtn, SIGNAL( clicked() ), this, SLOT( onRemoveBtn() ) ); - connect( myClearBtn, SIGNAL( clicked() ), this, SLOT( onClearBtn() ) ); +SMESHGUI_FilterTable::Table::Table( int numRows, int numCols, QWidget* parent ) +: QTable( numRows, numCols, parent, "SMESHGUI_FilterTable::Table" ) +{ +} - return aMainFrame; +SMESHGUI_FilterTable::Table::~Table() +{ } //======================================================================= -// name : SMESHGUI_FilterDlg::createSourceFrame -// Purpose : Create frame containing source radio button +// name : SMESHGUI_FilterTable::Table::SetEditable +// Purpose : Set editable of specified cell //======================================================================= -QButtonGroup* SMESHGUI_FilterDlg::createSourceGroup( QWidget* theParent ) +void SMESHGUI_FilterTable::Table::SetEditable( const bool isEditable, const int row, const int col ) { - QButtonGroup* aGrp = new QButtonGroup( 1, Qt::Vertical, tr( "SOURCE" ), theParent ); - - QRadioButton* aMeshBtn = new QRadioButton( tr( "MESH" ), aGrp ); - QRadioButton* aSelBtn = new QRadioButton( tr( "SELECTION" ), aGrp ); - QRadioButton* aGrpBtn = new QRadioButton( tr( "CURRENT_GROUP" ), aGrp ); -// QRadioButton* aNoneBtn = new QRadioButton( tr( "NONE" ), aGrp ); - - aGrp->insert( aMeshBtn, Mesh ); - aGrp->insert( aSelBtn, Selection ); - aGrp->insert( aGrpBtn, Dialog ); -// aGrp->insert( aNoneBtn, None ); + QTableItem* anItem = item( row, col ); + if( anItem ) + takeItem( anItem ); - aGrp->setButton( Selection ); + if ( !isEditable ) + setItem( row, col, new QTableItem( this, QTableItem::Never, "" ) ); + else + setItem( row, col, new QTableItem( this, QTableItem::OnTyping, "" ) ); +} - return aGrp; +//======================================================================= +// name : SMESHGUI_FilterTable::Table::IsEditable +// Purpose : Verify wheter cell is editable +//======================================================================= +bool SMESHGUI_FilterTable::Table::IsEditable( const int row, const int col ) const +{ + QTableItem* anItem = item( row, col ); + return anItem == 0 || anItem->editType() != QTableItem::Never; } //======================================================================= -// name : SMESHGUI_FilterDlg::createTable -// Purpose : Create table +// name : SMESHGUI_FilterTable::Table::insertRows +// Purpose : Insert rows ( virtual redefined ) //======================================================================= -SMESHGUI_FilterDlg::Table* SMESHGUI_FilterDlg::createTable( QWidget* theParent, - const int theType ) +void SMESHGUI_FilterTable::Table::insertRows( int row, int count ) { - // create table - Table* aTable= new Table( 0, 5, theParent ); + int anEditRow = currEditRow(); + int anEditCol = currEditCol(); - QHeader* aHeaders = aTable->horizontalHeader(); + if ( anEditRow >= 0 && anEditCol >= 0 ) + endEdit( anEditRow, anEditCol, true, false ); - QFontMetrics aMetrics( aHeaders->font() ); + QTable::insertRows( row, count ); +} - int aLenCr = abs( maxLength( getCriteria( theType ), aMetrics ) - - aMetrics.width( tr( "CRITERION" ) ) ) / aMetrics.width( ' ' ) + 5; +//======================================================================= +// name : SMESHGUI_FilterTable::Table::text +// Purpose : Get text from cell ( virtual redefined ) +//======================================================================= +QString SMESHGUI_FilterTable::Table::text( int row, int col ) const +{ + int anEditRow = currEditRow(); + int anEditCol = currEditCol(); - int aLenCo = abs( maxLength( getCriteria( theType ), aMetrics ) - - aMetrics.width( tr( "COMPARE" ) ) ) / aMetrics.width( ' ' ) + 5; + if ( anEditRow >= 0 && anEditCol >= 0 && anEditRow == row && anEditCol == col ) + ((Table*)this)->endEdit( row, col, true, false ); - QString aCrStr; - aCrStr.fill( ' ', aLenCr ); - QString aCoStr; - aCoStr.fill( ' ', 10 ); + return QTable::text( row, col ); +} - aHeaders->setLabel( 0, tr( "CRITERION" ) + aCrStr ); - aHeaders->setLabel( 1, tr( "COMPARE" ) + aCoStr ); - aHeaders->setLabel( 2, tr( "THRESHOLD_VALUE" ) ); - aHeaders->setLabel( 3, tr( "UNARY" ) ); - aHeaders->setLabel( 4, tr( "BINARY" ) + " " ); - // set geometry of the table - for ( int i = 0; i <= 4; i++ ) - aTable->adjustColumn( i ); +/* + Class : SMESHGUI_FilterTable + Description : Frame containig + - Button group for switching entity type + - Table for displaying filter criterions + - Buttons for editing table and filter libraries +*/ - aTable->updateGeometry(); - QSize aSize = aTable->sizeHint(); - int aWidth = aSize.width(); - aTable->setMinimumSize( QSize( aWidth, aWidth / 2 ) ); - aTable->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding) ); +//======================================================================= +// name : SMESHGUI_FilterTable::SMESHGUI_FilterTable +// Purpose : Constructor +//======================================================================= +SMESHGUI_FilterTable::SMESHGUI_FilterTable( QWidget* parent, + const int type ) +: QFrame( parent ) +{ + myEntityType = -1; + Init( type ); +} - if ( theType == SMESH::EDGE ) - connect( aTable, SIGNAL( valueChanged( int, int ) ), - this, SLOT( onCriterionChanged( int, int ) ) ); +//======================================================================= +// name : SMESHGUI_FilterTable::SMESHGUI_FilterTable +// Purpose : Constructor +//======================================================================= +SMESHGUI_FilterTable::SMESHGUI_FilterTable( QWidget* parent, + const QValueList& types ) +: QFrame( parent ) +{ + myEntityType = -1; + Init( types ); +} - return aTable; +SMESHGUI_FilterTable::~SMESHGUI_FilterTable() +{ } //======================================================================= -// name : SMESHGUI_FilterDlg::createButtonFrame -// Purpose : Create frame containing buttons +// name : SMESHGUI_FilterTable::Init +// Purpose : Create table corresponding to the specified type //======================================================================= -QFrame* SMESHGUI_FilterDlg::createButtonFrame( QWidget* theParent, const bool theModal ) +void SMESHGUI_FilterTable::Init( const int type ) { - QGroupBox* aGrp = new QGroupBox( 1, Qt::Vertical, theParent ); - - myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), aGrp ); - myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), aGrp ); - QLabel* aLbl = new QLabel( aGrp ); - myCloseBtn = new QPushButton( tr( "SMESH_BUT_CANCEL" ), aGrp ); + QValueList aTypes; + aTypes.append( type ); + Init( aTypes ); +} - aLbl->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); +//======================================================================= +// name : SMESHGUI_FilterTable::Init +// Purpose : Create table corresponding to the specified type +//======================================================================= +void SMESHGUI_FilterTable::Init( const QValueList& theTypes ) +{ + if ( theTypes.isEmpty() ) + return; + + // Create buttons if necessary + + if ( myTables.isEmpty() ) + { + int aType = theTypes.first(); + + // create main layout + QVBoxLayout* aMainLay = new QVBoxLayout( this ); + QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Horizontal, this ); + aMainGrp->setFrameStyle( QFrame::NoFrame ); + aMainGrp->setInsideMargin( 0 ); + aMainLay->addWidget( aMainGrp ); + + // create switch of entity types + myEntityTypeGrp = new QButtonGroup( 1, Qt::Vertical, tr( "ENTITY_TYPE" ), aMainGrp ); + const QMap& aSupportedTypes = getSupportedTypes(); + QMap::const_iterator anIter; + for ( anIter = aSupportedTypes.begin(); anIter != aSupportedTypes.end(); ++anIter ) + { + QRadioButton* aBtn = new QRadioButton( anIter.data(), myEntityTypeGrp ); + myEntityTypeGrp->insert( aBtn, anIter.key() ); + } + + myTableGrp = new QGroupBox( 1, Qt::Horizontal, tr( "FILTER" ), aMainGrp ); + QFrame* aTableFrame = new QFrame( myTableGrp ); + + // create table + mySwitchTableGrp = new QGroupBox( 1, Qt::Horizontal, aTableFrame ); + mySwitchTableGrp->setFrameStyle( QFrame::NoFrame ); + mySwitchTableGrp->setInsideMargin( 0 ); + + myTables[ aType ] = createTable( mySwitchTableGrp, aType ); + + // create buttons + myAddBtn = new QPushButton( tr( "ADD" ), aTableFrame ); + myRemoveBtn = new QPushButton( tr( "REMOVE" ), aTableFrame ); + myClearBtn = new QPushButton( tr( "CLEAR" ), aTableFrame ); + myInsertBtn = new QPushButton( tr( "INSERT" ), aTableFrame ); + myCopyFromBtn = new QPushButton( tr( "COPY_FROM" ), aTableFrame ); + myAddToBtn = new QPushButton( tr( "ADD_TO" ), aTableFrame ); + + myAddBtn->setAutoDefault( false ); + myRemoveBtn->setAutoDefault( false ); + myClearBtn->setAutoDefault( false ); + myInsertBtn->setAutoDefault( false ); + myCopyFromBtn->setAutoDefault( false ); + myAddToBtn->setAutoDefault( false ); + + myCopyFromBtn->hide(); + myAddToBtn->hide(); + + // layout widgets + QGridLayout* aLay = new QGridLayout( aTableFrame, 8, 2, 0, SPACING ); + + aLay->addMultiCellWidget( mySwitchTableGrp, 0, 6, 0, 0 ); + aLay->addWidget( myAddBtn, 0, 1 ); + aLay->addWidget( myInsertBtn, 1, 1 ); + aLay->addWidget( myRemoveBtn, 2, 1 ); + aLay->addWidget( myClearBtn, 3, 1 ); + aLay->addWidget( myCopyFromBtn, 5, 1 ); + aLay->addWidget( myAddToBtn, 6, 1 ); + aLay->addMultiCellWidget( createAdditionalFrame( aTableFrame ), 7, 7, 0, 1 ); + + aLay->setColStretch( 0, 1 ); + aLay->setColStretch( 1, 0 ); + + QSpacerItem* aVSpacer = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ); + aLay->addItem( aVSpacer, 4, 1 ); + + // signals and slots + connect( myAddBtn, SIGNAL( clicked() ), this, SLOT( onAddBtn() ) ); + connect( myInsertBtn, SIGNAL( clicked() ), this, SLOT( onInsertBtn() ) ); + connect( myRemoveBtn, SIGNAL( clicked() ), this, SLOT( onRemoveBtn() ) ); + connect( myClearBtn, SIGNAL( clicked() ), this, SLOT( onClearBtn() ) ); + + connect( myCopyFromBtn, SIGNAL( clicked() ), this, SLOT( onCopyFromBtn() ) ); + connect( myAddToBtn, SIGNAL( clicked() ), this, SLOT( onAddToBtn() ) ); + + connect( myEntityTypeGrp, SIGNAL( clicked( int ) ), this, SLOT( onEntityType( int ) ) ); + + myLibDlg = 0; + } + + // Hide buttons of entity types if necessary + const QMap& aSupportedTypes = getSupportedTypes(); + QMap::const_iterator anIt; + for ( anIt = aSupportedTypes.begin(); anIt != aSupportedTypes.end(); ++anIt ) + { + QButton* aBtn = myEntityTypeGrp->find( anIt.key() ); + theTypes.contains( anIt.key() ) ? aBtn->show() : aBtn->hide(); + } - connect( myOkBtn, SIGNAL( clicked() ), SLOT( onOk() ) ); - connect( myCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ) ; - connect( myApplyBtn, SIGNAL( clicked() ), SLOT( onApply() ) ); + // select first button if there is no selected buttons or it is hidden + QButton* aBtn = myEntityTypeGrp->selected(); + if ( aBtn == 0 || theTypes.find( myEntityTypeGrp->id( aBtn ) ) == theTypes.end() ) + myEntityTypeGrp->setButton( theTypes.first() ); - if ( theModal ) - myApplyBtn->hide(); + if ( theTypes.count() == 1 ) + myEntityTypeGrp->hide(); + else + myEntityTypeGrp->show(); - return aGrp; + myTableGrp->updateGeometry(); + int aType = myEntityTypeGrp->id( myEntityTypeGrp->selected() ); + onEntityType( aType ); } //======================================================================= -// name : SMESHGUI_FilterDlg::~SMESHGUI_FilterDlg -// Purpose : Destructor +// name : SMESHGUI_FilterTable::GetTableGrp +// Purpose : Get group box containing table. May be used for adding new widgets in it +////======================================================================= +QWidget* SMESHGUI_FilterTable::createAdditionalFrame( QWidget* theParent ) +{ + QFrame* aFrame = new QFrame( theParent ); + + QFrame* aLine1 = new QFrame( aFrame ); + QFrame* aLine2 = new QFrame( aFrame ); + aLine1->setFrameStyle( QFrame::HLine | QFrame::Sunken ); + aLine2->setFrameStyle( QFrame::HLine | QFrame::Sunken ); + aLine1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed) ); + aLine2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed) ); + + QLabel* aLabel = new QLabel( tr( "ADDITIONAL_PARAMETERS" ), aFrame ); + + myWgStack = new QWidgetStack( aFrame ); + + QGridLayout* aLay = new QGridLayout( aFrame, 2, 3, 0, SPACING ); + aLay->addWidget( aLine1, 0, 0 ); + aLay->addWidget( aLabel, 0, 1 ); + aLay->addWidget( aLine2, 0, 2 ); + aLay->addMultiCellWidget( myWgStack, 1, 1, 0, 2 ); + + return aFrame; +} + //======================================================================= -SMESHGUI_FilterDlg::~SMESHGUI_FilterDlg() +// name : SMESHGUI_FilterTable::GetTableGrp +// Purpose : Get group box containing table. May be used for adding new widgets in it +////======================================================================= +QGroupBox* SMESHGUI_FilterTable::GetTableGrp() { + return myTableGrp; } //======================================================================= -// name : SMESHGUI_FilterDlg::Init -// Purpose : Init dialog fields, connect signals and slots, show dialog +// name : SMESHGUI_FilterTable::onEntityType +// Purpose : SLOT. Called when entity type changed. +// Display corresponding table //======================================================================= -void SMESHGUI_FilterDlg::Init( const int theType ) +void SMESHGUI_FilterTable::onEntityType( int theType ) { - mySourceWg = 0; - mySelection = 0; - myType = theType; - myMesh = SMESH::SMESH_Mesh::_nil(); + if ( myEntityType == theType ) + return; - // activate corresponding tab - if ( !myTables.contains( myType ) ) - myTables[ myType ] = createTable( myTableGrp, myType ); + myIsValid = true; + emit NeedValidation(); + if ( !myIsValid ) + { + myEntityTypeGrp->setButton( myEntityType ); + return; + } + myEntityType = theType; + + if ( !myTables.contains( theType ) ) + myTables[ theType ] = createTable( mySwitchTableGrp, theType ); + TableMap::iterator anIter; for ( anIter = myTables.begin(); anIter != myTables.end(); ++anIter ) - if ( anIter.key() == theType ) - anIter.data()->show(); - else - anIter.data()->hide(); - - // set caption - setCaption( myType == SMESH::EDGE ? tr( "EDGES_TLT" ) : tr( "FACES_TLT" ) ); + myEntityType == anIter.key() ? anIter.data()->show() : anIter.data()->hide(); + updateBtnState(); qApp->processEvents(); - updateGeometry(); + myTables[ myEntityType ]->updateGeometry(); adjustSize(); - setEnabled( true ); - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( ( QDialog* )this ) ; + emit EntityTypeChanged( theType ); - connect( mySMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( onDeactivate() ) ); - connect( mySMESHGUI, SIGNAL( SignalCloseAllDialogs() ), SLOT( onClose() ) ); +} - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ); - this->move( x, y ); +//======================================================================= +// name : SMESHGUI_FilterTable::IsValid +// Purpose : Verify validity of entered data +//======================================================================= +bool SMESHGUI_FilterTable::IsValid( const bool theMess, const int theEntityType ) const +{ + int aType = theEntityType == -1 ? GetType() : theEntityType; + + Table* aTable = myTables[ aType ]; + for ( int i = 0, n = aTable->numRows(); i < n; i++ ) + { + int aCriterion = GetCriterionType( i, aType ); + + if ( aCriterion == FT_RangeOfIds || + aCriterion == FT_BelongToGeom || + aCriterion == FT_BelongToPlane || + aCriterion == FT_BelongToCylinder ) + { + if ( aTable->text( i, 2 ).isEmpty() ) + { + if ( theMess ) + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_INSUFFICIENT_DATA" ), tr( "ERROR" ), QMessageBox::Ok ); + return false; + } + } + else + { + bool aRes = false; + aTable->blockSignals( true ); + double aThreshold = ( int )aTable->text( i, 2 ).toDouble( &aRes ); + aTable->blockSignals( false ); + + if ( !aRes && aTable->IsEditable( i, 2 ) ) + { + if ( theMess ) + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_INSUFFICIENT_DATA" ), tr( "ERROR" ), QMessageBox::Ok ); + return false; + } + else if ( aType == SMESH::EDGE && + GetCriterionType( i, aType ) == SMESH::FT_MultiConnection && + aThreshold == 1 ) + { + if ( theMess ) + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_INSUFFICIENT_DATA" ), tr( "MULTIEDGES_ERROR" ), QMessageBox::Ok ); + return false; + } + } - this->show(); + QTableItem* anItem = aTable->item( i, 0 ); + if ( myAddWidgets.contains( anItem ) && !myAddWidgets[ anItem ]->IsValid() ) + return false; + } - return; + return true; } //======================================================================= -// name : SMESHGUI_FilterDlg::onOk -// Purpose : SLOT called when "Ok" button pressed. -// Assign filters VTK viewer and close dialog +// name : SMESHGUI_FilterTable::SetValidity +// Purpose : Set validity of the table //======================================================================= -void SMESHGUI_FilterDlg::onOk() +void SMESHGUI_FilterTable::SetValidity( const bool isValid ) { - if ( onApply() ) - { - disconnect( mySMESHGUI, 0, this, 0 ); - mySMESHGUI->ResetState() ; - accept(); - } - + myIsValid = isValid; } //======================================================================= -// name : SMESHGUI_FilterDlg::onClose -// Purpose : SLOT called when "Close" button pressed. Close dialog +// name : SMESHGUI_FilterTable::GetType +// Purpose : Get current entity type //======================================================================= -void SMESHGUI_FilterDlg::onClose() +int SMESHGUI_FilterTable::GetType() const { - disconnect( mySMESHGUI, 0, this, 0 ); - mySMESHGUI->ResetState() ; - reject() ; - return ; + return myEntityType; } //======================================================================= -// name : SMESHGUI_FilterDlg::onDeactivate -// Purpose : SLOT called when dialog must be deativated +// name : SMESHGUI_FilterTable::SetType +// Purpose : Set current entity type //======================================================================= -void SMESHGUI_FilterDlg::onDeactivate() +void SMESHGUI_FilterTable::SetType( const int type ) { - setEnabled( false ); + myEntityTypeGrp->setButton( type ); + onEntityType( type ); } //======================================================================= -// name : SMESHGUI_FilterDlg::enterEvent -// Purpose : Event filter +// name : SMESHGUI_FilterTable::RestorePreviousEntityType +// Purpose : Restore previous entity type //======================================================================= -void SMESHGUI_FilterDlg::enterEvent( QEvent* ) +void SMESHGUI_FilterTable::RestorePreviousEntityType() { -// mySMESHGUI->EmitSignalDeactivateDialog(); - setEnabled( true ); + SetType( myEntityType ); } +//======================================================================= +// name : SMESHGUI_FilterTable::GetCriterionType +// Purpose : Get type of criterion from specified row ( corresponding enums in h-file ) +//======================================================================= +int SMESHGUI_FilterTable::GetCriterionType( const int theRow, const int theType ) const +{ + int aType = theType == -1 ? GetType() : theType; + Table* aTable = myTables[ aType ]; + ComboItem* anItem = (ComboItem*)aTable->item( theRow, 0 ); + return anItem != 0 ? anItem->GetValue() : FT_Undefined; +} -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void SMESHGUI_FilterDlg::closeEvent( QCloseEvent* e ) +//======================================================================= +// name : SMESHGUI_FilterTable::GetCriterion +// Purpose : Get parameters of criterion from specified row +//======================================================================= +void SMESHGUI_FilterTable::GetCriterion( const int theRow, + SMESH::Filter::Criterion& theCriterion, + const int theEntityType ) const { - onClose() ; + int aType = theEntityType == -1 ? GetType() : theEntityType; + Table* aTable = myTables[ aType ]; + + theCriterion.Type = ( (ComboItem*)aTable->item( theRow, 0 ) )->GetValue(); + theCriterion.UnaryOp = ( (QCheckTableItem*)aTable->item( theRow, 3 ) )->isChecked() ? FT_LogicalNOT : FT_Undefined; + theCriterion.BinaryOp = theRow != aTable->numRows() - 1 ? + ( (ComboItem*)aTable->item( theRow, 4 ) )->GetValue() : FT_Undefined; + theCriterion.TypeOfElement = (ElementType)aType; + + int aCriterionType = GetCriterionType( theRow, aType ); + + if ( aCriterionType != FT_RangeOfIds && + aCriterionType != FT_BelongToGeom && + aCriterionType != FT_BelongToPlane && + aCriterionType != FT_BelongToCylinder ) + { + theCriterion.Compare = ( (ComboItem*)aTable->item( theRow, 1 ) )->GetValue(); + theCriterion.Threshold = aTable->item( theRow, 2 )->text().toDouble(); + } + else + theCriterion.ThresholdStr = aTable->text( theRow, 2 ).latin1(); + + QTableItem* anItem = aTable->item( theRow, 0 ); + if ( myAddWidgets.contains( anItem ) ) + theCriterion.Tolerance = myAddWidgets[ anItem ]->GetDouble( AdditionalWidget::Tolerance ); } //======================================================================= -// name : SMESHGUI_FilterDlg::getCriteria -// Purpose : Retrieve list of ids from given widget +// name : SMESHGUI_FilterTable::SetCriterion +// Purpose : Set parameters of criterion of specified row //======================================================================= -void SMESHGUI_FilterDlg::getIdsFromWg( const QWidget* theWg, QValueList& theRes ) const +void SMESHGUI_FilterTable::SetCriterion( const int theRow, + const SMESH::Filter::Criterion& theCriterion, + const int theEntityType ) { - theRes.clear(); - if ( theWg == 0 ) + int aType = theEntityType == -1 ? GetType() : theEntityType; + + Table* aTable = myTables[ aType ]; + + if ( theRow > aTable->numRows() - 1 ) return; - if ( theWg->inherits( "QListBox" ) ) + ( (ComboItem*)aTable->item( theRow, 0 ) )->SetValue( theCriterion.Type ); + onCriterionChanged( theRow, 0, aType ); + ( (ComboItem*)aTable->item( theRow, 1 ) )->SetValue( theCriterion.Compare ); + ( (QCheckTableItem*)aTable->item( theRow, 3 ) )->setChecked( theCriterion.UnaryOp == FT_LogicalNOT ); + + if ( theCriterion.BinaryOp != FT_Undefined ) { - QListBox* aListBox = ( QListBox* )theWg; - bool b; - for ( int i = 0, n = aListBox->count(); i < n; i++ ) - { - int anId = aListBox->text( i ).toInt( &b ); - if ( b ) - theRes.append( anId ); - } + if ( !aTable->IsEditable( theRow, 4 ) ) + aTable->setItem( theRow, 4, getBinaryItem( aTable ) ); + ( (ComboItem*)aTable->item( theRow, 4 ) )->SetValue( theCriterion.BinaryOp ); } - else if ( theWg->inherits( "QLineEdit" ) ) + else + aTable->SetEditable( false, theRow, 4 ); + + if ( theCriterion.Type != FT_RangeOfIds && + theCriterion.Type != FT_BelongToGeom && + theCriterion.Type != FT_BelongToPlane && + theCriterion.Type != FT_BelongToCylinder ) + aTable->setText( theRow, 2, QString( "%1" ).arg( theCriterion.Threshold, 0, 'g', 15 ) ); + else + aTable->setText( theRow, 2, QString( theCriterion.ThresholdStr ) ); + + if ( theCriterion.Compare == FT_EqualTo || + theCriterion.Type == FT_BelongToPlane || + theCriterion.Type == FT_BelongToCylinder ) { - QLineEdit* aLineEdit = ( QLineEdit* )theWg; - QString aStr = aLineEdit->text(); - QRegExp aRegExp( "(\\d+)" ); - bool b; - int aPos = 0; - while ( aPos >= 0 ) + QTableItem* anItem = aTable->item( theRow, 0 ); + if ( !myAddWidgets.contains( anItem ) ) { - aPos = aRegExp.search( aStr, aPos ); - if ( aPos > -1 ) - { - int anId = aRegExp.cap( 1 ).toInt( &b ); - if ( b ) - theRes.append( anId ); - aPos += aRegExp.matchedLength(); - } + myAddWidgets[ anItem ] = new AdditionalWidget( myWgStack ); + myWgStack->addWidget( myAddWidgets[ anItem ] ); } + myAddWidgets[ anItem ]->SetDouble( AdditionalWidget::Tolerance, theCriterion.Tolerance ); } + + emit CretarionChanged( theRow, aType ); + } //======================================================================= -// name : SMESHGUI_FilterDlg::getSelMode -// Purpose : Get criteria for specified type +// name : SMESHGUI_FilterTable::Update +// Purpose : Update table //======================================================================= -Selection_Mode SMESHGUI_FilterDlg::getSelMode( const int theType ) const +void SMESHGUI_FilterTable::Update() { - switch ( theType ) - { - case SMESH::NODE : return NodeSelection; - case SMESH::EDGE : return EdgeSelection; - case SMESH::FACE : return FaceSelection; - case SMESH::VOLUME : return VolumeSelection; - default : return ActorSelection; - } - + Table* aTable = myTables[ GetType() ]; + int aCurrRow = aTable->currentRow(); + int numRows = aTable->numRows(); + if ( ( aCurrRow < 0 || aCurrRow >= numRows ) && numRows > 0 ) + aTable->setCurrentCell( 0, 0 ); + updateAdditionalWidget(); } //======================================================================= -// name : SMESHGUI_FilterDlg::getCriteria -// Purpose : Get criteria for specified type +// name : SMESHGUI_FilterTable::AddCriterion +// Purpose : Add criterion with parameters //======================================================================= -void SMESHGUI_FilterDlg::setIdsToWg( QWidget* theWg, const QValueList& theIds ) +void SMESHGUI_FilterTable::AddCriterion( const SMESH::Filter::Criterion& theCriterion, + const int theEntityType ) { - if ( theWg == 0 ) - return; - - if ( theWg->inherits( "QListBox" ) ) - { - QListBox* aListBox = ( QListBox* )theWg; - aListBox->clear(); - - QStringList aStrList; - QValueList::const_iterator anIter; - for ( anIter = theIds.begin(); anIter != theIds.end(); ++anIter ) - aStrList.append( QString( "%1" ).arg( *anIter ) ); - - aListBox->insertStringList( aStrList ); - } - else if ( theWg->inherits( "QLineEdit" ) ) - { - QLineEdit* aLineEdit = ( QLineEdit* )theWg; - QString aStr; - QValueList::const_iterator anIter; - - for ( anIter = theIds.begin(); anIter != theIds.end(); ++ anIter ) - aStr += QString( "%1 " ).arg( *anIter ); - - if ( !aStr.isEmpty() ) - aStr.remove( aStr.length() - 1, 1 ); - - aLineEdit->setText( aStr ); - } + int aType = theEntityType == -1 ? GetType() : theEntityType; + Table* aTable = myTables[ aType ]; + addRow( aTable, aType ); + SetCriterion( aTable->numRows() - 1, theCriterion ); } //======================================================================= -// name : SMESHGUI_FilterDlg::getCriteria -// Purpose : Get criteria for specified type +// name : SMESHGUI_FilterTable::NumRows +// Purpose : Get number of criterions of current type //======================================================================= -const QStringList& SMESHGUI_FilterDlg::getCriteria( const int theType ) const +int SMESHGUI_FilterTable::NumRows( const int theEntityType ) const { - if ( theType == SMESH::EDGE ) - { - static QStringList aCriteria; - if ( aCriteria.isEmpty() ) - { - aCriteria.append( tr( "FREE_BORDERS" ) ); - aCriteria.append( tr( "MULTI_BORDERS" ) ); - aCriteria.append( tr( "LENGTH" ) ); - } - return aCriteria; - } - else if ( theType == SMESH::FACE ) - { - static QStringList aCriteria; - if ( aCriteria.isEmpty() ) - { - aCriteria.append( tr( "ASPECT_RATIO" ) ); - aCriteria.append( tr( "WARPING" ) ); - aCriteria.append( tr( "MINIMUM_ANGLE" ) ); - aCriteria.append( tr( "TAPER" ) ); - aCriteria.append( tr( "SKEW" ) ); - aCriteria.append( tr( "AREA" ) ); - } - return aCriteria; - } - else - { - static QStringList aCriteria; - return aCriteria; - } + return myTables[ theEntityType == -1 ? GetType() : theEntityType ]->numRows(); } //======================================================================= -// name : SMESHGUI_FilterDlg::getCompare -// Purpose : Get operation of comparison +// name : SMESHGUI_FilterTable::Clear +// Purpose : Clear current table //======================================================================= -const QStringList& SMESHGUI_FilterDlg::getCompare () const +void SMESHGUI_FilterTable::Clear( const int theType ) { - static QStringList aList; + int aType = theType == -1 ? GetType() : theType; + QTable* aTable = myTables[ aType ]; + + if ( aTable->numRows() == 0 ) + return; - if ( aList.isEmpty() ) + while ( aTable->numRows() > 0 ) { - aList.append( tr( "LESS_THAN" ) ); - aList.append( tr( "MORE_THAN" ) ); - aList.append( tr( "EQUAL_TO" ) ); + removeAdditionalWidget( aTable, 0 ); + aTable->removeRow( 0 ); } - return aList; + updateBtnState(); } //======================================================================= -// name : SMESHGUI_FilterDlg::getCriterionItem -// Purpose : Get combo table item for criteria of specified type +// name : SMESHGUI_FilterTable::onAddBtn +// Purpose : SLOT. Called then "Add" button pressed. +// Adds new string to table //======================================================================= -QTableItem* SMESHGUI_FilterDlg::getCriterionItem( QTable* theParent , const int theType ) +void SMESHGUI_FilterTable::onAddBtn() { - return new QComboTableItem( theParent, getCriteria( theType ) ); + int aType = GetType(); + addRow( myTables[ aType ], aType ); + + Table* aTable = myTables[ aType ]; + Update(); } //======================================================================= -// name : SMESHGUI_FilterDlg::getCompareItem -// Purpose : Get combo table item for operation of comparision +// name : SMESHGUI_FilterTable::onInsertBtn +// Purpose : SLOT. Called then "Insert" button pressed. +// Inserts new string before current one //======================================================================= -QTableItem* SMESHGUI_FilterDlg::getCompareItem( QTable* theParent ) +void SMESHGUI_FilterTable::onInsertBtn() { - return new QComboTableItem( theParent, getCompare() ); + addRow( myTables[ GetType() ], GetType(), false ); } //======================================================================= -// name : SMESHGUI_FilterDlg::getLogOpItem -// Purpose : +// name : SMESHGUI_FilterTable::onRemoveBtn +// Purpose : SLOT. Called then "Remove" button pressed. +// Removes current string from table //======================================================================= -QTableItem* SMESHGUI_FilterDlg::getLogOpItem( QTable* theParent ) +void SMESHGUI_FilterTable::onRemoveBtn() { - static QStringList aList; - if ( aList.isEmpty() ) + Table* aTable = myTables[ GetType() ]; + + if ( aTable->numRows() == 0 ) + return; + + QMemArray aRows; + for ( int i = 0, n = aTable->numRows(); i < n; i++ ) { - aList.append( tr( "AND" ) ); - aList.append( tr( "OR" ) ); + if ( aTable->isRowSelected( i ) ) + { + aRows.resize( aRows.size() + 1 ); + aRows[ aRows.size() - 1 ] = i; + removeAdditionalWidget( aTable, i ); + } } - return new QComboTableItem( theParent, aList ); -} + aTable->removeRows( aRows ); -//======================================================================= -// name : SMESHGUI_FilterDlg::getNotItem -// Purpose : Get check table item -//======================================================================= -QTableItem* SMESHGUI_FilterDlg::getNotItem( QTable* theParent ) -{ - return new QCheckTableItem( theParent, tr( "NOT" ) ); + // remove control of binary logical operation from last row + if ( aTable->numRows() > 0 ) + aTable->SetEditable( false, aTable->numRows() - 1, 4 ); + + updateBtnState(); } //======================================================================= -// name : SMESHGUI_FilterDlg::getCurrType -// Purpose : Get current entity type +// name : SMESHGUI_FilterTable::updateAdditionalWidget +// Purpose : Enable/Disable widget with additonal parameters //======================================================================= -int SMESHGUI_FilterDlg::getCurrType() const +void SMESHGUI_FilterTable::updateAdditionalWidget() { - return myType; + Table* aTable = myTables[ GetType() ]; + int aRow = aTable->currentRow(); + if ( aRow < 0 || aRow >= aTable->numRows() ) + { + myWgStack->setEnabled( false ); + return; + } + + ComboItem* anItem = ( (ComboItem*)aTable->item( aRow, 0 ) ); + bool toEnable = ( (ComboItem*)aTable->item( aRow, 1 ) )->GetValue() == FT_EqualTo && + GetCriterionType( aRow ) != FT_BelongToGeom && + GetCriterionType( aRow ) != FT_RangeOfIds && + GetCriterionType( aRow ) != FT_FreeEdges; + if ( !myAddWidgets.contains( anItem ) ) + { + myAddWidgets[ anItem ] = new AdditionalWidget( myWgStack ); + myWgStack->addWidget( myAddWidgets[ anItem ] ); + } + + myWgStack->raiseWidget( myWgStack->id( myAddWidgets[ anItem ] ) ); + myWgStack->setEnabled( toEnable ); } //======================================================================= -// name : SMESHGUI_FilterDlg::getCriterion -// Purpose : +// name : SMESHGUI_FilterTable::removeAdditionalWidget +// Purpose : Remove widgets containing additional parameters from widget +// stack and internal map //======================================================================= -int SMESHGUI_FilterDlg::getCriterion( const int theType, const int theRow ) const +void SMESHGUI_FilterTable::removeAdditionalWidget( QTable* theTable, const int theRow ) { - QComboTableItem* anItem = ( QComboTableItem* )myTables[ getCurrType() ]->item( theRow, 0 ); - return anItem->currentItem(); + QTableItem* anItem = theTable->item( theRow, 0 ); + if ( myAddWidgets.contains( anItem ) ) + { + myWgStack->removeWidget( myAddWidgets[ anItem ] ); + myAddWidgets[ anItem ]->reparent( 0, QPoint() ); + delete myAddWidgets[ anItem ]; + myAddWidgets.remove( anItem ); + } } //======================================================================= -// name : SMESHGUI_FilterDlg::addRow -// Purpose : +// name : SMESHGUI_FilterTable::onClearBtn +// Purpose : SLOT. Called then "Clear" button pressed. +// Removes all strings from table //======================================================================= -void SMESHGUI_FilterDlg::addRow( Table* theTable, const int theType ) +void SMESHGUI_FilterTable::onClearBtn() { - theTable->insertRows( theTable->numRows() ); - int aCurrRow = theTable->numRows() - 1; - - // Criteria - theTable->setItem( aCurrRow, 0, getCriterionItem( theTable, theType ) ); + QTable* aTable = myTables[ GetType() ]; - // Compare - theTable->setItem( aCurrRow, 1, getCompareItem( theTable ) ); + if ( aTable->numRows() == 0 ) + return; - //Logical operation NOT - theTable->setItem( aCurrRow, 3, getNotItem( theTable ) ); + while ( aTable->numRows() > 0 ) + { + removeAdditionalWidget( aTable, 0 ); + aTable->removeRow( 0 ); + } - // Logical binary operation for previous value - if ( aCurrRow > 0 ) - theTable->setItem( aCurrRow - 1, 4, getLogOpItem( theTable ) ); - theTable->SetEditable( false, aCurrRow, 4 ); + updateBtnState(); +} - onCriterionChanged( aCurrRow, 0 ); +//======================================================================= +// name : SMESHGUI_FilterTable::onCurrentChanged() +// Purpose : SLOT. Called when current cell changed +//======================================================================= +void SMESHGUI_FilterTable::onCurrentChanged( int theRow, int theCol ) +{ + updateAdditionalWidget(); + emit CurrentChanged( theRow, theCol ); } //======================================================================= -// name : SMESHGUI_FilterDlg::onAddBtn -// Purpose : SLOT. Called then "Add" button pressed. -// Adds new string to table +// name : SMESHGUI_FilterTable::onCriterionChanged() +// Purpose : Provides reaction on change of criterion //======================================================================= -void SMESHGUI_FilterDlg::onAddBtn() +void SMESHGUI_FilterTable::onCriterionChanged( const int row, const int col, const int entityType ) { - // QTable - int aType = getCurrType(); + int aType = entityType == -1 ? GetType() : entityType; Table* aTable = myTables[ aType ]; + ComboItem* aCompareItem = (ComboItem*)aTable->item( row, 1 ); - addRow( aTable, aType ); + int aCriterionType = GetCriterionType( row ); - updateBtnState(); + if ( aType == SMESH::EDGE && aCriterionType == SMESH::FT_FreeBorders || + aType == SMESH::FACE && aCriterionType == SMESH::FT_FreeEdges ) + { + if ( aCompareItem->count() > 0 ) + aCompareItem->setStringList( QStringList() ); + aTable->SetEditable( false, row, 2 ); + } + else if ( aCriterionType == SMESH::FT_RangeOfIds || + aCriterionType == SMESH::FT_BelongToGeom || + aCriterionType == SMESH::FT_BelongToPlane || + aCriterionType == SMESH::FT_BelongToCylinder ) + { + QMap aMap; + aMap[ FT_EqualTo ] = tr( "EQUAL_TO" ); + aCompareItem->setStringList( aMap ); + if ( !aTable->IsEditable( row, 2 ) ) + aTable->SetEditable( true, row, 2 ); + } + else + { + if ( aCompareItem->count() != 3 ) + { + aCompareItem->setStringList( QStringList() ); + aCompareItem->setStringList( getCompare() ); + } + + QString aText = aTable->text( row, 2 ); + bool isOk = false; + aText.toDouble( &isOk ); + aTable->setText( row, 2, isOk ? aText : QString("") ); + if ( !aTable->IsEditable( row, 2 ) ) + aTable->SetEditable( true, row, 2 ); + } + + updateAdditionalWidget(); + + emit CretarionChanged( row, entityType ); +} + +//======================================================================= +// name : SMESHGUI_FilterTable::onCriterionChanged() +// Purpose : SLOT. Called then contents of table changed +// Provides reaction on change of criterion +//======================================================================= +void SMESHGUI_FilterTable::onCriterionChanged( int row, int col ) +{ + onCriterionChanged( row, col, -1 ); +} + +//======================================================================= +// name : SMESHGUI_FilterTable::getFirstSelectedRow +// Purpose : Get first selected row +//======================================================================= +int SMESHGUI_FilterTable::getFirstSelectedRow() const +{ + QTable* aTable = myTables[ GetType() ]; + for ( int i = 0, n = aTable->numRows(); i < n; i++ ) + if ( aTable->isRowSelected( i ) ) + return i; + + int aRow = aTable->currentRow(); + return aRow >= 0 && aRow < aTable->numRows() ? aRow : -1; +} + +//======================================================================= +// name : SMESHGUI_FilterTable::addRow +// Purpose : Add row at the end of table +//======================================================================= +void SMESHGUI_FilterTable::addRow( Table* theTable, const int theType, const bool toTheEnd ) +{ + int aCurrRow = 0; + int aSelectedRow = getFirstSelectedRow(); + int aCurrCol = theTable->currentColumn(); + + if ( toTheEnd || aSelectedRow == -1 ) + { + theTable->insertRows( theTable->numRows() ); + aCurrRow = theTable->numRows() - 1; + } + else + { + theTable->insertRows( aSelectedRow ); + aCurrRow = aSelectedRow; + } + + // Criteria + theTable->setItem( aCurrRow, 0, getCriterionItem( theTable, theType ) ); + + // Compare + theTable->setItem( aCurrRow, 1, getCompareItem( theTable ) ); + + // Threshold + //theTable->setItem( aCurrRow, 2, new QTableItem( theTable ) ); + + //Logical operation NOT + theTable->setItem( aCurrRow, 3, getUnaryItem( theTable ) ); + + // Logical binary operation for previous value + int anAddBinOpStr = -1; + if ( aCurrRow == theTable->numRows() - 1 ) + anAddBinOpStr = aCurrRow - 1; + else if ( aCurrRow >= 0 ) + anAddBinOpStr = aCurrRow; + + if ( theTable->item( aCurrRow, 4 ) == 0 || + theTable->item( aCurrRow, 4 )->rtti() != 1 ) + { + + + if ( anAddBinOpStr >= 0 && + ( theTable->item( anAddBinOpStr, 4 ) == 0 || + theTable->item( anAddBinOpStr, 4 )->rtti() != 1 ) ) + theTable->setItem( anAddBinOpStr, 4, getBinaryItem( theTable ) ); + } + + theTable->SetEditable( false, theTable->numRows() - 1, 4 ); + + if ( aCurrRow >=0 && aCurrRow < theTable->numRows() && + aCurrCol >=0 && aCurrCol < theTable->numRows() ) + theTable->setCurrentCell( aCurrRow, aCurrCol ); + + onCriterionChanged( aCurrRow, 0 ); + + updateBtnState(); +} + +//======================================================================= +// name : SMESHGUI_FilterTable::getCriterionItem +// Purpose : Get combo table item for criteria of specified type +//======================================================================= +QTableItem* SMESHGUI_FilterTable::getCriterionItem( QTable* theParent , const int theType ) +{ + return new ComboItem( theParent, getCriteria( theType ) ); +} + +//======================================================================= +// name : SMESHGUI_FilterTable::getCompareItem +// Purpose : Get combo table item for operation of comparision +//======================================================================= +QTableItem* SMESHGUI_FilterTable::getCompareItem( QTable* theParent ) +{ + return new ComboItem( theParent, getCompare() ); +} + +//======================================================================= +// name : SMESHGUI_FilterTable::getBinaryItem +// Purpose : +//======================================================================= +QTableItem* SMESHGUI_FilterTable::getBinaryItem( QTable* theParent ) +{ + static QMap aMap; + if ( aMap.isEmpty() ) + { + aMap[ SMESH::FT_LogicalAND ] = tr( "AND" ); + aMap[ SMESH::FT_LogicalOR ] = tr( "OR" ); + } + + return new ComboItem( theParent, aMap ); +} + +//======================================================================= +// name : SMESHGUI_FilterTable::getUnaryItem +// Purpose : Get check table item +//======================================================================= +QTableItem* SMESHGUI_FilterTable::getUnaryItem( QTable* theParent ) +{ + return new QCheckTableItem( theParent, tr( "NOT" ) ); +} + +//======================================================================= +// name : SMESHGUI_FilterTable::getSupportedTypes +// Purpose : Get all supported type +//======================================================================= +const QMap& SMESHGUI_FilterTable::getSupportedTypes() const +{ + static QMap aTypes; + if ( aTypes.isEmpty() ) + { + aTypes[ SMESH::NODE ] = tr( "NODES" ); + aTypes[ SMESH::EDGE ] = tr( "EDGES" ); + aTypes[ SMESH::FACE ] = tr( "FACES" ); + aTypes[ SMESH::VOLUME ] = tr( "VOLUMES" ); + } + + return aTypes; +} + +//======================================================================= +// name : SMESHGUI_FilterTable::getCriteria +// Purpose : Get criteria for specified type +//======================================================================= +const QMap& SMESHGUI_FilterTable::getCriteria( const int theType ) const +{ + if ( theType == SMESH::NODE ) + { + static QMap aCriteria; + if ( aCriteria.isEmpty() ) + { + aCriteria[ SMESH::FT_RangeOfIds ] = tr( "RANGE_OF_IDS" ); + aCriteria[ SMESH::FT_BelongToGeom ] = tr( "BELONG_TO_GEOM" ); + aCriteria[ SMESH::FT_BelongToPlane ] = tr( "BELONG_TO_PLANE" ); + aCriteria[ SMESH::FT_BelongToCylinder ] = tr( "BELONG_TO_CYLINDER" ); + } + return aCriteria; + } + else if ( theType == SMESH::EDGE ) + { + static QMap aCriteria; + if ( aCriteria.isEmpty() ) + { + aCriteria[ SMESH::FT_FreeBorders ] = tr( "FREE_BORDERS" ); + aCriteria[ SMESH::FT_MultiConnection ] = tr( "MULTI_BORDERS" ); + aCriteria[ SMESH::FT_Length ] = tr( "LENGTH" ); + aCriteria[ SMESH::FT_RangeOfIds ] = tr( "RANGE_OF_IDS" ); + aCriteria[ SMESH::FT_BelongToGeom ] = tr( "BELONG_TO_GEOM" ); + aCriteria[ SMESH::FT_BelongToPlane ] = tr( "BELONG_TO_PLANE" ); + aCriteria[ SMESH::FT_BelongToCylinder ] = tr( "BELONG_TO_CYLINDER" ); + } + return aCriteria; + } + else if ( theType == SMESH::FACE ) + { + static QMap aCriteria; + if ( aCriteria.isEmpty() ) + { + aCriteria[ SMESH::FT_AspectRatio ] = tr( "ASPECT_RATIO" ); + aCriteria[ SMESH::FT_Warping ] = tr( "WARPING" ); + aCriteria[ SMESH::FT_MinimumAngle ] = tr( "MINIMUM_ANGLE" ); + aCriteria[ SMESH::FT_Taper ] = tr( "TAPER" ); + aCriteria[ SMESH::FT_Skew ] = tr( "SKEW" ); + aCriteria[ SMESH::FT_Area ] = tr( "AREA" ); + aCriteria[ SMESH::FT_FreeEdges ] = tr( "FREE_EDGES" ); + aCriteria[ SMESH::FT_RangeOfIds ] = tr( "RANGE_OF_IDS" ); + aCriteria[ SMESH::FT_BelongToGeom ] = tr( "BELONG_TO_GEOM" ); + aCriteria[ SMESH::FT_BelongToPlane ] = tr( "BELONG_TO_PLANE" ); + aCriteria[ SMESH::FT_BelongToCylinder ] = tr( "BELONG_TO_CYLINDER" ); + } + return aCriteria; + } + else if ( theType == SMESH::VOLUME ) + { + static QMap aCriteria; + if ( aCriteria.isEmpty() ) + { + aCriteria[ SMESH::FT_RangeOfIds ] = tr( "RANGE_OF_IDS" ); + aCriteria[ SMESH::FT_BelongToGeom ] = tr( "BELONG_TO_GEOM" ); + } + return aCriteria; + } + else + { + static QMap aCriteria; + return aCriteria; + } +} + + +//======================================================================= +// name : SMESHGUI_FilterTable::getCompare +// Purpose : Get operation of comparison +//======================================================================= +const QMap& SMESHGUI_FilterTable::getCompare() const +{ + static QMap aMap; + + if ( aMap.isEmpty() ) + { + aMap[ SMESH::FT_LessThan ] = tr( "LESS_THAN" ); + aMap[ SMESH::FT_MoreThan ] = tr( "MORE_THAN" ); + aMap[ SMESH::FT_EqualTo ] = tr( "EQUAL_TO" ); + } + + return aMap; +} + +//======================================================================= +// name : SMESHGUI_FilterTable::createTable +// Purpose : Create table +//======================================================================= +SMESHGUI_FilterTable::Table* SMESHGUI_FilterTable::createTable( QWidget* theParent, + const int theType ) +{ + // create table + Table* aTable= new Table( 0, 5, theParent ); + + QHeader* aHeaders = aTable->horizontalHeader(); + + QFontMetrics aMetrics( aHeaders->font() ); + + // append spaces to the header of criteria in order to + // provide visibility of criterion inside comboboxes + static int aMaxLenCr = 0; + + if ( aMaxLenCr == 0 ) + { + const QMap& aSupportedTypes = getSupportedTypes(); + QMap::const_iterator anIter; + for ( anIter = aSupportedTypes.begin(); anIter != aSupportedTypes.end(); ++anIter ) + aMaxLenCr = Max( maxLength( getCriteria( anIter.key() ), aMetrics ), aMaxLenCr ); + } + + static int aLenCr = abs( aMaxLenCr - + aMetrics.width( tr( "CRITERION" ) ) ) / aMetrics.width( ' ' ) + 5; + + static int aLenCo = abs( maxLength( getCompare(), aMetrics ) - + aMetrics.width( tr( "COMPARE" ) ) ) / aMetrics.width( ' ' ) + 5; + + QString aCrStr; + aCrStr.fill( ' ', aLenCr ); + QString aCoStr; + aCoStr.fill( ' ', 10 ); + + aHeaders->setLabel( 0, tr( "CRITERION" ) + aCrStr ); + aHeaders->setLabel( 1, tr( "COMPARE" ) + aCoStr ); + aHeaders->setLabel( 2, tr( "THRESHOLD_VALUE" ) ); + aHeaders->setLabel( 3, tr( "UNARY" ) ); + aHeaders->setLabel( 4, tr( "BINARY" ) + " " ); + + // set geometry of the table + for ( int i = 0; i <= 4; i++ ) + aTable->adjustColumn( i ); + + aTable->updateGeometry(); + QSize aSize = aTable->sizeHint(); + int aWidth = aSize.width(); + aTable->setMinimumSize( QSize( aWidth, aWidth / 2 ) ); + aTable->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding) ); + + connect( aTable, SIGNAL( valueChanged( int, int ) ), + this, SLOT( onCriterionChanged( int, int ) ) ); + + connect( aTable, SIGNAL( currentChanged( int, int ) ), + this, SLOT( onCurrentChanged( int, int ) ) ); + + return aTable; +} + +//======================================================================= +// name : SMESHGUI_FilterTable::updateBtnState +// Purpose : Update button state +//======================================================================= +void SMESHGUI_FilterTable::updateBtnState() +{ + myRemoveBtn->setEnabled( myTables[ GetType() ]->numRows() > 0 ); + myClearBtn->setEnabled( myTables[ GetType() ]->numRows() > 0 ); +} + +//======================================================================= +// name : SMESHGUI_FilterTable::SetEditable +// Purpose : Set read only flag for tables. Show/hide buttons for work with rows +//======================================================================= +void SMESHGUI_FilterTable::SetEditable( const bool isEditable ) +{ + TableMap::iterator anIter; + for ( anIter = myTables.begin(); anIter != myTables.end(); ++anIter ) + { + anIter.data()->setReadOnly( !isEditable ); + + if ( isEditable ) + { + myAddBtn->show(); + myInsertBtn->show(); + myRemoveBtn->show(); + myClearBtn->show(); + } + else + { + myAddBtn->hide(); + myInsertBtn->hide(); + myRemoveBtn->hide(); + myClearBtn->hide(); + } + } + + QMap::iterator anIter2; + for ( anIter2 = myAddWidgets.begin(); anIter2 != myAddWidgets.end(); ++anIter2 ) + anIter2.data()->SetEditable( isEditable ); +} + +//======================================================================= +// name : SMESHGUI_FilterTable::SetEnabled +// Purpose : Enable/Disable table. Switching type of elements already enabled +//======================================================================= +void SMESHGUI_FilterTable::SetEnabled( const bool isEnabled ) +{ + myAddBtn->setEnabled( isEnabled ); + myInsertBtn->setEnabled( isEnabled ); + myRemoveBtn->setEnabled( isEnabled ); + myClearBtn->setEnabled( isEnabled ); + + if ( isEnabled ) + updateBtnState(); + + QMap::iterator anIter2; + for ( anIter2 = myAddWidgets.begin(); anIter2 != myAddWidgets.end(); ++anIter2 ) + anIter2.data()->setEnabled( isEnabled ); +} + +//======================================================================= +// name : SMESHGUI_FilterTable::IsEditable +// Purpose : Verify whether table is editable +//======================================================================= +bool SMESHGUI_FilterTable::IsEditable() const +{ + return !myTables[ GetType() ]->isReadOnly(); +} + +//======================================================================= +// name : SMESHGUI_FilterTable::SetLibsEnabled +// Purpose : Show/hide buttons for work with libraries +//======================================================================= +void SMESHGUI_FilterTable::SetLibsEnabled( const bool isEnabled ) +{ + if ( isEnabled ) + { + myCopyFromBtn->show(); + myAddToBtn->show(); + } + else + { + myCopyFromBtn->hide(); + myAddToBtn->hide(); + } +} + +//======================================================================= +// name : SMESHGUI_FilterTable::onCopyFromBtn +// Purpose : SLOT. Called the "Copy from ..." button clicked +// Display filter library dialog +//======================================================================= +void SMESHGUI_FilterTable::onCopyFromBtn() +{ + if ( myLibDlg == 0 ) + myLibDlg = new SMESHGUI_FilterLibraryDlg( + this, GetType(), SMESHGUI_FilterLibraryDlg::COPY_FROM ); + else + myLibDlg->Init( GetType(), SMESHGUI_FilterLibraryDlg::COPY_FROM ); + + if ( myLibDlg->exec() == QDialog::Accepted ) + { + Copy( myLibDlg->GetTable() ); + Update(); + } +} + +//======================================================================= +// name : SMESHGUI_FilterTable::onAddToBtn +// Purpose : SLOT. Called the "Add to ..." button clicked +// Display filter library dialog +//======================================================================= +void SMESHGUI_FilterTable::onAddToBtn() +{ + if ( !IsValid( true ) ) + return; + if ( myLibDlg == 0 ) + myLibDlg = new SMESHGUI_FilterLibraryDlg( + this, GetType(), SMESHGUI_FilterLibraryDlg::ADD_TO ); + else + myLibDlg->Init( GetType(), SMESHGUI_FilterLibraryDlg::ADD_TO ); + + myLibDlg->SetTable( this ); + + myLibDlg->exec(); +} + +//======================================================================= +// name : SMESHGUI_FilterTable::Copy +// Purpose : Initialise table with values of other table +//======================================================================= +void SMESHGUI_FilterTable::Copy( const SMESHGUI_FilterTable* theTable ) +{ + Clear(); + + for ( int i = 0, n = theTable->NumRows(); i < n; i++ ) + { + SMESH::Filter::Criterion aCriterion = SMESHGUI_FilterDlg::createCriterion(); + theTable->GetCriterion( i, aCriterion ); + AddCriterion( aCriterion ); + } +} + +//======================================================================= +// name : SMESHGUI_FilterTable::CurrentCell +// Purpose : Returns current cell +//======================================================================= +bool SMESHGUI_FilterTable::CurrentCell( int& theRow, int& theCol ) const +{ + theRow = myTables[ GetType() ]->currentRow(); + theCol = myTables[ GetType() ]->currentColumn(); + return theRow >= 0 && theCol >= 0; +} + +//======================================================================= +// name : SMESHGUI_FilterTable::SetText +// Purpose : Set text and internal value in cell of threshold value +//======================================================================= +void SMESHGUI_FilterTable::SetThreshold( const int theRow, + const QString& theText, + const int theEntityType ) +{ + Table* aTable = myTables[ theEntityType == -1 ? GetType() : theEntityType ]; + aTable->setText( theRow, 2, theText ); +} + +//======================================================================= +// name : SMESHGUI_FilterTable::SetText +// Purpose : Get text and internal value from cell of threshold value +//======================================================================= +bool SMESHGUI_FilterTable::GetThreshold( const int theRow, + QString& theText, + const int theEntityType ) +{ + Table* aTable = myTables[ theEntityType == -1 ? GetType() : theEntityType ]; + QTableItem* anItem = aTable->item( theRow, 2 ); + if ( anItem != 0 ) + { + theText = anItem->text(); + return true; + } + else + return false; +} + +/* + Class : SMESHGUI_FilterDlg + Description : Dialog to specify filters for VTK viewer +*/ + + +//======================================================================= +// name : SMESHGUI_FilterDlg::SMESHGUI_FilterDlg +// Purpose : Constructor +//======================================================================= +SMESHGUI_FilterDlg::SMESHGUI_FilterDlg( QWidget* theParent, + const QValueList& theTypes, + const char* theName ) +: QDialog( theParent, theName, false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + construct( theTypes ); +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::SMESHGUI_FilterDlg +// Purpose : Constructor +//======================================================================= +SMESHGUI_FilterDlg::SMESHGUI_FilterDlg( QWidget* theParent, + const int theType, + const char* theName ) +: QDialog( theParent, theName, false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QValueList aTypes; + aTypes.append( theType ); + construct( aTypes ); +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::construct +// Purpose : Construct dialog ( called by constructor ) +//======================================================================= +void SMESHGUI_FilterDlg::construct( const QValueList& theTypes ) +{ + myTypes = theTypes; + + setCaption( tr( "CAPTION" ) ); + + QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); + + myMainFrame = createMainFrame ( this ); + QFrame* aBtnFrame = createButtonFrame( this ); + + aDlgLay->addWidget( myMainFrame ); + aDlgLay->addWidget( aBtnFrame ); + + aDlgLay->setStretchFactor( myMainFrame, 1 ); + Init( myTypes ); +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::createMainFrame +// Purpose : Create frame containing dialog's input fields +//======================================================================= +QFrame* SMESHGUI_FilterDlg::createMainFrame( QWidget* theParent ) +{ + QGroupBox* aMainFrame = new QGroupBox( 1, Qt::Horizontal, theParent ); + aMainFrame->setFrameStyle( QFrame::NoFrame ); + aMainFrame->setInsideMargin( 0 ); + + // filter frame + + myTable = new SMESHGUI_FilterTable( aMainFrame, myTypes ); + myTable->SetLibsEnabled( true ); + + QFrame* aLine = new QFrame( myTable->GetTableGrp() ); + aLine->setFrameStyle( QFrame::HLine | QFrame::Sunken ); + + mySetInViewer = new QCheckBox( tr( "SET_IN_VIEWER" ), myTable->GetTableGrp() ); + mySetInViewer->setChecked( true ); + + // other controls + mySourceGrp = createSourceGroup( aMainFrame ); + + connect( myTable, SIGNAL( CretarionChanged( const int, const int ) ), + SLOT( onCriterionChanged( const int, const int ) ) ); + + connect( myTable, SIGNAL( CurrentChanged( int, int ) ), + SLOT( onCurrentChanged( int, int ) ) ); + + return aMainFrame; +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::createSourceFrame +// Purpose : Create frame containing source radio button +//======================================================================= +QButtonGroup* SMESHGUI_FilterDlg::createSourceGroup( QWidget* theParent ) +{ + QButtonGroup* aGrp = new QButtonGroup( 1, Qt::Vertical, tr( "SOURCE" ), theParent ); + + QRadioButton* aMeshBtn = new QRadioButton( tr( "MESH" ), aGrp ); + QRadioButton* aSelBtn = new QRadioButton( tr( "SELECTION" ), aGrp ); + QRadioButton* aGrpBtn = new QRadioButton( tr( "CURRENT_GROUP" ), aGrp ); + + aGrp->insert( aMeshBtn, Mesh ); + aGrp->insert( aSelBtn, Selection ); + aGrp->insert( aGrpBtn, Dialog ); + + aGrp->setButton( Selection ); + + return aGrp; +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::updateMainButtons +// Purpose : Update visibility of main buttons ( OK, Cancel, Close ... ) +//======================================================================= +void SMESHGUI_FilterDlg::updateMainButtons() +{ + if ( myTypes.count() == 1 ) + { + myButtons[ BTN_Cancel ]->show(); + myButtons[ BTN_Apply ]->hide(); + myButtons[ BTN_Close ]->hide(); + } + else + { + myButtons[ BTN_Cancel ]->hide(); + myButtons[ BTN_Apply ]->show(); + myButtons[ BTN_Close ]->show(); + } + +// updateGeometry(); +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::createButtonFrame +// Purpose : Create frame containing buttons +//======================================================================= +QFrame* SMESHGUI_FilterDlg::createButtonFrame( QWidget* theParent ) +{ + QGroupBox* aGrp = new QGroupBox( 1, Qt::Vertical, theParent ); + + myButtons[ BTN_OK ] = new QPushButton( tr( "SMESH_BUT_OK" ), aGrp ); + myButtons[ BTN_Apply ] = new QPushButton( tr( "SMESH_BUT_APPLY" ), aGrp ); + + QLabel* aLbl = new QLabel( aGrp ); + aLbl->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + myButtons[ BTN_Cancel ] = new QPushButton( tr( "SMESH_BUT_CANCEL" ), aGrp ); + myButtons[ BTN_Close ] = new QPushButton( tr( "SMESH_BUT_CLOSE" ), aGrp ); + + connect( myButtons[ BTN_OK ], SIGNAL( clicked() ), SLOT( onOk() ) ); + connect( myButtons[ BTN_Cancel ], SIGNAL( clicked() ), SLOT( onClose() ) ) ; + connect( myButtons[ BTN_Close ], SIGNAL( clicked() ), SLOT( onClose() ) ) ; + connect( myButtons[ BTN_Apply ], SIGNAL( clicked() ), SLOT( onApply() ) ); + + updateMainButtons(); + + return aGrp; +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::~SMESHGUI_FilterDlg +// Purpose : Destructor +//======================================================================= +SMESHGUI_FilterDlg::~SMESHGUI_FilterDlg() +{ +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::Init +// Purpose : Init dialog fields, connect signals and slots, show dialog +//======================================================================= +void SMESHGUI_FilterDlg::Init( const int type ) +{ + QValueList aTypes; + aTypes.append( type ); + Init( aTypes ); +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::Init +// Purpose : Init dialog fields, connect signals and slots, show dialog +//======================================================================= +void SMESHGUI_FilterDlg::Init( const QValueList& theTypes ) +{ + mySourceWg = 0; + mySelection = 0; + myTypes = theTypes; + myMesh = SMESH::SMESH_Mesh::_nil(); + myIObjects.Clear(); + myIsSelectionChanged = false; + + myTable->Init( theTypes ); + + // set caption + if ( theTypes.count() == 1 ) + { + int aType = theTypes.first(); + if ( aType == SMESH::NODE ) setCaption( tr( "NODES_TLT" ) ); + else if ( aType == SMESH::EDGE ) setCaption( tr( "EDGES_TLT" ) ); + else if ( aType == SMESH::FACE ) setCaption( tr( "FACES_TLT" ) ); + else if ( aType == SMESH::VOLUME ) setCaption( tr( "VOLUMES_TLT" ) ); + } + else + setCaption( tr( "TLT" ) ); + + qApp->processEvents(); + updateGeometry(); + adjustSize(); + setEnabled( true ); + + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( ( QDialog* )this ) ; + + connect( mySMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( onDeactivate() ) ); + connect( mySMESHGUI, SIGNAL( SignalCloseAllDialogs() ), SLOT( onClose() ) ); + + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ); + this->move( x, y ); + + updateMainButtons(); + updateSelection(); + + // Initialise filter table with values of previous filter + QValueList::const_iterator anIter; + for ( anIter = theTypes.begin(); anIter != theTypes.end(); ++anIter ) + { + myTable->Clear( *anIter ); + if ( !myFilter[ *anIter ]->_is_nil() ) + { + SMESH::Filter::Criteria_var aCriteria = new SMESH::Filter::Criteria; + if ( myFilter[ *anIter ]->GetCriteria( aCriteria ) ) + { + for ( int i = 0, n = aCriteria->length(); i < n; i++ ) + myTable->AddCriterion( aCriteria[ i ], *anIter ); + } + } + } + + if ( myInsertState.contains( theTypes.first() ) ) + mySetInViewer->setChecked( myInsertState[ theTypes.first() ] ); + else + mySetInViewer->setChecked( true ); + if ( myApplyToState.contains( theTypes.first() ) ) + mySourceGrp->setButton( myApplyToState[ theTypes.first() ] ); + else + mySourceGrp->setButton( Selection ); +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::onOk +// Purpose : SLOT called when "Ok" button pressed. +// Assign filters VTK viewer and close dialog +//======================================================================= +void SMESHGUI_FilterDlg::onOk() +{ + if ( onApply() ) + { + mySelection->ClearFilters(); + disconnect( mySMESHGUI, 0, this, 0 ); + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + accept(); + emit Accepted(); + } +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::onClose +// Purpose : SLOT called when "Close" button pressed. Close dialog +//======================================================================= +void SMESHGUI_FilterDlg::onClose() +{ + // Restore previously selected object + if ( mySelection ) + { + mySelection->ClearFilters(); + mySelection->Clear(); + SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger anIter( myIObjects ); + for ( ; anIter.More(); anIter.Next() ) + { + mySelection->AddIObject( anIter.Key() ); + + TColStd_MapOfInteger aResMap; + const TColStd_IndexedMapOfInteger& anIndMap = anIter.Value(); + for ( int i = 1, n = anIndMap.Extent(); i <= n; i++ ) + aResMap.Add( anIndMap( i ) ); + + mySelection->AddOrRemoveIndex( anIter.Key(), aResMap, false ); + } + } + + disconnect( mySMESHGUI, 0, this, 0 ); + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + reject() ; + return ; +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::onDeactivate +// Purpose : SLOT called when dialog must be deativated +//======================================================================= +void SMESHGUI_FilterDlg::onDeactivate() +{ + setEnabled( false ); +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::enterEvent +// Purpose : Event filter +//======================================================================= +void SMESHGUI_FilterDlg::enterEvent( QEvent* ) +{ +// mySMESHGUI->EmitSignalDeactivateDialog(); + setEnabled( true ); +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_FilterDlg::closeEvent( QCloseEvent* e ) +{ + onClose() ; } //======================================================================= -// name : SMESHGUI_FilterDlg::onCriterionChanged() -// Purpose : SLOT. Called then contents of table changed -// Provides reaction on change of criterion +// name : SMESHGUI_FilterDlg::getIdsFromWg +// Purpose : Retrieve list of ids from given widget //======================================================================= -void SMESHGUI_FilterDlg::onCriterionChanged( int row, int col ) +void SMESHGUI_FilterDlg::getIdsFromWg( const QWidget* theWg, QValueList& theRes ) const { - int aType = getCurrType(); - if ( aType != SMESH::EDGE || col != 0 ) + theRes.clear(); + if ( theWg == 0 ) return; - Table* aTable = myTables[ aType ]; - QComboTableItem* aCompareItem = (QComboTableItem*)aTable->item( row, 1 ); - - if ( getCriterion( aType, row ) != FreeBorders ) + if ( theWg->inherits( "QListBox" ) ) { - if ( aCompareItem->count() == 0 ) - aCompareItem->setStringList( getCompare() ); - - QString aText = aTable->text( row, 2 ); - aTable->SetEditable( true, row, 2 ); - aTable->setText( row, 2, aText ); + QListBox* aListBox = ( QListBox* )theWg; + bool b; + for ( int i = 0, n = aListBox->count(); i < n; i++ ) + { + int anId = aListBox->text( i ).toInt( &b ); + if ( b ) + theRes.append( anId ); + } } - else + else if ( theWg->inherits( "QLineEdit" ) ) { - if ( aCompareItem->count() > 0 ) - aCompareItem->setStringList( QStringList() ); - aTable->SetEditable( false, row, 2 ); + QLineEdit* aLineEdit = ( QLineEdit* )theWg; + QString aStr = aLineEdit->text(); + QRegExp aRegExp( "(\\d+)" ); + bool b; + int aPos = 0; + while ( aPos >= 0 ) + { + aPos = aRegExp.search( aStr, aPos ); + if ( aPos > -1 ) + { + int anId = aRegExp.cap( 1 ).toInt( &b ); + if ( b ) + theRes.append( anId ); + aPos += aRegExp.matchedLength(); + } + } } } //======================================================================= -// name : SMESHGUI_FilterDlg::onRemoveBtn -// Purpose : SLOT. Called then "Remove" button pressed. -// Removes current string from table +// name : SMESHGUI_FilterDlg::getSelMode +// Purpose : Get selection mode of specified type //======================================================================= -void SMESHGUI_FilterDlg::onRemoveBtn() +Selection_Mode SMESHGUI_FilterDlg::getSelMode( const int theType ) const { - Table* aTable = myTables[ getCurrType() ]; - - if ( aTable->numRows() == 0 ) - return; - - QMemArray aRows; - for ( int i = 0, n = aTable->numRows(); i < n; i++ ) + switch ( theType ) { - if ( aTable->isRowSelected( i ) ) - { - aRows.resize( aRows.size() + 1 ); - aRows[ aRows.size() - 1 ] = i; - } + case SMESH::NODE : return NodeSelection; + case SMESH::EDGE : return EdgeSelection; + case SMESH::FACE : return FaceSelection; + case SMESH::VOLUME : return VolumeSelection; + default : return ActorSelection; } - aTable->removeRows( aRows ); - - // remove control of binary logical operation from last row - if ( aTable->numRows() > 0 ) - aTable->SetEditable( false, aTable->numRows() - 1, 4 ); - - updateBtnState(); } //======================================================================= -// name : SMESHGUI_FilterDlg::onClearBtn -// Purpose : SLOT. Called then "Clear" button pressed. -// Removes all strings from table +// name : SMESHGUI_FilterDlg::setIdsToWg +// Purpose : Insert identifiers in specified widgets //======================================================================= -void SMESHGUI_FilterDlg::onClearBtn() +void SMESHGUI_FilterDlg::setIdsToWg( QWidget* theWg, const QValueList& theIds ) { - QTable* aTable = myTables[ getCurrType() ]; - - if ( aTable->numRows() == 0 ) + if ( theWg == 0 ) return; - while ( aTable->numRows() > 0 ) - aTable->removeRow( 0 ); + if ( theWg->inherits( "QListBox" ) ) + { + QListBox* aListBox = ( QListBox* )theWg; + aListBox->clear(); - updateBtnState(); -} + QStringList aStrList; + QValueList::const_iterator anIter; + for ( anIter = theIds.begin(); anIter != theIds.end(); ++anIter ) + aStrList.append( QString( "%1" ).arg( *anIter ) ); -//======================================================================= -// name : SMESHGUI_FilterDlg::updateBtnState -// Purpose : Update button state -//======================================================================= -void SMESHGUI_FilterDlg::updateBtnState() -{ - myRemoveBtn->setEnabled( myTables[ getCurrType() ]->numRows() > 0 ); - myClearBtn->setEnabled( myTables[ getCurrType() ]->numRows() > 0 ); + aListBox->insertStringList( aStrList ); + } + else if ( theWg->inherits( "QLineEdit" ) ) + { + QLineEdit* aLineEdit = ( QLineEdit* )theWg; + QString aStr; + QValueList::const_iterator anIter; + + for ( anIter = theIds.begin(); anIter != theIds.end(); ++ anIter ) + aStr += QString( "%1 " ).arg( *anIter ); + + if ( !aStr.isEmpty() ) + aStr.remove( aStr.length() - 1, 1 ); + + aLineEdit->setText( aStr ); + } } //======================================================================= @@ -800,53 +1991,73 @@ void SMESHGUI_FilterDlg::updateBtnState() //======================================================================= bool SMESHGUI_FilterDlg::isValid() const { - Table* aTable = myTables[ getCurrType() ]; - for ( int i = 0, n = aTable->numRows(); i < n; i++ ) + if ( !myTable->IsValid() ) + return false; + + for ( int i = 0, n = myTable->NumRows(); i < n; i++ ) { - bool isEditable = aTable->IsEditable( i ,2 ); - bool aRes = false; - int aThreshold = ( int )aTable->text( i, 2 ).toDouble( &aRes ); - if ( isEditable && !aRes ) - { - QMessageBox::information( mySMESHGUI->GetDesktop(), - tr( "SMESH_INSUFFICIENT_DATA" ), tr( "ERROR" ), - QMessageBox::Ok ); - return false; - } - else if ( getCurrType() == SMESH::EDGE && - getCriterion( SMESH::EDGE, i ) == MultiBorders && - aThreshold == 1 ) + int aType = myTable->GetCriterionType( i ); + if ( aType == FT_BelongToGeom || + aType == FT_BelongToPlane || + aType == FT_BelongToCylinder ) { - QMessageBox::information( mySMESHGUI->GetDesktop(), - tr( "SMESH_INSUFFICIENT_DATA" ), tr( "MULTIEDGES_ERROR" ), - QMessageBox::Ok ); - return false; + QString aName; + myTable->GetThreshold( i, aName ); + + SALOMEDS::Study::ListOfSObject_var aList = SMESHGUI::GetSMESHGUI()->GetActiveStudy()-> + getStudyDocument()->FindObjectByName( aName.latin1(), "GEOM" ); + if ( aList->length() == 0 ) + { + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_INSUFFICIENT_DATA" ), tr( "BAD_SHAPE_NAME" ).arg( aName ), QMessageBox::Ok ); + return false; + } + + if ( aType == FT_BelongToCylinder || aType == FT_BelongToPlane ) + { + GEOM::GEOM_Object_var aGeomObj = + GEOM::GEOM_Object::_narrow( aList[ 0 ]->GetObject() ); + if ( !aGeomObj->_is_nil() ) + { + TopoDS_Shape aFace; + if ( !GEOMBase::GetShape( aGeomObj, aFace ) || + aFace.IsNull() || + aFace.ShapeType() != TopAbs_FACE ) + { + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_INSUFFICIENT_DATA" ), tr( "SHAPE_IS_NOT_A_FACE" ).arg( aName ), QMessageBox::Ok ); + return false; + } + + Handle(Geom_Surface) aSurf = BRep_Tool::Surface( TopoDS::Face( aFace ) ); + if ( aSurf.IsNull() ) + { + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_INSUFFICIENT_DATA" ), tr( "SHAPE_IS_NOT_A_FACE" ).arg( aName ), QMessageBox::Ok ); + return false; + } + + if ( aType == FT_BelongToPlane && !aSurf->IsKind( STANDARD_TYPE( Geom_Plane ) ) ) + { + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_INSUFFICIENT_DATA" ), tr( "SHAPE_IS_NOT_A_PLANE" ).arg( aName ), QMessageBox::Ok ); + return false; + } + + if ( aType == FT_BelongToCylinder && !aSurf->IsKind( STANDARD_TYPE( Geom_CylindricalSurface ) ) ) + { + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_INSUFFICIENT_DATA" ), tr( "SHAPE_IS_NOT_A_CYLINDER" ).arg( aName ), QMessageBox::Ok ); + return false; + } + } + } } } return true; } -//======================================================================= -// name : SMESHGUI_FilterDlg::GetResultIds -// Purpose : Get filtered ids -//======================================================================= -/*void SMESHGUI_FilterDlg::GetResultIds( SMESH::SMESH_Mesh_ptr theMesh, - QValueList& theIds ) const -{ - if ( !myPredicate->_is_nil() ) - theIds = myInputIds; - else - myPredicate->SetMesh( theMesh ); - - theIds.clear(); - QValueList::const_iterator anIter; - for ( anIter = myInputIds.begin(); anIter != myInputIds.end(); ++anIter ) - if ( myPredicate->IsSatisfy( *anIter ) ) - theIds.append( *anIter ); -} -*/ - //======================================================================= // name : SMESHGUI_FilterDlg::SetSourceWg // Purpose : Set widget of parent dialog containing idsto be filtered if @@ -872,7 +2083,29 @@ void SMESHGUI_FilterDlg::SetMesh( SMESH::SMESH_Mesh_ptr theMesh ) //======================================================================= void SMESHGUI_FilterDlg::SetSelection( SALOME_Selection* theSel ) { + if ( mySelection ) + disconnect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( onSelectionDone() ) ); + mySelection = theSel; + + if ( mySelection ) + { + myIObjects.Clear(); + const SALOME_ListIO& anObjs = mySelection->StoredIObjects(); + SALOME_ListIteratorOfListIO anIter( anObjs ); + for ( ;anIter.More(); anIter.Next() ) + { + TColStd_IndexedMapOfInteger aMap; + mySelection->GetIndex( anIter.Value(), aMap ); + myIObjects.Bind( anIter.Value(), aMap ); + } + + connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); + + updateSelection(); + } + else + myIObjects.Clear(); } //======================================================================= @@ -887,19 +2120,23 @@ bool SMESHGUI_FilterDlg::onApply() try { - int aCurrType = getCurrType(); + int aCurrType = myTable->GetType(); - SMESH::Predicate_ptr aPredicate = createPredicate( aCurrType ); + if ( !createFilter( aCurrType ) ) + return false; - if ( mySetInViewer->isChecked() ) - insertFilterInViewer( aPredicate ); + insertFilterInViewer(); - if ( !aPredicate->_is_nil() ) + if ( !myFilter[ aCurrType ]->GetPredicate()->_is_nil() ) { QValueList aResultIds; - filterSource( aCurrType, aPredicate, aResultIds ); + filterSource( aCurrType, aResultIds ); selectInViewer( aCurrType, aResultIds ); } + + myInsertState[ aCurrType ] = mySetInViewer->isChecked(); + myApplyToState[ aCurrType ] = mySourceGrp->id( mySourceGrp->selected() ); + } catch( const SALOME::SALOME_Exception& S_ex ) { @@ -913,202 +2150,64 @@ bool SMESHGUI_FilterDlg::onApply() } //======================================================================= -// name : SMESHGUI_FilterDlg::createPredicate +// name : SMESHGUI_FilterDlg::createFilter // Purpose : Create predicate for given type //======================================================================= -SMESH::Predicate_ptr SMESHGUI_FilterDlg::createPredicate( const int theType ) +bool SMESHGUI_FilterDlg::createFilter( const int theType ) { - SMESH::FilterManager_ptr aFilterMgr = mySMESHGUI->GetFilterMgr(); + SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager(); if ( aFilterMgr->_is_nil() ) - return SMESH::Predicate::_nil(); - - QTable* aTable = myTables[ theType ]; - if ( aTable == 0 ) - return SMESH::Predicate::_nil(); - - // CREATE two lists ( PREDICATES and LOG OP ) - - // Criterion - QValueList aPredicates; - QValueList aLogOps; - for ( int i = 0, n = aTable->numRows(); i < n; i++ ) - { - int aCriterion = getCriterion( theType, i ); - - SMESH::Predicate_ptr aPredicate = SMESH::Predicate::_nil(); - SMESH::NumericalFunctor_ptr aFunctor = SMESH::NumericalFunctor::_nil(); - - if ( theType == SMESH::EDGE ) - { - switch ( aCriterion ) - { - case FreeBorders: - aPredicate = aFilterMgr->CreateFreeBorders(); - break; - case MultiBorders: - aFunctor = aFilterMgr->CreateMultiConnection(); - break; - case Length: - aFunctor = aFilterMgr->CreateLength(); - break; - default: - continue; - } - } - else - { - switch ( aCriterion ) - { - case AspectRatio: - aFunctor = aFilterMgr->CreateAspectRatio(); - break; - case Warping: - aFunctor = aFilterMgr->CreateWarping(); - break; - case MinimumAngle: - aFunctor = aFilterMgr->CreateMinimumAngle(); - break; - case Taper: - aFunctor = aFilterMgr->CreateTaper(); - break; - case Skew: - aFunctor = aFilterMgr->CreateSkew(); - break; - case Area: - aFunctor = aFilterMgr->CreateArea(); - break; - default: - continue; - } - } - - // Comparator - if ( !aFunctor->_is_nil() && aPredicate->_is_nil() ) - { - QComboTableItem* aCombo = (QComboTableItem*)aTable->item( i, 1 ); - int aCompareOp = aCombo->currentItem(); - double aThreshold = aTable->text( i, 2 ).toDouble(); - - SMESH::Comparator_ptr aComparator = SMESH::Comparator::_nil(); - - if ( aCompareOp == LessThan ) - aComparator = aFilterMgr->CreateLessThan(); - else if ( aCompareOp == MoreThan ) - aComparator = aFilterMgr->CreateMoreThan(); - else if ( aCompareOp == EqualTo ) - aComparator = aFilterMgr->CreateEqualTo(); - else - continue; - - aComparator->SetNumFunctor( aFunctor ); - aComparator->SetMargin( aThreshold ); - - aPredicate = aComparator; - } - - // Logical not - QCheckTableItem* anItem = (QCheckTableItem*)aTable->item( i, 3 ); - if ( anItem->isChecked() ) - { - SMESH::LogicalNOT_ptr aNotPred = aFilterMgr->CreateLogicalNOT(); - aNotPred->SetPredicate( aPredicate ); - aPredicate = aNotPred; - } - - // logical op - int aLogOp = ( i == n - 1 ) ? LO_Undefined - : ( (QComboTableItem*)aTable->item( i, 4 ) )->currentItem(); - aPredicates.append( aPredicate ); - aLogOps.append( aLogOp ); - - } // for - - // CREATE ONE PREDICATE FROM PREVIOUSLY CREATED MAP - - // combine all "AND" operations - - QValueList aResList; + return false; - QValueList::iterator aPredIter; - QValueList::iterator aLogOpIter; + int n = myTable->NumRows(); - SMESH::Predicate_ptr aPrevPredicate = SMESH::Predicate::_nil(); - int aPrevLogOp = LO_Undefined; + SMESH::Filter::Criteria_var aCriteria = new SMESH::Filter::Criteria; + aCriteria->length( n ); - for ( aPredIter = aPredicates.begin(), aLogOpIter = aLogOps.begin(); - aPredIter != aPredicates.end() && aLogOpIter != aLogOps.end(); - ++aPredIter, ++aLogOpIter ) + long aPrecision = -1; + if ( QAD_CONFIG->hasSetting( "SMESH:ControlsPrecision" ) ) { - int aCurrLogOp = *aLogOpIter; - - SMESH::Predicate_ptr aCurrPred = SMESH::Predicate::_nil(); - - if ( aPrevLogOp == LO_And ) - { - - SMESH::LogicalBinary_ptr aBinaryPred = aFilterMgr->CreateLogicalAND(); - aBinaryPred->SetPredicate1( aPrevPredicate ); - aBinaryPred->SetPredicate2( *aPredIter ); - aCurrPred = aBinaryPred; - } - else - aCurrPred = *aPredIter; - - if ( aCurrLogOp != LO_And ) - aResList.append( aCurrPred ); - - aPrevPredicate = aCurrPred; - aPrevLogOp = aCurrLogOp; + QString aStr = QAD_CONFIG->getSetting( "SMESH:ControlsPrecision" ); + bool isOk = false; + int aVal = aStr.toInt( &isOk ); + if ( isOk ) + aPrecision = aVal; } - - // combine all "OR" operations - - SMESH::Predicate_ptr aResPredicate = SMESH::Predicate::_nil(); - - if ( aResList.count() == 1 ) - aResPredicate = aResList.first(); - else if ( aResList.count() > 1 ) + + for ( CORBA::ULong i = 0; i < n; i++ ) { - QValueList::iterator anIter = aResList.begin(); - aResPredicate = *anIter; - anIter++; - for ( ; anIter != aResList.end(); ++anIter ) - { - SMESH::LogicalBinary_ptr aBinaryPred = aFilterMgr->CreateLogicalOR(); - aBinaryPred->SetPredicate1( aResPredicate ); - aBinaryPred->SetPredicate2( *anIter ); - aResPredicate = aBinaryPred; - } + SMESH::Filter::Criterion aCriterion = createCriterion(); + myTable->GetCriterion( i, aCriterion ); + aCriterion.Precision = aPrecision; + aCriteria[ i ] = aCriterion; } - return aResPredicate; + myFilter[ theType ] = aFilterMgr->CreateFilter(); + myFilter[ theType ]->SetCriteria( aCriteria.inout() ); + + return true; } //======================================================================= // name : SMESHGUI_FilterDlg::insertFilterInViewer // Purpose : Insert filter in viewer //======================================================================= -void SMESHGUI_FilterDlg::insertFilterInViewer( SMESH::Predicate_ptr thePred ) +void SMESHGUI_FilterDlg::insertFilterInViewer() { - VTKViewer_InteractorStyleSALOME* aStyle = ((VTKViewer_ViewFrame*)mySMESHGUI->GetActiveStudy()-> - getActiveStudyFrame()->getRightFrame()->getViewFrame())-> - getRWInteractor()->GetInteractorStyleSALOME(); - - if ( thePred->_is_nil() ) - { - if ( myType == SMESH::EDGE ) - aStyle->RemoveEdgeFilter(); - else if ( myType == SMESH::FACE ) - aStyle->RemoveFaceFilter(); - } - else + if ( VTKViewer_InteractorStyleSALOME* aStyle = SMESH::GetInteractorStyle() ) { - Handle(SMESHGUI_Filter) aFilter = new SMESHGUI_Filter(); - aFilter->SetPredicate( thePred ); - if ( myType == SMESH::EDGE ) - aStyle->SetEdgeFilter( aFilter ); - else if ( myType == SMESH::FACE ) - aStyle->SetFaceFilter( aFilter ); + SMESH::ElementType anEntType = (SMESH::ElementType)myTable->GetType(); + + if ( myFilter[ myTable->GetType() ]->_is_nil() || + myFilter[ myTable->GetType() ]->GetPredicate()->_is_nil() || + !mySetInViewer->isChecked() ) + SMESH::RemoveFilter( getFilterId( anEntType ), aStyle ); + else + { + Handle(SMESHGUI_PredicateFilter) aFilter = new SMESHGUI_PredicateFilter(); + aFilter->SetPredicate( myFilter[ myTable->GetType() ]->GetPredicate() ); + SMESH::SetFilter( aFilter, aStyle ); + } } } @@ -1117,34 +2216,32 @@ void SMESHGUI_FilterDlg::insertFilterInViewer( SMESH::Predicate_ptr thePred ) // Purpose : Filter source ids //======================================================================= void SMESHGUI_FilterDlg::filterSource( const int theType, - SMESH::Predicate_ptr thePred, QValueList& theResIds ) { theResIds.clear(); - + if ( myFilter[ theType ]->_is_nil() ) + return; + int aSourceId = mySourceGrp->id( mySourceGrp->selected() ); if ( aSourceId == Mesh ) { if ( myMesh->_is_nil() ) return; - SMESH::FilterManager_ptr aFilterMgr = mySMESHGUI->GetFilterMgr(); - SMESH::Filter_var aFilter = aFilterMgr->CreateFilter(); - aFilter->SetPredicate( thePred ); - SMESH::long_array_var anIds = aFilter->GetElementsId( myMesh ); + SMESH::long_array_var anIds = myFilter[ theType ]->GetElementsId( myMesh ); for ( int i = 0, n = anIds->length(); i < n; i++ ) theResIds.append( anIds[ i ] ); } else if ( aSourceId == Selection ) { - filterSelectionSource( theType, thePred, theResIds ); + filterSelectionSource( theType, theResIds ); } else if ( aSourceId == Dialog ) { // retrieve ids from dialog QValueList aDialogIds; getIdsFromWg( mySourceWg, aDialogIds ); - + if ( myMesh->_is_nil() ) { theResIds = aDialogIds; @@ -1152,10 +2249,11 @@ void SMESHGUI_FilterDlg::filterSource( const int theType, } // filter ids - thePred->SetMesh( myMesh ); + SMESH::Predicate_ptr aPred = myFilter[ theType ]->GetPredicate(); + aPred->SetMesh( myMesh ); QValueList::const_iterator anIter; for ( anIter = aDialogIds.begin(); anIter != aDialogIds.end(); ++ anIter ) - if ( thePred->IsSatisfy( *anIter ) ) + if ( aPred->IsSatisfy( *anIter ) ) theResIds.append( *anIter ); // set ids to the dialog @@ -1168,7 +2266,6 @@ void SMESHGUI_FilterDlg::filterSource( const int theType, // Purpose : Filter source selection //======================================================================= void SMESHGUI_FilterDlg::filterSelectionSource( const int theType, - SMESH::Predicate_ptr thePred, QValueList& theResIds ) { theResIds.clear(); @@ -1177,14 +2274,13 @@ void SMESHGUI_FilterDlg::filterSelectionSource( const int theType, // Create map of entities to be filtered TColStd_MapOfInteger aToBeFiltered; - Standard_Boolean aRes = false; - SALOME_ListIteratorOfListIO anIter( mySelection->StoredIObjects() ); - + SALOME_DataMapIteratorOfDataMapOfIOMapOfInteger anIter( myIObjects ); + for ( ; anIter.More(); anIter.Next() ) { // process sub mesh - SMESH::SMESH_subMesh_ptr aSubMesh = mySMESHGUI->ConvertIOinSubMesh( anIter.Value(), aRes ); - if ( aRes && !aSubMesh->_is_nil() ) + SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface( anIter.Key() ); + if ( !aSubMesh->_is_nil() ) { if ( aSubMesh->GetFather()->GetId() == myMesh->GetId() ) { @@ -1196,8 +2292,9 @@ void SMESHGUI_FilterDlg::filterSelectionSource( const int theType, } // process group - SMESH::SMESH_Group_ptr aGroup = mySMESHGUI->ConvertIOinSMESHGroup( anIter.Value(), aRes ); - if ( aRes && !aGroup->_is_nil() ) + SMESH::SMESH_GroupBase_var aGroup = + SMESH::IObjectToInterface( anIter.Key() ); + if ( !aGroup->_is_nil() ) { if ( aGroup->GetType() == theType && aGroup->GetMesh()->GetId() == myMesh->GetId() ) { @@ -1208,33 +2305,28 @@ void SMESHGUI_FilterDlg::filterSelectionSource( const int theType, } // process mesh - SMESH::SMESH_Mesh_ptr aMeshPtr = mySMESHGUI->ConvertIOinMesh( anIter.Value(), aRes ); - if ( aRes && !aMeshPtr->_is_nil() && aMeshPtr->GetId() == myMesh->GetId() ) + SMESH::SMESH_Mesh_var aMeshPtr = SMESH::IObjectToInterface( anIter.Key() ); + if ( !aMeshPtr->_is_nil() && aMeshPtr->GetId() == myMesh->GetId() ) { - TColStd_MapOfInteger aVtkMap; - mySelection->GetIndex( anIter.Value(), aVtkMap ); + const TColStd_IndexedMapOfInteger& aSelMap = anIter.Value(); - if ( aVtkMap.Extent() > 0 ) + if ( aSelMap.Extent() > 0 ) { - SMESH_Actor *anActor = mySMESHGUI->FindActorByEntry( - anIter.Value()->getEntry(), aRes, true ); - if ( aRes && anActor != 0 ) + if(SMESH_Actor *anActor = SMESH::FindActorByEntry( anIter.Key()->getEntry() ) ) { - TColStd_MapIteratorOfMapOfInteger aVtkMapIter( aVtkMap ); - for ( ; aVtkMapIter.More(); aVtkMapIter.Next() ) - aToBeFiltered.Add( theType == SMESH::NODE - ? anActor->GetNodeObjId( aVtkMapIter.Key() ) - : anActor->GetElemObjId( aVtkMapIter.Key() ) ); + for ( int i = 1; i <= aSelMap.Extent(); i++ ) + aToBeFiltered.Add( aSelMap(i) ); } } } } // Filter entities - thePred->SetMesh( myMesh ); + SMESH::Predicate_ptr aPred = myFilter[ theType ]->GetPredicate(); + aPred->SetMesh( myMesh ); TColStd_MapIteratorOfMapOfInteger aResIter( aToBeFiltered ); for ( ; aResIter.More(); aResIter.Next() ) - if ( thePred->IsSatisfy( aResIter.Key() ) ) + if ( aPred->IsSatisfy( aResIter.Key() ) ) theResIds.append( aResIter.Key() ); } @@ -1247,6 +2339,8 @@ void SMESHGUI_FilterDlg::selectInViewer( const int theType, const QValueList_is_nil() ) return; + mySelection->ClearFilters(); + // Set new selection mode if necessary Selection_Mode aSelMode = getSelMode( theType ); if ( aSelMode != mySelection->SelectionMode() ) @@ -1254,31 +2348,135 @@ void SMESHGUI_FilterDlg::selectInViewer( const int theType, const QValueListClearIObjects(); mySelection->ClearFilters(); if ( aSelMode == NodeSelection ) - mySMESHGUI->ViewNodes(); + SMESH::SetPointRepresentation(true); QAD_Application::getDesktop()->SetSelectionMode( aSelMode ); } - Standard_Boolean aRes = false; - SMESH_Actor* anActor = mySMESHGUI->FindActor( myMesh, aRes, true ); - if ( !aRes || anActor == 0 || !anActor->hasIO() ) + // Clear selection + SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh); + if ( !anActor || !anActor->hasIO() ) return; Handle(SALOME_InteractiveObject) anIO = anActor->getIO(); mySelection->ClearIObjects(); mySelection->AddIObject( anIO, false ); + // Remove filter corresponding to the current type from viewer + int aType = myTable->GetType(); + int aFilterId = SMESHGUI_UnknownFilter; + if ( aType == SMESH::EDGE ) aFilterId = SMESHGUI_EdgeFilter; + else if ( aType == SMESH::FACE ) aFilterId = SMESHGUI_FaceFilter; + else if ( aType == SMESH::VOLUME ) aFilterId = SMESHGUI_VolumeFilter; + Handle(VTKViewer_Filter) aFilter = SMESH::GetFilter( aFilterId ); + SMESH::RemoveFilter( aFilterId ); + + // get vtk ids TColStd_MapOfInteger aMap; QValueList::const_iterator anIter; for ( anIter = theIds.begin(); anIter != theIds.end(); ++anIter ) { - std::vector aVtkList = anActor->GetElemVtkId( *anIter ); - std::vector::iterator it; - for ( it = aVtkList.begin(); it != aVtkList.end(); ++it ) - aMap.Add( *it ); + aMap.Add( *anIter ); } + // Set new selection mySelection->AddOrRemoveIndex( anIO, aMap, false, true ); + + // insert previously stored filter in viewer if necessary + if ( !aFilter.IsNull() ) + SMESH::SetFilter( aFilter ); +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::createCriterion +// Purpose : Create criterion structure with default values +//======================================================================= +SMESH::Filter::Criterion SMESHGUI_FilterDlg::createCriterion() +{ + SMESH::Filter::Criterion aCriterion; + + aCriterion.Type = FT_Undefined; + aCriterion.Compare = FT_Undefined; + aCriterion.Threshold = 0; + aCriterion.UnaryOp = FT_Undefined; + aCriterion.BinaryOp = FT_Undefined; + aCriterion.ThresholdStr = ""; + aCriterion.TypeOfElement = SMESH::ALL; + + return aCriterion; +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::onSelectionDone +// Purpose : SLOT called when selection changed. +// If current cell corresponds to the threshold value of +// BelongToGeom criterion name of selected object is set in this cell +//======================================================================= +void SMESHGUI_FilterDlg::onSelectionDone() +{ + int aRow, aCol; + if ( mySelection->IObjectCount() != 1 || + !myTable->CurrentCell( aRow, aCol ) || + myTable->GetCriterionType( aRow ) != FT_BelongToGeom && + myTable->GetCriterionType( aRow ) != FT_BelongToPlane && + myTable->GetCriterionType( aRow ) != FT_BelongToCylinder) + return; + + Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject() ; + GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface( anIO ) ; + if ( !anObj->_is_nil() ) + myTable->SetThreshold( aRow, anIO->getName() ); +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::onCriterionChanged +// Purpose : SLOT called when cretarion of current row changed. Update selection +//======================================================================= +void SMESHGUI_FilterDlg::onCriterionChanged( const int , const int ) +{ + updateSelection(); +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::onCurrentChanged +// Purpose : SLOT called when current row changed. Update selection +//======================================================================= +void SMESHGUI_FilterDlg::onCurrentChanged( int, int ) +{ + updateSelection(); +} + +//======================================================================= +// name : SMESHGUI_FilterDlg::updateSelection +// Purpose : UpdateSelection in accordance with current row +//======================================================================= +void SMESHGUI_FilterDlg::updateSelection() +{ + if ( mySelection == 0 ) + return; + + mySelection->ClearFilters(); + + int aRow, aCol; + if ( myTable->CurrentCell( aRow, aCol ) && + ( myTable->GetCriterionType( aRow ) == FT_BelongToGeom || + myTable->GetCriterionType( aRow ) == FT_BelongToPlane || + myTable->GetCriterionType( aRow ) == FT_BelongToCylinder ) ) + { + if ( myTable->GetCriterionType( aRow ) == FT_BelongToGeom ) + mySelection->AddFilter( new SALOME_TypeFilter( "GEOM" ) ); + else if ( myTable->GetCriterionType( aRow ) == FT_BelongToPlane ) + mySelection->AddFilter( new GEOM_FaceFilter( StdSelect_Plane ) ); + else if ( myTable->GetCriterionType( aRow ) == FT_BelongToCylinder ) + mySelection->AddFilter( new GEOM_FaceFilter( StdSelect_Cylinder ) ); + + myIsSelectionChanged = true; + } + else + { + if ( myIsSelectionChanged ) + mySelection->AddFilter( new SALOME_TypeFilter( "This filter deactivate selection" ) ); + } } @@ -1296,6 +2494,10 @@ void SMESHGUI_FilterDlg::selectInViewer( const int theType, const QValueList -#include -#include -#include - -#include -#include CORBA_SERVER_HEADER(SMESH_Filter) -#include CORBA_SERVER_HEADER(SMESH_Mesh) - -class QCloseEvent; -class QWidgetStack; -class QStringList; -class QTableItem; -class QFrame; -class QEvent; -class QPushButton; -class QTable; -class SALOME_Selection; -class SMESHGUI; -class QComboBox; -class QButtonGroup; -class QCheckBox; -class QGroupBox; - - -/* - Class : SMESHGUI_FilterDlg - Description : Dialog to specify filters for VTK viewer -*/ - -class SMESHGUI_FilterDlg : public QDialog -{ - Q_OBJECT - - class Table; - - // Edge criteria - enum { FreeBorders = 0, MultiBorders, Length }; - - // Face criteria - enum { AspectRatio = 0, Warping, MinimumAngle, Taper, Skew, Area }; - - // Comparision - enum { LessThan = 0, MoreThan, EqualTo }; - - // Logical operations - enum { LO_And = 0, LO_Or, LO_Undefined }; - - // Source elements to be selected - enum { Mesh, Selection, Dialog, None }; - - typedef QMap TableMap; - -public: - SMESHGUI_FilterDlg( QWidget* parent, - const int type, - const bool theModal = true, - const char* name = 0 ); - virtual ~SMESHGUI_FilterDlg(); - - void Init( const int type ); - - void SetSelection( SALOME_Selection* ); - void SetMesh( SMESH::SMESH_Mesh_ptr ); - void SetSourceWg( QWidget* ); - -private slots: - - void onAddBtn(); - void onRemoveBtn(); - void onClearBtn(); - void onCriterionChanged( int, int ); - - void onOk(); - bool onApply(); - void onClose(); - void onDeactivate(); - -private: - - void closeEvent( QCloseEvent* e ); - void enterEvent ( QEvent * ); - - void updateBtnState(); - - // dialog creation - QFrame* createButtonFrame( QWidget*, const bool ); - QFrame* createMainFrame( QWidget* ); - Table* createTable( QWidget*, const int ); - QButtonGroup* createSourceGroup( QWidget* ); - void addRow( Table*, const int ); - QTableItem* getCriterionItem( QTable*, const int ); - QTableItem* getCompareItem( QTable* ); - QTableItem* getNotItem( QTable* ); - QTableItem* getLogOpItem( QTable* ); - const QStringList& getCriteria( const int theType ) const; - const QStringList& getCompare () const; - - // query - int getCurrType() const; - int getCriterion( const int theType, const int theRow ) const; - - // execution - bool isValid() const; - SMESH::Predicate_ptr createPredicate( const int theType ); - void insertFilterInViewer( SMESH::Predicate_ptr thePred ); - void selectInViewer( const int theType, - const QValueList& theIds ); - void filterSource( const int theType, - SMESH::Predicate_ptr thePred, - QValueList& theResIds ); - void filterSelectionSource( const int theType, - SMESH::Predicate_ptr thePred, - QValueList& theResIds ); - void getIdsFromWg( const QWidget*, QValueList& ) const; - void setIdsToWg( QWidget*, const QValueList& ); - Selection_Mode getSelMode( const int ) const; - -private: - - // widgets - QFrame* myMainFrame; - QGroupBox* myTableGrp; - - TableMap myTables; - QPushButton* myAddBtn; - QPushButton* myRemoveBtn; - QPushButton* myClearBtn; - QButtonGroup* mySourceGrp; - QCheckBox* mySetInViewer; - - QPushButton* myOkBtn; - QPushButton* myApplyBtn; - QPushButton* myCloseBtn; - - // initial fields - int myType; - SMESHGUI* mySMESHGUI; - SALOME_Selection* mySelection; - SMESH::SMESH_Mesh_ptr myMesh; - QWidget* mySourceWg; -}; - -#endif - - - - - - - - - - - - - - - - - - - - +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_FilterDlg.h +// Author : Sergey LITONIN +// Module : SMESH + + +#ifndef SMESHGUI_FilterDlg_H +#define SMESHGUI_FilterDlg_H + +#include +#include +#include +#include + +#include "SALOME_Selection.h" +#include "SALOME_InteractiveObject.hxx" +#include "SALOME_DataMapOfIOMapOfInteger.hxx" + +#include + +#include +#include CORBA_SERVER_HEADER(SMESH_Filter) +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +class QButtonGroup; +class QCheckBox; +class QCloseEvent; +class QComboBox; +class QEvent; +class QGroupBox; +class QPushButton; +class QStringList; +class QTable; +class QTableItem; +class QWidgetStack; +class SALOME_Selection; +class SMESHGUI; +class SMESHGUI_FilterLibraryDlg; + +/* + Class : SMESHGUI_FilterTable + Description : Frame containig + - Button group for switching entity type + - Table for displaying filter criterions + - Buttons for editing table +*/ + +class SMESHGUI_FilterTable : public QFrame +{ + Q_OBJECT + + class Table; + class ComboItem; + class AdditionalWidget; + + typedef QMap TableMap; + +public: + + SMESHGUI_FilterTable( QWidget* parent, + const int type ); + SMESHGUI_FilterTable( QWidget* parent, + const QValueList& type ); + virtual ~SMESHGUI_FilterTable(); + + void Init( const int type ); + void Init( const QValueList& types ); + + QGroupBox* GetTableGrp(); + + bool IsValid( const bool = true, const int theEntityType = -1 ) const; + int GetType() const; + void SetType( const int ); + void RestorePreviousEntityType(); + int NumRows( const int theEntityType = -1 ) const; + void Clear( const int theEntityType = -1 ); + void SetEditable( const bool ); + void SetEnabled( const bool ); + void SetLibsEnabled( const bool ); + bool IsEditable() const; + + int GetCriterionType( const int theRow, const int theType = -1 ) const; + + void GetCriterion( const int theRow, + SMESH::Filter::Criterion& theCriterion, + const int theEntityType = -1 ) const; + + void SetCriterion( const int theRow, + const SMESH::Filter::Criterion& theCriterion, + const int theEntityType = -1 ); + + void AddCriterion( const SMESH::Filter::Criterion& theCriterion, + const int theEntityType = -1 ); + + void Copy( const SMESHGUI_FilterTable* ); + void SetValidity( const bool ); + + bool CurrentCell( int& theRow, int& theCol ) const; + void SetThreshold( const int theRow, + const QString& theText, + const int theEntityType = -1 ); + + bool GetThreshold( const int theRow, + QString& theText, + const int theEntityType = -1 ); + + void Update(); + + +signals: + + void CopyFromClicked(); + void AddToClicked(); + void EntityTypeChanged( const int ); + void NeedValidation(); + void CretarionChanged( const int theRow, const int theEntityType ); + void CurrentChanged( int, int ); + +private slots: + + void onAddBtn(); + void onInsertBtn(); + void onRemoveBtn(); + void onClearBtn(); + void onCopyFromBtn(); + void onAddToBtn(); + void onCriterionChanged( int, int ); + void onEntityType( int ); + void onCurrentChanged( int, int ); + +private: + + void addRow( Table*, const int, const bool toTheEnd = true ); + QTableItem* getCriterionItem( QTable*, const int ); + QTableItem* getCompareItem( QTable* ); + QTableItem* getUnaryItem( QTable* ); + QTableItem* getBinaryItem( QTable* ); + const QMap& getCriteria( const int theType ) const; + const QMap& getCompare() const; + Table* createTable( QWidget*, const int ); + QWidget* createAdditionalFrame( QWidget* theParent ); + int getFirstSelectedRow() const; + void onCriterionChanged( const int, const int, const int ); + + void updateBtnState(); + void removeAdditionalWidget( QTable* theTable, const int theRow ); + void updateAdditionalWidget(); + + const QMap& getSupportedTypes() const; + +private: + + QGroupBox* myTableGrp; + QGroupBox* mySwitchTableGrp; + + TableMap myTables; + QPushButton* myAddBtn; + QPushButton* myInsertBtn; + QPushButton* myRemoveBtn; + QPushButton* myClearBtn; + QPushButton* myCopyFromBtn; + QPushButton* myAddToBtn; + + QButtonGroup* myEntityTypeGrp; + int myEntityType; + int myIsValid; + + SMESHGUI_FilterLibraryDlg* myLibDlg; + + QWidgetStack* myWgStack; + QMap myAddWidgets; +}; + + +/* + Class : SMESHGUI_FilterDlg + Description : Dialog to specify filters for VTK viewer +*/ + +class SMESHGUI_FilterDlg : public QDialog +{ + Q_OBJECT + + // Source elements to be selected + enum { Mesh, Selection, Dialog, None }; + + // Buttons + enum { BTN_OK, BTN_Cancel, BTN_Apply, BTN_Close }; + +public: + SMESHGUI_FilterDlg( QWidget* parent, + const QValueList& types, + const char* name = 0 ); + + SMESHGUI_FilterDlg( QWidget* parent, + const int type, + const char* name = 0 ); + virtual ~SMESHGUI_FilterDlg(); + + void Init( const QValueList& types ); + void Init( const int type ); + + void SetSelection( SALOME_Selection* ); + void SetMesh( SMESH::SMESH_Mesh_ptr ); + void SetSourceWg( QWidget* ); + + static SMESH::Filter::Criterion createCriterion(); + +signals: + + void Accepted(); + +private slots: + + void onOk(); + bool onApply(); + void onClose(); + void onDeactivate(); + void onSelectionDone(); + void onCriterionChanged( const int, const int ); + void onCurrentChanged( int, int ); + +private: + + void construct( const QValueList& types ); + + void closeEvent( QCloseEvent* e ); + void enterEvent ( QEvent * ); + + // dialog creation + QFrame* createButtonFrame( QWidget* ); + QFrame* createMainFrame( QWidget* ); + QButtonGroup* createSourceGroup( QWidget* ); + void updateMainButtons(); + + // execution + bool isValid() const; + bool createFilter( const int theType ); + void insertFilterInViewer(); + void selectInViewer( const int theType, + const QValueList& theIds ); + void filterSource( const int theType, + QValueList& theResIds ); + void filterSelectionSource( const int theType, + QValueList& theResIds ); + void getIdsFromWg( const QWidget*, QValueList& ) const; + void setIdsToWg( QWidget*, const QValueList& ); + Selection_Mode getSelMode( const int ) const; + void updateSelection(); + +private: + + // widgets + QFrame* myMainFrame; + QButtonGroup* mySourceGrp; + + QCheckBox* mySetInViewer; + + QMap myButtons; + + SMESHGUI_FilterTable* myTable; + + // initial fields + QValueList myTypes; + SMESHGUI* mySMESHGUI; + SALOME_Selection* mySelection; + SMESH::SMESH_Mesh_ptr myMesh; + QWidget* mySourceWg; + + SALOME_DataMapOfIOMapOfInteger myIObjects; + bool myIsSelectionChanged; + QMap< int, SMESH::Filter_var > myFilter; + QMap< int, bool > myInsertState; + QMap< int, int > myApplyToState; +}; + +#endif + + + + + + + + + + + + + + + + + + + + diff --git a/src/SMESHGUI/SMESHGUI_FilterLibraryDlg.cxx b/src/SMESHGUI/SMESHGUI_FilterLibraryDlg.cxx new file mode 100644 index 000000000..c5db40231 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_FilterLibraryDlg.cxx @@ -0,0 +1,1159 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_FilterLibraryDlg.cxx +// Author : Sergey LITONIN +// Module : SMESH + +#include "SMESHGUI_FilterLibraryDlg.h" +#include "SMESHGUI.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_FilterUtils.h" + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SPACING 5 +#define MARGIN 10 + +/* + Class : SMESHGUI_FilterLibraryDlg::Dialog + Description : Dialog for opening filter library +*/ + +class SMESHGUI_FilterLibraryDlg::Dialog : public QAD_FileDlg +{ +public: + Dialog( QWidget* theParent, const bool theToOpen ); + virtual ~Dialog(); + +protected: + virtual bool acceptData(); +}; + +SMESHGUI_FilterLibraryDlg::Dialog::Dialog( QWidget* theParent, + const bool theToOpen ) +: QAD_FileDlg( theParent, theToOpen ) +{ +} + +SMESHGUI_FilterLibraryDlg::Dialog::~Dialog() +{ +} + +bool SMESHGUI_FilterLibraryDlg::Dialog::acceptData() +{ + if ( mode() != QFileDialogP::AnyFile ) + return QAD_FileDlg::acceptData(); + else + return true; +} + + +/* + Class : SMESHGUI_FilterLibraryDlg + Description : Dialog to specify filters for VTK viewer +*/ + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::SMESHGUI_FilterLibraryDlg +// Purpose : Constructor +//======================================================================= +SMESHGUI_FilterLibraryDlg::SMESHGUI_FilterLibraryDlg( QWidget* theParent, + const QValueList& theTypes, + const int theMode, + const char* theName ) +: QDialog( theParent, theName, true, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + construct( theTypes, theMode ); +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::SMESHGUI_FilterLibraryDlg +// Purpose : Constructor +//======================================================================= +SMESHGUI_FilterLibraryDlg::SMESHGUI_FilterLibraryDlg( QWidget* theParent, + const int theType, + const int theMode, + const char* theName ) +: QDialog( theParent, theName, true, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + QValueList aTypes; + aTypes.append( theType ); + construct( aTypes, theMode ); +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::construct +// Purpose : Construct dialog ( called by constructor ) +//======================================================================= +void SMESHGUI_FilterLibraryDlg::construct( const QValueList& theTypes, const int theMode ) +{ + myTypes = theTypes; + myMode = theMode; + + QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); + + myMainFrame = createMainFrame ( this ); + QFrame* aBtnFrame = createButtonFrame( this ); + + aDlgLay->addWidget( myMainFrame ); + aDlgLay->addWidget( aBtnFrame ); + + aDlgLay->setStretchFactor( myMainFrame, 1 ); + + Init( myTypes, myMode ); +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::createMainFrame +// Purpose : Create frame containing dialog's input fields +//======================================================================= +QFrame* SMESHGUI_FilterLibraryDlg::createMainFrame( QWidget* theParent ) +{ + QGroupBox* aMainFrame = new QGroupBox( 1, Qt::Horizontal, theParent ); + aMainFrame->setFrameStyle( QFrame::NoFrame ); + aMainFrame->setInsideMargin( 0 ); + + // library name + + QGroupBox* aGrp = new QGroupBox( 1, Qt::Vertical, aMainFrame ); + aGrp->setFrameStyle( QFrame::NoFrame ); + aGrp->setInsideMargin( 0 ); + + new QLabel( tr( "LIBRARY_FILE" ), aGrp ); + myFileName = new QLineEdit( aGrp ); + myOpenBtn = new QPushButton( aGrp ); + myOpenBtn->setPixmap( QAD_Desktop::getResourceManager()->loadPixmap( + "QAD", tr("ICON_FILE_OPEN") ) ); + + // filters list box + + aGrp = new QGroupBox( 1, Qt::Vertical, tr( "FILTER_NAMES" ), aMainFrame ); + QFrame* aFrame = new QFrame( aGrp ); + myListBox = new QListBox( aFrame ); + myAddBtn = new QPushButton( tr( "ADD" ), aFrame ); + myDeleteBtn = new QPushButton( tr( "DELETE" ), aFrame ); + + QGridLayout* aLay = new QGridLayout( aFrame, 3, 2, 0, 5 ); + aLay->addMultiCellWidget( myListBox, 0, 2, 0, 0 ); + aLay->addWidget( myAddBtn, 0, 1 ); + aLay->addWidget( myDeleteBtn, 1, 1 ); + QSpacerItem* aVSpacer = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ); + aLay->addItem( aVSpacer, 2, 1 ); + + // filter name + + myNameGrp = new QGroupBox( 1, Qt::Vertical, aMainFrame ); + myNameGrp->setFrameStyle( QFrame::NoFrame ); + myNameGrp->setInsideMargin( 0 ); + new QLabel( tr( "FILTER_NAME" ), myNameGrp ); + myName = new QLineEdit( myNameGrp ); + + // table + + myTable = new SMESHGUI_FilterTable( aMainFrame, myTypes ); + myTable->SetEditable( myMode == EDIT ); + myTable->SetLibsEnabled( false ); + + myListBox->setMinimumHeight( ( int )( myTable->sizeHint().height() * 0.5 ) ); + myListBox->setRowMode( QListBox::FitToWidth ); + myListBox->setSelectionMode( QListBox::Single ); + + myOpenBtn->setAutoDefault( false ); + myAddBtn->setAutoDefault( false ); + myDeleteBtn->setAutoDefault( false ); + + // connect signals and slots + + connect( myFileName, SIGNAL( returnPressed() ), this, SLOT( onReturnPressed() ) ); + connect( myOpenBtn , SIGNAL( clicked() ), this, SLOT( onBrowse() ) ); + + connect( myListBox, SIGNAL( highlighted( const QString& ) ), + this, SLOT( onFilterChanged( const QString& ) ) ); + + connect( myAddBtn, SIGNAL( clicked() ), this, SLOT( onAddBtnPressed() ) ); + connect( myDeleteBtn, SIGNAL( clicked() ), this, SLOT( onDeleteBtnPressed() ) ); + + connect( myName, SIGNAL( textChanged( const QString& ) ), + this, SLOT( onFilterNameChanged( const QString& ) ) ); + + connect( myTable, SIGNAL( EntityTypeChanged( const int ) ), + this, SLOT( onEntityTypeChanged( const int ) ) ); + + connect( myTable, SIGNAL( NeedValidation() ), this, SLOT( onNeedValidation() ) ); + + return aMainFrame; +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::createButtonFrame +// Purpose : Create frame containing buttons +//======================================================================= +QFrame* SMESHGUI_FilterLibraryDlg::createButtonFrame( QWidget* theParent ) +{ + QGroupBox* aGrp = new QGroupBox( 1, Qt::Vertical, theParent ); + + myButtons[ BTN_OK ] = new QPushButton( tr( "SMESH_BUT_OK" ), aGrp ); + myButtons[ BTN_Apply ] = new QPushButton( tr( "SMESH_BUT_APPLY" ), aGrp ); + + QLabel* aLbl = new QLabel( aGrp ); + aLbl->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + myButtons[ BTN_Cancel ] = new QPushButton( tr( "SMESH_BUT_CANCEL" ), aGrp ); + myButtons[ BTN_Close ] = new QPushButton( tr( "SMESH_BUT_CLOSE" ), aGrp ); + + connect( myButtons[ BTN_OK ], SIGNAL( clicked() ), SLOT( onOk() ) ); + connect( myButtons[ BTN_Cancel ], SIGNAL( clicked() ), SLOT( onClose() ) ) ; + connect( myButtons[ BTN_Close ], SIGNAL( clicked() ), SLOT( onClose() ) ) ; + connect( myButtons[ BTN_Apply ], SIGNAL( clicked() ), SLOT( onApply() ) ); + + QMap::iterator anIter; + for ( anIter = myButtons.begin(); anIter != myButtons.end(); ++anIter ) + anIter.data()->setAutoDefault( false ); + + updateMainButtons(); + + return aGrp; +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::updateMainButtons +// Purpose : Update visibility of main buttons ( OK, Cancel, Close ... ) +//======================================================================= +void SMESHGUI_FilterLibraryDlg::updateMainButtons() +{ + if ( myTypes.count() == 1 ) + { + myButtons[ BTN_Cancel ]->show(); + myButtons[ BTN_Apply ]->hide(); + myButtons[ BTN_Close ]->hide(); + } + else + { + myButtons[ BTN_Cancel ]->hide(); + myButtons[ BTN_Apply ]->show(); + myButtons[ BTN_Close ]->show(); + } +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::~SMESHGUI_FilterLibraryDlg +// Purpose : Destructor +//======================================================================= +SMESHGUI_FilterLibraryDlg::~SMESHGUI_FilterLibraryDlg() +{ +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::Init +// Purpose : Init dialog fields, connect signals and slots, show dialog +//======================================================================= +void SMESHGUI_FilterLibraryDlg::Init( const int type, const int theMode ) +{ + QValueList aTypes; + aTypes.append( type ); + Init( aTypes, theMode ); +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::Init +// Purpose : Init dialog fields, connect signals and slots, show dialog +//======================================================================= +void SMESHGUI_FilterLibraryDlg::Init( const QValueList& theTypes, const int theMode ) +{ + myMode = theMode; + myTypes = theTypes; + myTable->Init( theTypes ); + myCurrFilterName = ""; + myCurrFilter = -1; + myListBox->clear(); + myName->clear(); + myTable->Clear(); + + updateControlsVisibility(); + setEnabled( true ); + + SMESHGUI* aModeler = SMESHGUI::GetSMESHGUI(); + + connect( aModeler, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( onDeactivate() ) ); + connect( aModeler, SIGNAL( SignalCloseAllDialogs() ), SLOT( onClose() ) ); + + if ( myMode == ADD_TO ) + { + setCaption( tr( "ADD_TO_TLT" ) ); + if ( myFileName->text().isEmpty() ) + myFileName->setText( getDefaultLibraryName() ); + processNewLibrary(); + } + else if ( myMode == COPY_FROM ) + { + setCaption( tr( "COPY_FROM_TLT" ) ); + if ( myFileName->text().isEmpty() ) + myFileName->setText( getDefaultLibraryName() ); + processNewLibrary(); + if ( myListBox->count() > 0 ) + myListBox->setCurrentItem( 0 ); + } + else + { + setCaption( tr( "EDIT_LIB_TLT" ) ); + if ( myFileName->text().isEmpty() ) + myFileName->setText( getDefaultLibraryName() ); + processNewLibrary(); + if ( myListBox->count() > 0 ) + myListBox->setCurrentItem( 0 ); + } + + int x, y ; + aModeler->DefineDlgPosition( this, x, y ); + this->move( x, y ); + + this->show(); + + updateMainButtons(); + isPermissionValid( false ); +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::updateControlsVisibility +// Purpose : Update visibility of controls in accordance with myMode +//======================================================================= +void SMESHGUI_FilterLibraryDlg::updateControlsVisibility() +{ + if ( myMode == ADD_TO ) + { + myNameGrp->show(); + myNameGrp->setEnabled( true ); + myAddBtn->hide(); + myDeleteBtn->hide(); + myTable->SetEditable( false ); + } + else if ( myMode == COPY_FROM ) + { + myNameGrp->hide(); + myNameGrp->setEnabled( false ); + myAddBtn->hide(); + myDeleteBtn->hide(); + myTable->SetEditable( false ); + } + else if ( myMode == EDIT ) + { + myNameGrp->show(); + myNameGrp->setEnabled( true ); + myAddBtn->show(); + myDeleteBtn->show(); + myTable->SetEditable( true ); + } + + qApp->processEvents(); + updateGeometry(); + adjustSize(); +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::onApply +// Purpose : SLOT called when "Apply" button pressed. +//======================================================================= +bool SMESHGUI_FilterLibraryDlg::onApply() +{ + if ( !isValid( true ) || !isPermissionValid( false ) ) + return false; + + if ( myLibrary->_is_nil() ) + { + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_WRN_WARNING" ), tr( "LIBRARY_IS_NOT_LOADED" ), QMessageBox::Ok ); + return false; + } + + const char* aName = myFileName->text().latin1(); + if ( strcmp( myLibrary->GetFileName(), aName ) != 0 ) + myLibrary->SetFileName( aName ); + + bool aResult = false; + + if ( myMode == COPY_FROM || myListBox->count() == 0 ) + { + aResult = true; + } + else if ( myMode == EDIT || myMode == ADD_TO ) + { + SMESH::Filter_var aFilter = createFilter(); + if ( !myLibrary->Replace( myCurrFilterName, myName->text(), aFilter.in() ) ) + { + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_ERROR" ), tr( "ERROR_OF_EDITING" ), QMessageBox::Ok ); + aResult = false; + } + else + aResult = true; + } + + if ( aResult && myMode != COPY_FROM ) + aResult = myLibrary->Save(); + + if ( aResult ) + { + char* aFileName = myLibrary->GetFileName(); + getDefaultLibraryName() = QString( aFileName ); + delete aFileName; + } + else if ( myMode != COPY_FROM ) + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_ERROR" ), tr( "ERROR_OF_SAVING" ), QMessageBox::Ok ); + + + return aResult; +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::onOk +// Purpose : SLOT called when "Ok" button pressed. +// Assign filters VTK viewer and close dialog +//======================================================================= +void SMESHGUI_FilterLibraryDlg::onOk() +{ + if ( onApply() ) + { + disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); + SMESHGUI::GetSMESHGUI()->ResetState() ; + accept(); + } +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::onClose +// Purpose : SLOT called when "Close" button pressed. Close dialog +//======================================================================= +void SMESHGUI_FilterLibraryDlg::onClose() +{ + disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); + SMESHGUI::GetSMESHGUI()->ResetState() ; + reject() ; +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::onDeactivate +// Purpose : SLOT called when dialog must be deativated +//======================================================================= +void SMESHGUI_FilterLibraryDlg::onDeactivate() +{ + setEnabled( false ); +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::enterEvent +// Purpose : Event filter +//======================================================================= +void SMESHGUI_FilterLibraryDlg::enterEvent( QEvent* ) +{ + setEnabled( true ); +} + +//================================================================================= +// function : closeEvent() +// purpose : Close dialog +//================================================================================= +void SMESHGUI_FilterLibraryDlg::closeEvent( QCloseEvent* e ) +{ + onClose() ; +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::getFileName +// Purpose : Get file name +//======================================================================= +QString SMESHGUI_FilterLibraryDlg::getFileName() const +{ + return myFileName != 0 ? myFileName->text() : QString(""); +} + +//================================================================ +// Function : setFileName +// Purpose : Set file name to line edit +//================================================================ +void SMESHGUI_FilterLibraryDlg::setFileName( const QString& txt, const bool autoExt ) +{ + if ( myFileName == 0 ) + return; + myFileName->setText( autoExt ? autoExtension( txt ) : txt ); +} + +//================================================================ +// Function : autoExtension +// Purpose : Append extension to the file name +//================================================================ +QString SMESHGUI_FilterLibraryDlg::autoExtension( const QString& theFileName ) const +{ + QString anExt = theFileName.section( '.', -1 ); + return anExt != "xml" && anExt != "XML" ? theFileName + ".xml" : theFileName; +} + +//================================================================ +// Function : filterWildCards +// Purpose : +//================================================================ +QStringList SMESHGUI_FilterLibraryDlg::filterWildCards( const QString& theFilter ) const +{ + QStringList res; + + int b = theFilter.findRev( "(" ); + int e = theFilter.findRev( ")" ); + if ( b != -1 && e != -1 ) + { + QString content = theFilter.mid( b + 1, e - b - 1 ).stripWhiteSpace(); + QStringList lst = QStringList::split( " ", content ); + for ( QStringList::const_iterator it = lst.begin(); it != lst.end(); ++it ) + if ( (*it).find( "." ) != -1 ) + res.append( (*it).stripWhiteSpace() ); + } + return res; +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::prepareFilters +// Purpose : Prepare filters for dialog +//======================================================================= +QStringList SMESHGUI_FilterLibraryDlg::prepareFilters() const +{ + static QStringList aList; + if ( aList.isEmpty() ) + { + aList.append( tr( "XML_FILT" ) ); + //aList.append( tr( "ALL_FILES_FILTER" ) ); + } + + return aList; +} + +//================================================================ +// Function : onBrowse +// Purpose : SLOT. Display "Open file" dialog for chosing library name +//================================================================ +void SMESHGUI_FilterLibraryDlg::onBrowse() +{ + Dialog* aDlg = new Dialog( this, true ); + aDlg->setCaption( tr( "OPEN_LIBRARY" ) ); + + aDlg->setMode( myMode == COPY_FROM ? QFileDialogP::ExistingFile : QFileDialogP::AnyFile ); + aDlg->setFilters( prepareFilters() ); + aDlg->setSelection( getFileName() ); + + QPushButton* anOkBtn = ( QPushButton* )aDlg->child( "OK", "QPushButton" ); + if ( anOkBtn != 0 ) + anOkBtn->setText( tr( "SMESH_BUT_OK" ) ); + + if ( aDlg->exec() != Accepted ) + return; + + QString fName = aDlg->selectedFile(); + + if ( fName.isEmpty() ) + return; + + if ( QFileInfo( fName ).extension().isEmpty() ) + fName = autoExtension( fName ); + + fName = QDir::convertSeparators( fName ); + QString prev = QDir::convertSeparators( getFileName() ); + + if ( prev == fName ) + return; + + setFileName( fName ); + + QString aName = myListBox->text( myListBox->count() - 1 ); + processNewLibrary(); + + if ( myMode == ADD_TO ) + { + myTable->Copy( (SMESHGUI_FilterTable*)parentWidget() ); + myCurrFilterName = ""; + myCurrFilter = -1; + addFilterToLib( aName ); + } + + isPermissionValid( false ); +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::processNewLibrary +// Purpose : SLOT. Calleds when file name changed +//======================================================================= +void SMESHGUI_FilterLibraryDlg::processNewLibrary() +{ + SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager(); + if ( aFilterMgr->_is_nil() ) + return; + + myLibrary = aFilterMgr->LoadLibrary( autoExtension( getFileName() ) ); + if ( myLibrary->_is_nil() ) + { + if ( myMode == COPY_FROM ) + { + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_ERROR" ), tr( "ERROR_LOAD" ), QMessageBox::Ok ); + return; + } + else + { + myLibrary = aFilterMgr->CreateLibrary(); + myLibrary->SetFileName( getFileName().latin1() ); + } + } + + updateList(); +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::updateList +// Purpose : Fill list box with filter names +//======================================================================= +void SMESHGUI_FilterLibraryDlg::updateList() +{ + QStringList aList; + SMESH::string_array_var aNames = myLibrary->GetNames( (SMESH::ElementType)myTable->GetType() ); + for ( int i = 0, n = aNames->length(); i < n; i++ ) + aList.append( QString( aNames[ i ] ) ); + myListBox->clear(); + myListBox->insertStringList( aList ); + if ( myListBox->count() == 0 ) + { + myTable->Clear( myTable->GetType() ); + myName->clear(); + myName->setEnabled( false ); + myTable->SetEnabled( false ); + } + else + { + myName->setEnabled( true ); + myTable->SetEnabled( true ); + if ( myListBox->count() ) + { + myCurrFilterName = ""; + myListBox->setCurrentItem( 0 ); + } + } +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::isNameValid +// Purpose : Verify validity if entered data +//======================================================================= +bool SMESHGUI_FilterLibraryDlg::isNameValid( const bool theMess ) const +{ + // verify validity of filter name + if ( myName->isEnabled() && !myCurrFilterName.isEmpty() ) + { + QString aCurrName = myName->text(); + if ( aCurrName.isEmpty() ) + { + if ( theMess ) + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_INSUFFICIENT_DATA" ), tr( "EMPTY_FILTER_NAME" ), QMessageBox::Ok ); + return false; + } + + SMESH::string_array_var aNames = myLibrary->GetAllNames(); + for ( int f = 0, n = aNames->length(); f < n; f++ ) + { + if ( aNames[ f ] == aCurrName && aNames[ f ] != myCurrFilterName ) + { + if ( theMess ) + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_INSUFFICIENT_DATA" ), tr( "ERROR_FILTER_NAME" ), QMessageBox::Ok ); + return false; + } + } + } + + return true; +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::isPermissionValid +// Purpose : Verify write permission on file +//======================================================================= +bool SMESHGUI_FilterLibraryDlg::isPermissionValid( const bool theIsExistingOnly ) +{ + if ( myMode == COPY_FROM ) + return true; + + // Verify write permission + bool isWritable = false; + + QString fName( myFileName->text() ); + if ( QFileInfo( fName ).extension().isEmpty() ) + fName = autoExtension( fName ); + + fName = QDir::convertSeparators( fName ); + + if ( QFileInfo( fName ).exists() ) + isWritable = QFileInfo( fName ).isWritable(); + else if ( !theIsExistingOnly ) + { + QFileInfo aDirInfo( QFileInfo( fName ).dirPath( true ) ); + isWritable = aDirInfo.isWritable(); + /*if ( QDir( QFileInfo( fName ).dirPath( true ) ).exists() || + QDir().mkdir( QFileInfo( fName ).dirPath( true ) ) ) + { + QFile aFile( fName ); + if ( aFile.open( IO_WriteOnly ) ) + isWritable = true; + else + aFile.close(); + } + */ + } + else + isWritable = true; + + if ( !isWritable ) + { + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_WRN_WARNING" ), tr( "NO_PERMISSION" ), QMessageBox::Ok ); + return false; + } + + return true; +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::isValid +// Purpose : Verify validity if entered data +//======================================================================= +bool SMESHGUI_FilterLibraryDlg::isValid( const bool theMess ) const +{ + // verify validity of table + if ( !myTable->IsValid( theMess ) || !isNameValid( theMess ) ) + return false; + else + return true; +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::onFilterChanged +// Purpose : SLOT. Called when selected filter of library changed +//======================================================================= +void SMESHGUI_FilterLibraryDlg::onFilterChanged( const QString& theName ) +{ + if ( myLibrary->_is_nil() ) + return; + + // Save parameters of filter if it was changed + + if ( !myCurrFilterName.isEmpty() && myTable->IsEditable() ) + { + if ( !isValid( true ) ) + { + myListBox->blockSignals( true ); + myListBox->setCurrentItem( myCurrFilter ); + myListBox->blockSignals( false ); + return; + } + + SMESH::Filter_var aFilter = createFilter(); + myLibrary->Replace( myCurrFilterName.latin1(), myName->text().latin1(), aFilter ); + } + + // Fill table with filter parameters + + SMESH::Filter_var aFilter = myLibrary->Copy( theName ); + myCurrFilterName = theName; + myCurrFilter = myListBox->currentItem(); + myName->setText( theName ); + + + SMESH::Filter::Criteria_var aCriteria; + + myTable->Clear( myTable->GetType() ); + + if ( !aFilter->GetCriteria( aCriteria ) ) + return; + + for ( int i = 0, n = aCriteria->length(); i < n; i++ ) + myTable->AddCriterion( aCriteria[ i ], myTable->GetType() ); + + myTable->Update(); +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::onReturnPressed +// Purpose : SLOT. Called when enter button is pressed in library name field +// Reload library +//======================================================================= +void SMESHGUI_FilterLibraryDlg::onReturnPressed() +{ + QString aName = myListBox->text( myListBox->count() - 1 ); + + processNewLibrary(); + + if ( myMode == ADD_TO ) + { + myTable->Copy( (SMESHGUI_FilterTable*)parentWidget() ); + myCurrFilterName = ""; + myCurrFilter = -1; + addFilterToLib( aName ); + } + + isPermissionValid( false ); +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::enableMainButtons +// Purpose : Update state of "OK", "Cancel" buttons +//======================================================================= +void SMESHGUI_FilterLibraryDlg::enableMainButtons() +{ + /*bool isEnabled = isValid( false ); + if ( myButtons.contains( BTN_OK ) ) + myButtons[ BTN_OK ]->setEnabled( isEnabled ); + else if ( myButtons.contains( BTN_Apply ) ) + myButtons[ BTN_OK ]->setEnabled( isEnabled ); + if ( myButtons.contains( BTN_Cancel ) ) + myButtons[ BTN_Cancel ]->setEnabled( isEnabled ); + else if ( myButtons.contains( BTN_Close ) ) + myButtons[ BTN_Cancel ]->setEnabled( isEnabled ); + */ +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::createFilter +// Purpose : Cerate filter in accordance with library +//======================================================================= +SMESH::Filter_ptr SMESHGUI_FilterLibraryDlg::createFilter( const int theType ) +{ + int n = myTable->NumRows( theType ); + + SMESH::Filter::Criteria_var aCriteria = new SMESH::Filter::Criteria; + aCriteria->length( n ); + + for ( int i = 0; i < n; i++ ) + { + SMESH::Filter::Criterion aCriterion = SMESHGUI_FilterDlg::createCriterion(); + myTable->GetCriterion( i, aCriterion ); + aCriteria[ i ] = aCriterion; + } + + SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager(); + SMESH::Filter_var aFilter = aFilterMgr->CreateFilter(); + aFilter->SetCriteria( aCriteria.inout() ); + + return aFilter._retn(); +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::onAddBtnPressed +// Purpose : SLOT. Called when "Add" button pressed +// Add new filter to the end of library +//======================================================================= +void SMESHGUI_FilterLibraryDlg::onAddBtnPressed() +{ + // Save parameters of filter if it was changed + if ( !myCurrFilterName.isEmpty() && myTable->IsEditable() ) + { + if ( !isValid( true ) ) + return; + + SMESH::Filter_var aFilter = createFilter(); + myLibrary->Replace( myCurrFilterName.latin1(), myName->text().latin1(), aFilter ); + } + + addFilterToLib( getDefaultFilterName() ); +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::onAddBtnPressed +// Purpose : SLOT. Called when "Add" button pressed +// Add new filter to the end of library +//======================================================================= +void SMESHGUI_FilterLibraryDlg::addFilterToLib( const QString& theName ) +{ + if ( myLibrary->_is_nil() ) + { + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_WRN_WARNING" ), tr( "LIBRARY_IS_NOT_LOADED" ), QMessageBox::Ok ); + return; + } + + // create filter + SMESH::Filter_var aFilter = createFilter(); + + // if name of filter already exist in the library assign default name for the filter + QString aName( theName ); + SMESH::string_array_var aNames = myLibrary->GetAllNames(); + for ( int i = 0, n = aNames->length(); i < n; i++ ) + if ( aName == QString( aNames[ i ] ) ) + { + aName = getDefaultFilterName(); + break; + } + + // add new filter in library + bool aResult = !aFilter->GetPredicate()->_is_nil() + ? myLibrary->Add( aName.latin1(), aFilter ) + : myLibrary->AddEmpty( aName.latin1(), (SMESH::ElementType)myTable->GetType() ); + + if ( !aResult ) + { + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_ERROR" ), tr( "ERROR_OF_ADDING" ), QMessageBox::Ok ); + } + + updateList(); + myCurrFilterName = ""; + myCurrFilter = -1; + setSelected( aName ); + + if ( theName != aName ) + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), tr( "SMESH_WARNING" ), + tr( "ASSIGN_NEW_NAME" ).arg( theName ).arg( aName ) , QMessageBox::Ok ); +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::getDefaultLibraryName +// Purpose : Get default library name +//======================================================================= +QString& SMESHGUI_FilterLibraryDlg::getDefaultLibraryName() const +{ + static QString aName; + if ( aName.isEmpty() ) + { + QString aHomeDir = QDir( QDir::home() ).absPath(); + aName = aHomeDir + "/" + tr ( "LIB_NAME" ); + } + return aName; +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::getDefaultFilterName +// Purpose : Create default filter name +//======================================================================= +QString SMESHGUI_FilterLibraryDlg::getDefaultFilterName() const +{ + QString aName; + + if ( myTable->GetType() == SMESH::NODE ) + aName = tr( "NODE" ); + else if ( myTable->GetType() == SMESH::EDGE ) + aName = tr( "EDGE" ); + else if ( myTable->GetType() == SMESH::FACE ) + aName = tr( "FACE" ); + else if ( myTable->GetType() == SMESH::VOLUME ) + aName = tr( "VOLUME" ); + else if ( myTable->GetType() == SMESH::ALL ) + aName = tr( "ELEMENT" ); + else + aName = tr( "SELECTION" ); + + aName += tr( "FILTER" ); + + + QMap< QString, int > anAllNames; + SMESH::string_array_var aNames = myLibrary->GetAllNames(); + for( int i = 0, n = aNames->length(); i < n; i++ ) + anAllNames[ QString( aNames[ i ] ) ] = -1; + + bool isNotValid = true; + int k = 1; + QString aNewName; + while ( isNotValid ) + { + isNotValid = false; + aNewName = aName + "_" + QString( "%1" ).arg( k ); + if ( anAllNames.contains( aNewName ) ) + { + isNotValid = true; + k++; + } + } + + return aNewName; +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::setSelected +// Purpose : set selected item in list box containing filters +//======================================================================= +bool SMESHGUI_FilterLibraryDlg::setSelected( const QString& theName ) +{ + int anIndex = getIndex( theName ); + if ( anIndex != -1 ) + { + myListBox->setCurrentItem( anIndex ); + myCurrFilterName = theName; + myCurrFilter = anIndex; + } + return anIndex != -1; +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::getIndex +// Purpose : Get index of the filter in list box +//======================================================================= +int SMESHGUI_FilterLibraryDlg::getIndex( const QString& theName ) const +{ + for ( int i = 0, n = myListBox->count(); i < n; i++ ) + if ( myListBox->text( i ) == theName) + return i; + return -1; +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::onDeleteBtnPressed +// Purpose : SLOT. Called when "Delete" button pressed +//======================================================================= +void SMESHGUI_FilterLibraryDlg::onDeleteBtnPressed() +{ + if ( myLibrary->_is_nil() ) + { + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_WRN_WARNING" ), tr( "LIBRARY_IS_NOT_LOADED" ), QMessageBox::Ok ); + return; + } + + int anIndex = getIndex( myCurrFilterName ); + + if ( anIndex == -1 || !myLibrary->Delete( myCurrFilterName.latin1() ) ) + { + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_ERROR" ), tr( "ERROR_OF_DELETING" ), QMessageBox::Ok ); + } + else + { + myCurrFilterName = ""; + myCurrFilterName = -1; + myListBox->removeItem( anIndex ); + + if ( anIndex >= 1 ) + myListBox->setSelected( anIndex - 1, true ); + else if ( anIndex == 0 && myListBox->count() > 0 ) + myListBox->setSelected( 0, true ); + else + myTable->Clear(); + } + + myTable->SetEnabled( myListBox->count() > 0 ); + if ( myListBox->count() == 0 ) + { + myName->setText( "" ); + myName->setEnabled( false ); + } +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::onFilterNameChanged +// Purpose : SLOT. Called when name of filter changed +// Change filter name in list box +//======================================================================= +void SMESHGUI_FilterLibraryDlg::onFilterNameChanged( const QString& theName ) +{ + int aCurrItem = myListBox->currentItem(); + if ( aCurrItem == -1 ) + return; + + myListBox->blockSignals( true ); + myListBox->changeItem( theName, aCurrItem ); + myListBox->blockSignals( false ); +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::SetTable +// Purpose : Set table +//======================================================================= +void SMESHGUI_FilterLibraryDlg::SetTable( const SMESHGUI_FilterTable* theTable ) +{ + myTable->Copy( theTable ); + myName->setText( getDefaultFilterName() ); + addFilterToLib( myName->text() ); + myTable->Update(); +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::GetTable +// Purpose : Get table +//======================================================================= +const SMESHGUI_FilterTable* SMESHGUI_FilterLibraryDlg::GetTable() const +{ + return myTable; +} + + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::onEntityTypeChanged +// Purpose : SLOT. Called when entiyt type changed +//======================================================================= +void SMESHGUI_FilterLibraryDlg::onEntityTypeChanged( const int theType ) +{ + if ( myLibrary->_is_nil() ) + return; + + myName->clear(); + myCurrFilterName = ""; + myCurrFilter = -1; + updateList(); + if ( myListBox->count() ) + myListBox->setCurrentItem( 0 ); +} + +//======================================================================= +// name : SMESHGUI_FilterLibraryDlg::onNeedValidation +// Purpose : +//======================================================================= +void SMESHGUI_FilterLibraryDlg::onNeedValidation() +{ + if ( !myCurrFilterName.isEmpty() ) + { + bool valid = isValid( true ); + myTable->SetValidity( valid ); + + if ( valid ) + { + SMESH::Filter_var aFilter = createFilter( myTable->GetType() ); + myLibrary->Replace( myCurrFilterName.latin1(), myName->text().latin1(), aFilter ); + } + } +} + + + + + + + diff --git a/src/SMESHGUI/SMESHGUI_FilterLibraryDlg.h b/src/SMESHGUI/SMESHGUI_FilterLibraryDlg.h new file mode 100644 index 000000000..88b52661c --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_FilterLibraryDlg.h @@ -0,0 +1,154 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_FilterLibraryDlg.h +// Author : Sergey LITONIN +// Module : SMESH + + +#ifndef SMESHGUI_FilterLibraryDlg_H +#define SMESHGUI_FilterLibraryDlg_H + +#include +#include + +#include +#include CORBA_SERVER_HEADER(SMESH_Filter) + +class QCloseEvent; +class QListBox; +class QFrame; +class QEvent; +class QLineEdit; +class QPushButton; +class QGroupBox; + +/* + Class : SMESHGUI_FilterLibraryDlg + Description : Dialog to specify filters for VTK viewer +*/ + +class SMESHGUI_FilterLibraryDlg : public QDialog +{ + Q_OBJECT + + // Buttons + enum { BTN_OK, BTN_Cancel, BTN_Apply, BTN_Close }; + + class Dialog; + +public: + + // Mode + enum { ADD_TO, COPY_FROM, EDIT }; + +public: + + SMESHGUI_FilterLibraryDlg( QWidget* parent, + const QValueList& types, + const int mode, + const char* name = 0 ); + + SMESHGUI_FilterLibraryDlg( QWidget* parent, + const int type, + const int mode, + const char* name = 0 ); + + virtual ~SMESHGUI_FilterLibraryDlg(); + + void Init( const QValueList& types, const int theMode ); + void Init( const int type, const int theMode ); + + const SMESHGUI_FilterTable* GetTable() const; + void SetTable( const SMESHGUI_FilterTable* ); + +private: + + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; + +private slots: + + void onOk(); + bool onApply(); + void onClose(); + + void onDeactivate(); + + void onBrowse(); + void onReturnPressed(); + void onFilterChanged( const QString& ); + void onAddBtnPressed(); + void onDeleteBtnPressed(); + void onFilterNameChanged( const QString& ); + void onEntityTypeChanged( const int ); + void onNeedValidation(); + +private: + + void construct( const QValueList& types, const int mode ); + QFrame* createButtonFrame( QWidget* ); + QFrame* createMainFrame ( QWidget* ); + bool isValid( const bool theMess = true ) const; + bool isNameValid( const bool theMess = true ) const; + SMESH::Filter_ptr createFilter( const int theType = -1 ); + QStringList prepareFilters() const; + QString autoExtension( const QString& ) const; + bool setSelected( const QString& ); + int getIndex( const QString& ) const; + void updateControlsVisibility(); + void updateMainButtons(); + void enableMainButtons(); + void processNewLibrary(); + QString getFileName() const; + void setFileName( const QString& txt, const bool autoExtension = true ); + QStringList filterWildCards( const QString& theFilter ) const; + QString& getDefaultLibraryName() const; + QString getDefaultFilterName() const; + void addFilterToLib( const QString& name ); + void updateList(); + bool isPermissionValid( const bool theIsExistingOnly ); + +private: + + QFrame* myMainFrame; + QMap myButtons; + SMESHGUI_FilterTable* myTable; + QLineEdit* myFileName; + QPushButton* myOpenBtn; + QListBox* myListBox; + QPushButton* myAddBtn; + QPushButton* myDeleteBtn; + QGroupBox* myNameGrp; + QLineEdit* myName; + + QValueList myTypes; + int myMode; + + SMESH::FilterLibrary_var myLibrary; + QString myCurrFilterName; + int myCurrFilter; + +}; + +#endif diff --git a/src/SMESHGUI/SMESHGUI_FilterUtils.cxx b/src/SMESHGUI/SMESHGUI_FilterUtils.cxx new file mode 100644 index 000000000..4b0ae92de --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_FilterUtils.cxx @@ -0,0 +1,37 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + + +#include "SMESHGUI_FilterUtils.h" +#include "SMESHGUI_SMESHGenUtils.h" + + +namespace SMESH +{ + + SMESH::FilterManager_var GetFilterManager() + { + static SMESH::FilterManager_var aFilterManager; + if(CORBA::is_nil(aFilterManager)){ + aFilterManager = GetSMESHGen()->CreateFilterManager(); + } + return aFilterManager; + } + +} diff --git a/src/SMESHGUI/SMESHGUI_FilterUtils.h b/src/SMESHGUI/SMESHGUI_FilterUtils.h new file mode 100644 index 000000000..85bd3d01a --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_FilterUtils.h @@ -0,0 +1,34 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#ifndef SMESHGUI_FilterUtils_HeaderFile +#define SMESHGUI_FilterUtils_HeaderFile + +#include "SALOMEconfig.h" +#include CORBA_SERVER_HEADER(SMESH_Filter) + + +namespace SMESH{ + + SMESH::FilterManager_var GetFilterManager(); + +} + + +#endif diff --git a/src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx b/src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx new file mode 100644 index 000000000..a7dc4011b --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx @@ -0,0 +1,60 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + + +#include "QAD_Desktop.h" + +#include "SMESHGUI_GEOMGenUtils.h" +#include "SMESHGUI_Utils.h" +#include CORBA_CLIENT_HEADER(SMESH_Mesh) + +namespace SMESH{ + + GEOM::GEOM_Gen_var GetGEOMGen() + { + static GEOM::GEOM_Gen_var aGEOMGen; + if(CORBA::is_nil(aGEOMGen)){ + if(QAD_Desktop* aDesktop = QAD_Application::getDesktop()){ + Engines::Component_var aComponent = aDesktop->getEngine("FactoryServer","GEOM"); + aGEOMGen = GEOM::GEOM_Gen::_narrow(aComponent); + } + } + return aGEOMGen; + } + + + GEOM::GEOM_Object_var GetShapeOnMeshOrSubMesh(SALOMEDS::SObject_ptr theMeshOrSubmesh) + { + if(!theMeshOrSubmesh->_is_nil()) { + CORBA::Object_var Obj = theMeshOrSubmesh->GetObject(); + if ( !CORBA::is_nil( Obj ) ) { + SMESH::SMESH_Mesh_var aMesh = + SObjectToInterface( theMeshOrSubmesh ); + if ( !aMesh->_is_nil() ) + return aMesh->GetShapeToMesh(); + SMESH::SMESH_subMesh_var aSubmesh = + SObjectToInterface( theMeshOrSubmesh ); + if ( !aSubmesh->_is_nil() ) + return aSubmesh->GetSubShape(); + } + } + return GEOM::GEOM_Object::_nil(); + } + +} diff --git a/src/SMESHGUI/SMESHGUI_GEOMGenUtils.h b/src/SMESHGUI/SMESHGUI_GEOMGenUtils.h new file mode 100644 index 000000000..ebc0a43e9 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_GEOMGenUtils.h @@ -0,0 +1,38 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#ifndef SMESHGUI_GEOMGenUtils_HeaderFile +#define SMESHGUI_GEOMGenUtils_HeaderFile + +#include "SALOMEconfig.h" +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include CORBA_CLIENT_HEADER(SALOMEDS) + + +namespace SMESH +{ + + GEOM::GEOM_Gen_var GetGEOMGen(); + + GEOM::GEOM_Object_var GetShapeOnMeshOrSubMesh(SALOMEDS::SObject_ptr theSObject); + +} + + +#endif diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx index d6928d673..ed7295a11 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx @@ -26,14 +26,20 @@ // Module : SMESH // $Header$ -using namespace std; #include "SMESHGUI_GroupDlg.h" #include "SMESHGUI_FilterDlg.h" +#include "SMESHGUI_Filter.h" #include "SMESHGUI.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_MeshUtils.h" +#include "SMESHGUI_GroupUtils.h" +#include "SMESHGUI_FilterUtils.h" +#include "SMESHGUI_GEOMGenUtils.h" + #include "SALOMEGUI_QtCatchCorbaException.hxx" #include "SALOME_ListIteratorOfListIO.hxx" -#include "VTKViewer_InteractorStyleSALOME.h" #include "VTKViewer_ViewFrame.h" #include "QAD_Application.h" #include "QAD_Desktop.h" @@ -43,6 +49,8 @@ using namespace std; #include "SMESH_Actor.h" +#include "GEOMBase.h" + // QT Includes #include #include @@ -57,11 +65,14 @@ using namespace std; #include #include #include +#include // STL includes #include #include +using namespace std; + //================================================================================= // class : SMESHGUI_GroupDlg() // purpose : @@ -72,8 +83,15 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( QWidget* parent, const char* name, SALOME_ { if ( !name ) setName( "SMESHGUI_GroupDlg" ); initDialog(theSel, true); - init(theMesh); - + if (!theMesh->_is_nil()) + init(theMesh); + else { + mySelectSubMesh->setEnabled(false); + mySelectGroup->setEnabled(false); + myGeomGroupBtn->setEnabled(false); + myGeomGroupLine->setEnabled(false); + } + /* Move widget on the botton right corner of main widget */ int x, y ; mySMESHGUI->DefineDlgPosition(this, x, y); @@ -86,8 +104,13 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( QWidget* parent, const char* name, SALOME_ { if ( !name ) setName( "SMESHGUI_GroupDlg" ); initDialog(theSel, false); - init(theGroup); - + if (!theGroup->_is_nil()) + init(theGroup); + else { + mySelectSubMesh->setEnabled(false); + mySelectGroup->setEnabled(false); + } + /* Move widget on the botton right corner of main widget */ int x, y ; mySMESHGUI->DefineDlgPosition(this, x, y); @@ -97,17 +120,31 @@ SMESHGUI_GroupDlg::SMESHGUI_GroupDlg( QWidget* parent, const char* name, SALOME_ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) { myFilterDlg = 0; + myCreate = create; + myCurrentLineEdit = 0; QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); if (create) setCaption( tr( "SMESH_CREATE_GROUP_TITLE" ) ); - else + else setCaption( tr( "SMESH_EDIT_GROUP_TITLE" ) ); + setSizeGripEnabled( TRUE ); - QVBoxLayout* aMainLayout = new QVBoxLayout(this, 11, 6); + QGridLayout* aMainLayout = new QGridLayout(this, 7, 3, 11, 6); + /***************************************************************/ + QLabel* meshGroupLab = new QLabel(this, "mesh/group label"); + if (create) + meshGroupLab->setText(tr("SMESH_MESH")); + else + meshGroupLab->setText(tr("SMESH_GROUP")); + myMeshGroupBtn = new QPushButton(this, "mesh/group button"); + myMeshGroupBtn->setPixmap(image0); + myMeshGroupLine = new QLineEdit(this, "mesh/group line"); + myMeshGroupLine->setReadOnly(true); + /***************************************************************/ myTypeGroup = new QButtonGroup(1, Qt::Vertical, this, "Group types"); myTypeGroup->setTitle(tr("SMESH_ELEMENTS_TYPE")); @@ -126,14 +163,27 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) myTypeId = -1; /***************************************************************/ - QHBox* aNameBox = new QHBox(this, "name box"); - QLabel* aName = new QLabel(aNameBox, "name label"); + QLabel* aName = new QLabel(this, "name label"); aName->setText(tr("SMESH_NAME")); aName->setMinimumSize(50,0); - myName = new QLineEdit(aNameBox, "name"); - + myName = new QLineEdit(this, "name"); + + /***************************************************************/ + myGrpTypeGroup = new QButtonGroup(1, Qt::Vertical, this, "Type of group"); + myGrpTypeGroup->setTitle(tr("SMESH_GROUP_TYPE")); + myGrpTypeGroup->setExclusive(true); + QRadioButton* rb1 = new QRadioButton( tr("SMESH_GROUP_STANDALONE"), myGrpTypeGroup); + QRadioButton* rb2 = new QRadioButton( tr("SMESH_GROUP_GEOMETRY"), myGrpTypeGroup); + myGrpTypeGroup->setEnabled(create); + myGrpTypeId = -1; + + /***************************************************************/ + myWGStack = new QWidgetStack( this, "widget stack"); + QWidget* wg1 = new QFrame( myWGStack, "first widget" ); + QWidget* wg2 = new QFrame( myWGStack, "second widget" ); + /***************************************************************/ - QGroupBox* aContentBox = new QGroupBox(1, Qt::Horizontal, this, "content box"); + QGroupBox* aContentBox = new QGroupBox(1, Qt::Horizontal, wg1, "content box"); aContentBox->setTitle(tr("SMESH_CONTENT")); QFrame* aContent = new QFrame(aContentBox, "content"); QGridLayout* aLayout = new QGridLayout(aContent, 7, 4); @@ -144,7 +194,6 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) aLabel->setText(tr("SMESH_ID_ELEMENTS")); myElements = new QListBox(aContent, "elements list"); myElements->setSelectionMode(QListBox::Extended); - // myElements->setMinimumHeight(150); myFilter = new QPushButton(aContent, "filter"); myFilter->setText(tr("SMESH_BUT_FILTER")); @@ -168,13 +217,10 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) aLayout->setRowStretch(2, 1); aLayout->setRowStretch(5, 1); - aContentBox->setMinimumHeight(aContent->sizeHint().height() + - aContentBox->sizeHint().height()); - /***************************************************************/ - QGroupBox* aSelectBox = new QGroupBox(3, Qt::Horizontal, this, "select box"); + QGroupBox* aSelectBox = new QGroupBox(3, Qt::Horizontal, wg1, "select box"); aSelectBox->setTitle(tr("SMESH_SELECT_FROM")); - + mySelectSubMesh = new QCheckBox(aSelectBox, "submesh checkbox"); mySelectSubMesh->setText(tr("SMESH_SUBMESH")); mySelectSubMesh->setMinimumSize(50, 0); @@ -184,7 +230,7 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) mySubMeshLine = new QLineEdit(aSelectBox, "submesh line"); mySubMeshLine->setReadOnly(true); onSelectSubMesh(false); - + mySelectGroup = new QCheckBox(aSelectBox, "group checkbox"); mySelectGroup->setText(tr("SMESH_GROUP")); mySelectGroup->setMinimumSize(50, 0); @@ -194,10 +240,36 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) myGroupLine = new QLineEdit(aSelectBox, "group line"); myGroupLine->setReadOnly(true); onSelectGroup(false); + + /***************************************************************/ + QGridLayout* wg1Layout = new QGridLayout( wg1, 3, 1, 0, 6 ); + wg1Layout->addWidget(aContentBox, 0, 0); + wg1Layout->addWidget(aSelectBox, 1, 0); + wg1Layout->setRowStretch(2, 5); - aSelectBox->setMinimumHeight(mySubMeshBtn->sizeHint().height() + - myGroupBtn->sizeHint().height() + - aSelectBox->sizeHint().height()); + /***************************************************************/ + QLabel* geomObject = new QLabel(wg2, "geometry object label"); + geomObject->setText(tr("SMESH_OBJECT_GEOM")); + myGeomGroupBtn = new QPushButton(wg2, "geometry group button"); + myGeomGroupBtn->setText(""); + myGeomGroupBtn->setPixmap(image0); + myGeomGroupLine = new QLineEdit(wg2, "geometry group line"); + myGeomGroupLine->setReadOnly(true); //VSR ??? + onSelectGeomGroup(false); + + /***************************************************************/ + QGridLayout* wg2Layout = new QGridLayout( wg2, 2, 3, 0, 6 ); + wg2Layout->addWidget(geomObject, 0, 0); + wg2Layout->addWidget(myGeomGroupBtn, 0, 1); + wg2Layout->addWidget(myGeomGroupLine,0, 2); + wg2Layout->setRowStretch(1, 5); + + /***************************************************************/ + QVBoxLayout* dumb = new QVBoxLayout(myWGStack); + dumb->addWidget(wg1); + dumb->addWidget(wg2); + myWGStack->addWidget( wg1, myGrpTypeGroup->id(rb1) ); + myWGStack->addWidget( wg2, myGrpTypeGroup->id(rb2) ); /***************************************************************/ QFrame* aButtons = new QFrame(this, "button box"); @@ -222,13 +294,22 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) aBtnLayout->addWidget(aCloseBtn); /***************************************************************/ - aMainLayout->addWidget(myTypeGroup); - aMainLayout->addWidget(aNameBox); - aMainLayout->addWidget(aContentBox); - aMainLayout->addWidget(aSelectBox); - aMainLayout->addWidget(aButtons); + aMainLayout->addWidget(meshGroupLab, 0, 0); + aMainLayout->addWidget(myMeshGroupBtn, 0, 1); + aMainLayout->addWidget(myMeshGroupLine, 0, 2); + aMainLayout->addMultiCellWidget(myTypeGroup, 1, 1, 0, 2); + aMainLayout->addWidget(aName, 2, 0); + aMainLayout->addWidget(myName, 2, 2); + aMainLayout->addMultiCellWidget(myGrpTypeGroup, 3, 3, 0, 2); + aMainLayout->addMultiCellWidget(myWGStack, 4, 4, 0, 2); + aMainLayout->setRowStretch( 5, 5 ); + aMainLayout->addMultiCellWidget(aButtons, 6, 6, 0, 2); /* signals and slots connections */ + connect(myMeshGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection())); + + connect(myGrpTypeGroup, SIGNAL(clicked(int)), this, SLOT(onGrpTypeChanged(int))); + connect(myTypeGroup, SIGNAL(clicked(int)), this, SLOT(onTypeChanged(int))); connect(myName, SIGNAL(textChanged(const QString&)), this, SLOT(onNameChanged(const QString&))); @@ -243,6 +324,7 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) connect(mySelectGroup, SIGNAL(toggled(bool)), this, SLOT(onSelectGroup(bool))); connect(mySubMeshBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection())); connect(myGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection())); + connect(myGeomGroupBtn, SIGNAL(clicked()), this, SLOT(setCurrentSelection())); connect(aOKBtn, SIGNAL(clicked()), this, SLOT(onOK())); connect(aApplyBtn, SIGNAL(clicked()), this, SLOT(onApply())); @@ -255,13 +337,20 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) mySMESHGUI->SetState(800); mySelectionMode = -1; + myMeshFilter = new SMESH_TypeFilter(MESH); mySubMeshFilter = new SMESH_TypeFilter(SUBMESH); myGroupFilter = new SMESH_TypeFilter(GROUP); - connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(onClose())); + connect(mySMESHGUI, SIGNAL(SignalDeactivateActiveDialog()), this, SLOT(onDeactivate())); connect(mySMESHGUI, SIGNAL(SignalCloseAllDialogs()), this, SLOT(onClose())); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(onObjectSelectionChanged())); + myGrpTypeGroup->setButton(myGrpTypeGroup->id(rb1)); // VSR !!! + onGrpTypeChanged(myGrpTypeGroup->id(rb1)); // VSR!!! + + if (myMesh->_is_nil() ) + myTypeGroup->setButton(0); + updateButtons(); } @@ -271,7 +360,12 @@ void SMESHGUI_GroupDlg::initDialog(SALOME_Selection* theSel, bool create) //================================================================================= SMESHGUI_GroupDlg::~SMESHGUI_GroupDlg() { - // no need to delete child widgets, Qt does it all for us + // no need to delete child widgets, Qt does it all for us + if ( myFilterDlg != 0 ) + { + myFilterDlg->reparent( 0, QPoint() ); + delete myFilterDlg; + } } @@ -284,10 +378,15 @@ void SMESHGUI_GroupDlg::init(SMESH::SMESH_Mesh_ptr theMesh) /* init data from current selection */ myMesh = SMESH::SMESH_Mesh::_duplicate(theMesh); myGroup = SMESH::SMESH_Group::_nil(); + + myActor = SMESH::FindActorByObject(myMesh); + SMESH::SetPickable(myActor); + + QString aName = mySelection->firstIObject()->getName(); + myMeshGroupLine->setText(aName) ; + myMeshGroupLine->home( false ); - Standard_Boolean aResult; - myActor = mySMESHGUI->FindActor(myMesh, aResult, true); - mySMESHGUI->SetPickable(myActor); + myCurrentLineEdit = 0; myTypeGroup->setButton(0); onTypeChanged(0); @@ -299,16 +398,14 @@ void SMESHGUI_GroupDlg::init(SMESH::SMESH_Mesh_ptr theMesh) //================================================================================= void SMESHGUI_GroupDlg::init(SMESH::SMESH_Group_ptr theGroup) { - myMesh = theGroup->GetMesh(); myGroup = SMESH::SMESH_Group::_duplicate(theGroup); - - Standard_Boolean aResult; - myActor = mySMESHGUI->FindActor(myMesh, aResult, true); + + myActor = SMESH::FindActorByObject(myMesh); if ( !myActor ) - myActor = mySMESHGUI->FindActor(myGroup, aResult, true); - mySMESHGUI->SetPickable(myActor); - + myActor = SMESH::FindActorByObject(myGroup); + SMESH::SetPickable(myActor); + int aType = 0; switch(theGroup->GetType()) { case SMESH::NODE: aType= 0; break; @@ -316,12 +413,18 @@ void SMESHGUI_GroupDlg::init(SMESH::SMESH_Group_ptr theGroup) case SMESH::FACE: aType = 2; break; case SMESH::VOLUME: aType = 3; break; } - myTypeGroup->setButton(aType); - onTypeChanged(aType); - + myName->setText(myGroup->GetName()); myName->home(false); + myMeshGroupLine->setText(myGroup->GetName()); + myCurrentLineEdit = 0; + myTypeGroup->setButton(aType); + myElements->clear(); + setSelectionMode(aType); + myTypeId = aType; + + myIdList.clear(); if (!theGroup->IsEmpty()) { SMESH::long_array_var anElements = myGroup->GetListOfID(); int k = anElements->length(); @@ -340,7 +443,12 @@ void SMESHGUI_GroupDlg::init(SMESH::SMESH_Group_ptr theGroup) //================================================================================= void SMESHGUI_GroupDlg::updateButtons() { - bool enable = !myName->text().stripWhiteSpace().isEmpty() && myElements->count() > 0; + bool enable; + + if (myGrpTypeId == 0) + enable = !myName->text().stripWhiteSpace().isEmpty() && myElements->count() > 0; + else if (myGrpTypeId == 1) + enable = !myName->text().stripWhiteSpace().isEmpty() && !CORBA::is_nil( myGeomGroup ); QPushButton* aBtn; aBtn = (QPushButton*) child("ok", "QPushButton"); if (aBtn) aBtn->setEnabled(enable); @@ -359,7 +467,7 @@ void SMESHGUI_GroupDlg::onNameChanged(const QString& text) //================================================================================= // function : onTypeChanged() -// purpose : Radio button management +// purpose : Group elements type radio button management //================================================================================= void SMESHGUI_GroupDlg::onTypeChanged(int id) { @@ -367,11 +475,23 @@ void SMESHGUI_GroupDlg::onTypeChanged(int id) myElements->clear(); if (myCurrentLineEdit == 0) setSelectionMode(id); - myFilter->setEnabled(id == 1 || id == 2); } myTypeId = id; } +//================================================================================= +// function : onGrpTypeChanged() +// purpose : Group type radio button management +//================================================================================= +void SMESHGUI_GroupDlg::onGrpTypeChanged(int id) +{ + if (myGrpTypeId != id) { + myWGStack->raiseWidget( id ); + onSelectGeomGroup(id == 1); + } + myGrpTypeId = id; +} + //================================================================================= // function : setSelectionMode() // purpose : Radio button management @@ -381,20 +501,23 @@ void SMESHGUI_GroupDlg::setSelectionMode(int theMode) if (mySelectionMode != theMode) { mySelection->ClearIObjects(); mySelection->ClearFilters(); - if (mySelectionMode == 0) - mySMESHGUI->EraseSimulationActors(); + SMESH::SetPointRepresentation(false); if (theMode < 4) { - if (theMode == 0) { - mySMESHGUI->ViewNodes(); + switch(theMode){ + case 0: + if ( myActor ) + myActor->SetPointRepresentation(true); + else + SMESH::SetPointRepresentation(true); QAD_Application::getDesktop()->SetSelectionMode(NodeSelection, true); - } - else if (theMode == 1) { + break; + case 1: QAD_Application::getDesktop()->SetSelectionMode(EdgeSelection, true); - } - else if (theMode == 2) { + break; + case 2: QAD_Application::getDesktop()->SetSelectionMode(FaceSelection, true); - } - else { + break; + default: QAD_Application::getDesktop()->SetSelectionMode(VolumeSelection, true); } } @@ -404,6 +527,8 @@ void SMESHGUI_GroupDlg::setSelectionMode(int theMode) mySelection->AddFilter(mySubMeshFilter); else if (theMode == 5) mySelection->AddFilter(myGroupFilter); + else if (theMode == 6) + mySelection->AddFilter(myMeshFilter); } mySelectionMode = theMode; } @@ -415,7 +540,10 @@ void SMESHGUI_GroupDlg::setSelectionMode(int theMode) //================================================================================= bool SMESHGUI_GroupDlg::onApply() { - if (!myName->text().stripWhiteSpace().isEmpty() && myElements->count() > 0) { + if (mySMESHGUI->ActiveStudyLocked()) + return false; + + if ( myGrpTypeId == 0 && !myName->text().stripWhiteSpace().isEmpty() && myElements->count() > 0) { mySelection->ClearIObjects(); if (myGroup->_is_nil()) { SMESH::ElementType aType = SMESH::ALL; @@ -433,9 +561,9 @@ bool SMESHGUI_GroupDlg::onApply() anIdList[i] = anItem->text().toInt(); } - myGroup = mySMESHGUI->AddGroup(myMesh, aType, myName->text()); - myGroup->Add(anIdList); - + myGroup = SMESH::AddGroup(myMesh, aType, myName->text()); + myGroup->Add(anIdList.inout()); + /* init for next operation */ myName->setText(""); myElements->clear(); @@ -447,6 +575,7 @@ bool SMESHGUI_GroupDlg::onApply() QValueList aAddList; QValueList::iterator anIt; QListBoxItem* anItem; + for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) { int anId = anItem->text().toInt(); if ((anIt = myIdList.find(anId)) == myIdList.end()) @@ -460,7 +589,7 @@ bool SMESHGUI_GroupDlg::onApply() int i; for (i = 0, anIt = aAddList.begin(); anIt != aAddList.end(); anIt++, i++) anIdList[i] = *anIt; - myGroup->Add(anIdList); + myGroup->Add(anIdList.inout()); } if (!myIdList.empty()) { SMESH::long_array_var anIdList = new SMESH::long_array; @@ -468,7 +597,7 @@ bool SMESHGUI_GroupDlg::onApply() int i; for (i = 0, anIt = myIdList.begin(); anIt != myIdList.end(); anIt++, i++) anIdList[i] = *anIt; - myGroup->Remove(anIdList); + myGroup->Remove(anIdList.inout()); } /* init for next operation */ myIdList.clear(); @@ -477,9 +606,32 @@ bool SMESHGUI_GroupDlg::onApply() } mySMESHGUI->GetActiveStudy()->updateObjBrowser(true); + SMESH::UpdateView(); // asv: fix of BUG PAL5515 mySelection->ClearIObjects(); return true; } + else if (myGrpTypeId == 1 && !myName->text().stripWhiteSpace().isEmpty() && !CORBA::is_nil( myGeomGroup )) + { + SMESH::ElementType aType = SMESH::ALL; + switch(myTypeId) { + case 0: aType = SMESH::NODE; break; + case 1: aType = SMESH::EDGE; break; + case 2: aType = SMESH::FACE; break; + case 3: aType = SMESH::VOLUME; break; + } + + SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); + GEOM::GEOM_IGroupOperations_var aGroupOp = SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); + + SMESH::SMESH_GroupOnGeom_var aGroupOnGeom = myMesh->CreateGroupFromGEOM(aType, myName->text(),myGeomGroup); + + mySMESHGUI->GetActiveStudy()->updateObjBrowser(true); + mySelection->ClearIObjects(); + /* init for next operation */ + myName->setText(""); + return true; + } + return false; } @@ -493,16 +645,6 @@ void SMESHGUI_GroupDlg::onOK() onClose(); } -//================================================================================= -// function : onClose() -// purpose : -//================================================================================= -void SMESHGUI_GroupDlg::onClose() -{ - close(); -} - - static bool busy = false; //================================================================================= // function : onListSelectionChanged() @@ -520,18 +662,8 @@ void SMESHGUI_GroupDlg::onListSelectionChanged() QListBoxItem* anItem; for (anItem = myElements->firstItem(); anItem != 0; anItem = anItem->next()) { if (anItem->isSelected()) { - std::vector aVtkList; - if (myTypeId == 0) - aVtkList = myActor->GetNodeVtkId(anItem->text().toInt()); - else - aVtkList = myActor->GetElemVtkId(anItem->text().toInt()); - - if (aVtkList.size() > 0) { - std::vector::iterator it; - for (it = aVtkList.begin(); it != aVtkList.end(); ++it) { - aIndexes.Add(*it); - } - } + int anId = anItem->text().toInt(); + aIndexes.Add(anId); } } mySelection->AddOrRemoveIndex(myActor->getIO(), aIndexes, false, false); @@ -546,39 +678,174 @@ void SMESHGUI_GroupDlg::onListSelectionChanged() //================================================================================= void SMESHGUI_GroupDlg::onObjectSelectionChanged() { - if (busy) return; + if (busy || !isEnabled()) return; busy = true; int aNbSel = mySelection->IObjectCount(); myElements->clearSelection(); - + if (myCurrentLineEdit) { myCurrentLineEdit->setText("") ; QString aString = ""; + + if (myCurrentLineEdit == myMeshGroupLine) + { + mySelectSubMesh->setEnabled(false); + mySelectGroup->setEnabled(false); + myGroupLine->setText(""); + mySubMeshLine->setText(""); + + myGeomGroupBtn->setEnabled(false); + myGeomGroupLine->setEnabled(false); + myGeomGroupLine->setText(""); + if (!myCreate) + myName->setText(""); + + myElements->clear(); + + if(aNbSel != 1) + { + myGroup = SMESH::SMESH_Group::_nil(); + myMesh = SMESH::SMESH_Mesh::_nil(); + busy = false; + return; + } + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + + if (myCreate) + { + myMesh = SMESH::IObjectToInterface(IO); + if(myMesh->_is_nil()) + return; + myGroup = SMESH::SMESH_Group::_nil(); + + myActor = SMESH::FindActorByObject(myMesh); + SMESH::SetPickable(myActor); + + aString = mySelection->firstIObject()->getName(); + myMeshGroupLine->setText(aString) ; + myMeshGroupLine->home( false ); + + mySelectSubMesh->setEnabled(true); + mySelectGroup->setEnabled(true); + myGeomGroupBtn->setEnabled(true); + myGeomGroupLine->setEnabled(true); + updateButtons(); + } + else + { + SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface(IO); + if(aGroup->_is_nil()) + return; + busy = false; + myCurrentLineEdit = 0; + init(aGroup); + busy = true; + mySelectSubMesh->setEnabled(true); + mySelectGroup->setEnabled(true); + myGeomGroupBtn->setEnabled(true); + myGeomGroupLine->setEnabled(true); + } + myCurrentLineEdit = 0; + busy = false; + if (!myCreate) + return; + + if (myTypeId == -1) + onTypeChanged(0); + else + { + myElements->clear(); + setSelectionMode(myTypeId); + } + + return; + } + else if (myCurrentLineEdit == myGeomGroupLine) + { + + if(aNbSel != 1) + { + myGeomGroup = GEOM::GEOM_Object::_nil(); + busy = false; + return; + } + + Standard_Boolean testResult = Standard_False; + myGeomGroup = GEOMBase::ConvertIOinGEOMObject(mySelection->firstIObject(), testResult ); + + // Check if the object is a geometry group + if(!testResult || CORBA::is_nil( myGeomGroup )) + { + myGeomGroup = GEOM::GEOM_Object::_nil(); + busy = false; + return; + } + // Check if group constructed on the same shape as a mesh or on its child + SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); + GEOM::GEOM_IGroupOperations_var anOp = SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); + // The main shape of the group + GEOM::GEOM_Object_var aGroupMainShape; + if( myGeomGroup->GetType() == 37 ) + aGroupMainShape = anOp->GetMainShape( myGeomGroup ); + else + aGroupMainShape = GEOM::GEOM_Object::_duplicate(myGeomGroup); + SALOMEDS::SObject_var aGroupMainShapeSO = aStudy->FindObjectIOR( aStudy->ConvertObjectToIOR(aGroupMainShape) ); + // The mesh SObject + SALOMEDS::SObject_var aMeshSO = aStudy->FindObjectIOR( aStudy->ConvertObjectToIOR(myMesh) ); + + SALOMEDS::SObject_var anObj, aRef; + bool isRefOrSubShape = false; + if ( aMeshSO->FindSubObject( 1, anObj ) && anObj->ReferencedObject( aRef )) { + if ( strcmp( aRef->GetID(), aGroupMainShapeSO->GetID() ) == 0 ) + isRefOrSubShape = true; + else + { + SALOMEDS::SObject_var aFather = aGroupMainShapeSO->GetFather(); + SALOMEDS::SComponent_var aComponent = aGroupMainShapeSO->GetFatherComponent(); + while ( !isRefOrSubShape && strcmp( aFather->GetID(), aComponent->GetID() ) != 0 ) + { + if (strcmp( aRef->GetID(), aFather->GetID() ) == 0) + isRefOrSubShape = true; + else + aFather = aFather->GetFather(); + } + } + } + if ( !isRefOrSubShape ) + { + myGeomGroup = GEOM::GEOM_Object::_nil(); + busy = false; + return; + } + } + if (aNbSel >= 1) { if (aNbSel > 1) { - if (myCurrentLineEdit = mySubMeshLine) + if (myCurrentLineEdit == mySubMeshLine) aString = tr("SMESH_SUBMESH_SELECTED").arg(aNbSel); - else if (myCurrentLineEdit = myGroupLine) + else if (myCurrentLineEdit == myGroupLine || myCurrentLineEdit == myGeomGroupLine) aString = tr("SMESH_GROUP_SELECTED").arg(aNbSel); } else { aString = mySelection->firstIObject()->getName(); } } - + myCurrentLineEdit->setText(aString) ; myCurrentLineEdit->home( false ); + + updateButtons(); } else { if (aNbSel == 1) { QString aListStr = ""; int aNbItems = 0; if (myTypeId == 0) { - aNbItems = mySMESHGUI->GetNameOfSelectedNodes(mySelection, aListStr); + aNbItems = SMESH::GetNameOfSelectedNodes(mySelection, aListStr); } else { - aNbItems = mySMESHGUI->GetNameOfSelectedElements(mySelection, aListStr); + aNbItems = SMESH::GetNameOfSelectedElements(mySelection, aListStr); } if (aNbItems > 0) { QStringList anElements = QStringList::split(" ", aListStr); @@ -590,6 +857,14 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() } } } + + if ( !myActor ) { + if ( !myGroup->_is_nil() ) + myActor = SMESH::FindActorByObject(myGroup); + else + myActor = SMESH::FindActorByObject(myMesh); + } + busy = false; } @@ -603,7 +878,10 @@ void SMESHGUI_GroupDlg::onSelectSubMesh(bool on) if (on) { if (mySelectGroup->isChecked()) { mySelectGroup->setChecked(false); - } + } + //VSR: else if (mySelectGeomGroup->isChecked()) { + //VSR: mySelectGeomGroup->setChecked(false); + //VSR: } myCurrentLineEdit = mySubMeshLine; setSelectionMode(4); } @@ -617,6 +895,7 @@ void SMESHGUI_GroupDlg::onSelectSubMesh(bool on) mySubMeshLine->setEnabled(on); } + //================================================================================= // function : (onSelectGroup) // purpose : Called when selection in 3D view or ObjectBrowser is changed @@ -640,6 +919,32 @@ void SMESHGUI_GroupDlg::onSelectGroup(bool on) myGroupLine->setEnabled(on); } + +//================================================================================= +// function : (onSelectGeomGroup) +// purpose : Called when selection in 3D view or ObjectBrowser is changed +//================================================================================= +void SMESHGUI_GroupDlg::onSelectGeomGroup(bool on) +{ + if (on) { + if (mySelectSubMesh->isChecked()) { + mySelectSubMesh->setChecked(false); + } + else if (mySelectGroup->isChecked()) { + mySelectGroup->setChecked(false); + } + myCurrentLineEdit = myGeomGroupLine; + setSelectionMode(7); + } + else { + myGeomGroupLine->setText(""); + myCurrentLineEdit = 0; + if (myTypeId != -1) + setSelectionMode(myTypeId); + } +} + + //================================================================================= // function : setCurrentSelection() // purpose : @@ -648,7 +953,15 @@ void SMESHGUI_GroupDlg::setCurrentSelection() { QPushButton* send = (QPushButton*)sender(); myCurrentLineEdit = 0; - if (send == mySubMeshBtn) { + if (send == myMeshGroupBtn) { + myCurrentLineEdit = myMeshGroupLine; + if (myCreate) + setSelectionMode(6); + else + setSelectionMode(5); + onObjectSelectionChanged(); + } + else if (send == mySubMeshBtn) { myCurrentLineEdit = mySubMeshLine; onObjectSelectionChanged(); } @@ -656,6 +969,11 @@ void SMESHGUI_GroupDlg::setCurrentSelection() myCurrentLineEdit = myGroupLine; onObjectSelectionChanged(); } + else if (send == myGeomGroupBtn) { + myCurrentLineEdit = myGeomGroupLine; + setSelectionMode(7); + onObjectSelectionChanged(); + } } @@ -674,9 +992,12 @@ void SMESHGUI_GroupDlg::setFilters() case 3 : aType = SMESH::VOLUME; break; default: return; } - + if ( myFilterDlg == 0 ) - myFilterDlg = new SMESHGUI_FilterDlg( this, aType, true ); + { + myFilterDlg = new SMESHGUI_FilterDlg( (QWidget*)parent(), aType ); + connect( myFilterDlg, SIGNAL( Accepted() ), SLOT( onFilterAccepted() ) ); + } else myFilterDlg->Init( aType ); @@ -684,9 +1005,16 @@ void SMESHGUI_GroupDlg::setFilters() myFilterDlg->SetMesh( myMesh ); myFilterDlg->SetSourceWg( myElements ); - if ( myFilterDlg->exec() != QDialog::Accepted ) - return; + myFilterDlg->show(); +} +//================================================================================= +// function : onFilterAccepted() +// purpose : SLOT. Called when Filter dlg closed with OK button. +// Uncheck "Select submesh" and "Select group" checkboxes +//================================================================================= +void SMESHGUI_GroupDlg::onFilterAccepted() +{ if ( mySelectSubMesh->isChecked() || mySelectGroup->isChecked() ) { mySelectionMode = myTypeId; @@ -702,7 +1030,7 @@ void SMESHGUI_GroupDlg::setFilters() void SMESHGUI_GroupDlg::onAdd() { int aNbSel = mySelection->IObjectCount(); - if (aNbSel == 0) return; + if (aNbSel == 0 || !myActor || myMesh->_is_nil()) return; busy = true; @@ -715,14 +1043,14 @@ void SMESHGUI_GroupDlg::onAdd() } if (myCurrentLineEdit == 0) { - if (aNbSel != 1) { busy = false; return; } + //if (aNbSel != 1) { busy = false; return; } QString aListStr = ""; int aNbItems = 0; if (myTypeId == 0) { - aNbItems = mySMESHGUI->GetNameOfSelectedNodes(mySelection, aListStr); + aNbItems = SMESH::GetNameOfSelectedNodes(mySelection, myActor->getIO(), aListStr); } else { - aNbItems = mySMESHGUI->GetNameOfSelectedElements(mySelection, aListStr); + aNbItems = SMESH::GetNameOfSelectedElements(mySelection, myActor->getIO(), aListStr); } if (aNbItems > 0) { QStringList anElements = QStringList::split(" ", aListStr); @@ -738,52 +1066,30 @@ void SMESHGUI_GroupDlg::onAdd() } } else if (myCurrentLineEdit == mySubMeshLine) { - Standard_Boolean aRes; SALOME_ListIteratorOfListIO anIt(mySelection->StoredIObjects()); for (; anIt.More(); anIt.Next()) { - SMESH::SMESH_subMesh_var aSubMesh = mySMESHGUI->ConvertIOinSubMesh(anIt.Value(), aRes); - if (aRes && !aSubMesh->_is_nil()) { + SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(anIt.Value()); + if (!aSubMesh->_is_nil()) { // check if mesh is the same if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) { - if (aType == SMESH::NODE) { - try { - SMESH::long_array_var anElements = aSubMesh->GetNodesId(); - int k = anElements->length(); - QListBoxItem* anItem = 0; - for (int i = 0; i < k; i++) { - QString aText = QString::number(anElements[i]); - anItem = myElements->findItem(aText, Qt::ExactMatch); - if (!anItem) { - anItem = new QListBoxText(aText); - myElements->insertItem(anItem); - } - myElements->setSelected(anItem, true); - } - } - catch (const SALOME::SALOME_Exception& ex) { - QtCatchCorbaException(ex); - } - } - else { - try { - SMESH::long_array_var anElements = aSubMesh->GetElementsId(); - int k = anElements->length(); - QListBoxItem* anItem = 0; - for (int i = 0; i < k; i++) { - QString aText = QString::number(anElements[i]); - anItem = myElements->findItem(aText, Qt::ExactMatch); - if (!anItem) { - anItem = new QListBoxText(aText); - myElements->insertItem(anItem); - } - myElements->setSelected(anItem, true); - } - } - catch (const SALOME::SALOME_Exception& ex) { - QtCatchCorbaException(ex); - } - } - } + try { + SMESH::long_array_var anElements = aSubMesh->GetElementsByType ( aType ); + int k = anElements->length(); + QListBoxItem* anItem = 0; + for (int i = 0; i < k; i++) { + QString aText = QString::number(anElements[i]); + anItem = myElements->findItem(aText, Qt::ExactMatch); + if (!anItem) { + anItem = new QListBoxText(aText); + myElements->insertItem(anItem); + } + myElements->setSelected(anItem, true); + } + } + catch (const SALOME::SALOME_Exception& ex) { + QtCatchCorbaException(ex); + } + } } } mySelectSubMesh->setChecked(false); @@ -791,11 +1097,10 @@ void SMESHGUI_GroupDlg::onAdd() onListSelectionChanged(); } else if (myCurrentLineEdit == myGroupLine) { - Standard_Boolean aRes; SALOME_ListIteratorOfListIO anIt(mySelection->StoredIObjects()); for (; anIt.More(); anIt.Next()) { - SMESH::SMESH_Group_var aGroup = mySMESHGUI->ConvertIOinSMESHGroup(anIt.Value(), aRes); - if (aRes && !aGroup->_is_nil()) { + SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface(anIt.Value()); + if (!aGroup->_is_nil()) { // check if mesh is the same if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) { SMESH::long_array_var anElements = aGroup->GetListOfID(); @@ -817,6 +1122,50 @@ void SMESHGUI_GroupDlg::onAdd() busy = false; onListSelectionChanged(); } + else if (myCurrentLineEdit == myGeomGroupLine && !CORBA::is_nil(myGeomGroup)) { + + SALOMEDS::Study_var aStudy = SMESH::GetActiveStudyDocument(); + GEOM::GEOM_IGroupOperations_var aGroupOp = SMESH::GetGEOMGen()->GetIGroupOperations(aStudy->StudyId()); + + SMESH::ElementType aGroupType = SMESH::ALL; + switch(aGroupOp->GetType(myGeomGroup)) { + case 7: aGroupType = SMESH::NODE; break; + case 6: aGroupType = SMESH::EDGE; break; + case 4: aGroupType = SMESH::FACE; break; + case 2: aGroupType = SMESH::VOLUME; break; + default: return; + } + + if (aGroupType == aType) { + SALOMEDS::SObject_var aGroupSO = aStudy->FindObjectIOR( aStudy->ConvertObjectToIOR(myGeomGroup) ); + // Construct filter + SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager(); + SMESH::Filter_var aFilter = aFilterMgr->CreateFilter(); + SMESH::BelongToGeom_var aBelongToGeom = aFilterMgr->CreateBelongToGeom();; + aBelongToGeom->SetGeom(myGeomGroup); + aBelongToGeom->SetShapeName(aGroupSO->GetName()); + aBelongToGeom->SetElementType(aType); + aFilter->SetPredicate( aBelongToGeom ); + + SMESH::long_array_var anElements = aFilter->GetElementsId( myMesh ); + + int k = anElements->length(); + QListBoxItem* anItem = 0; + for (int i = 0; i < k; i++) { + QString aText = QString::number(anElements[i]); + anItem = myElements->findItem(aText, Qt::ExactMatch); + if (!anItem) { + anItem = new QListBoxText(aText); + myElements->insertItem(anItem); + } + myElements->setSelected(anItem, true); + } + } + + //VSR: mySelectGeomGroup->setChecked(false); + busy = false; + onListSelectionChanged(); + } busy = false; // mySelection->ClearIObjects(); updateButtons(); @@ -849,11 +1198,10 @@ void SMESHGUI_GroupDlg::onRemove() } if (myCurrentLineEdit == mySubMeshLine) { - Standard_Boolean aRes; SALOME_ListIteratorOfListIO anIt(mySelection->StoredIObjects()); for (; anIt.More(); anIt.Next()) { - SMESH::SMESH_subMesh_var aSubMesh = mySMESHGUI->ConvertIOinSubMesh(anIt.Value(), aRes); - if (aRes && !aSubMesh->_is_nil()) { + SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(anIt.Value()); + if (!aSubMesh->_is_nil()) { // check if mesh is the same if (aSubMesh->GetFather()->GetId() == myMesh->GetId()) { if (aType == SMESH::NODE) { @@ -892,7 +1240,7 @@ void SMESHGUI_GroupDlg::onRemove() Standard_Boolean aRes; SALOME_ListIteratorOfListIO anIt(mySelection->StoredIObjects()); for (; anIt.More(); anIt.Next()) { - SMESH::SMESH_Group_var aGroup = mySMESHGUI->ConvertIOinSMESHGroup(anIt.Value(), aRes); + SMESH::SMESH_Group_var aGroup = SMESH::IObjectToInterface(anIt.Value()); if (aRes && !aGroup->_is_nil()) { // check if mesh is the same if (aGroup->GetType() == aType && aGroup->GetMesh()->GetId() == myMesh->GetId()) { @@ -954,18 +1302,26 @@ void SMESHGUI_GroupDlg::onSort() // purpose : //================================================================================= void SMESHGUI_GroupDlg::closeEvent( QCloseEvent* e ) +{ + onClose(); +} + +//======================================================================= +// name : SMESHGUI_GroupDlg::onClose +// Purpose : SLOT called when "Close" button pressed. Close dialog +//======================================================================= +void SMESHGUI_GroupDlg::onClose() { QAD_StudyFrame* aStudyFrame = mySMESHGUI->GetActiveStudy()->getActiveStudyFrame(); if (aStudyFrame->getTypeView() == VIEW_VTK) { - mySMESHGUI->SetPickable(); - if (mySelectionMode == 0) - mySMESHGUI->EraseSimulationActors(); + SMESH::SetPointRepresentation(false); + SMESH::SetPickable(); // remove filters from viewer - VTKViewer_InteractorStyleSALOME* aStyle = ((VTKViewer_ViewFrame*)aStudyFrame->getRightFrame()->getViewFrame())->getRWInteractor()->GetInteractorStyleSALOME(); - aStyle->RemoveEdgeFilter(); - aStyle->RemoveFaceFilter(); - + if(VTKViewer_InteractorStyleSALOME* aStyle = SMESH::GetInteractorStyle()){ + SMESH::RemoveFilter(SMESHGUI_EdgeFilter,aStyle); + SMESH::RemoveFilter(SMESHGUI_FaceFilter,aStyle); + } } mySelection->ClearIObjects(); @@ -973,5 +1329,39 @@ void SMESHGUI_GroupDlg::closeEvent( QCloseEvent* e ) mySelection->ClearFilters(); mySMESHGUI->ResetState(); - QDialog::closeEvent( e ); + reject(); +} + +//======================================================================= +// name : SMESHGUI_GroupDlg::onDeactivate +// Purpose : SLOT called when dialog must be deativated +//======================================================================= +void SMESHGUI_GroupDlg::onDeactivate() +{ + setEnabled( false ); +} + +//======================================================================= +// name : SMESHGUI_GroupDlg::enterEvent +// Purpose : Event filter +//======================================================================= +void SMESHGUI_GroupDlg::enterEvent( QEvent* ) +{ + if ( !isEnabled() ) { + SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); + setEnabled( true ); + mySelectionMode = -1; + setSelectionMode( myTypeId ); + } +} + +//======================================================================= +//function : hideEvent +//purpose : caused by ESC key +//======================================================================= + +void SMESHGUI_GroupDlg::hideEvent ( QHideEvent * e ) +{ + if ( !isMinimized() ) + onClose(); } diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.h b/src/SMESHGUI/SMESHGUI_GroupDlg.h index b18abdfd1..9c19f9563 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.h +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.h @@ -42,9 +42,11 @@ class QLineEdit; class QButtonGroup; +class QGroupBox; class QListBox; class QPushButton; class QCheckBox; +class QWidgetStack; class SMESHGUI; class SMESH_Actor; class SMESHGUI_FilterDlg; @@ -74,39 +76,53 @@ public slots: private slots: void onTypeChanged(int id); + void onGrpTypeChanged(int id); void onOK(); void onClose(); bool onApply(); + void onDeactivate(); void onListSelectionChanged(); void onObjectSelectionChanged(); void onSelectSubMesh(bool on); void onSelectGroup(bool on); + void onSelectGeomGroup(bool on); void setCurrentSelection(); void setFilters(); void onSort(); void onNameChanged(const QString& text); + void onFilterAccepted(); private: void initDialog(SALOME_Selection* theSel, bool create); void init(SMESH::SMESH_Mesh_ptr theMesh); void init(SMESH::SMESH_Group_ptr theGroup); void closeEvent(QCloseEvent* e); + void enterEvent ( QEvent * ) ; + void hideEvent ( QHideEvent * ); /* ESC key */ void setSelectionMode(int theMode); void updateButtons(); SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ SALOME_Selection* mySelection ; /* User shape selection */ SMESH_Actor* myActor; /* Current mesh actor */ + int myGrpTypeId ; /* Current group type id : standalone or group on geometry */ int myTypeId ; /* Current type id = radio button id */ QLineEdit* myCurrentLineEdit; /* Current LineEdit */ + QPushButton* myMeshGroupBtn; + QLineEdit* myMeshGroupLine; + QButtonGroup* myTypeGroup; QLineEdit* myName; + + QButtonGroup* myGrpTypeGroup; + + QWidgetStack* myWGStack; QListBox* myElements; QPushButton* myFilter; @@ -118,15 +134,23 @@ private: QPushButton* myGroupBtn; QLineEdit* myGroupLine; + QCheckBox* mySelectGeomGroup; + QPushButton* myGeomGroupBtn; + QLineEdit* myGeomGroupLine; + SMESH::SMESH_Mesh_var myMesh; SMESH::SMESH_Group_var myGroup; QValueList myIdList; + GEOM::GEOM_Object_var myGeomGroup; int mySelectionMode; + Handle(SMESH_TypeFilter) myMeshFilter; Handle(SMESH_TypeFilter) mySubMeshFilter; Handle(SMESH_TypeFilter) myGroupFilter; SMESHGUI_FilterDlg* myFilterDlg; + + bool myCreate; }; #endif // DIALOGBOX_GROUP_H diff --git a/src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx new file mode 100644 index 000000000..c5b07386e --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_GroupOpDlg.cxx @@ -0,0 +1,401 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_GroupOpDlg.cxx +// Author : Sergey LITONIN +// Module : SMESH + +#include "SMESHGUI_GroupOpDlg.h" + +#include "QAD_Desktop.h" + +#include "SMESHGUI.h" +#include "SMESHGUI_Utils.h" +#include "SALOME_Selection.h" +#include "SMESH_TypeFilter.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include + +#define SPACING 5 +#define MARGIN 10 + +/* + Class : SMESHGUI_GroupOpDlg + Description : Perform boolean operations on groups +*/ + +//======================================================================= +// name : SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg +// Purpose : Constructor +//======================================================================= +SMESHGUI_GroupOpDlg::SMESHGUI_GroupOpDlg( QWidget* theParent, + SALOME_Selection* theSelection, + const int theMode ) +: QDialog( theParent, "SMESHGUI_GroupOpDlg", false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + myMode = theMode; + + if ( myMode == UNION ) setCaption( tr( "UNION_OF_TWO_GROUPS" ) ); + else if ( myMode == INTERSECT ) setCaption( tr( "INTERSECTION_OF_TWO_GROUPS" ) ); + else setCaption( tr( "CUT_OF_TWO_GROUPS" ) ); + + QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); + + QFrame* aMainFrame = createMainFrame ( this ); + QFrame* aBtnFrame = createButtonFrame( this ); + + aDlgLay->addWidget( aMainFrame ); + aDlgLay->addWidget( aBtnFrame ); + + aDlgLay->setStretchFactor( aMainFrame, 1 ); + + Init( theSelection ); +} + +//======================================================================= +// name : SMESHGUI_GroupOpDlg::createMainFrame +// Purpose : Create frame containing dialog's input fields +//======================================================================= +QFrame* SMESHGUI_GroupOpDlg::createMainFrame( QWidget* theParent ) +{ + QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Horizontal, theParent ); + aMainGrp->setFrameStyle( QFrame::NoFrame ); + aMainGrp->setInsideMargin( 0 ); + + QGroupBox* aNameGrp = new QGroupBox( 1, Qt::Vertical, tr( "NAME" ), aMainGrp ); + new QLabel( tr( "RESULT_NAME" ), aNameGrp ); + myNameEdit = new QLineEdit( aNameGrp ); + + QGroupBox* anArgGrp = new QGroupBox( 3, Qt::Horizontal, tr( "ARGUMENTS" ), aMainGrp ); + + new QLabel( myMode == CUT ? tr( "MAIN_OBJECT" ) :tr( "OBJECT_1" ), anArgGrp ); + myBtn1 = new QPushButton( anArgGrp ); + myEdit1 = new QLineEdit( anArgGrp ); + + new QLabel( myMode == CUT ? tr( "TOOL_OBJECT" ) :tr( "OBJECT_2" ), anArgGrp ); + myBtn2 = new QPushButton( anArgGrp ); + myEdit2 = new QLineEdit( anArgGrp ); + + myEdit1->setReadOnly( true ); + myEdit2->setReadOnly( true ); + + QPixmap aPix( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr( "ICON_SELECT" ) ) ); + myBtn1->setPixmap( aPix ); + myBtn2->setPixmap( aPix ); + + return aMainGrp; +} + +//======================================================================= +// name : SMESHGUI_GroupOpDlg::createButtonFrame +// Purpose : Create frame containing buttons +//======================================================================= +QFrame* SMESHGUI_GroupOpDlg::createButtonFrame( QWidget* theParent ) +{ + QFrame* aFrame = new QFrame( theParent ); + aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken ); + + myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), aFrame ); + myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), aFrame ); + myCloseBtn = new QPushButton( tr( "SMESH_BUT_CLOSE" ), aFrame ); + + QSpacerItem* aSpacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); + + QHBoxLayout* aLay = new QHBoxLayout( aFrame, MARGIN, SPACING ); + + aLay->addWidget( myOkBtn ); + aLay->addWidget( myApplyBtn ); + aLay->addItem( aSpacer); + aLay->addWidget( myCloseBtn ); + + // connect signals and slots + connect( myOkBtn, SIGNAL( clicked() ), SLOT( onOk() ) ); + connect( myCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ) ; + connect( myApplyBtn, SIGNAL( clicked() ), SLOT( onApply() ) ); + + return aFrame; +} + +//======================================================================= +// name : SMESHGUI_GroupOpDlg::~SMESHGUI_GroupOpDlg +// Purpose : Destructor +//======================================================================= +SMESHGUI_GroupOpDlg::~SMESHGUI_GroupOpDlg() +{ +} + +//======================================================================= +// name : SMESHGUI_GroupOpDlg::Init +// Purpose : Init dialog fields, connect signals and slots, show dialog +//======================================================================= +void SMESHGUI_GroupOpDlg::Init( SALOME_Selection* theSelection ) +{ + mySelection = theSelection; + SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); + aSMESHGUI->SetActiveDialogBox( ( QDialog* )this ) ; + myFocusWg = myEdit1; + + myGroup1 = SMESH::SMESH_GroupBase::_nil(); + myGroup2 = SMESH::SMESH_GroupBase::_nil(); + + // selection and SMESHGUI + connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); + connect( aSMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( onDeactivate() ) ); + connect( aSMESHGUI, SIGNAL( SignalCloseAllDialogs() ), SLOT( ClickOnClose() ) ); + + connect( myBtn1, SIGNAL( clicked() ), this, SLOT( onFocusChanged() ) ); + connect( myBtn2, SIGNAL( clicked() ), this, SLOT( onFocusChanged() ) ); + + int x, y ; + aSMESHGUI->DefineDlgPosition( this, x, y ); + this->move( x, y ); + this->show(); + + // set selection mode + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection, true ); + mySelection->AddFilter( new SMESH_TypeFilter( GROUP ) ); + + return; +} + +//======================================================================= +// name : SMESHGUI_GroupOpDlg::isValid +// Purpose : Verify validity of input data +//======================================================================= +bool SMESHGUI_GroupOpDlg::isValid() +{ + // Verify validity of group name + if ( myNameEdit->text() == "" ) + { + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_INSUFFICIENT_DATA" ), tr( "EMPTY_NAME" ), QMessageBox::Ok ); + return false; + } + + // Verufy wheter arguments speciffiyed + if ( myGroup1->_is_nil() || myGroup2->_is_nil() ) + { + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_INSUFFICIENT_DATA" ), tr( "INCORRECT_ARGUMENTS" ), QMessageBox::Ok ); + return false; + } + + // Verify whether arguments belongs to same mesh + SMESH::SMESH_Mesh_ptr aMesh1 = myGroup1->GetMesh(); + SMESH::SMESH_Mesh_ptr aMesh2 = myGroup2->GetMesh(); + + int aMeshId1 = !aMesh1->_is_nil() ? aMesh1->GetId() : -1; + int aMeshId2 = !aMesh2->_is_nil() ? aMesh2->GetId() : -1; + + if ( aMeshId1 != aMeshId2 || aMeshId1 == -1 ) + { + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_INSUFFICIENT_DATA" ), tr( "DIFF_MESHES" ), QMessageBox::Ok ); + return false; + } + + // Verify whether groups have same types of entities + if ( myGroup1->GetType() != myGroup2->GetType() ) + { + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_INSUFFICIENT_DATA" ), tr( "DIFF_TYPES" ), QMessageBox::Ok ); + return false; + } + + + return true; +} + +//======================================================================= +// name : SMESHGUI_GroupOpDlg::onApply +// Purpose : SLOT called when "Apply" button pressed. +//======================================================================= +bool SMESHGUI_GroupOpDlg::onApply() +{ + if ( !isValid() || SMESHGUI::GetSMESHGUI()->ActiveStudyLocked() ) + 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.latin1() ); + else if ( myMode == INTERSECT ) aNewGrp = aMesh->IntersectGroups( myGroup1, myGroup2, aName.latin1() ); + else aNewGrp = aMesh->CutGroups( myGroup1, myGroup2, aName.latin1() ); + + if ( !aNewGrp->_is_nil() ) + { + SMESHGUI::GetSMESHGUI()->GetActiveStudy()->updateObjBrowser( true ); + reset(); + return true; + } + else + { + QMessageBox::critical( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_ERROR" ), tr( "SMESH_OPERATION_FAILED" ), "OK" ); + return false; + } +} + +//======================================================================= +// name : SMESHGUI_GroupOpDlg::onOk +// Purpose : SLOT called when "Ok" button pressed. +//======================================================================= +void SMESHGUI_GroupOpDlg::onOk() +{ + if ( onApply() ) + onClose(); +} + +//======================================================================= +// name : SMESHGUI_GroupOpDlg::onClose +// Purpose : SLOT called when "Close" button pressed. Close dialog +//======================================================================= +void SMESHGUI_GroupOpDlg::onClose() +{ + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + disconnect( mySelection, 0, this, 0 ); + disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); + SMESHGUI::GetSMESHGUI()->ResetState(); + mySelection->ClearFilters(); + reject(); +} + +//======================================================================= +// name : SMESHGUI_GroupOpDlg::onSelectionDone +// Purpose : SLOT called when selection changed +//======================================================================= +void SMESHGUI_GroupOpDlg::onSelectionDone() +{ + if ( myFocusWg == myEdit1 ) + myGroup1 = SMESH::SMESH_GroupBase::_nil(); + else + myGroup2 = SMESH::SMESH_GroupBase::_nil(); + + myFocusWg->setText( "" ); + + if ( mySelection->IObjectCount() == 1 ) + { + SMESH::SMESH_GroupBase_var aGroup = + SMESH::IObjectToInterface( mySelection->firstIObject() ); + + if ( !aGroup->_is_nil() ) + { + myFocusWg->setText( aGroup->GetName() ); + + if ( myFocusWg == myEdit1 ) + myGroup1 = aGroup; + else + myGroup2 = aGroup; + } + } +} + +//======================================================================= +// name : SMESHGUI_GroupOpDlg::onDeactivate +// Purpose : SLOT called when dialog must be deativated +//======================================================================= +void SMESHGUI_GroupOpDlg::onDeactivate() +{ + setEnabled( false ); + mySelection->ClearFilters(); +} + +//======================================================================= +// name : SMESHGUI_GroupOpDlg::enterEvent +// Purpose : Event filter +//======================================================================= +void SMESHGUI_GroupOpDlg::enterEvent( QEvent* ) +{ + SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog() ; + setEnabled( true ); + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection, true ); + mySelection->AddFilter( new SMESH_TypeFilter( GROUP ) ); +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +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 +//======================================================================= +void SMESHGUI_GroupOpDlg::reset() +{ + myNameEdit->setText( "" ); + myEdit1->setText( "" ); + myEdit2->setText( "" ); + myFocusWg = myEdit1; + myNameEdit->setFocus(); +} + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SMESHGUI/SMESHGUI_GroupOpDlg.h b/src/SMESHGUI/SMESHGUI_GroupOpDlg.h new file mode 100644 index 000000000..a82136f14 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_GroupOpDlg.h @@ -0,0 +1,109 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_GroupOpDlg.h +// Author : Sergey LITONIN +// Module : SMESH + + +#ifndef SMESHGUI_GroupOpDlg_H +#define SMESHGUI_GroupOpDlg_H + +#include + +#include +#include CORBA_SERVER_HEADER(SMESH_Group) + +class QCloseEvent; +class QLabel; +class QFrame; +class QPushButton; +class SALOME_Selection; +class QLineEdit; + +/* + Class : SMESHGUI_GroupOpDlg + Description : Perform boolean operations on groups +*/ + +class SMESHGUI_GroupOpDlg : public QDialog +{ + Q_OBJECT + +public: + enum { UNION, INTERSECT, CUT }; + +public: + SMESHGUI_GroupOpDlg( QWidget*, SALOME_Selection*, const int ); + virtual ~SMESHGUI_GroupOpDlg(); + + void Init( SALOME_Selection* ) ; + +private: + + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; + +private slots: + + void onOk(); + bool onApply(); + void onClose(); + + void onDeactivate(); + void onSelectionDone(); + void onFocusChanged(); + +private: + + QFrame* createButtonFrame( QWidget* ); + QFrame* createMainFrame ( QWidget* ); + bool isValid(); + void reset(); + +private: + + QPushButton* myOkBtn; + QPushButton* myApplyBtn; + QPushButton* myCloseBtn; + + QLineEdit* myNameEdit; + QLineEdit* myEdit1; + QLineEdit* myEdit2; + QPushButton* myBtn1; + QPushButton* myBtn2; + + SALOME_Selection* mySelection; + int myMode; + + QLineEdit* myFocusWg; + + SMESH::SMESH_GroupBase_var myGroup1; + SMESH::SMESH_GroupBase_var myGroup2; + +}; + +#endif + + + + + diff --git a/src/SMESHGUI/SMESHGUI_GroupUtils.cxx b/src/SMESHGUI/SMESHGUI_GroupUtils.cxx new file mode 100644 index 000000000..14462a9be --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_GroupUtils.cxx @@ -0,0 +1,46 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + + +#include "QAD_Study.h" +#include "SALOMEGUI_QtCatchCorbaException.hxx" + +#include "SMESHGUI_GroupUtils.h" +#include "SMESHGUI_Utils.h" + +namespace SMESH +{ + + SMESH::SMESH_Group_var AddGroup( SMESH::SMESH_Mesh_ptr theMesh, + SMESH::ElementType theType, + const char* theGroupName ) + { + SMESH::SMESH_Group_var aGroup; + try { + if ( !theMesh->_is_nil() ) + aGroup = theMesh->CreateGroup( theType, theGroupName ); + } + catch( const SALOME::SALOME_Exception& S_ex ) { + QtCatchCorbaException( S_ex ); + } + GetActiveStudy()->updateObjBrowser( true ); + return aGroup._retn(); + } + +} diff --git a/src/SMESHGUI/SMESHGUI_GroupUtils.h b/src/SMESHGUI/SMESHGUI_GroupUtils.h new file mode 100644 index 000000000..9cd9783c1 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_GroupUtils.h @@ -0,0 +1,36 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#ifndef SMESHGUI_GroupUtils_HeaderFile +#define SMESHGUI_GroupUtils_HeaderFile + +#include "SALOMEconfig.h" +#include CORBA_SERVER_HEADER(SMESH_Mesh) +#include CORBA_SERVER_HEADER(SMESH_Group) + + +namespace SMESH{ + + SMESH::SMESH_Group_var AddGroup(SMESH::SMESH_Mesh_ptr theMesh, + SMESH::ElementType theType, + const char* theGroupName); +} + + +#endif diff --git a/src/SMESHGUI/SMESHGUI_Hypotheses.cxx b/src/SMESHGUI/SMESHGUI_Hypotheses.cxx new file mode 100644 index 000000000..c3bb01382 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_Hypotheses.cxx @@ -0,0 +1,490 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include +#include + +#include "SMESHGUI_Hypotheses.h" +#include "SMESHGUI_Utils.h" + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +namespace SMESH{ + + using namespace std; + + typedef map THypothesisDataMap; + THypothesisDataMap myHypothesesMap; + THypothesisDataMap myAlgorithmsMap; + + typedef map THypCreatorMap; + THypCreatorMap myHypCreatorMap; + + void InitAvailableHypotheses() + { + QAD_WaitCursor wc; + if (myHypothesesMap.empty() && myAlgorithmsMap.empty()) { + // Resource manager + QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager(); + if (!resMgr) return; + + // Find name of a resource XML file ("SMESH_Meshers.xml"); + QString HypsXml; + char* cenv = getenv("SMESH_MeshersList"); + if (cenv) + HypsXml.sprintf("%s", cenv); + + QStringList HypsXmlList = QStringList::split( ":", HypsXml, false ); + if (HypsXmlList.count() == 0) + { + QAD_MessageBox::error1(QAD_Application::getDesktop(), + tr("SMESH_WRN_WARNING"), + tr("MESHERS_FILE_NO_VARIABLE"), + tr("SMESH_BUT_OK")); + return; + } + + // loop on files in HypsXml + QString aNoAccessFiles; + for ( int i = 0; i < HypsXmlList.count(); i++ ) { + QString HypsXml = HypsXmlList[ i ]; + + // Find full path to the resource XML file + QString xmlFile = HypsXml + ".xml"; + xmlFile = QAD_Tools::addSlash(resMgr->findFile(xmlFile, HypsXml)) + xmlFile; + + QFile file (QAD_Tools::unix2win(xmlFile)); + if (file.exists() && file.open(IO_ReadOnly)) { + file.close(); + + SMESHGUI_XmlHandler* myXmlHandler = new SMESHGUI_XmlHandler(); + ASSERT(myXmlHandler); + + QXmlInputSource source (file); + QXmlSimpleReader reader; + reader.setContentHandler(myXmlHandler); + reader.setErrorHandler(myXmlHandler); + bool ok = reader.parse(source); + file.close(); + if (ok) { + addMap( myXmlHandler->myHypothesesMap, myHypothesesMap ); + addMap( myXmlHandler->myAlgorithmsMap, myAlgorithmsMap ); + } + else { + QAD_MessageBox::error1(myDesktop, + tr("INF_PARSE_ERROR"), + tr(myXmlHandler->errorProtocol()), + tr("SMESH_BUT_OK")); + } + } + else { + if (aNoAccessFiles.isEmpty()) + aNoAccessFiles = xmlFile; + else + aNoAccessFiles += ", " + xmlFile; + } + } // end loop + + + if (!aNoAccessFiles.isEmpty()) { + QString aMess = tr("MESHERS_FILE_CANT_OPEN") + " " + aNoAccessFiles + "\n"; + aMess += tr("MESHERS_FILE_CHECK_VARIABLE"); + wc.stop(); + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + tr("SMESH_WRN_WARNING"), + aMess, + tr("SMESH_BUT_OK")); + wc.start(); + } + } + } + + + GetAvailableHypotheses (const bool isAlgo) + { + QStringList aHypList; + + // Init list of available hypotheses, if needed + InitAvailableHypotheses(); + + // fill list of hypotheses/algorithms + THypothesisDataMap::iterator anIter; + if (isAlgo) { + anIter = myAlgorithmsMap.begin(); + for (; anIter != myAlgorithmsMap.end(); anIter++) { + aHypList.append(((*anIter).first).c_str()); + } + } + else { + anIter = myHypothesesMap.begin(); + for (; anIter != myHypothesesMap.end(); anIter++) { + aHypList.append(((*anIter).first).c_str()); + } + } + + return aHypList; + } + + + HypothesisData* GetHypothesisData (const char* aHypType) + { + HypothesisData* aHypData = 0; + + // Init list of available hypotheses, if needed + InitAvailableHypotheses(); + + if (myHypothesesMap.find(aHypType) == myHypothesesMap.end()) { + if (myAlgorithmsMap.find(aHypType) != myAlgorithmsMap.end()) { + aHypData = myAlgorithmsMap[aHypType]; + } + } + else { + aHypData = myHypothesesMap[aHypType]; + } + return aHypData; + } + + + SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator (const QString& aHypType) + { + const char* sHypType = aHypType.latin1(); + if(MYDEBUG) MESSAGE("Get HypothesisCreator for " << sHypType); + + SMESHGUI_GenericHypothesisCreator* aCreator = 0; + + // check, if creator for this hypothesis type already exists + if (myHypCreatorMap.find(sHypType) != myHypCreatorMap.end()) { + aCreator = myHypCreatorMap[sHypType]; + } + else { + // 1. Init list of available hypotheses, if needed + InitAvailableHypotheses(); + + // 2. Get names of plugin libraries + HypothesisData* aHypData = GetHypothesisData(sHypType); + if (!aHypData) { + return aCreator; + } + QString aClientLibName = aHypData->ClientLibName; + QString aServerLibName = aHypData->ServerLibName; + + // 3. Load Client Plugin Library + try { + // load plugin library + if(MYDEBUG) MESSAGE("Loading client meshers plugin library ..."); + void* libHandle = dlopen (aClientLibName, RTLD_LAZY); + if (!libHandle) { + // report any error, if occured + const char* anError = dlerror(); + if(MYDEBUG) MESSAGE(anError); + } + else { + // get method, returning hypothesis creator + if(MYDEBUG) MESSAGE("Find GetHypothesisCreator() method ..."); + typedef SMESHGUI_GenericHypothesisCreator* (*GetHypothesisCreator) \ + (QString aHypType, QString aServerLibName, SMESHGUI* aSMESHGUI); + GetHypothesisCreator procHandle = + (GetHypothesisCreator)dlsym( libHandle, "GetHypothesisCreator" ); + if (!procHandle) { + if(MYDEBUG) MESSAGE("bad hypothesis client plugin library"); + dlclose(libHandle); + } + else { + // get hypothesis creator + if(MYDEBUG) MESSAGE("Get Hypothesis Creator for " << aHypType); + aCreator = procHandle(aHypType, aServerLibName, smeshGUI); + if (!aCreator) { + if(MYDEBUG) MESSAGE("no such a hypothesis in this plugin"); + } + else { + // map hypothesis creator to a hypothesis name + myHypCreatorMap[sHypType] = aCreator; + } + } + } + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + } + + return aCreator; + } + + + SMESH::SMESH_Hypothesis_ptr CreateHypothesis (const QString& aHypType, + const QString& aHypName, + const bool isAlgo = false) + { + if(MYDEBUG) MESSAGE("Create " << aHypType << " with name " << aHypName); + + SMESH::SMESH_Hypothesis_var Hyp; + + HypothesisData* aHypData = GetHypothesisData((char*)aHypType.latin1()); + QString aServLib = aHypData->ServerLibName; + + try { + Hyp = SMESH::GetSMESHGen()->CreateHypothesis(aHypType, aServLib); + if (!Hyp->_is_nil()) { + SALOMEDS::SObject_var SHyp = SMESH::FindSObject(Hyp.in()); + if (!SHyp->_is_nil()) { + if ( !aHypName.isEmpty() ) + SMESH::SetName( SHyp, aHypName ); + myActiveStudy->updateObjBrowser(true); + return Hyp._retn(); + } + } + } + catch (const SALOME::SALOME_Exception & S_ex) { + QtCatchCorbaException(S_ex); + } + + return SMESH::SMESH_Hypothesis::_nil(); + } + + + bool AddHypothesisOnMesh (SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp) + { + if(MYDEBUG) MESSAGE ("SMESHGUI::AddHypothesisOnMesh"); + int res = SMESH::HYP_UNKNOWN_FATAL; + QAD_WaitCursor wc; + + if ( !aMesh->_is_nil() ) { + SALOMEDS::SObject_var SM = SMESH::FindSObject( aMesh ); + GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(SM); + try { + res = aMesh->AddHypothesis( aShapeObject, aHyp ); + if ( res < SMESH::HYP_UNKNOWN_FATAL ) { + SALOMEDS::SObject_var SH = SMESH::FindSObject(aHyp); + if ( !SM->_is_nil() && !SH->_is_nil() ) { + SMESH::ModifiedMesh(SM, false); + } + } + if ( res > SMESH::HYP_OK ) { + wc.stop(); + processHypothesisStatus( res, aHyp, this, true ); + wc.start(); + } + } + catch( const SALOME::SALOME_Exception& S_ex ) { + wc.stop(); + QtCatchCorbaException( S_ex ); + res = SMESH::HYP_UNKNOWN_FATAL; + } + } + return res < SMESH::HYP_UNKNOWN_FATAL; + } + + + bool AddHypothesisOnSubMesh (SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp) + { + if(MYDEBUG) MESSAGE( "SMESHGUI::AddHypothesisOnSubMesh() "); + int res = SMESH::HYP_UNKNOWN_FATAL; + QAD_WaitCursor wc; + + if ( !aSubMesh->_is_nil() && ! aHyp->_is_nil() ) { + try { + SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather(); + SALOMEDS::SObject_var SsubM = SMESH::FindSObject( aSubMesh ); + GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( SsubM ); + if ( !aMesh->_is_nil() && !SsubM->_is_nil() && !aShapeObject->_is_nil() ) { + res = aMesh->AddHypothesis( aShapeObject, aHyp ); + if ( res < SMESH::HYP_UNKNOWN_FATAL ) { + SMESH::ModifiedMesh( SsubM, false ); + } + if ( res > SMESH::HYP_OK ) { + wc.stop(); + processHypothesisStatus( res, aHyp, this, true ); + wc.start(); + } + } + else { + SCRUTE( aHyp->_is_nil() ); + SCRUTE( aMesh->_is_nil() ); + SCRUTE( SsubM->_is_nil() ); + SCRUTE( aShapeObject->_is_nil() ); + } + } + catch( const SALOME::SALOME_Exception& S_ex ) { + wc.stop(); + QtCatchCorbaException( S_ex ); + res = SMESH::HYP_UNKNOWN_FATAL; + } + } + else { + SCRUTE( aSubMesh->_is_nil() ); + SCRUTE( aHyp->_is_nil() ); + } + return res < SMESH::HYP_UNKNOWN_FATAL; + } + + bool RemoveHypothesisOrAlgorithmOnMesh (const Handle(SALOME_InteractiveObject)& IObject) + { + int res = SMESH::HYP_UNKNOWN_FATAL; + QAD_WaitCursor wc; + + if (IObject->hasReference()) { + try { + SMESH::SMESH_Hypothesis_var anHyp = + SMESH::IObjectToInterface(IObject); + SALOMEDS::SObject_var SO_Applied_Hypothesis = + smeshGUI->myStudy->FindObjectID(IObject->getReference()); + if (!SO_Applied_Hypothesis->_is_nil()) { + SALOMEDS::SObject_var MorSM = SMESH::GetMeshOrSubmesh(SO_Applied_Hypothesis); + if (!MorSM->_is_nil()) { + GEOM::GEOM_Object_var aShape = SMESH::GetShapeOnMeshOrSubMesh(MorSM); + if (!aShape->_is_nil()){ + SMESH::SMESH_Mesh_var aMesh = + SMESH::SObjectToInterface(MorSM); + SMESH::SMESH_subMesh_var aSubMesh = + SMESH::SObjectToInterface(MorSM); + + if (!aSubMesh->_is_nil()) + aMesh = aSubMesh->GetFather(); + + if (!aMesh->_is_nil()) { + res = aMesh->RemoveHypothesis(aShape, anHyp); + if ( res < SMESH::HYP_UNKNOWN_FATAL ) + SMESH::ModifiedMesh(MorSM, false); + if ( res > SMESH::HYP_OK ) { + wc.stop(); + processHypothesisStatus( res, anHyp, this, false ); + wc.start(); + } + } + } + } + + SALOMEDS::SObject_var SO_Applied_Hypothesis = + smeshGUI->myStudy->FindObjectID(IObject->getReference()); + if (!SO_Applied_Hypothesis->_is_nil()) { + SALOMEDS::SObject_var MorSM = SMESH::GetMeshOrSubmesh(SO_Applied_Hypothesis); + if (!MorSM->_is_nil()) { + GEOM::GEOM_Object_var aShapeObject =SMESH::GetShapeOnMeshOrSubMesh(MorSM); + if (!aShapeObject->_is_nil()){ + SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface(MorSM); + SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface(MorSM); + + if (!aSubMesh->_is_nil()) + aMesh = aSubMesh->GetFather(); + + if (!aMesh->_is_nil()) { + res = aMesh->RemoveHypothesis(aShapeObject, anHyp); + if ( res < SMESH::HYP_UNKNOWN_FATAL ) + SMESH::ModifiedMesh(MorSM, false); + if ( res > SMESH::HYP_OK ) { + wc.stop(); + processHypothesisStatus( res, anHyp, this, false ); + wc.start(); + } + } + } + } + } + } + } + catch( const SALOME::SALOME_Exception& S_ex ) { + wc.stop(); + QtCatchCorbaException( S_ex ); + res = SMESH::HYP_UNKNOWN_FATAL; + } + } + else if (IObject->hasEntry()) { + if(MYDEBUG) MESSAGE("IObject entry " << IObject->getEntry()); + } + return res < SMESH::HYP_UNKNOWN_FATAL; + } + + bool RemoveHypothesisOrAlgorithmOnMesh (SALOMEDS::SObject_ptr MorSM, + SMESH::SMESH_Hypothesis_ptr anHyp) + { + SALOMEDS::SObject_var AHR, aRef; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + int res = SMESH::HYP_UNKNOWN_FATAL; + QAD_WaitCursor wc; + + if (!MorSM->_is_nil()) { + try { + GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(MorSM); + if (!aShapeObject->_is_nil()) { + SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface(MorSM); + SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface(MorSM); + + if ( !aSubMesh->_is_nil() ) + aMesh = aSubMesh->GetFather(); + + if (!aMesh->_is_nil()) { + res = aMesh->RemoveHypothesis(aShapeObject, anHyp); + if ( res < SMESH::HYP_UNKNOWN_FATAL ) + SMESH::ModifiedMesh(MorSM, false); + if ( res > SMESH::HYP_OK ) { + wc.stop(); + processHypothesisStatus( res, anHyp, this, false ); + wc.start(); + } + } + } + } catch( const SALOME::SALOME_Exception& S_ex ) { + wc.stop(); + QtCatchCorbaException( S_ex ); + res = SMESH::HYP_UNKNOWN_FATAL; + } + } + return res < SMESH::HYP_UNKNOWN_FATAL; + } + + SALOMEDS::Study::ListOfSObject* GetMeshesUsingAlgoOrHypothesis( SMESH::SMESH_Hypothesis_ptr AlgoOrHyp ) + { + SALOMEDS::Study::ListOfSObject_var listSOmesh = + new SALOMEDS::Study::ListOfSObject; + listSOmesh->length(0); + unsigned int index = 0; + if (!AlgoOrHyp->_is_nil()) { + SALOMEDS::SObject_var SO_Hypothesis = SMESH::FindSObject(AlgoOrHyp); + if (!SO_Hypothesis->_is_nil()) { + SALOMEDS::Study::ListOfSObject_var listSO = + smeshGUI->myStudy->FindDependances(SO_Hypothesis); + if(MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency number ="<length()); + for (unsigned int i = 0; i < listSO->length(); i++) { + SALOMEDS::SObject_ptr SO = listSO[i]; + if (!SO->_is_nil()) { + SALOMEDS::SObject_var aFather = SO->GetFather(); + if (!aFather->_is_nil()) { + SALOMEDS::SObject_var SOfatherFather = aFather->GetFather(); + if (!SOfatherFather->_is_nil()) { + if(MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency added to list"); + index++; + listSOmesh->length(index); + listSOmesh[index - 1] = SOfatherFather; + } + } + } + } + } + } + if(MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): completed"); + return listSOmesh._retn(); + } + +} diff --git a/src/SMESHGUI/SMESHGUI_Hypotheses.h b/src/SMESHGUI/SMESHGUI_Hypotheses.h index 932226296..85a621791 100644 --- a/src/SMESHGUI/SMESHGUI_Hypotheses.h +++ b/src/SMESHGUI/SMESHGUI_Hypotheses.h @@ -28,6 +28,7 @@ #ifndef SMESHGUI_Hypotheses_HeaderFile #define SMESHGUI_Hypotheses_HeaderFile +#include #include CORBA_SERVER_HEADER(SMESH_Hypothesis) // QT Includes diff --git a/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx new file mode 100644 index 000000000..323b1ec68 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_HypothesesUtils.cxx @@ -0,0 +1,554 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#include +#include + +#include + +#include "QAD.h" +#include "QAD_Tools.h" +#include "QAD_Config.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" +#include "QAD_WaitCursor.h" +#include "QAD_ResourceMgr.h" + +#include "SALOMEGUI_QtCatchCorbaException.hxx" + +#include "SMESHGUI_HypothesesUtils.h" +#include "SMESHGUI_Hypotheses.h" +#include "SMESHGUI_XmlHandler.h" +#include "SMESHGUI.h" + +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_GEOMGenUtils.h" +#include "SMESHGUI_SMESHGenUtils.h" + +#include "SALOMEconfig.h" +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +namespace SMESH{ + + using namespace std; + + typedef map THypothesisDataMap; + THypothesisDataMap myHypothesesMap; + THypothesisDataMap myAlgorithmsMap; + + typedef map THypCreatorMap; + THypCreatorMap myHypCreatorMap; + + void addMap( const THypothesisDataMap& theMap, + THypothesisDataMap& toMap) + { + THypothesisDataMap::const_iterator it; + for ( it = theMap.begin(); it != theMap.end(); it++ ) + toMap.insert( *it ); + } + + + void processHypothesisStatus(const int theHypStatus, + SMESH::SMESH_Hypothesis_ptr theHyp, + const bool theIsAddition) + { + if ( theHypStatus > SMESH::HYP_OK ) { + + // get Hyp name + QString aHypName ("NULL Hypothesis"); + if ( !CORBA::is_nil( theHyp )) { + SALOMEDS::SObject_var Shyp = SMESH::FindSObject( theHyp ); + if ( !CORBA::is_nil( Shyp )) + // name in study + aHypName = Shyp->GetName(); + else + // label in xml file + aHypName = GetHypothesisData( theHyp->GetName() )->Label; + } + + // message + bool isFatal = ( theHypStatus >= SMESH::HYP_UNKNOWN_FATAL ); + QString aMsg; + if ( theIsAddition ) + aMsg = ( isFatal ? "SMESH_CANT_ADD_HYP" : "SMESH_ADD_HYP_WRN"); + else + aMsg = ( isFatal ? "SMESH_CANT_RM_HYP" : "SMESH_RM_HYP_WRN"); + + aMsg = QObject::tr( aMsg ).arg( aHypName ) + + QObject::tr( QString( "SMESH_HYP_%1" ).arg( theHypStatus )); + + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + QObject::tr( "SMESH_WRN_WARNING" ), + aMsg, + QObject::tr( "SMESH_BUT_OK" )); + } + } + + + void InitAvailableHypotheses() + { + QAD_WaitCursor wc; + if (myHypothesesMap.empty() && myAlgorithmsMap.empty()) { + // Resource manager + QAD_ResourceMgr* resMgr = QAD_Desktop::createResourceManager(); + if (!resMgr) return; + + // Find name of a resource XML file ("SMESH_Meshers.xml"); + QString HypsXml; + char* cenv = getenv("SMESH_MeshersList"); + if (cenv) + HypsXml.sprintf("%s", cenv); + + QStringList HypsXmlList = QStringList::split( ":", HypsXml, false ); + if (HypsXmlList.count() == 0) + { + QAD_MessageBox::error1(QAD_Application::getDesktop(), + QObject::tr("SMESH_WRN_WARNING"), + QObject::tr("MESHERS_FILE_NO_VARIABLE"), + QObject::tr("SMESH_BUT_OK")); + return; + } + + // loop on files in HypsXml + QString aNoAccessFiles; + for ( int i = 0; i < HypsXmlList.count(); i++ ) { + QString HypsXml = HypsXmlList[ i ]; + + // Find full path to the resource XML file + QString xmlFile = HypsXml + ".xml"; + xmlFile = QAD_Tools::addSlash(resMgr->findFile(xmlFile, HypsXml)) + xmlFile; + + QFile file (QAD_Tools::unix2win(xmlFile)); + if (file.exists() && file.open(IO_ReadOnly)) { + file.close(); + + SMESHGUI_XmlHandler* aXmlHandler = new SMESHGUI_XmlHandler(); + ASSERT(aXmlHandler); + + QXmlInputSource source (file); + QXmlSimpleReader reader; + reader.setContentHandler(aXmlHandler); + reader.setErrorHandler(aXmlHandler); + bool ok = reader.parse(source); + file.close(); + if (ok) { + addMap( aXmlHandler->myHypothesesMap, myHypothesesMap ); + addMap( aXmlHandler->myAlgorithmsMap, myAlgorithmsMap ); + } + else { + QAD_MessageBox::error1(QAD_Application::getDesktop(), + QObject::tr("INF_PARSE_ERROR"), + QObject::tr(aXmlHandler->errorProtocol()), + QObject::tr("SMESH_BUT_OK")); + } + } + else { + if (aNoAccessFiles.isEmpty()) + aNoAccessFiles = xmlFile; + else + aNoAccessFiles += ", " + xmlFile; + } + } // end loop + + + if (!aNoAccessFiles.isEmpty()) { + QString aMess = QObject::tr("MESHERS_FILE_CANT_OPEN") + " " + aNoAccessFiles + "\n"; + aMess += QObject::tr("MESHERS_FILE_CHECK_VARIABLE"); + wc.stop(); + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + QObject::tr("SMESH_WRN_WARNING"), + aMess, + QObject::tr("SMESH_BUT_OK")); + wc.start(); + } + } + } + + + QStringList GetAvailableHypotheses(const bool isAlgo) + { + QStringList aHypList; + + // Init list of available hypotheses, if needed + InitAvailableHypotheses(); + + // fill list of hypotheses/algorithms + THypothesisDataMap::iterator anIter; + if (isAlgo) { + anIter = myAlgorithmsMap.begin(); + for (; anIter != myAlgorithmsMap.end(); anIter++) { + aHypList.append(((*anIter).first).c_str()); + } + } + else { + anIter = myHypothesesMap.begin(); + for (; anIter != myHypothesesMap.end(); anIter++) { + aHypList.append(((*anIter).first).c_str()); + } + } + + return aHypList; + } + + + HypothesisData* GetHypothesisData (const char* aHypType) + { + HypothesisData* aHypData = 0; + + // Init list of available hypotheses, if needed + InitAvailableHypotheses(); + + if (myHypothesesMap.find(aHypType) == myHypothesesMap.end()) { + if (myAlgorithmsMap.find(aHypType) != myAlgorithmsMap.end()) { + aHypData = myAlgorithmsMap[aHypType]; + } + } + else { + aHypData = myHypothesesMap[aHypType]; + } + return aHypData; + } + + + SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator(const char* aHypType) + { + if(MYDEBUG) MESSAGE("Get HypothesisCreator for " << aHypType); + + SMESHGUI_GenericHypothesisCreator* aCreator = 0; + + // check, if creator for this hypothesis type already exists + if (myHypCreatorMap.find(aHypType) != myHypCreatorMap.end()) { + aCreator = myHypCreatorMap[aHypType]; + } + else { + // 1. Init list of available hypotheses, if needed + InitAvailableHypotheses(); + + // 2. Get names of plugin libraries + HypothesisData* aHypData = GetHypothesisData(aHypType); + if (!aHypData) { + return aCreator; + } + QString aClientLibName = aHypData->ClientLibName; + QString aServerLibName = aHypData->ServerLibName; + + // 3. Load Client Plugin Library + try { + // load plugin library + if(MYDEBUG) MESSAGE("Loading client meshers plugin library ..."); + void* libHandle = dlopen (aClientLibName, RTLD_LAZY); + if (!libHandle) { + // report any error, if occured + const char* anError = dlerror(); + if(MYDEBUG) MESSAGE(anError); + } + else { + // get method, returning hypothesis creator + if(MYDEBUG) MESSAGE("Find GetHypothesisCreator() method ..."); + typedef SMESHGUI_GenericHypothesisCreator* (*GetHypothesisCreator) \ + (QString aHypType, QString aServerLibName, SMESHGUI* aSMESHGUI); + GetHypothesisCreator procHandle = + (GetHypothesisCreator)dlsym( libHandle, "GetHypothesisCreator" ); + if (!procHandle) { + if(MYDEBUG) MESSAGE("bad hypothesis client plugin library"); + dlclose(libHandle); + } + else { + // get hypothesis creator + if(MYDEBUG) MESSAGE("Get Hypothesis Creator for " << aHypType); + aCreator = procHandle(aHypType, aServerLibName, SMESHGUI::GetSMESHGUI()); + if (!aCreator) { + if(MYDEBUG) MESSAGE("no such a hypothesis in this plugin"); + } + else { + // map hypothesis creator to a hypothesis name + myHypCreatorMap[aHypType] = aCreator; + } + } + } + } + catch (const SALOME::SALOME_Exception& S_ex) { + QtCatchCorbaException(S_ex); + } + } + + return aCreator; + } + + + SMESH::SMESH_Hypothesis_ptr CreateHypothesis(const char* aHypType, + const char* aHypName, + const bool isAlgo) + { + if(MYDEBUG) MESSAGE("Create " << aHypType << " with name " << aHypName); + + SMESH::SMESH_Hypothesis_var Hyp; + + HypothesisData* aHypData = GetHypothesisData(aHypType); + QString aServLib = aHypData->ServerLibName; + + try { + Hyp = SMESH::GetSMESHGen()->CreateHypothesis(aHypType, aServLib); + if (!Hyp->_is_nil()) { + SALOMEDS::SObject_var SHyp = SMESH::FindSObject(Hyp.in()); + if (!SHyp->_is_nil()) { + if ( strcmp(aHypName,"") != 0 ) + SMESH::SetName( SHyp, aHypName ); + GetActiveStudy()->updateObjBrowser(true); + return Hyp._retn(); + } + } + } + catch (const SALOME::SALOME_Exception & S_ex) { + QtCatchCorbaException(S_ex); + } + + return SMESH::SMESH_Hypothesis::_nil(); + } + + + bool AddHypothesisOnMesh (SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp) + { + if(MYDEBUG) MESSAGE ("SMESHGUI::AddHypothesisOnMesh"); + int res = SMESH::HYP_UNKNOWN_FATAL; + QAD_WaitCursor wc; + + if ( !aMesh->_is_nil() ) { + SALOMEDS::SObject_var SM = SMESH::FindSObject( aMesh ); + GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(SM); + try { + res = aMesh->AddHypothesis( aShapeObject, aHyp ); + if ( res < SMESH::HYP_UNKNOWN_FATAL ) { + SALOMEDS::SObject_var SH = SMESH::FindSObject(aHyp); + if ( !SM->_is_nil() && !SH->_is_nil() ) { + SMESH::ModifiedMesh(SM, false); + } + } + if ( res > SMESH::HYP_OK ) { + wc.stop(); + processHypothesisStatus( res, aHyp, true ); + wc.start(); + } + } + catch( const SALOME::SALOME_Exception& S_ex ) { + wc.stop(); + QtCatchCorbaException( S_ex ); + res = SMESH::HYP_UNKNOWN_FATAL; + } + } + return res < SMESH::HYP_UNKNOWN_FATAL; + } + + + bool AddHypothesisOnSubMesh (SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp) + { + if(MYDEBUG) MESSAGE( "SMESHGUI::AddHypothesisOnSubMesh() "); + int res = SMESH::HYP_UNKNOWN_FATAL; + QAD_WaitCursor wc; + + if ( !aSubMesh->_is_nil() && ! aHyp->_is_nil() ) { + try { + SMESH::SMESH_Mesh_var aMesh = aSubMesh->GetFather(); + SALOMEDS::SObject_var SsubM = SMESH::FindSObject( aSubMesh ); + GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh( SsubM ); + if ( !aMesh->_is_nil() && !SsubM->_is_nil() && !aShapeObject->_is_nil() ) { + res = aMesh->AddHypothesis( aShapeObject, aHyp ); + if ( res < SMESH::HYP_UNKNOWN_FATAL ) { + SMESH::ModifiedMesh( SsubM, false ); + } + if ( res > SMESH::HYP_OK ) { + wc.stop(); + processHypothesisStatus( res, aHyp, true ); + wc.start(); + } + } + else { + SCRUTE( aHyp->_is_nil() ); + SCRUTE( aMesh->_is_nil() ); + SCRUTE( SsubM->_is_nil() ); + SCRUTE( aShapeObject->_is_nil() ); + } + } + catch( const SALOME::SALOME_Exception& S_ex ) { + wc.stop(); + QtCatchCorbaException( S_ex ); + res = SMESH::HYP_UNKNOWN_FATAL; + } + } + else { + SCRUTE( aSubMesh->_is_nil() ); + SCRUTE( aHyp->_is_nil() ); + } + return res < SMESH::HYP_UNKNOWN_FATAL; + } + + bool RemoveHypothesisOrAlgorithmOnMesh (const Handle(SALOME_InteractiveObject)& IObject) + { + int res = SMESH::HYP_UNKNOWN_FATAL; + QAD_WaitCursor wc; + + if (IObject->hasReference()) { + try { + SALOMEDS::Study_var aStudy = GetActiveStudyDocument(); + SMESH_Hypothesis_var anHyp = IObjectToInterface(IObject); + SALOMEDS::SObject_var aHypSObj = aStudy->FindObjectID(IObject->getReference()); + if (!aHypSObj->_is_nil()) { + SALOMEDS::SObject_var MorSM = SMESH::GetMeshOrSubmesh(aHypSObj); + if (!MorSM->_is_nil()) { + GEOM::GEOM_Object_var aShape = SMESH::GetShapeOnMeshOrSubMesh(MorSM); + if (!aShape->_is_nil()){ + SMESH::SMESH_Mesh_var aMesh = + SMESH::SObjectToInterface(MorSM); + SMESH::SMESH_subMesh_var aSubMesh = + SMESH::SObjectToInterface(MorSM); + + if (!aSubMesh->_is_nil()) + aMesh = aSubMesh->GetFather(); + + if (!aMesh->_is_nil()) { + res = aMesh->RemoveHypothesis(aShape, anHyp); + if ( res < SMESH::HYP_UNKNOWN_FATAL ) + SMESH::ModifiedMesh(MorSM, false); + if ( res > SMESH::HYP_OK ) { + wc.stop(); + processHypothesisStatus( res, anHyp, false ); + wc.start(); + } + } + } + } + + SALOMEDS::SObject_var aHypSObj = aStudy->FindObjectID(IObject->getReference()); + if (!aHypSObj->_is_nil()) { + SALOMEDS::SObject_var MorSM = SMESH::GetMeshOrSubmesh(aHypSObj); + if (!MorSM->_is_nil()) { + GEOM::GEOM_Object_var aShapeObject =SMESH::GetShapeOnMeshOrSubMesh(MorSM); + if (!aShapeObject->_is_nil()){ + SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface(MorSM); + SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface(MorSM); + + if (!aSubMesh->_is_nil()) + aMesh = aSubMesh->GetFather(); + + if (!aMesh->_is_nil()) { + res = aMesh->RemoveHypothesis(aShapeObject, anHyp); + if ( res < SMESH::HYP_UNKNOWN_FATAL ) + SMESH::ModifiedMesh(MorSM, false); + if ( res > SMESH::HYP_OK ) { + wc.stop(); + processHypothesisStatus( res, anHyp, false ); + wc.start(); + } + } + } + } + } + } + } + catch( const SALOME::SALOME_Exception& S_ex ) { + wc.stop(); + QtCatchCorbaException( S_ex ); + res = SMESH::HYP_UNKNOWN_FATAL; + } + } + else if (IObject->hasEntry()) { + if(MYDEBUG) MESSAGE("IObject entry " << IObject->getEntry()); + } + return res < SMESH::HYP_UNKNOWN_FATAL; + } + + bool RemoveHypothesisOrAlgorithmOnMesh (SALOMEDS::SObject_ptr MorSM, + SMESH::SMESH_Hypothesis_ptr anHyp) + { + SALOMEDS::SObject_var AHR, aRef; + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeIOR_var anIOR; + int res = SMESH::HYP_UNKNOWN_FATAL; + QAD_WaitCursor wc; + + if (!MorSM->_is_nil()) { + try { + GEOM::GEOM_Object_var aShapeObject = SMESH::GetShapeOnMeshOrSubMesh(MorSM); + if (!aShapeObject->_is_nil()) { + SMESH::SMESH_Mesh_var aMesh = SMESH::SObjectToInterface(MorSM); + SMESH::SMESH_subMesh_var aSubMesh = SMESH::SObjectToInterface(MorSM); + + if ( !aSubMesh->_is_nil() ) + aMesh = aSubMesh->GetFather(); + + if (!aMesh->_is_nil()) { + res = aMesh->RemoveHypothesis(aShapeObject, anHyp); + if ( res < SMESH::HYP_UNKNOWN_FATAL ) + SMESH::ModifiedMesh(MorSM, false); + if ( res > SMESH::HYP_OK ) { + wc.stop(); + processHypothesisStatus( res, anHyp, false ); + wc.start(); + } + } + } + } catch( const SALOME::SALOME_Exception& S_ex ) { + wc.stop(); + QtCatchCorbaException( S_ex ); + res = SMESH::HYP_UNKNOWN_FATAL; + } + } + return res < SMESH::HYP_UNKNOWN_FATAL; + } + + SALOMEDS::Study::ListOfSObject* GetMeshesUsingAlgoOrHypothesis( SMESH::SMESH_Hypothesis_ptr AlgoOrHyp ) + { + SALOMEDS::Study::ListOfSObject_var listSOmesh = + new SALOMEDS::Study::ListOfSObject; + listSOmesh->length(0); + unsigned int index = 0; + if (!AlgoOrHyp->_is_nil()) { + SALOMEDS::SObject_var SO_Hypothesis = SMESH::FindSObject(AlgoOrHyp); + if (!SO_Hypothesis->_is_nil()) { + SALOMEDS::Study::ListOfSObject_var listSO = + GetActiveStudyDocument()->FindDependances(SO_Hypothesis); + if(MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency number ="<length()); + for (unsigned int i = 0; i < listSO->length(); i++) { + SALOMEDS::SObject_ptr SO = listSO[i]; + if (!SO->_is_nil()) { + SALOMEDS::SObject_var aFather = SO->GetFather(); + if (!aFather->_is_nil()) { + SALOMEDS::SObject_var SOfatherFather = aFather->GetFather(); + if (!SOfatherFather->_is_nil()) { + if(MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): dependency added to list"); + index++; + listSOmesh->length(index); + listSOmesh[index - 1] = SOfatherFather; + } + } + } + } + } + } + if(MYDEBUG) MESSAGE("SMESHGUI::GetMeshesUsingAlgoOrHypothesis(): completed"); + return listSOmesh._retn(); + } + +} diff --git a/src/SMESHGUI/SMESHGUI_HypothesesUtils.h b/src/SMESHGUI/SMESHGUI_HypothesesUtils.h new file mode 100644 index 000000000..d87f45cb8 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_HypothesesUtils.h @@ -0,0 +1,71 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// Copyright (C) 2003 CEA +// +// 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.org +// +// +// +// File : SMESHGUI_Hypotheses.h +// Author : Julia DOROVSKIKH +// Module : SMESH +// $Header$ + +#ifndef SMESHGUI_HypothesesUtils_HeaderFile +#define SMESHGUI_HypothesesUtils_HeaderFile + +#include +#include + +#include "SALOME_InteractiveObject.hxx" + +#include "SALOMEconfig.h" +#include CORBA_CLIENT_HEADER(SALOMEDS) +#include CORBA_SERVER_HEADER(SMESH_Mesh) +#include CORBA_SERVER_HEADER(SMESH_Hypothesis) + +class HypothesisData; +class SMESHGUI_GenericHypothesisCreator; + +namespace SMESH{ + + void InitAvailableHypotheses(); + + QStringList GetAvailableHypotheses(const bool isAlgo); + + HypothesisData* GetHypothesisData(const char* aHypType); + + SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator(const char* aHypType); + + SMESH::SMESH_Hypothesis_ptr CreateHypothesis(const char* aHypType, + const char* aHypName, + const bool isAlgo = false); + + bool AddHypothesisOnMesh(SMESH::SMESH_Mesh_ptr aMesh, SMESH::SMESH_Hypothesis_ptr aHyp); + + bool AddHypothesisOnSubMesh(SMESH::SMESH_subMesh_ptr aSubMesh, SMESH::SMESH_Hypothesis_ptr aHyp); + + bool RemoveHypothesisOrAlgorithmOnMesh(const Handle(SALOME_InteractiveObject)& IObject); + + bool RemoveHypothesisOrAlgorithmOnMesh(SALOMEDS::SObject_ptr MorSM, + SMESH::SMESH_Hypothesis_ptr anHyp); + + SALOMEDS::Study::ListOfSObject* GetMeshesUsingAlgoOrHypothesis(SMESH::SMESH_Hypothesis_ptr AlgoOrHyp ) ; + +} + +#endif diff --git a/src/SMESHGUI/SMESHGUI_IdValidator.h b/src/SMESHGUI/SMESHGUI_IdValidator.h new file mode 100644 index 000000000..680dacba8 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_IdValidator.h @@ -0,0 +1,68 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// Copyright (C) 2003 CEA +// +// 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.org +// +// +// +// File : SMESHGUI_IdValidator.h +// Author : Edward AGAPOV +// Module : SMESH +// $Header: /dn05/salome/PAL/SMESH/SMESH_SRC/src/SMESHGUI/SMESHGUI_IdValidator.h + +#ifndef SMESHGUI_IdValidator_HeaderFile +#define SMESHGUI_IdValidator_HeaderFile + +#include + +// validator for manual input of Ids + +class SMESHGUI_IdValidator: public QValidator +{ + public: + + SMESHGUI_IdValidator(QWidget * parent, const char * name = 0, const int maxNbId = 0): + QValidator(parent,name), myMaxNbId(maxNbId) {} + + State validate ( QString & text, int & pos) const + { + text.replace( QRegExp(" *[^0-9]+ *"), " " ); + if ( myMaxNbId && text.length() > myMaxNbId) { // truncate extra ids + int ind = 0, nbId = 0; + while ( ind < text.length() ) { + if ( text.at( ind ) != ' ' ) { + if ( ++nbId > myMaxNbId ) { + text.truncate( ind ); + break; + } + ind = text.find( ' ', ind ); + if ( ind < 0 ) break; + } + ind++; + } + } + if ( pos > text.length() ) + pos = text.length(); + return Acceptable; + } + + private: + int myMaxNbId; +}; + +#endif diff --git a/src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx b/src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx index ac34a76c7..68a737503 100644 --- a/src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_InitMeshDlg.cxx @@ -26,10 +26,14 @@ // Module : SMESH // $Header$ -using namespace std; #include "SMESHGUI_InitMeshDlg.h" + #include "SMESHGUI.h" -#include "SALOME_ListIteratorOfListIO.hxx" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_SMESHGenUtils.h" +#include "SMESHGUI_HypothesesUtils.h" + +#include "GEOMBase.h" #include "QAD_Application.h" #include "QAD_Desktop.h" @@ -37,6 +41,9 @@ using namespace std; #include "QAD_WaitCursor.h" #include "QAD_Operation.h" +#include "SALOME_ListIteratorOfListIO.hxx" +#include "SALOMEGUI_QtCatchCorbaException.hxx" + #include "utilities.h" // QT Includes @@ -47,6 +54,30 @@ using namespace std; #include #include +using namespace std; + +namespace SMESH{ + SMESH::SMESH_Mesh_var InitMesh(GEOM::GEOM_Object_ptr theShapeObject, + const char* theMeshName) + { + SMESH::SMESH_Mesh_var aMesh; + try { + SMESH::SMESH_Gen_var aSMESHGen = SMESH::GetSMESHGen(); + if ( !aSMESHGen->_is_nil() && !theShapeObject->_is_nil() ) { + aMesh = aSMESHGen->CreateMesh( theShapeObject ); + if ( !aMesh->_is_nil() ) { + SALOMEDS::SObject_var aMeshSObject = SMESH::FindSObject( aMesh.in() ); + SMESH::SetName( aMeshSObject, theMeshName ); + } + } + } + catch( const SALOME::SALOME_Exception& S_ex ) { + QtCatchCorbaException( S_ex ); + } + return aMesh._retn(); + } +} + //================================================================================= // class : SMESHGUI_InitMeshDlg() // purpose : Constructs a SMESHGUI_InitMeshDlg which is a child of 'parent', with the @@ -88,6 +119,7 @@ SMESHGUI_InitMeshDlg::SMESHGUI_InitMeshDlg( QWidget* parent, const char* name, S SelectButtonC1A1->setToggleButton( FALSE ); GroupC1Layout->addWidget( SelectButtonC1A1, 1, 1 ); LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + LineEditC1A1->setReadOnly( true ); GroupC1Layout->addWidget( LineEditC1A1, 1, 2 ); TextLabelC1A1Hyp = new QLabel( tr( "SMESH_OBJECT_HYPOTHESIS" ), GroupC1, "TextLabelC1A1Hyp" ); @@ -96,6 +128,7 @@ SMESHGUI_InitMeshDlg::SMESHGUI_InitMeshDlg( QWidget* parent, const char* name, S SelectButtonC1A1Hyp->setPixmap( image0 ); GroupC1Layout->addWidget( SelectButtonC1A1Hyp, 2, 1 ); LineEditC1A1Hyp = new QLineEdit( GroupC1, "LineEditC1A1Hyp" ); + LineEditC1A1Hyp->setReadOnly( true ); GroupC1Layout->addWidget( LineEditC1A1Hyp, 2, 2 ); TextLabelC1A1Algo = new QLabel( tr( "SMESH_OBJECT_ALGORITHM" ), GroupC1, "TextLabelC1A1Algo" ); @@ -104,6 +137,7 @@ SMESHGUI_InitMeshDlg::SMESHGUI_InitMeshDlg( QWidget* parent, const char* name, S SelectButtonC1A1Algo->setPixmap( image0 ); GroupC1Layout->addWidget( SelectButtonC1A1Algo, 3, 1 ); LineEditC1A1Algo = new QLineEdit( GroupC1, "LineEditC1A1Algo" ); + LineEditC1A1Algo->setReadOnly( true ); GroupC1Layout->addWidget( LineEditC1A1Algo, 3, 2 ); SMESHGUI_InitMeshDlgLayout->addWidget( GroupC1, 1, 0 ); @@ -182,7 +216,7 @@ void SMESHGUI_InitMeshDlg::Init( SALOME_Selection* Sel ) this->move( x, y ) ; this->show() ; - LineEdit_NameMesh->setText( tr( "SMESH_OBJECT_MESH" ) ); + LineEdit_NameMesh->setText( GetDefaultMeshName() ); LineEdit_NameMesh->setFocus() ; myEditCurrentArgument = LineEditC1A1 ; mySelection->ClearFilters() ; @@ -210,6 +244,9 @@ void SMESHGUI_InitMeshDlg::ClickOnOk() //================================================================================= bool SMESHGUI_InitMeshDlg::ClickOnApply() { + if (mySMESHGUI->ActiveStudyLocked()) + return false; + QString myNameMesh = LineEdit_NameMesh->text().stripWhiteSpace(); if ( myNameMesh.isEmpty() ) { QAD_MessageBox::warn1( this, tr( "SMESH_WRN_WARNING" ), tr( "SMESH_WRN_EMPTY_NAME" ), tr( "SMESH_BUT_OK" ) ); @@ -227,18 +264,18 @@ bool SMESHGUI_InitMeshDlg::ClickOnApply() op->start(); // create mesh - SMESH::SMESH_Mesh_var aMesh = mySMESHGUI->InitMesh( myGeomShape, myNameMesh ) ; + SMESH::SMESH_Mesh_var aMesh = SMESH::InitMesh( myGeomShape, myNameMesh ) ; if ( !aMesh->_is_nil() ) { // assign hypotheses for( int i = 0; i < HypoList.count(); i++ ) { - SALOMEDS::SObject_var aHypSO = mySMESHGUI->GetStudy()->FindObjectID( HypoList[i] ); + SALOMEDS::SObject_var aHypSO = SMESH::GetActiveStudyDocument()->FindObjectID( HypoList[i] ); if ( !aHypSO->_is_nil() ) { CORBA::Object_var anObject = aHypSO->GetObject(); if ( !CORBA::is_nil( anObject ) ) { SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject ); if ( !aHyp->_is_nil() ) { - if ( !mySMESHGUI->AddHypothesisOnMesh( aMesh, aHyp ) ) { + if ( !SMESH::AddHypothesisOnMesh( aMesh, aHyp ) ) { // abort transaction op->abort(); return false; @@ -249,13 +286,13 @@ bool SMESHGUI_InitMeshDlg::ClickOnApply() } // assign algorithms for( int i = 0; i < AlgoList.count(); i++ ) { - SALOMEDS::SObject_var aHypSO = mySMESHGUI->GetStudy()->FindObjectID( AlgoList[i] ); + SALOMEDS::SObject_var aHypSO = SMESH::GetActiveStudyDocument()->FindObjectID( AlgoList[i] ); if ( !aHypSO->_is_nil() ) { CORBA::Object_var anObject = aHypSO->GetObject(); if ( !CORBA::is_nil( anObject ) ) { SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( anObject ); if ( !aHyp->_is_nil() ) { - if ( !mySMESHGUI->AddAlgorithmOnMesh( aMesh, aHyp ) ) { + if ( !SMESH::AddHypothesisOnMesh( aMesh, aHyp ) ) { // abort transaction op->abort(); return false; @@ -267,6 +304,7 @@ bool SMESHGUI_InitMeshDlg::ClickOnApply() } // commit transaction op->finish(); + LineEdit_NameMesh->setText( GetDefaultMeshName() ); return true; } @@ -289,21 +327,24 @@ void SMESHGUI_InitMeshDlg::SelectionIntoArgument() { QString aString = ""; - int nbSel = mySMESHGUI->GetNameOfSelectedIObjects(mySelection, aString) ; + int nbSel = SMESH::GetNameOfSelectedIObjects( mySelection, aString ); - if ( myEditCurrentArgument == LineEditC1A1 ) { + if ( myEditCurrentArgument == LineEditC1A1 ) + { // geom shape - if ( nbSel != 1 ) { - myGeomShape = GEOM::GEOM_Shape::_nil(); + if ( nbSel != 1 ) + { + myGeomShape = GEOM::GEOM_Object::_nil(); aString = ""; } - else { - Standard_Boolean testResult ; + else + { Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; - myGeomShape = mySMESHGUI->ConvertIOinGEOMShape(IO, testResult) ; - if( !testResult ) { - myGeomShape = GEOM::GEOM_Shape::_nil(); - aString = ""; + myGeomShape = SMESH::IObjectToInterface( IO ) ; + if ( myGeomShape->_is_nil() || !GEOMBase::IsShape( myGeomShape ) ) + { + myGeomShape = GEOM::GEOM_Object::_nil(); + aString = ""; } } } @@ -432,7 +473,26 @@ void SMESHGUI_InitMeshDlg::UpdateControlState() buttonApply->setEnabled( isEnabled ); } +//================================================================================= +// function : GetDefaultMeshName() +// purpose : Generates default mesh name(Mesh_1, Mesh_2, etc.) +//================================================================================= +QString SMESHGUI_InitMeshDlg::GetDefaultMeshName() +{ + SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); + int aNumber = 0; + QString aMeshName; + SALOMEDS::SObject_var obj; + + do + { + aMeshName = QString(tr("SMESH_OBJECT_MESH")) +"_"+QString::number(++aNumber); + obj = aStudy->FindObject(aMeshName); + } + while (!obj->_is_nil()); + return aMeshName; +} diff --git a/src/SMESHGUI/SMESHGUI_InitMeshDlg.h b/src/SMESHGUI/SMESHGUI_InitMeshDlg.h index ec04b7942..afdcc8584 100644 --- a/src/SMESHGUI/SMESHGUI_InitMeshDlg.h +++ b/src/SMESHGUI/SMESHGUI_InitMeshDlg.h @@ -40,7 +40,6 @@ // IDL Headers #include #include CORBA_SERVER_HEADER(GEOM_Gen) -#include CORBA_SERVER_HEADER(GEOM_Shape) #include CORBA_SERVER_HEADER(SMESH_Gen) class QGroupBox; @@ -63,18 +62,19 @@ public: protected: void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; + void enterEvent( QEvent * ) ; private: void Init( SALOME_Selection* Sel ) ; void UpdateControlState(); + QString SMESHGUI_InitMeshDlg::GetDefaultMeshName(); private: SMESHGUI* mySMESHGUI ; SALOME_Selection* mySelection ; - GEOM::GEOM_Shape_var myGeomShape ; + GEOM::GEOM_Object_var myGeomShape ; QLineEdit* myEditCurrentArgument; Handle(SALOME_TypeFilter) myGeomFilter; diff --git a/src/SMESHGUI/SMESHGUI_MergeNodesDlg.cxx b/src/SMESHGUI/SMESHGUI_MergeNodesDlg.cxx new file mode 100644 index 000000000..85ecdbec9 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_MergeNodesDlg.cxx @@ -0,0 +1,707 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_MergeNodesDlg.cxx +// Author : Michael ZORIN +// Module : SMESH +// $Header: + +#include "SMESHGUI_MergeNodesDlg.h" + +#include "SMESHGUI.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_IdValidator.h" +#include "SMESHGUI_SpinBox.h" +#include "SMESH_Actor.h" +#include "SMDS_Mesh.hxx" + +#include "GEOMBase.h" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +//================================================================================= +// class : SMESHGUI_MergeNodesDlg() +// purpose : +//================================================================================= +SMESHGUI_MergeNodesDlg::SMESHGUI_MergeNodesDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, + bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | + Qt::WDestructiveClose) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_MERGE_NODES"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); + + if ( !name ) + setName( "SMESHGUI_MergeNodesDlg" ); + resize( 303, 185 ); + setCaption( tr( "SMESH_MERGE_NODES" ) ); + setSizeGripEnabled( TRUE ); + SMESHGUI_MergeNodesDlgLayout = new QGridLayout( this ); + SMESHGUI_MergeNodesDlgLayout->setSpacing( 6 ); + SMESHGUI_MergeNodesDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) ); + GroupConstructors->setTitle( tr( "SMESH_MERGE_NODES" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + QHBoxLayout* RBLayout = new QHBoxLayout( 0, 0, 6, "Layout2"); + RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" ); + RadioButton1->setText( tr( "" ) ); + RadioButton1->setPixmap( image0 ); + RBLayout->addWidget( RadioButton1); + GroupConstructorsLayout->addLayout( RBLayout, 0, 0 ); + SMESHGUI_MergeNodesDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_MergeNodesDlgLayout->addWidget( GroupButtons, 4, 0 ); + + /***************************************************************/ + + // Controls for mesh defining + GroupMesh = new QGroupBox( this, "GroupMesh" ); + GroupMesh->setTitle( tr( "SMESH_MESH" ) ); + GroupMesh->setColumnLayout(0, Qt::Vertical ); + GroupMesh->layout()->setSpacing( 0 ); + GroupMesh->layout()->setMargin( 0 ); + GroupMeshLayout = new QGridLayout( GroupMesh->layout() ); + GroupMeshLayout->setAlignment( Qt::AlignTop ); + GroupMeshLayout->setSpacing( 6 ); + GroupMeshLayout->setMargin( 11 ); + + TextLabelName = new QLabel( GroupMesh, "TextLabelName" ); + TextLabelName->setText( tr( "SMESH_NAME" ) ); + GroupMeshLayout->addWidget( TextLabelName, 0, 0 ); + + SelectMeshButton = new QPushButton( GroupMesh, "SelectMeshButton" ); + SelectMeshButton->setPixmap( image1 ); + GroupMeshLayout->addWidget( SelectMeshButton, 0, 1 ); + + LineEditMesh = new QLineEdit(GroupMesh, "LineEditMesh"); + LineEditMesh->setReadOnly(true); + GroupMeshLayout->addWidget( LineEditMesh, 0, 2 ); + + SMESHGUI_MergeNodesDlgLayout->addWidget( GroupMesh, 1, 0 ); + + // Controls for coincident nodes detecting + GroupCoincident = new QGroupBox( this, "GroupCoincident" ); + GroupCoincident->setTitle( tr( "COINCIDENT_NODES" ) ); + GroupCoincident->setColumnLayout(0, Qt::Vertical ); + GroupCoincident->layout()->setSpacing( 0 ); + GroupCoincident->layout()->setMargin( 0 ); + QGridLayout* GroupCoincidentLayout = new QGridLayout( GroupCoincident->layout() ); + GroupCoincidentLayout->setAlignment( Qt::AlignTop ); + GroupCoincidentLayout->setSpacing( 6 ); + GroupCoincidentLayout->setMargin( 11 ); + + TextLabelTolerance = new QLabel( GroupCoincident, "TextLabelTolerance" ); + TextLabelTolerance->setText( tr( "SMESH_TOLERANCE" ) ); + GroupCoincidentLayout->addWidget( TextLabelTolerance, 0, 0 ); + + SpinBoxTolerance = new SMESHGUI_SpinBox( GroupCoincident, "SpinBoxTolerance" ); + GroupCoincidentLayout->addWidget( SpinBoxTolerance, 0, 1 ); + + QPushButton* DetectButton = new QPushButton( GroupCoincident, "DetectButton" ); + DetectButton->setText( tr("DETECT") ); + GroupCoincidentLayout->addWidget( DetectButton, 0, 2 ); + + ListCoincident = new QListView( GroupCoincident ); + ListCoincident->setSorting( -1 ); + ListCoincident->addColumn( "Nodes" ); + ListCoincident->header()->hide(); + + GroupCoincidentLayout->addMultiCellWidget( ListCoincident, 1, 1, 0, 1 ); + + SelectAllCB = new QCheckBox(GroupCoincident, "SelectAllCB"); + SelectAllCB->setText(tr("SELECT_ALL")); + GroupCoincidentLayout->addWidget( SelectAllCB, 2, 0 ); + + SMESHGUI_MergeNodesDlgLayout->addWidget( GroupCoincident, 2, 0 ); + + // Controls for editing group of nodes + GroupEdit = new QGroupBox( this, "GroupEdit" ); + GroupEdit->setTitle( tr( "EDIT_GROUP_OF_NODES" ) ); + GroupEdit->setColumnLayout(0, Qt::Vertical ); + GroupEdit->layout()->setSpacing( 0 ); + GroupEdit->layout()->setMargin( 0 ); + QGridLayout* GroupEditLayout = new QGridLayout( GroupEdit->layout() ); + GroupEditLayout->setAlignment( Qt::AlignTop ); + GroupEditLayout->setSpacing( 6 ); + GroupEditLayout->setMargin( 11 ); + + ListEdit = new QListBox( GroupEdit, "ListEdit" ); + ListEdit->setColumnMode(QListBox::FitToHeight); + ListEdit->setSelectionMode( QListBox::Extended ); + GroupEditLayout->addMultiCellWidget( ListEdit, 0, 2, 0, 0 ); + + QPushButton* AddButton = new QPushButton( GroupEdit, "AddButton" ); + AddButton->setText( tr("SMESH_BUT_ADD") ); + GroupEditLayout->addWidget( AddButton, 0, 1 ); + + QPushButton* RemoveButton = new QPushButton( GroupEdit, "RemoveButton" ); + RemoveButton->setText( tr("SMESH_BUT_REMOVE") ); + GroupEditLayout->addWidget( RemoveButton, 1, 1 ); + + QSpacerItem* spacer = new QSpacerItem( 20, 200, QSizePolicy::Minimum, QSizePolicy::Expanding ); + GroupEditLayout->addItem( spacer, 2, 1 ); + + SMESHGUI_MergeNodesDlgLayout->addWidget( GroupEdit, 3, 0 ); + + /* Initialisations */ + SpinBoxTolerance->RangeStepAndValidator( 0.0, 999999.999, 0.1, 3 ); + SpinBoxTolerance->SetValue(1e-05); + + RadioButton1->setChecked( TRUE ); + + mySelection = Sel; + + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + myMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ); + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + + connect( SelectMeshButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ); + connect( DetectButton, SIGNAL ( clicked() ), this, SLOT( onDetect() ) ); + connect( ListCoincident, SIGNAL ( selectionChanged() ), this, SLOT( onSelectNodesGroup() ) ); + connect( ListCoincident, SIGNAL ( pressed( QListViewItem* ) ), this, SLOT( updateControls() ) ); + connect( ListCoincident, SIGNAL ( currentChanged( QListViewItem* ) ), this, SLOT( updateControls() ) ); + connect( SelectAllCB, SIGNAL( toggled(bool) ), this, SLOT(onSelectAll(bool) ) ); + connect( ListEdit, SIGNAL ( selectionChanged() ), this, SLOT( onSelectNodesFromGroup() ) ); + connect( AddButton, SIGNAL ( clicked() ), this, SLOT( onAdd() ) ); + connect( RemoveButton, SIGNAL ( clicked() ), this, SLOT( onRemove() ) ); + + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ); + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + /* to close dialog if study change */ + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ); + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + resize(0,0); + buttonOk->setEnabled(false); + buttonApply->setEnabled(false); +} + +//================================================================================= +// function : ~SMESHGUI_MergeNodesDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_MergeNodesDlg::~SMESHGUI_MergeNodesDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool SMESHGUI_MergeNodesDlg::ClickOnApply() +{ + if (mySMESHGUI->ActiveStudyLocked() || myMesh->_is_nil()) + return false; + + try + { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + + QApplication::setOverrideCursor(Qt::waitCursor); + SMESH::array_of_long_array_var aGroupsOfNodes = new SMESH::array_of_long_array; + aGroupsOfNodes->length(ListCoincident->childCount()); + QListViewItem* item = ListCoincident->firstChild(); + + int anArrayNum = 0; + while (item) + { + QStringList aListIds = QStringList(""); + if (((QCheckListItem*) item)->isOn()) + aListIds = QStringList::split( " ", item->text(0), false); + + SMESH::long_array_var anIds = new SMESH::long_array; + anIds->length(aListIds.count()); + + for ( int i = 0; i < aListIds.count(); i++ ) + anIds[i] = aListIds[i].toInt(); + + aGroupsOfNodes[anArrayNum++] = anIds.inout(); + + item = item->itemBelow(); + } + + aMeshEditor->MergeNodes (aGroupsOfNodes.inout()); + QApplication::restoreOverrideCursor(); + } + catch( ... ) + { + } + + mySelection->ClearIObjects(); + SMESH::UpdateView(); + + onDetect(); + return true; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_MergeNodesDlg::ClickOnOk() +{ + if( ClickOnApply()) + ClickOnCancel() ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_MergeNodesDlg::ClickOnCancel() +{ + mySelection->ClearFilters(); + mySelection->ClearIObjects(); + SMESH::SetPointRepresentation(false); + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + reject() ; +} + + +//================================================================================= +// function : onEditNodesGroup() +// purpose : +//================================================================================= +void SMESHGUI_MergeNodesDlg::onEditNodesGroup() +{ + if ( ListCoincident->childCount() < 1 ) + return; + + QString aNewIds = ""; + + QListBoxItem* anItem; + for (anItem = ListEdit->firstItem(); anItem != 0; anItem = anItem->next()) + aNewIds+=QString(" %1").arg(anItem->text()); + + ListCoincident->currentItem()->setText(0, aNewIds); +} + + +//================================================================================= +// function : updateControls() +// purpose : +//================================================================================= +void SMESHGUI_MergeNodesDlg::updateControls() +{ + if ( ListCoincident->childCount() < 1 ) + { + SMESH::SetPointRepresentation(false); + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + return; + } + + bool hasChecked = false, hasUnchecked = false; + + QListViewItem* item = ListCoincident->firstChild(); + + while (item && (!hasChecked || !hasUnchecked)) + { + if (((QCheckListItem*) item)->isOn()) + hasChecked = true; + else + hasUnchecked = true; + + item = item->itemBelow(); + } + + if (hasUnchecked) + SelectAllCB->setChecked(false); + + bool enable = !(myMesh->_is_nil()) && hasChecked; + + buttonOk->setEnabled(enable); + buttonApply->setEnabled(enable); +} + + +//================================================================================= +// function : onDetect() +// purpose : +//================================================================================= +void SMESHGUI_MergeNodesDlg::onDetect() +{ + if(myMesh->_is_nil()) + return; + + try + { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + + QApplication::setOverrideCursor(Qt::waitCursor); + ListCoincident->clear(); + ListEdit->clear(); + + SMESH::array_of_long_array_var aNodeGroups; + aMeshEditor->FindCoincidentNodes(SpinBoxTolerance->GetValue(), aNodeGroups); + + for ( int i = 0; i < aNodeGroups->length(); i++ ) + { + SMESH::long_array& aGroup = aNodeGroups[i]; + + QString aNodeIds; + for ( int j = 0; j < aGroup.length(); j++ ) + aNodeIds+=QString(" %1").arg(aGroup[j]); + + new QCheckListItem ( ListCoincident, aNodeIds, QCheckListItem::CheckBox ); + } + QApplication::restoreOverrideCursor(); + } + catch( ... ) + { + } + + updateControls(); +} + + +//================================================================================= +// function : onSelectNodesGroup() +// purpose : +//================================================================================= +void SMESHGUI_MergeNodesDlg::onSelectNodesGroup() +{ + if(!myActor) + return; + + myEditCurrentArgument = (QWidget*)ListCoincident; + + QListViewItem* aSelectedItem = ListCoincident->selectedItem(); + if (!aSelectedItem) + return; + + QStringList aListId = QStringList::split( " ", aSelectedItem->text(0), false); + + ListEdit->clear(); + ListEdit->insertStringList(aListId); + + mySelection->ClearIObjects(); + mySelection->AddIObject( myActor->getIO() ); + + SMESH::SetPointRepresentation(true); + QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + + ListEdit->selectAll(true); +} + + +//================================================================================= +// function : onSelectAll() +// purpose : +//================================================================================= +void SMESHGUI_MergeNodesDlg::onSelectAll(bool isToggled) +{ + if (isToggled) + { + int aNbItems = 0; + QListViewItem* item = ListCoincident->firstChild(); + while (item) + { + aNbItems++; + if (!((QCheckListItem*) item)->isOn()) + ((QCheckListItem*) item)->setOn(true); + item = item->itemBelow(); + } + + if (aNbItems) + { + buttonOk->setEnabled(true); + buttonApply->setEnabled(true); + } + } +} + + +//================================================================================= +// function : onSelectNodesFromGroup() +// purpose : +//================================================================================= +void SMESHGUI_MergeNodesDlg::onSelectNodesFromGroup() +{ + if (!myActor) + return; + + mySelection->ClearIObjects(); + + TColStd_MapOfInteger aIndexes; + QListBoxItem* anItem; + for (anItem = ListEdit->firstItem(); anItem != 0; anItem = anItem->next()) { + if (anItem->isSelected()) { + int anId = anItem->text().toInt(); + aIndexes.Add(anId); + } + } + mySelection->AddOrRemoveIndex(myActor->getIO(), aIndexes, false, false); + mySelection->AddIObject(myActor->getIO()); +} + + +//================================================================================= +// function : onAdd() +// purpose : +//================================================================================= +void SMESHGUI_MergeNodesDlg::onAdd() +{ + if (!myActor) + return; + + QString aListStr = ""; + int aNbNnodes = 0; + + aNbNnodes = SMESH::GetNameOfSelectedNodes(mySelection, myActor->getIO(), aListStr); + if (aNbNnodes < 1) + return; + + QStringList aNodes = QStringList::split(" ", aListStr); + QListBoxItem* anItem = 0; + + for (QStringList::iterator it = aNodes.begin(); it != aNodes.end(); ++it) { + anItem = ListEdit->findItem(*it, Qt::ExactMatch); + if (!anItem) { + anItem = new QListBoxText(*it); + ListEdit->insertItem(anItem); + } + ListEdit->setSelected(anItem, true); + } + + onEditNodesGroup(); +} + + +//================================================================================= +// function : onRemove() +// purpose : +//================================================================================= +void SMESHGUI_MergeNodesDlg::onRemove() +{ + if (myEditCurrentArgument != (QWidget*)ListCoincident) + return; + + for (int i = ListEdit->count(); i > 0; i--) + { + if (ListEdit->isSelected(i-1)) + ListEdit->removeItem(i-1); + } + onEditNodesGroup(); +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void SMESHGUI_MergeNodesDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + disconnect( mySelection, 0, this, 0 ); + mySelection->ClearIObjects(); + mySelection->ClearFilters(); + + if(send == SelectMeshButton) + { + myEditCurrentArgument = (QWidget*)LineEditMesh; + SMESH::SetPointRepresentation(false); + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + mySelection->AddFilter(myMeshOrSubMeshFilter) ; + } + + myEditCurrentArgument->setFocus(); + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + SelectionIntoArgument() ; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void SMESHGUI_MergeNodesDlg::SelectionIntoArgument() +{ + if (myEditCurrentArgument == (QWidget*)LineEditMesh) + { + QString aString = ""; + LineEditMesh->setText( aString ); + + ListCoincident->clear(); + ListEdit->clear(); + + int nbSel = SMESH::GetNameOfSelectedIObjects(mySelection, aString); + if(nbSel != 1) + return; + + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + myMesh = SMESH::IObjectToInterface(IO) ; + myActor = SMESH::FindActorByEntry( mySelection->firstIObject()->getEntry() ); + if(myMesh->_is_nil() || !myActor) + return; + + LineEditMesh->setText( aString ); + } +} + + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_MergeNodesDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupMesh->setEnabled(false); + GroupCoincident->setEnabled(false); + GroupEdit->setEnabled(false); + GroupButtons->setEnabled(false) ; + mySMESHGUI->ResetState() ; + mySMESHGUI->SetActiveDialogBox(0) ; + } +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_MergeNodesDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupMesh->setEnabled(true); + GroupCoincident->setEnabled(true); + GroupEdit->setEnabled(true); + GroupButtons->setEnabled(true) ; + + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + SelectionIntoArgument(); +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_MergeNodesDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_MergeNodesDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + ClickOnCancel() ; +} + + +//======================================================================= +//function : hideEvent +//purpose : caused by ESC key +//======================================================================= + +void SMESHGUI_MergeNodesDlg::hideEvent ( QHideEvent * e ) +{ + if ( !isMinimized() ) + ClickOnCancel(); +} diff --git a/src/SMESHGUI/SMESHGUI_MergeNodesDlg.h b/src/SMESHGUI/SMESHGUI_MergeNodesDlg.h new file mode 100644 index 000000000..ad390853b --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_MergeNodesDlg.h @@ -0,0 +1,134 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_MergeNodesDlg.h +// Author : Michael ZORIN +// Module : SMESH +// $Header: + +#ifndef DIALOGBOX_MERGENODES_H +#define DIALOGBOX_MERGENODES_H + +#include "SALOME_Selection.h" +#include "SMESH_TypeFilter.hxx" + +// QT Includes +#include + +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class QCheckBox; +class QListView; +class QListViewItem; +class QListBox; +class SMESHGUI; +class SMESHGUI_SpinBox; +class SMESH_Actor; + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) + + +//================================================================================= +// class : SMESHGUI_MergeNodesDlg +// purpose : +//================================================================================= +class SMESHGUI_MergeNodesDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_MergeNodesDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_MergeNodesDlg(); + +private: + + void Init() ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void hideEvent ( QHideEvent * ); /* ESC key */ + void onEditNodesGroup(); + + SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + + QWidget* myEditCurrentArgument; + + SMESH::SMESH_Mesh_var myMesh; + SMESH_Actor* myActor; + Handle(SMESH_TypeFilter) myMeshOrSubMeshFilter; + + QButtonGroup* GroupConstructors; + QRadioButton* RadioButton1; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + QGroupBox* GroupMesh; + QGroupBox* GroupCoincident; + QGroupBox* GroupEdit; + QLabel* TextLabelName; + QLabel* TextLabelTolerance; + QLineEdit* LineEditMesh; + QPushButton* SelectMeshButton; + QPushButton* DetectButton; + QPushButton* AddButton; + QPushButton* RemoveButton; + QCheckBox* SelectAllCB; + QListView* ListCoincident; + QListBox* ListEdit; + SMESHGUI_SpinBox* SpinBoxTolerance; + +private slots: + + void ClickOnOk(); + void ClickOnCancel(); + bool ClickOnApply(); + void updateControls(); + void onDetect(); + void onSelectNodesGroup(); + void onSelectAll(bool isToggled); + void onSelectNodesFromGroup(); + void onAdd(); + void onRemove(); + void SetEditCurrentArgument(); + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + +protected: + QGridLayout* SMESHGUI_MergeNodesDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupMeshLayout; + QGridLayout* GroupCoincidentLayout; + QGridLayout* GroupEditLayout; +}; + +#endif // DIALOGBOX_MERGENODES_H diff --git a/src/SMESHGUI/SMESHGUI_MeshInfosDlg.cxx b/src/SMESHGUI/SMESHGUI_MeshInfosDlg.cxx index b1946d689..40837ecde 100644 --- a/src/SMESHGUI/SMESHGUI_MeshInfosDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshInfosDlg.cxx @@ -26,15 +26,6 @@ // Module : SMESH // $Header$ -using namespace std; -#include "SMESHGUI_MeshInfosDlg.h" - -#include "SMESHGUI.h" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_WaitCursor.h" -#include "utilities.h" - // QT Includes #include #include @@ -44,6 +35,23 @@ using namespace std; #include #include +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_WaitCursor.h" + +#include "SMESHGUI_MeshInfosDlg.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI.h" + +// IDL Headers +#include "SALOMEconfig.h" +#include CORBA_SERVER_HEADER(SMESH_Mesh) +#include CORBA_SERVER_HEADER(SMESH_Group) + +#include "utilities.h" + +using namespace std; + #define COLONIZE( str ) ( QString( str ).contains( ":" ) > 0 ? QString( str ) : QString( str ) + " :" ) //================================================================================= @@ -367,7 +375,7 @@ void SMESHGUI_MeshInfosDlg::DumpMeshInfos() myStartSelection = false; mySelectLab->setText( "" ); Handle(SALOME_InteractiveObject) IObject = mySelection->firstIObject(); - SALOMEDS::SObject_var aSO = SMESHGUI::GetSMESHGUI()->GetStudy()->FindObjectID( IObject->getEntry() ); + SALOMEDS::SObject_var aSO = SMESH::GetActiveStudyDocument()->FindObjectID( IObject->getEntry() ); if ( !aSO->_is_nil() ) { CORBA::Object_var anObject = aSO->GetObject(); if ( !CORBA::is_nil( anObject ) ) { @@ -393,14 +401,14 @@ void SMESHGUI_MeshInfosDlg::DumpMeshInfos() myWGStack->raiseWidget( mySubMeshWidget ); setCaption( tr( "SMESH_MESHINFO_TITLE" ) + " [" + tr("SMESH_SUBMESH") +"]" ); mySubMeshName->setText( aSO->GetName() ); - mySubMeshNbNodes->setNum( (int)aSubMesh->GetNumberOfNodes() ); + mySubMeshNbNodes->setNum( (int)aSubMesh->GetNumberOfNodes( true ) ); mySubMeshNbElements->setNum( (int)aSubMesh->GetNumberOfElements() ); mySubMeshNbEdges->setNum( (int)( aSubMesh->GetElementsByType( SMESH::EDGE )->length() ) ); mySubMeshNbFaces->setNum( (int)( aSubMesh->GetElementsByType( SMESH::FACE )->length() ) ); mySubMeshNbVolumes->setNum( (int)( aSubMesh->GetElementsByType( SMESH::VOLUME )->length() ) ); return; } - SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_narrow( anObject ); + SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( anObject ); if ( !aGroup->_is_nil() ) { myWGStack->raiseWidget( myGroupWidget ); setCaption( tr( "SMESH_MESHINFO_TITLE" ) + " [" + tr("SMESH_GROUP") +"]" ); diff --git a/src/SMESHGUI/SMESHGUI_MeshInfosDlg.h b/src/SMESHGUI/SMESHGUI_MeshInfosDlg.h index c5f65073d..c8123d8c0 100644 --- a/src/SMESHGUI/SMESHGUI_MeshInfosDlg.h +++ b/src/SMESHGUI/SMESHGUI_MeshInfosDlg.h @@ -29,11 +29,6 @@ #ifndef SMESHGUI_MESHINFOSDLG_H #define SMESHGUI_MESHINFOSDLG_H -// IDL Headers -#include -#include CORBA_SERVER_HEADER(SMESH_Gen) -#include CORBA_SERVER_HEADER(SMESH_Mesh) - // QT Includes #include diff --git a/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx b/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx new file mode 100755 index 000000000..da8fde1c9 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_MeshPatternDlg.cxx @@ -0,0 +1,1151 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_MeshPatternDlg.cxx +// Author : Sergey LITONIN +// Module : SMESH + +#include "SMESHGUI_MeshPatternDlg.h" + +#include "QAD_Desktop.h" +#include "QAD_FileDlg.h" + +#include "SMESHGUI_SpinBox.h" +#include "SMESHGUI.h" +#include "SALOME_Selection.h" +#include "SMESH_NumberFilter.hxx" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_CreatePatternDlg.h" +#include "SMESHGUI_PatternWidget.h" +#include "SMESH_Actor.h" +#include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "VTKViewer_ViewFrame.h" +#include "SMESHGUI_PatternUtils.h" +#include "SMESH_ActorUtils.h" + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#define SPACING 5 +#define MARGIN 10 + +/* + Class : SMESHGUI_MeshPatternDlg + Description : Dialog to specify filters for VTK viewer +*/ + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::SMESHGUI_MeshPatternDlg +// Purpose : Constructor +//======================================================================= +SMESHGUI_MeshPatternDlg::SMESHGUI_MeshPatternDlg( QWidget* theParent, + SALOME_Selection* theSelection, + const char* theName ) +: QDialog( theParent, theName, false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + setCaption( tr( "CAPTION" ) ); + + QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); + + QFrame* aMainFrame = createMainFrame ( this ); + QFrame* aBtnFrame = createButtonFrame( this ); + + + + + aDlgLay->addWidget( aMainFrame ); + aDlgLay->addWidget( aBtnFrame ); + + aDlgLay->setStretchFactor( aMainFrame, 1 ); + + myCreationDlg = 0; + Init( theSelection ); +} + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::createMainFrame +// Purpose : Create frame containing dialog's input fields +//======================================================================= +QFrame* SMESHGUI_MeshPatternDlg::createMainFrame( QWidget* theParent ) +{ + QPixmap iconSlct( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_SELECT" ) ) ); + QPixmap icon2d ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_2d" ) ) ); + QPixmap icon3d ( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_3d" ) ) ); + QPixmap iconOpen( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_FILE_OPEN" ) ) ); + + QPixmap iconSample2d( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_SAMPLE_2D" ) ) ); + QPixmap iconSample3d( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", tr( "ICON_PATTERN_SAMPLE_3D" ) ) ); + + QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Horizontal, theParent ); + aMainGrp->setFrameStyle( QFrame::NoFrame ); + aMainGrp->setInsideMargin( 0 ); + + // Pattern type group + + myTypeGrp = new QButtonGroup( 1, Qt::Vertical, tr( "PATTERN_TYPE" ), aMainGrp ); + mySwitch2d = new QRadioButton( myTypeGrp ); + mySwitch3d = new QRadioButton( myTypeGrp ); + mySwitch2d->setPixmap( icon2d ); + mySwitch3d->setPixmap( icon3d ); + myTypeGrp->insert( mySwitch2d, Type_2d ); + myTypeGrp->insert( mySwitch3d, Type_3d ); + + + // Mesh group + + QGroupBox* aMeshGrp = new QGroupBox( 1, Qt::Vertical, tr( "SMESH_MESH" ), aMainGrp ); + new QLabel( tr( "SMESH_MESH" ), aMeshGrp ); + mySelBtn[ Mesh ] = new QPushButton( aMeshGrp ); + mySelBtn[ Mesh ]->setPixmap( iconSlct ); + mySelEdit[ Mesh ] = new QLineEdit( aMeshGrp ); + mySelEdit[ Mesh ]->setReadOnly( true ); + + // Pattern group + + QGroupBox* aPatGrp = new QGroupBox( 1, Qt::Horizontal, tr( "PATTERN" ), aMainGrp ); + + // pattern name + QGroupBox* aNameGrp = new QGroupBox( 1, Qt::Vertical, aPatGrp ); + aNameGrp->setFrameStyle( QFrame::NoFrame ); + aNameGrp->setInsideMargin( 0 ); + new QLabel( tr( "PATTERN" ), aNameGrp ); + myName = new QLineEdit( aNameGrp ); + myName->setReadOnly( true ); + myOpenBtn = new QPushButton( aNameGrp ); + myOpenBtn->setPixmap( iconOpen ); + myNewBtn = new QPushButton( tr( "NEW" ), aNameGrp ); + + // selection widgets + QGroupBox* aGrp = new QGroupBox( 3, Qt::Horizontal, aPatGrp ); + aGrp->setFrameStyle( QFrame::NoFrame ); + aGrp->setInsideMargin( 0 ); + + for ( int i = Object; i <= Vertex2; i++ ) + { + mySelLbl[ i ] = new QLabel( aGrp ); + mySelBtn[ i ] = new QPushButton( aGrp ); + mySelBtn[ i ]->setPixmap( iconSlct ); + mySelEdit[ i ] = new QLineEdit( aGrp ); + mySelEdit[ i ]->setReadOnly( true ); + } + + // reverse check box + myReverseChk = new QCheckBox( tr( "REVERSE" ), aPatGrp ); + + // Pictures 2d and 3d + for ( int i = 0; i < 2; i++ ) + { + QWidget* aPreview, *aPicture; + if ( i == 0 ) + { + myPicture2d = new SMESHGUI_PatternWidget( aPatGrp ), + myPicture2d->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Expanding ) ); + } + else + { + myPicture3d = new QFrame( aPatGrp ), + myPreview3d = new QLabel( myPicture3d ); + myPreview3d->setPixmap( iconSample3d ); + QGridLayout* aLay = new QGridLayout( myPicture3d, 3, 3, 0, 0 ); + QSpacerItem* aSpacerH1 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); + QSpacerItem* aSpacerH2 = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); + QSpacerItem* aSpacerV1 = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ); + QSpacerItem* aSpacerV2 = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ); + aLay->addItem( aSpacerH1, 1, 0 ); + aLay->addItem( aSpacerH2, 1, 2 ); + aLay->addItem( aSpacerV1, 0, 1 ); + aLay->addItem( aSpacerV2, 2, 1 ); + aLay->addWidget( myPreview3d, 1, 1 ); + } + } + + myPreviewChk = new QCheckBox( tr( "PREVIEW" ), aPatGrp ); + + // Connect signals and slots + + connect( myTypeGrp, SIGNAL( clicked( int ) ), SLOT( onTypeChanged( int ) ) ); + connect( myOpenBtn, SIGNAL( clicked() ), SLOT( onOpen() ) ); + connect( myNewBtn, SIGNAL( clicked() ), SLOT( onNew() ) ); + connect( myReverseChk, SIGNAL( toggled( bool ) ), SLOT( onReverse( bool ) ) ); + connect( myPreviewChk, SIGNAL( toggled( bool ) ), SLOT( onPreview( bool ) ) ); + + QMap< int, QPushButton* >::iterator anIter; + for ( anIter = mySelBtn.begin(); anIter != mySelBtn.end(); ++anIter ) + connect( *anIter, SIGNAL( clicked() ), SLOT( onSelInputChanged() ) ); + + return aMainGrp; +} + +//======================================================================= + +// name : SMESHGUI_MeshPatternDlg::createButtonFrame +// Purpose : Create frame containing buttons +//======================================================================= +QFrame* SMESHGUI_MeshPatternDlg::createButtonFrame( QWidget* theParent ) +{ + QFrame* aFrame = new QFrame( theParent ); + aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken ); + + myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), aFrame ); + myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), aFrame ); + myCloseBtn = new QPushButton( tr( "SMESH_BUT_CLOSE" ), aFrame ); + + QSpacerItem* aSpacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); + + QHBoxLayout* aLay = new QHBoxLayout( aFrame, MARGIN, SPACING ); + + aLay->addWidget( myOkBtn ); + aLay->addWidget( myApplyBtn ); + aLay->addItem( aSpacer); + aLay->addWidget( myCloseBtn ); + + connect( myOkBtn, SIGNAL( clicked() ), SLOT( onOk() ) ); + connect( myCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ) ; + connect( myApplyBtn, SIGNAL( clicked() ), SLOT( onApply() ) ); + + return aFrame; +} + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::~SMESHGUI_MeshPatternDlg +// Purpose : Destructor +//======================================================================= +SMESHGUI_MeshPatternDlg::~SMESHGUI_MeshPatternDlg() +{ +} + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::Init +// Purpose : Init dialog fields, connect signals and slots, show dialog +//======================================================================= +void SMESHGUI_MeshPatternDlg::Init( SALOME_Selection* theSelection ) +{ + myPattern = SMESH::GetPattern(); + myPreviewActor = 0; + myIsCreateDlgOpen = false; + mySelInput = Mesh; + myType = -1; + myNbPoints = -1; + mySelection = theSelection; + SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); + aSMESHGUI->SetActiveDialogBox( ( QDialog* )this ); + myMesh = SMESH::SMESH_Mesh::_nil(); + + myMeshShape = GEOM::GEOM_Object::_nil(); + myGeomObj[ Object ] = GEOM::GEOM_Object::_nil(); + myGeomObj[ Vertex1 ] = GEOM::GEOM_Object::_nil(); + myGeomObj[ Vertex2 ] = GEOM::GEOM_Object::_nil(); + + // selection and SMESHGUI + connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); + connect( aSMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( onDeactivate() ) ); + connect( aSMESHGUI, SIGNAL( SignalCloseAllDialogs() ), SLOT( onClose() ) ); + + myTypeGrp->setButton( Type_2d ); + onTypeChanged( Type_2d ); + + updateGeometry(); + + resize( minimumSize() ); + + activateSelection(); + onSelectionDone(); + + int x, y ; + aSMESHGUI->DefineDlgPosition( this, x, y ); + this->move( x, y ); + this->show(); +} + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::isValid +// Purpose : Verify validity of entry data +//======================================================================= +bool SMESHGUI_MeshPatternDlg::isValid( const bool theMess ) +{ + if ( myMesh->_is_nil() || myMeshShape->_is_nil() || myGeomObj[ Object ]->_is_nil() || + myGeomObj[ Vertex1 ]->_is_nil() || myType == Type_3d && myGeomObj[ Vertex2 ]->_is_nil() ) + { + if ( theMess ) + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_INSUFFICIENT_DATA" ), tr( "SMESHGUI_INVALID_PARAMETERS" ), QMessageBox::Ok ); + return false; + } + else + return true; +} + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::onApply +// Purpose : SLOT called when "Apply" button pressed. +//======================================================================= +bool SMESHGUI_MeshPatternDlg::onApply() +{ + try + { + if ( !isValid() ) + return false; + + if ( myType == Type_2d ) + myPattern->ApplyToFace( + myGeomObj[ Object ], myGeomObj[ Vertex1 ], myReverseChk->isChecked() ); + else + myPattern->ApplyTo3DBlock( + myGeomObj[ Object ], myGeomObj[ Vertex1 ], myGeomObj[ Vertex2 ] ); + + if ( myPattern->MakeMesh( myMesh ) ) + { + mySelection->ClearIObjects(); + SMESH::UpdateView(); + SMESHGUI::GetSMESHGUI()->GetActiveStudy()->updateObjBrowser( true ); + return true; + } + else + { + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_ERROR" ), tr( "SMESH_OPERATION_FAILED" ), QMessageBox::Ok ); + return false; + } + } + catch( const SALOME::SALOME_Exception& S_ex ) + { + QtCatchCorbaException( S_ex ); + } + catch( ... ) + { + } + + return false; +} + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::onOk +// Purpose : SLOT called when "Ok" button pressed. +//======================================================================= +void SMESHGUI_MeshPatternDlg::onOk() +{ + if ( onApply() ) + onClose(); +} + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::onClose +// Purpose : SLOT called when "Close" button pressed. Close dialog +//======================================================================= +void SMESHGUI_MeshPatternDlg::onClose() +{ + mySelection->ClearFilters(); + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + disconnect( mySelection, 0, this, 0 ); + disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); + SMESHGUI::GetSMESHGUI()->ResetState(); + erasePreview(); + reject(); +} + + + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::onSelectionDone +// Purpose : SLOT called when selection changed +//======================================================================= +void SMESHGUI_MeshPatternDlg::onSelectionDone() +{ + try + { + if ( mySelection->IObjectCount() != 1 ) + return; + + if ( mySelInput == Mesh ) + { + // Retrieve mesh from selection + Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject(); + SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface( anIO ); + if ( aMesh->_is_nil() ) + return; + + // Get geom object corresponding to the mesh + SALOMEDS::Study_var aStudy = + SMESHGUI::GetSMESHGUI()->GetActiveStudy()->getStudyDocument(); + + SALOMEDS::SObject_var aSO = SMESH::FindSObject( aMesh.in() ); + if ( aSO->_is_nil() ) + return; + + bool isFound = false; + SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator( aSO ); + for( ; anIter->More(); anIter->Next() ) + { + SALOMEDS::SObject_var aSO = anIter->Value(); + SALOMEDS::SObject_var aRefSO; + + GEOM::GEOM_Object_var aMeshShape = GEOM::GEOM_Object::_narrow( + aSO->ReferencedObject( aRefSO )? aRefSO->GetObject() : aSO->GetObject() ); + + if ( !aMeshShape->_is_nil() ) + { + isFound = true; + myMeshShape = aMeshShape; + break; + + } + } + + if ( !isFound ) + return; + + // Clear fields of geom objects if mesh was changed + if ( myMesh != aMesh ) + { + for ( int i = Object; i <= Vertex2; i++ ) + { + myGeomObj[ i ] = GEOM::GEOM_Object::_nil(); + mySelEdit[ i ]->setText( "" ); + } + } + + myMesh = aMesh; + + // Set name of mesh in line edit + QString aName; + SMESH::GetNameOfSelectedIObjects( mySelection, aName ); + mySelEdit[ Mesh ]->setText( aName ); + } + else + { + // Get geom object from selection + Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject(); + GEOM::GEOM_Object_var anObj = SMESH::IObjectToInterface( anIO ); + if ( anObj->_is_nil() ) + return; + + // Clear fields of vertexes if face or 3d block was changed + if ( anObj != myGeomObj[ mySelInput ] && mySelInput == Object ) + { + for ( int i = Vertex1; i <= Vertex2; i++ ) + { + myGeomObj[ i ] = GEOM::GEOM_Object::_nil(); + mySelEdit[ i ]->setText( "" ); + } + } + + myGeomObj[ mySelInput ] = anObj; + + // Set name of geom object in line edit + QString aName; + SMESH::GetNameOfSelectedIObjects( mySelection, aName ); + mySelEdit[ mySelInput ]->setText( aName ); + } + } + catch( const SALOME::SALOME_Exception& S_ex ) + { + QtCatchCorbaException( S_ex ); + resetSelInput(); + } + catch( ... ) + { + resetSelInput(); + } + + updateWgState(); + displayPreview(); +} + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::resetSelInput +// Purpose : Reset fields corresponding to the current selection input +//======================================================================= +void SMESHGUI_MeshPatternDlg::resetSelInput() +{ + if ( mySelInput == Mesh ) + { + myMesh = SMESH::SMESH_Mesh::_nil(); + myMeshShape = GEOM::GEOM_Object::_nil(); + } + + else + myGeomObj[ mySelInput ] = GEOM::GEOM_Object::_nil(); + + mySelEdit[ mySelInput ]->setText( "" ); +} + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::onDeactivate +// Purpose : SLOT called when dialog must be deativated +//======================================================================= +void SMESHGUI_MeshPatternDlg::onDeactivate() +{ + mySelection->ClearFilters(); + //if ( myReverseChk->isChecked() ) + // erasePreview(); + disconnect( mySelection, 0, this, 0 ); + setEnabled( false ); +} + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::enterEvent +// Purpose : Event filter +//======================================================================= +void SMESHGUI_MeshPatternDlg::enterEvent( QEvent* ) +{ + if ( myIsCreateDlgOpen ) + return; + + if ( myReverseChk->isChecked() ) + displayPreview(); + SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog() ; + setEnabled( true ); + activateSelection(); + connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_MeshPatternDlg::closeEvent( QCloseEvent* e ) +{ + onClose() ; +} + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::onSelInputChanged +// Purpose : SLOT. Called when -> button clicked. +// Change current selection input field +//======================================================================= +void SMESHGUI_MeshPatternDlg::onSelInputChanged() +{ + const QObject* aSender = sender(); + for ( int i = Mesh; i <= Vertex2; i++ ) + if ( aSender == mySelBtn[ i ] ) + mySelInput = i; + + activateSelection(); + onSelectionDone(); +} + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::prepareFilters +// Purpose : Prepare filters for dialog +//======================================================================= + +QStringList SMESHGUI_MeshPatternDlg::prepareFilters() const +{ + static QStringList aList; + if ( aList.isEmpty() ) + { + aList.append( tr( "PATTERN_FILT" ) ); + //aList.append( tr( "ALL_FILES_FILTER" ) ); + } + + return aList; +} + +//================================================================ + +// Function : SMESHGUI_MeshPatternDlg::autoExtension +// Purpose : Append extension to the file name +//================================================================ +QString SMESHGUI_MeshPatternDlg::autoExtension( const QString& theFileName ) const +{ + QString anExt = theFileName.section( '.', -1 ); + return anExt != "smp" && anExt != "SMP" ? theFileName + ".smp" : theFileName; +} + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::onOpen +// Purpose : SLOT. Called when "Open" button clicked. +// Displays file open dialog +//======================================================================= +void SMESHGUI_MeshPatternDlg::onOpen() +{ + QAD_FileDlg* aDlg = new QAD_FileDlg( this, true ); + aDlg->setCaption( tr( "LOAD_PATTERN" ) ); + aDlg->setMode( QFileDialogP::ExistingFile ); + aDlg->setFilters( prepareFilters() ); + if ( myName->text() != "" ) + aDlg->setSelection( myName->text() + ".smp" ); + QPushButton* anOkBtn = ( QPushButton* )aDlg->child( "OK", "QPushButton" ); + if ( anOkBtn != 0 ) + anOkBtn->setText( tr( "SMESH_BUT_OK" ) ); + + if ( aDlg->exec() != Accepted ) + return; + + QString fName = aDlg->selectedFile(); + if ( fName.isEmpty() ) + return; + + if ( QFileInfo( fName ).extension().isEmpty() ) + fName = autoExtension( fName ); + + fName = QDir::convertSeparators( fName ); + + QString prev = QDir::convertSeparators( myName->text() ); + if ( prev == fName ) + return; + + // Read string from file + QFile aFile( fName ); + if ( !aFile.open( IO_ReadOnly ) ) + { + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_ERROR" ), tr( "ERROR_OF_OPENING" ), QMessageBox::Ok ); + return; + } + + QByteArray aDataArray = aFile.readAll(); + const char* aData = aDataArray.data(); + if ( aData == 0 ) + { + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_ERROR" ), tr( "ERROR_OF_READING" ), QMessageBox::Ok ); + return; + } + + if ( loadFromFile( aData ) ) + myName->setText( QFileInfo( fName ).baseName() ); + + updateWgState(); + displayPreview(); +} + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::onCloseCreationDlg +// Purpose : SLOT. Called when "Pattern creation" dialog closed with "Close" +//======================================================================= +void SMESHGUI_MeshPatternDlg::onCloseCreationDlg() +{ + setEnabled( true ); + myIsCreateDlgOpen = false; +} + + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::onOkCreationDlg +// Purpose : SLOT. Called when "Pattern creation" dialog closed with OK +// or SAVE buttons. Initialize myPattern field. Redisplay preview +//======================================================================= +void SMESHGUI_MeshPatternDlg::onOkCreationDlg() +{ + myPattern = SMESH::SMESH_Pattern::_duplicate( myCreationDlg->GetPattern() ); + myName->setText( myCreationDlg->GetPatternName() ); + displayPreview(); + setEnabled( true ); + myIsCreateDlgOpen = false; +} + + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::onNew +// Purpose : SLOT. Called when "New..." button clicked. Create new pattern +//======================================================================= +void SMESHGUI_MeshPatternDlg::onNew() +{ + setEnabled( false ); + myIsCreateDlgOpen = true; + if ( myCreationDlg == 0 ) + { + myCreationDlg = new SMESHGUI_CreatePatternDlg( this, mySelection, myType ); + connect( myCreationDlg, SIGNAL( NewPattern() ), SLOT( onOkCreationDlg() ) ); + connect( myCreationDlg, SIGNAL( Close() ), SLOT( onCloseCreationDlg() ) ); + } + else + myCreationDlg->Init( mySelection, myType ); + + myCreationDlg->SetMesh( myMesh ); + myCreationDlg->show(); +} + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::onReverse +// Purpose : SLOT. Called when state of "Reverse order..." checkbox chaged +// Calculate new points of the mesh to be created. Redisplay preview +//======================================================================= +void SMESHGUI_MeshPatternDlg::onReverse( bool ) +{ + displayPreview(); +} + +//======================================================================= + +// name : SMESHGUI_MeshPatternDlg::onPreview +// Purpose : SLOT. Called when state of "Preview" checkbox changed +// Display/Erase preview +//======================================================================= +void SMESHGUI_MeshPatternDlg::onPreview( bool ) +{ + displayPreview(); +} + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::displayPreview +// Purpose : Display preview +//======================================================================= +void SMESHGUI_MeshPatternDlg::displayPreview() +{ + try + { + // Redisplay preview in dialog + + SMESH::point_array_var pnts = myPattern->GetPoints(); + SMESH::long_array_var keyPoints = myPattern->GetKeyPoints(); + SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints(); + + if ( pnts->length() == 0 || + keyPoints->length() == 0 || + elemPoints->length() == 0 ) + { + erasePreview(); + return; + } + + else + { + PointVector aPoints( pnts->length() ); + QValueVector aKeyPoints( keyPoints->length() ); + ConnectivityVector anElemPoints( elemPoints->length() ); + + for ( int i = 0, n = pnts->length(); i < n; i++ ) + aPoints[ i ] = pnts[ i ]; + + for ( int i2 = 0, n2 = keyPoints->length(); i2 < n2; i2++ ) + aKeyPoints[ i2 ] = keyPoints[ i2 ]; + + for ( int i3 = 0, n3 = elemPoints->length(); i3 < n3; i3++ ) + { + QValueVector aVec( elemPoints[ i3 ].length() ); + for ( int i4 = 0, n4 = elemPoints[ i3 ].length(); i4 < n4; i4++ ) + aVec[ i4 ] = elemPoints[ i3 ][ i4 ]; + + anElemPoints[ i3 ] = aVec; + } + + myPicture2d->SetPoints( aPoints, aKeyPoints, anElemPoints ); + } + + + // Redisplay preview in 3D viewer + + if ( myPreviewActor != 0 ) + { + if ( VTKViewer_ViewFrame* vf = SMESH::GetCurrentVtkView() ) + { + vf->RemoveActor(myPreviewActor); + vf->Repaint(); + } + myPreviewActor->Delete(); + myPreviewActor = 0; + } + + if ( !myPreviewChk->isChecked() || !isValid( false ) ) + return; + + vtkUnstructuredGrid* aGrid = getGrid(); + if ( aGrid == 0 ) + return; + + // Create and display actor + vtkDataSetMapper* aMapper = vtkDataSetMapper::New(); + aMapper->SetInput( aGrid ); + + myPreviewActor = SALOME_Actor::New(); + myPreviewActor->PickableOff(); + myPreviewActor->SetMapper( aMapper ); + + vtkProperty* aProp = vtkProperty::New(); + aProp->SetRepresentationToWireframe(); + aProp->SetColor( 250, 0, 250 ); + if ( SMESH_Actor* anActor = SMESH::FindActorByObject( myMesh ) ) + aProp->SetLineWidth( SMESH::GetFloat( "SMESH:SettingsWidth", 1 ) +1 ); + else + aProp->SetLineWidth( 1 ); + myPreviewActor->SetProperty( aProp ); + + myPreviewActor->SetRepresentation( 3 ); + + SMESH::GetCurrentVtkView()->AddActor( myPreviewActor ); + SMESH::GetCurrentVtkView()->Repaint(); + + aProp->Delete(); + aGrid->Delete(); + } + catch( const SALOME::SALOME_Exception& S_ex ) + { + QtCatchCorbaException( S_ex ); + erasePreview(); + } + catch( ... ) + { + erasePreview(); + } +} + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::erasePreview +// Purpose : Erase preview +//======================================================================= +void SMESHGUI_MeshPatternDlg::erasePreview() +{ + // Erase preview in 2D viewer + myPicture2d->SetPoints( PointVector(), QValueVector(), ConnectivityVector() ); + + // Erase preview in 3D viewer + if ( myPreviewActor == 0 ) + return; + + + if ( VTKViewer_ViewFrame* vf = SMESH::GetCurrentVtkView() ) + { + vf->RemoveActor(myPreviewActor); + vf->Repaint(); + } + myPreviewActor->Delete(); + myPreviewActor = 0; +} + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::updateWgState +// Purpose : Enable/disable selection widgets +//======================================================================= +void SMESHGUI_MeshPatternDlg::updateWgState() +{ + if ( myMesh->_is_nil() ) + { + for ( int i = Object; i <= Vertex2; i++ ) + { + mySelBtn [ i ]->setEnabled( false ); + mySelEdit[ i ]->setEnabled( false ); + mySelEdit[ i ]->setText( "" ); + } + } + else + { + mySelBtn [ Object ]->setEnabled( true ); + mySelEdit[ Object ]->setEnabled( true ); + + if ( myGeomObj[ Object ]->_is_nil() ) + { + for ( int i = Vertex1; i <= Vertex2; i++ ) + { + mySelBtn [ i ]->setEnabled( false ); + mySelEdit[ i ]->setEnabled( false ); + mySelEdit[ i ]->setText( "" ); + } + } + else + { + for ( int i = Object; i <= Vertex2; i++ ) + { + mySelBtn [ i ]->setEnabled( true ); + mySelEdit[ i ]->setEnabled( true ); + } + } + } +} + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::activateSelection +// Purpose : Activate selection in accordance with current selection input +//======================================================================= +void SMESHGUI_MeshPatternDlg::activateSelection() +{ + mySelection->ClearFilters(); + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + + if ( mySelInput == Object && !myMeshShape->_is_nil() ) + { + if ( myType == Type_2d ) + { + if ( myNbPoints > 0 ) + mySelection->AddFilter( new SMESH_NumberFilter( + + "GEOM", TopAbs_VERTEX, myNbPoints, TopAbs_FACE, myMeshShape ) ); + else + mySelection->AddFilter( new SMESH_NumberFilter( + "GEOM", TopAbs_SHAPE, myNbPoints, TopAbs_FACE, myMeshShape ) ); + } + else + { + TColStd_MapOfInteger aTypes; + aTypes.Add( TopAbs_SHELL ); + aTypes.Add( TopAbs_SOLID ); + mySelection->AddFilter( new SMESH_NumberFilter( + "GEOM", TopAbs_FACE, 6, aTypes, myMeshShape, true ) ); + } + } + else if ( ( mySelInput == Vertex1 || mySelInput == Vertex2 ) && !myGeomObj[ Object ]->_is_nil() ) + { + mySelection->AddFilter( new SMESH_NumberFilter( + "GEOM", TopAbs_SHAPE, 1, TopAbs_VERTEX, myGeomObj[ Object ] ) ); + } +} + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::loadFromFile +// Purpose : Load pattern from file +//======================================================================= +bool SMESHGUI_MeshPatternDlg::loadFromFile( const QString& theName ) +{ + try + { + SMESH::SMESH_Pattern_var aPattern = SMESH::GetPattern(); + + if ( !aPattern->LoadFromFile( theName.latin1() ) || + myType == Type_2d && !aPattern->Is2D()) + { + SMESH::SMESH_Pattern::ErrorCode aCode = aPattern->GetErrorCode(); + QString aMess; + if ( aCode == SMESH::SMESH_Pattern::ERR_READ_NB_POINTS ) aMess = tr( "ERR_READ_NB_POINTS" ); + else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_POINT_COORDS ) aMess = tr( "ERR_READ_POINT_COORDS" ); + else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_TOO_FEW_POINTS ) aMess = tr( "ERR_READ_TOO_FEW_POINTS" ); + else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_3D_COORD ) aMess = tr( "ERR_READ_3D_COORD" ); + else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_NO_KEYPOINT ) aMess = tr( "ERR_READ_NO_KEYPOINT" ); + else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_BAD_INDEX ) aMess = tr( "ERR_READ_BAD_INDEX" ); + else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_ELEM_POINTS ) aMess = tr( "ERR_READ_ELEM_POINTS" ); + else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_NO_ELEMS ) aMess = tr( "ERR_READ_NO_ELEMS" ); + else if ( aCode == SMESH::SMESH_Pattern::ERR_READ_BAD_KEY_POINT ) aMess = tr( "ERR_READ_BAD_KEY_POINT" ); + else aMess = tr( "ERROR_OF_LOADING" ); + + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_ERROR" ), aMess, QMessageBox::Ok ); + return false; + } + else + { + myPattern = aPattern; + return true; + } + } + catch( const SALOME::SALOME_Exception& S_ex ) + { + QtCatchCorbaException( S_ex ); + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_ERROR" ), tr( "ERROR_OF_LOADING" ), QMessageBox::Ok ); + return false; + } +} + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::onTypeChanged + +// Purpose : SLOT. Called when pattern type changed. +// Change dialog's look and feel +//======================================================================= +void SMESHGUI_MeshPatternDlg::onTypeChanged( int theType ) +{ + if ( myType == theType ) + return; + + myType = theType; + + myNbPoints = -1; + myGeomObj[ Object ] = GEOM::GEOM_Object::_nil(); + myGeomObj[ Vertex1 ] = GEOM::GEOM_Object::_nil(); + myGeomObj[ Vertex2 ] = GEOM::GEOM_Object::_nil(); + myPattern = SMESH::GetPattern(); + + myName->setText( "" ); + mySelEdit[ Object ]->setText( "" ); + mySelEdit[ Vertex1 ]->setText( "" ); + mySelEdit[ Vertex2 ]->setText( "" ); + + if ( theType == Type_2d ) + { + mySelLbl [ Vertex2 ]->hide(); + mySelBtn [ Vertex2 ]->hide(); + mySelEdit[ Vertex2 ]->hide(); + myReverseChk->show(); + myPicture2d->show(); + myPicture3d->hide(); + mySelLbl[ Object ]->setText( tr( "FACE" ) ); + mySelLbl[ Vertex1 ]->setText( tr( "VERTEX" ) ); + } + else + { + mySelLbl [ Vertex2 ]->show(); + mySelBtn [ Vertex2 ]->show(); + mySelEdit[ Vertex2 ]->show(); + myReverseChk->hide(); + myPicture2d->hide(); + myPicture3d->show(); + mySelLbl[ Object ]->setText( tr( "3D_BLOCK" ) ); + mySelLbl[ Vertex1 ]->setText( tr( "VERTEX1" ) ); + mySelLbl[ Vertex2 ]->setText( tr( "VERTEX2" ) ); + } + + mySelInput = Mesh; + activateSelection(); + updateWgState(); + displayPreview(); +} + +//======================================================================= +// name : SMESHGUI_MeshPatternDlg::getGrid +// Purpose : Get unstructured grid for pattern +//======================================================================= +vtkUnstructuredGrid* SMESHGUI_MeshPatternDlg::getGrid() +{ + try + { + // Get points from pattern + SMESH::point_array_var pnts = myType == Type_2d + ? myPattern->ApplyToFace( myGeomObj[ Object ], myGeomObj[ Vertex1 ], myReverseChk->isChecked() ) + : myPattern->ApplyTo3DBlock( myGeomObj[ Object ], myGeomObj[ Vertex1 ], myGeomObj[ Vertex2 ] ); + + SMESH::array_of_long_array_var elemPoints = myPattern->GetElementPoints(); + + if ( pnts->length() == 0 || elemPoints->length() == 0 ) + return 0; + + + + // to do : to be removed ///////////////////////////////////////////// + +#ifdef DEB_SLN + for ( int i1 = 0, n1 = pnts->length(); i1 < n1; i1++ ) + printf( "%d: %g %g %g\n", i1, pnts[ i1 ].x, pnts[ i1 ].y, pnts[ i1 ].z ); + + printf( "\nELEMENTS : \n" ); + for ( int i2 = 0, n2 = elemPoints->length(); i2 < n2; i2++ ) + { + + printf( "%d: ", i2 ); + for ( int i3 = 0, n3 = elemPoints[ i2 ].length(); i3 < n3; i3++ ) + printf( "%d ", elemPoints[ i2 ][ i3 ] ); + + printf( "\n" ); + + } +#endif + ////////////////////////////////////////////////////////////////////// + + // Calculate number of points used for cell + vtkIdType aNbCells = elemPoints->length(); + vtkIdType aCellsSize = 0; + for ( int i = 0, n = elemPoints->length(); i < n; i++ ) + aCellsSize += elemPoints[ i ].length(); + + // Create unstructured grid and other usefull arrays + vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New(); + + vtkCellArray* aConnectivity = vtkCellArray::New(); + aConnectivity->Allocate( aCellsSize, 0 ); + + vtkPoints* aPoints = vtkPoints::New(); + aPoints->SetNumberOfPoints( pnts->length() ); + + vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New(); + aCellTypesArray->SetNumberOfComponents( 1 ); + aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() ); + + vtkIdList *anIdList = vtkIdList::New(); + + // Fill array of points + for ( int p = 0, nbPnt = pnts->length(); p < nbPnt; p++ ) + aPoints->SetPoint( p, pnts[ p ].x, pnts[ p ].y, pnts[ p ].z ); + + for ( int e = 0, nbElem = elemPoints->length(); e < nbElem; e++ ) + { + int nbPoints = elemPoints[ e ].length(); + anIdList->SetNumberOfIds( nbPoints ); + for ( int i = 0; i < nbPoints; i++ ) + anIdList->SetId( i, elemPoints[ e ][ i ] ); + + aConnectivity->InsertNextCell( anIdList ); + + if ( nbPoints == 3 ) aCellTypesArray->InsertNextValue( VTK_TRIANGLE ); + else if ( nbPoints == 5 ) aCellTypesArray->InsertNextValue( VTK_PYRAMID ); + else if ( nbPoints == 6 ) aCellTypesArray->InsertNextValue( VTK_WEDGE ); + else if ( nbPoints == 8 ) aCellTypesArray->InsertNextValue( VTK_HEXAHEDRON ); + else if ( nbPoints == 4 && myType == Type_2d ) aCellTypesArray->InsertNextValue( VTK_QUAD ); + else if ( nbPoints == 4 && myType == Type_3d ) aCellTypesArray->InsertNextValue( VTK_TETRA ); + else aCellTypesArray->InsertNextValue( VTK_EMPTY_CELL ); + } + + vtkIntArray* aCellLocationsArray = vtkIntArray::New(); + aCellLocationsArray->SetNumberOfComponents( 1 ); + aCellLocationsArray->SetNumberOfTuples( aNbCells ); + + aConnectivity->InitTraversal(); + for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ ) + aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) ); + + aGrid->SetPoints( aPoints ); + aGrid->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity ); + + aConnectivity->Delete(); + aPoints->Delete(); + aCellTypesArray->Delete(); + anIdList->Delete(); + aCellLocationsArray->Delete(); + + return aGrid; + } + catch( ... ) + { + return 0; + } +} + + + + + + + + + + + + + + + + + + + + diff --git a/src/SMESHGUI/SMESHGUI_MeshPatternDlg.h b/src/SMESHGUI/SMESHGUI_MeshPatternDlg.h new file mode 100755 index 000000000..1c1787b0c --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_MeshPatternDlg.h @@ -0,0 +1,169 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_MeshPatternDlg.h +// Author : Sergey LITONIN +// Module : SMESH + + +#ifndef SMESHGUI_MeshPatternDlg_H +#define SMESHGUI_MeshPatternDlg_H + +#include + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(GEOM_Gen) +#include CORBA_SERVER_HEADER(SMESH_Mesh) +#include CORBA_SERVER_HEADER(SMESH_Pattern) + +class QCloseEvent; +class QFrame; +class QLineEdit; +class SMESHGUI_SpinBox; +class QPushButton; +class SALOME_Selection; +class QRadioButton; +class QCheckBox; +class QButtonGroup; +class QLabel; +class SMESHGUI_CreatePatternDlg; +class SMESHGUI_PatternWidget; +class vtkUnstructuredGrid; +class SALOME_Actor; + +/* + Class : SMESHGUI_MeshPatternDlg + Description : Dialog to specify filters for VTK viewer +*/ + +class SMESHGUI_MeshPatternDlg : public QDialog +{ + Q_OBJECT + + // Pattern type + enum { Type_2d, Type_3d }; + + // selection input + enum { Mesh, Object, Vertex1, Vertex2 }; + +public: + SMESHGUI_MeshPatternDlg( QWidget*, + SALOME_Selection*, + const char* = 0 ); + virtual ~SMESHGUI_MeshPatternDlg(); + + void Init( SALOME_Selection* ); + +private slots: + + void onOk(); + bool onApply(); + void onClose(); + + void onDeactivate(); + + void onSelectionDone(); + void onSelInputChanged(); + + void onTypeChanged( int ); + void onOpen(); + void onNew(); + void onReverse( bool ); + void onPreview( bool ); + void onOkCreationDlg(); + void onCloseCreationDlg(); + +private: + + QFrame* createButtonFrame( QWidget* ); + QFrame* createMainFrame ( QWidget* ); + void displayPreview(); + vtkUnstructuredGrid* getGrid(); + void erasePreview(); + void updateWgState(); + bool loadFromFile( const QString& ); + void activateSelection(); + QStringList prepareFilters() const; + QString autoExtension( const QString& theFileName ) const; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; + bool isValid( const bool theMess = true ); + void resetSelInput(); + +private: + + QPushButton* myOkBtn; + QPushButton* myApplyBtn; + QPushButton* myCloseBtn; + + QButtonGroup* myTypeGrp; + QRadioButton* mySwitch2d; + QRadioButton* mySwitch3d; + + QMap< int, QPushButton* > mySelBtn; + QMap< int, QLineEdit* > mySelEdit; + QMap< int, QLabel* > mySelLbl; + + QLineEdit* myName; + QPushButton* myOpenBtn; + QPushButton* myNewBtn; + + QCheckBox* myReverseChk; + SMESHGUI_PatternWidget* myPicture2d; + QFrame* myPicture3d; + QLabel* myPreview3d; + + QCheckBox* myPreviewChk; + + SALOME_Selection* mySelection; + int mySelInput; + int myNbPoints; + int myType; + bool myIsCreateDlgOpen; + + SMESH::SMESH_Mesh_var myMesh; + GEOM::GEOM_Object_var myMeshShape; + QMap< int, GEOM::GEOM_Object_var > myGeomObj; + + SMESHGUI_CreatePatternDlg* myCreationDlg; + SMESH::SMESH_Pattern_var myPattern; + SALOME_Actor* myPreviewActor; +}; + +#endif + + + + + + + + + + + + + + + + + diff --git a/src/SMESHGUI/SMESHGUI_MeshUtils.cxx b/src/SMESHGUI/SMESHGUI_MeshUtils.cxx new file mode 100644 index 000000000..9c8d313c6 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_MeshUtils.cxx @@ -0,0 +1,47 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + + +#include "SMESHGUI_MeshUtils.h" +#include "SMESHGUI_Utils.h" + +#include "SALOMEconfig.h" +#include CORBA_SERVER_HEADER(SMESH_Group) + +namespace SMESH +{ + + SMESH_Mesh_var GetMeshByIO(const Handle(SALOME_InteractiveObject)& theIO) + { + CORBA::Object_var anObj = IObjectToObject(theIO); + if(!CORBA::is_nil(anObj)){ + SMESH_Mesh_var aMesh = SMESH_Mesh::_narrow(anObj); + if(!CORBA::is_nil(aMesh)) + return aMesh; + SMESH_GroupBase_var aGroup = SMESH_GroupBase::_narrow(anObj); + if(!CORBA::is_nil(aGroup)) + return aGroup->GetMesh(); + SMESH_subMesh_var aSubMesh = SMESH_subMesh::_narrow(anObj); + if(!CORBA::is_nil(aSubMesh)) + return aSubMesh->GetFather(); + } + return SMESH_Mesh::_nil(); + } + +} diff --git a/src/SMESHGUI/SMESHGUI_MeshUtils.h b/src/SMESHGUI/SMESHGUI_MeshUtils.h new file mode 100644 index 000000000..011de3404 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_MeshUtils.h @@ -0,0 +1,36 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#ifndef SMESHGUI_MeshUtils_HeaderFile +#define SMESHGUI_MeshUtils_HeaderFile + +#include "SALOME_InteractiveObject.hxx" + +#include "SALOMEconfig.h" +#include CORBA_SERVER_HEADER(SMESH_Mesh) + + +namespace SMESH{ + + SMESH_Mesh_var GetMeshByIO(const Handle(SALOME_InteractiveObject)& theIO); + +} + + +#endif diff --git a/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx b/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx index f44ffac11..e163f8095 100644 --- a/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_MoveNodesDlg.cxx @@ -27,459 +27,529 @@ // $Header$ #include "SMESHGUI_MoveNodesDlg.h" + +#include "SMESHGUI.h" #include "SMESHGUI_SpinBox.h" +#include "SMESHGUI_IdValidator.h" + +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_MeshUtils.h" + #include "SMESH_Actor.h" -#include "SMESHGUI.h" +#include "SMDS_Mesh.hxx" +#include "SMDS_MeshNode.hxx" -#include "QAD_Application.h" +#include "SALOME_Selection.h" +#include "VTKViewer_ViewFrame.h" #include "QAD_Desktop.h" +#include "QAD_RightFrame.h" #include "QAD_MessageBox.h" + #include "utilities.h" -// QT Includes -#include +#include +#include +#include +#include +#include +#include +#include + #include #include #include #include #include #include -#include -#include -#include -#include #include +#include +#include + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) -// Open CASCADE Include -#include +#define MARGIN 10 +#define SPACING 5 -using namespace std; //================================================================================= // class : SMESHGUI_MoveNodesDlg() // purpose : //================================================================================= -SMESHGUI_MoveNodesDlg::SMESHGUI_MoveNodesDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, - bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +SMESHGUI_MoveNodesDlg::SMESHGUI_MoveNodesDlg( QWidget* theParent, + SALOME_Selection* theSelection, + const char* theName ) + +: QDialog( theParent, theName, false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) { - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_MOVE_NODE"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); - - if ( !name ) - setName( "SMESHGUI_MoveNodesDlg" ); - resize( 303, 185 ); - setCaption( tr( "SMESH_MOVE_NODES_TITLE" ) ); - setSizeGripEnabled( TRUE ); - SMESHGUI_MoveNodesDlgLayout = new QGridLayout( this ); - SMESHGUI_MoveNodesDlgLayout->setSpacing( 6 ); - SMESHGUI_MoveNodesDlgLayout->setMargin( 11 ); - - /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( tr( "SMESH_NODES" ) ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); - Constructor1->setText( tr( "" ) ); - Constructor1->setPixmap( image0 ); - Constructor1->setChecked( TRUE ); - Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); - Constructor1->setMinimumSize( QSize( 50, 0 ) ); - GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer, 0, 1 ); - SMESHGUI_MoveNodesDlgLayout->addWidget( GroupConstructors, 0, 0 ); - - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_9, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - SMESHGUI_MoveNodesDlgLayout->addWidget( GroupButtons, 3, 0 ); - - /***************************************************************/ - GroupC1 = new QGroupBox( this, "GroupC1" ); - GroupC1->setTitle( tr( "SMESH_MOVE" ) ); - GroupC1->setMinimumSize( QSize( 0, 0 ) ); - GroupC1->setFrameShape( QGroupBox::Box ); - GroupC1->setFrameShadow( QGroupBox::Sunken ); - GroupC1->setColumnLayout(0, Qt::Vertical ); - GroupC1->layout()->setSpacing( 0 ); - GroupC1->layout()->setMargin( 0 ); - GroupC1Layout = new QGridLayout( GroupC1->layout() ); - GroupC1Layout->setAlignment( Qt::AlignTop ); - GroupC1Layout->setSpacing( 6 ); - GroupC1Layout->setMargin( 11 ); - TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); - TextLabelC1A1->setText( tr( "SMESH_ID_NODES" ) ); - TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A1->setFrameShape( QLabel::NoFrame ); - TextLabelC1A1->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); - SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); - SelectButtonC1A1->setText( tr( "" ) ); - SelectButtonC1A1->setPixmap( image1 ); - SelectButtonC1A1->setToggleButton( FALSE ); - GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); - LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); - GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); - - SMESHGUI_MoveNodesDlgLayout->addWidget( GroupC1, 1, 0 ); - - /***************************************************************/ - GroupCoordinates = new QGroupBox( this, "GroupCoordinates" ); - GroupCoordinates->setTitle( tr( "SMESH_COORDINATES" ) ); - GroupCoordinates->setColumnLayout(0, Qt::Vertical ); - GroupCoordinates->layout()->setSpacing( 0 ); - GroupCoordinates->layout()->setMargin( 0 ); - GroupCoordinatesLayout = new QGridLayout( GroupCoordinates->layout() ); - GroupCoordinatesLayout->setAlignment( Qt::AlignTop ); - GroupCoordinatesLayout->setSpacing( 6 ); - GroupCoordinatesLayout->setMargin( 11 ); - TextLabel_X = new QLabel( GroupCoordinates, "TextLabel_X" ); - TextLabel_X->setText( tr( "SMESH_X" ) ); - GroupCoordinatesLayout->addWidget( TextLabel_X, 0, 0 ); - TextLabel_Y = new QLabel( GroupCoordinates, "TextLabel_Y" ); - TextLabel_Y->setText( tr( "SMESH_Y" ) ); - GroupCoordinatesLayout->addWidget( TextLabel_Y, 0, 2 ); + myPreviewActor = 0; + myBusy = false; + mySelection = 0; - SpinBox_X = new SMESHGUI_SpinBox( GroupCoordinates, "SpinBox_X" ) ; - GroupCoordinatesLayout->addWidget( SpinBox_X, 0, 1 ); - - SpinBox_Y = new SMESHGUI_SpinBox( GroupCoordinates, "SpinBox_Y" ) ; - GroupCoordinatesLayout->addWidget( SpinBox_Y, 0, 3 ); - - SpinBox_Z = new SMESHGUI_SpinBox( GroupCoordinates, "SpinBox_Z" ) ; - GroupCoordinatesLayout->addWidget( SpinBox_Z, 0, 5 ); + setCaption( tr( "CAPTION" ) ); + + QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); + QFrame* aMainFrame = createMainFrame ( this ); + QFrame* aBtnFrame = createButtonFrame( this ); - TextLabel_Z = new QLabel( GroupCoordinates, "TextLabel_Z" ); - TextLabel_Z->setText( tr( "SMESH_Z" ) ); - GroupCoordinatesLayout->addWidget( TextLabel_Z, 0, 4 ); + aDlgLay->addWidget( aMainFrame ); + aDlgLay->addWidget( aBtnFrame ); - SMESHGUI_MoveNodesDlgLayout->addWidget( GroupCoordinates, 2, 0 ); + aDlgLay->setStretchFactor( aMainFrame, 1 ); - Init(Sel) ; /* Initialisations */ + Init( theSelection ) ; } -//================================================================================= -// function : ~SMESHGUI_MoveNodesDlg() -// purpose : Destroys the object and frees any allocated resources -//================================================================================= -SMESHGUI_MoveNodesDlg::~SMESHGUI_MoveNodesDlg() +//======================================================================= +// name : SMESHGUI_MoveNodesDlg::createButtonFrame +// Purpose : Create frame containing buttons +//======================================================================= +QFrame* SMESHGUI_MoveNodesDlg::createButtonFrame( QWidget* theParent ) { - // no need to delete child widgets, Qt does it all for us -} + QFrame* aFrame = new QFrame( theParent ); + aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken ); + myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), aFrame ); + myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), aFrame ); + myCloseBtn = new QPushButton( tr( "SMESH_BUT_CLOSE" ), aFrame ); -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void SMESHGUI_MoveNodesDlg::Init( SALOME_Selection* Sel ) -{ + QSpacerItem* aSpacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); - /* Get setting of step value from file configuration */ - double step ; - // QString St = QAD_CONFIG->getSetting( "xxxxxxxxxxxxx" ) ; TODO - // step = St.toDouble() ; TODO - step = 25.0 ; - - GroupC1->show(); - myConstructorId = 0 ; - Constructor1->setChecked( TRUE ); - myEditCurrentArgument = LineEditC1A1 ; - mySelection = Sel; - this->myOkNodes = false ; - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; - - /* min, max, step and decimals for spin boxes */ - SpinBox_X->RangeStepAndValidator( -999.999, +999.999, step, 3 ) ; - SpinBox_Y->RangeStepAndValidator( -999.999, +999.999, step, 3 ) ; - SpinBox_Z->RangeStepAndValidator( -999.999, +999.999, step, 3 ) ; - SpinBox_X->SetValue( 0.0 ) ; - SpinBox_Y->SetValue( 0.0 ) ; - SpinBox_Z->SetValue( 0.0 ) ; - - /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); - - connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - /* to close dialog if study change */ - connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - - connect( SpinBox_X, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - connect( SpinBox_Y, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - connect( SpinBox_Z, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - - /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ + QHBoxLayout* aLay = new QHBoxLayout( aFrame, MARGIN, SPACING ); - SelectionIntoArgument(); - - return ; -} + aLay->addWidget( myOkBtn ); + aLay->addWidget( myApplyBtn ); + aLay->addItem( aSpacer); + aLay->addWidget( myCloseBtn ); + connect( myOkBtn, SIGNAL( clicked() ), SLOT( onOk() ) ); + connect( myCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ) ; + connect( myApplyBtn, SIGNAL( clicked() ), SLOT( onApply() ) ); -//================================================================================= -// function : ConstructorsClicked() -// purpose : Radio button management -//================================================================================= -void SMESHGUI_MoveNodesDlg::ConstructorsClicked(int constructorId) -{ - return ; + return aFrame; } +//======================================================================= +// name : SMESHGUI_MoveNodesDlg::createMainFrame +// Purpose : Create frame containing dialog's input fields +//======================================================================= +QFrame* SMESHGUI_MoveNodesDlg::createMainFrame( QWidget* theParent ) +{ + QFrame* aFrame = new QFrame( theParent ); + + QPixmap iconMoveNode( + QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr( "ICON_DLG_MOVE_NODE" ) ) ); + QPixmap iconSelect( + QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr( "ICON_SELECT" ) ) ); + + QButtonGroup* aPixGrp = new QButtonGroup( 1, Qt::Vertical, tr( "MESH_NODE" ), aFrame ); + aPixGrp->setExclusive( TRUE ); + QRadioButton* aRBut = new QRadioButton( aPixGrp ); + aRBut->setPixmap( iconMoveNode ); + aRBut->setChecked( TRUE ); + + QGroupBox* anIdGrp = new QGroupBox( 1, Qt::Vertical, tr( "SMESH_MOVE" ), aFrame ); + new QLabel( tr( "NODE_ID" ), anIdGrp ); + ( new QPushButton( anIdGrp ) )->setPixmap( iconSelect ); + myId = new QLineEdit( anIdGrp ); + myId->setValidator( new SMESHGUI_IdValidator( this, "validator", 1 )); + + QGroupBox* aCoordGrp = new QGroupBox( 1, Qt::Vertical, tr( "SMESH_COORDINATES" ), aFrame ); + new QLabel( tr( "SMESH_X" ), aCoordGrp ); + myX = new SMESHGUI_SpinBox( aCoordGrp ); + new QLabel( tr( "SMESH_Y" ), aCoordGrp ); + myY = new SMESHGUI_SpinBox( aCoordGrp ); + new QLabel( tr( "SMESH_Z" ), aCoordGrp ); + myZ = new SMESHGUI_SpinBox( aCoordGrp ); + + myX->RangeStepAndValidator( -999999.999, +999999.999, 25.0, 3 ); + myY->RangeStepAndValidator( -999999.999, +999999.999, 25.0, 3 ); + myZ->RangeStepAndValidator( -999999.999, +999999.999, 25.0, 3 ); + + QVBoxLayout* aLay = new QVBoxLayout( aFrame ); + aLay->addWidget( aPixGrp ); + aLay->addWidget( anIdGrp ); + aLay->addWidget( aCoordGrp ); + + // connect signale and slots + connect( myX, SIGNAL ( valueChanged( double) ), this, SLOT( redisplayPreview() ) ); + connect( myY, SIGNAL ( valueChanged( double) ), this, SLOT( redisplayPreview() ) ); + connect( myZ, SIGNAL ( valueChanged( double) ), this, SLOT( redisplayPreview() ) ); + connect( myId, SIGNAL( textChanged(const QString&) ), SLOT( onTextChange(const QString&) )); + + return aFrame; +} -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -void SMESHGUI_MoveNodesDlg::ClickOnApply() +//======================================================================= +// name : SMESHGUI_MoveNodesDlg::~SMESHGUI_MoveNodesDlg +// Purpose : +//======================================================================= +SMESHGUI_MoveNodesDlg::~SMESHGUI_MoveNodesDlg() { - switch(myConstructorId) - { - case 0 : - { - if(myOkNodes) { - mySMESHGUI->EraseSimulationActors(); -// mySMESHGUI->MoveNode( myMesh, myIdnode, LineEdit_X->text().toFloat(), LineEdit_Y->text().toFloat(), LineEdit_Z->text().toFloat() ) ; -// mySelection->ClearIObjects(); - } - break ; - } - } - return ; + erasePreview(); } -//================================================================================= -// function : ClickOnOk() -// purpose : -//================================================================================= -void SMESHGUI_MoveNodesDlg::ClickOnOk() +//======================================================================= +// name : SMESHGUI_MoveNodesDlg::Init +// Purpose : Init dialog fields +//======================================================================= +void SMESHGUI_MoveNodesDlg::Init( SALOME_Selection* theSelection ) { - this->ClickOnApply() ; - this->ClickOnCancel() ; + myPreviewActor = 0; + myMeshActor = 0; + myBusy = false; + mySelection = theSelection; + + SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); + aSMESHGUI->SetActiveDialogBox( ( QDialog* )this ) ; - return ; + // selection and SMESHGUI + connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); + connect( aSMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( onDeactivate() ) ); + connect( aSMESHGUI, SIGNAL( SignalCloseAllDialogs() ), SLOT( onClose() ) ); + + reset(); + setEnabled( true ); + + int x, y ; + aSMESHGUI->DefineDlgPosition( this, x, y ); + this->move( x, y ); + this->show(); + + // set selection mode + SMESH::SetPointRepresentation(true); + QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + onSelectionDone(); } - -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void SMESHGUI_MoveNodesDlg::ClickOnCancel() +//======================================================================= +// name : SMESHGUI_MoveNodesDlg::isValid +// Purpose : Verify validity of entry information +//======================================================================= +bool SMESHGUI_MoveNodesDlg::isValid( const bool theMess ) const { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - disconnect( mySelection, 0, this, 0 ); - mySMESHGUI->ResetState() ; - mySMESHGUI->EraseSimulationActors(); - reject() ; - return ; + if ( myId->text().isEmpty() ) + { + if ( theMess ) + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_WARNING" ), tr( "NODE_ID_IS_NOT_DEFINED" ), QMessageBox::Ok ); + return false; + } + return true; } - -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection as changed or other case -//================================================================================= -void SMESHGUI_MoveNodesDlg::SelectionIntoArgument() +//======================================================================= +// name : SMESHGUI_MoveNodesDlg::reset +// Purpose : Reset the dialog state +//======================================================================= +void SMESHGUI_MoveNodesDlg::reset() { + myId->clear(); + myX->SetValue( 0 ); + myY->SetValue( 0 ); + myZ->SetValue( 0 ); + redisplayPreview(); + updateButtons(); +} - disconnect( SpinBox_X, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - disconnect( SpinBox_Y, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - disconnect( SpinBox_Z, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - - mySMESHGUI->EraseSimulationActors(); - - myEditCurrentArgument->setText("") ; - myOkNodes = false; - QString aString = ""; +//======================================================================= +// name : SMESHGUI_MoveNodesDlg::nApply +// Purpose : SLOT called when "Apply" button pressed. +//======================================================================= +bool SMESHGUI_MoveNodesDlg::onApply() +{ + if (SMESHGUI::GetSMESHGUI()->ActiveStudyLocked()) + return false; + + if ( !isValid( true ) ) + return false; + + SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( myMeshActor->getIO() ); + if(aMesh->_is_nil() ) + { + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_ERROR" ), tr( "SMESHG_NO_MESH" ), QMessageBox::Ok ); + return false; + } - int nbSel = mySelection->IObjectCount(); - if(nbSel != 1) - return ; + SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor(); + if ( aMeshEditor->_is_nil() ) + return false; - int nbNodes = mySMESHGUI->GetNameOfSelectedNodes(mySelection, aString) ; - if(nbNodes != 1) { - SpinBox_X->SetValue(0.0) ; - SpinBox_Y->SetValue(0.0) ; - SpinBox_Z->SetValue(0.0) ; - return ; + int anId = myId->text().toInt(); + bool aResult = false; + try + { + aResult = aMeshEditor->MoveNode( anId, myX->GetValue(), myY->GetValue(), myZ->GetValue() ); } - - if ( mySelection->SelectionMode() != NodeSelection ){ - QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), - tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_OK") ); - return; + catch( ... ) + { } - myEditCurrentArgument->setText(aString) ; - Standard_Boolean res; - myMesh = mySMESHGUI->ConvertIOinMesh( mySelection->firstIObject(), res ); - if (!res) - return ; + if ( aResult ) + { + Handle(SALOME_InteractiveObject) anIO = myMeshActor->getIO(); + mySelection->ClearIObjects(); + SMESH::UpdateView(); + mySelection->AddIObject( anIO, false ); + reset(); + } + + return aResult; +} - SMESH_Actor* ac = mySMESHGUI->FindActorByEntry( mySelection->firstIObject()->getEntry(), res, false ); - if ( !res ) - return ; - mySelection->GetIndex( mySelection->firstIObject(), myMapIndex); +//======================================================================= +// name : SMESHGUI_MoveNodesDlg::onOk +// Purpose : SLOT called when "Ok" button pressed. +//======================================================================= +void SMESHGUI_MoveNodesDlg::onOk() +{ + if ( onApply() ) + onClose(); +} - TColStd_MapIteratorOfMapOfInteger ite( myMapIndex ); - if ( ite.More() ) { - myIdnode = ite.Key(); - mySimulationActor = mySMESHGUI->SimulationMoveNode( ac, myIdnode ); - } else - return ; - MESSAGE ( " myIdnode " << myIdnode ); +//======================================================================= +// name : SMESHGUI_MoveNodesDlg::onClose +// Purpose : SLOT called when "Close" button pressed. Close dialog +//======================================================================= +void SMESHGUI_MoveNodesDlg::onClose() +{ + mySelection->ClearIObjects(); + SMESH::SetPointRepresentation(false); + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + disconnect( mySelection, 0, this, 0 ); + disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); + SMESHGUI::GetSMESHGUI()->ResetState(); + reject(); +} - float *pt = ac->GetMapper()->GetInput()->GetPoint(myIdnode); - MESSAGE ( " pt " << pt[0] << ";" << pt[1] << ";" << pt[2] ) - SpinBox_X->SetValue( (double)pt[0] ) ; - SpinBox_Y->SetValue( (double)pt[1] ) ; - SpinBox_Z->SetValue( (double)pt[2] ) ; - connect( SpinBox_X, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - connect( SpinBox_Y, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - connect( SpinBox_Z, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; +//======================================================================= +//function : onTextChange +//purpose : +//======================================================================= - myOkNodes = true ; - return ; +void SMESHGUI_MoveNodesDlg::onTextChange(const QString& theNewText) +{ + if ( myBusy ) return; + + myOkBtn->setEnabled( false ); + myApplyBtn->setEnabled( false ); + erasePreview(); + + // select entered node + SMDS_Mesh* aMesh = 0; + if ( myMeshActor ) + aMesh = myMeshActor->GetObject()->GetMesh(); + if ( aMesh ) { + + myBusy = true; + mySelection->ClearIObjects(); + mySelection->AddIObject( myMeshActor->getIO() ); + myBusy = false; + + const SMDS_MeshElement * e = aMesh->FindElement( theNewText.toInt() ); + if ( e ) + mySelection->AddOrRemoveIndex (myMeshActor->getIO(), e->GetID(), true); + } } - -//================================================================================= -// function : SetEditCurrentArgument() -// purpose : -//================================================================================= -void SMESHGUI_MoveNodesDlg::SetEditCurrentArgument() +//======================================================================= +// name : SMESHGUI_MoveNodesDlg::onSelectionDone +// Purpose : SLOT called when selection changed +//======================================================================= +void SMESHGUI_MoveNodesDlg::onSelectionDone() { - QPushButton* send = (QPushButton*)sender(); - switch (myConstructorId) + if ( myBusy ) return; + myMeshActor = 0; + + if ( mySelection->IObjectCount() == 1 ) { + myMeshActor = SMESH::FindActorByEntry(mySelection->firstIObject()->getEntry()); + if ( myMeshActor ) { - case 0: /* default constructor */ - { - if(send == SelectButtonC1A1) { - LineEditC1A1->setFocus() ; - myEditCurrentArgument = LineEditC1A1; - } - SelectionIntoArgument() ; - break; + QString aText; + if ( SMESH::GetNameOfSelectedNodes( mySelection, aText ) == 1 ) { + if(SMDS_Mesh* aMesh = myMeshActor->GetObject()->GetMesh()) { + if(const SMDS_MeshNode* aNode = aMesh->FindNode(aText.toInt())) { + myBusy = true; + myId->setText( aText ); + myX->SetValue( aNode->X() ); + myY->SetValue( aNode->Y() ); + myZ->SetValue( aNode->Z() ); + myBusy = false; + erasePreview(); // avoid overlapping of a selection and a preview + updateButtons(); + return; + } + } } } - return ; + } + + reset(); } -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void SMESHGUI_MoveNodesDlg::DeactivateActiveDialog() + +//======================================================================= +// name : SMESHGUI_MoveNodesDlg::onDeactivate +// Purpose : SLOT called when dialog must be deativated +//======================================================================= +void SMESHGUI_MoveNodesDlg::onDeactivate() { - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupC1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - mySMESHGUI->EraseSimulationActors() ; - mySMESHGUI->ResetState() ; - mySMESHGUI->SetActiveDialogBox(0) ; - } - return ; + setEnabled( false ); + erasePreview(); } -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void SMESHGUI_MoveNodesDlg::ActivateThisDialog() +//======================================================================= +// name : SMESHGUI_MoveNodesDlg::enterEvent +// Purpose : Event filter +//======================================================================= +void SMESHGUI_MoveNodesDlg::enterEvent( QEvent* ) { - /* Emit a signal to deactivate the active dialog */ - mySMESHGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupC1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; + if ( !isEnabled() ) + { + SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); + + // set selection mode + SMESH::SetPointRepresentation(true); + QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + + redisplayPreview(); - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; - return ; + setEnabled( true ); + } } //================================================================================= -// function : enterEvent() +// function : closeEvent() // purpose : //================================================================================= -void SMESHGUI_MoveNodesDlg::enterEvent(QEvent* e) +void SMESHGUI_MoveNodesDlg::closeEvent( QCloseEvent* e ) { - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; - return ; + onClose() ; + SMESH::GetCurrentVtkView()->Repaint(); } +//======================================================================= +//function : hideEvent +//purpose : may be caused by ESC key +//======================================================================= -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void SMESHGUI_MoveNodesDlg::closeEvent( QCloseEvent* e ) +void SMESHGUI_MoveNodesDlg::hideEvent ( QHideEvent * e ) { - /* same than click on cancel button */ - this->ClickOnCancel() ; - return ; + if ( !isMinimized() ) + onClose(); } +//======================================================================= +// name : SMESHGUI_MoveNodesDlg::updateButtons +// Purpose : Update buttons state +//======================================================================= +void SMESHGUI_MoveNodesDlg::updateButtons() +{ + bool isEnabled = isValid( false ); + myOkBtn->setEnabled( isEnabled ); + myApplyBtn->setEnabled( isEnabled ); +} -//================================================================================= -// function : ValueChangedInSpinBox() -// purpose : -//================================================================================= -void SMESHGUI_MoveNodesDlg::ValueChangedInSpinBox( double newValue ) +//======================================================================= +// name : SMESHGUI_MoveNodesDlg::erasePreview +// Purpose : Erase preview +//======================================================================= +void SMESHGUI_MoveNodesDlg::erasePreview() +{ + if ( myPreviewActor == 0 ) + return; + + if ( VTKViewer_ViewFrame* vf = SMESH::GetCurrentVtkView() ) + vf->RemoveActor(myPreviewActor); + myPreviewActor->Delete(); + myPreviewActor = 0; + SMESH::GetCurrentVtkView()->Repaint(); +} + +//======================================================================= +// name : SMESHGUI_MoveNodesDlg::redisplayPreview +// Purpose : Redisplay preview +//======================================================================= +void SMESHGUI_MoveNodesDlg::redisplayPreview() { - double vx = SpinBox_X->GetValue() ; - double vy = SpinBox_Y->GetValue() ; - double vz = SpinBox_Z->GetValue() ; + if ( myBusy ) + return; + + if ( myPreviewActor != 0 ) + erasePreview(); + + if ( !isValid( false ) ) + return; + + vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New(); - mySMESHGUI->DisplaySimulationMoveNode( mySimulationActor, myIdnode, vx, vy , vz ); + vtkPoints* aPoints = vtkPoints::New(); + aPoints->SetNumberOfPoints( 1 ); + aPoints->SetPoint( 0, myX->GetValue(), myY->GetValue(), myZ->GetValue() ); + + // Create cells + + vtkIdList *anIdList = vtkIdList::New(); + anIdList->SetNumberOfIds( 1 ); + + vtkCellArray *aCells = vtkCellArray::New(); + aCells->Allocate( 2, 0 ); + + vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New(); + aCellTypesArray->SetNumberOfComponents( 1 ); + aCellTypesArray->Allocate( 1 ); + + anIdList->SetId( 0, 0 ); + aCells->InsertNextCell( anIdList ); + aCellTypesArray->InsertNextValue( VTK_VERTEX ); + + vtkIntArray* aCellLocationsArray = vtkIntArray::New(); + aCellLocationsArray->SetNumberOfComponents( 1 ); + aCellLocationsArray->SetNumberOfTuples( 1 ); + + aCells->InitTraversal(); + vtkIdType npts; + aCellLocationsArray->SetValue( 0, aCells->GetTraversalLocation( npts ) ); + + aGrid->SetCells( aCellTypesArray, aCellLocationsArray, aCells ); + + aGrid->SetPoints( aPoints ); + aGrid->SetCells( aCellTypesArray, aCellLocationsArray,aCells ); + + // Create and display actor + vtkDataSetMapper* aMapper = vtkDataSetMapper::New(); + aMapper->SetInput( aGrid ); + + myPreviewActor = SALOME_Actor::New(); + myPreviewActor->PickableOff(); + myPreviewActor->SetMapper( aMapper ); + + vtkProperty* aProp = vtkProperty::New(); + aProp->SetRepresentationToWireframe(); + aProp->SetColor( 250, 0, 250 ); + aProp->SetPointSize( 5 ); + myPreviewActor->SetProperty( aProp ); + + SMESH::GetCurrentVtkView()->AddActor( myPreviewActor ); + SMESH::GetCurrentVtkView()->Repaint(); + + aProp->Delete(); + aCellLocationsArray->Delete(); + aCellTypesArray->Delete(); + aCells->Delete(); + anIdList->Delete(); + aPoints->Delete(); + aGrid->Delete(); } + diff --git a/src/SMESHGUI/SMESHGUI_MoveNodesDlg.h b/src/SMESHGUI/SMESHGUI_MoveNodesDlg.h index a3ab0a7ce..c1b18de9c 100644 --- a/src/SMESHGUI/SMESHGUI_MoveNodesDlg.h +++ b/src/SMESHGUI/SMESHGUI_MoveNodesDlg.h @@ -29,33 +29,15 @@ #ifndef DIALOGBOX_MOVE_NODES_H #define DIALOGBOX_MOVE_NODES_H -#include "SALOME_Selection.h" - -// QT Includes -#include #include +#include "SALOME_Selection.h" -// Open CASCADE Includes -#include - -class QVBoxLayout; -class QHBoxLayout; -class QGridLayout; -class QButtonGroup; -class QGroupBox; -class QLabel; class QLineEdit; class QPushButton; -class QRadioButton; -class SMESHGUI; class SMESHGUI_SpinBox; - -// IDL Headers -#include -#include CORBA_SERVER_HEADER(SMESH_Mesh) - -// VTK Include -#include +class SALOME_Actor; +class QFrame; +class SMESH_Actor; //================================================================================= // class : SMESHGUI_MoveNodesDlg @@ -63,67 +45,57 @@ class SMESHGUI_SpinBox; //================================================================================= class SMESHGUI_MoveNodesDlg : public QDialog { - Q_OBJECT + Q_OBJECT public: - SMESHGUI_MoveNodesDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); - ~SMESHGUI_MoveNodesDlg(); + + SMESHGUI_MoveNodesDlg( QWidget*, + SALOME_Selection*, + const char* = 0 ); + virtual ~SMESHGUI_MoveNodesDlg(); + + void Init( SALOME_Selection* ) ; + +private slots: + + void onOk(); + bool onApply(); + void onClose(); + + void onDeactivate(); + + void onSelectionDone(); + void redisplayPreview(); + void onTextChange(const QString&); private: - void Init( SALOME_Selection* Sel ) ; - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ - - SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ - SALOME_Selection* mySelection ; /* User shape selection */ - bool myOkNodes ; /* to check when arguments is defined */ - int myConstructorId ; /* Current constructor id = radio button id */ - int myIdnode; - QLineEdit* myEditCurrentArgument; /* Current LineEdit */ - - SMESH::SMESH_Mesh_var myMesh; - TColStd_MapOfInteger myMapIndex; - - vtkActor *mySimulationActor; - - QGroupBox* GroupCoordinates; - QLabel* TextLabel_X; - QLabel* TextLabel_Y; - QLabel* TextLabel_Z; - SMESHGUI_SpinBox* SpinBox_X; - SMESHGUI_SpinBox* SpinBox_Y; - SMESHGUI_SpinBox* SpinBox_Z; - - QButtonGroup* GroupConstructors; - QRadioButton* Constructor1; - QGroupBox* GroupButtons; - QPushButton* buttonOk; - QPushButton* buttonCancel; - QPushButton* buttonApply; - QGroupBox* GroupC1; - QLabel* TextLabelC1A1; - QPushButton* SelectButtonC1A1; - QLineEdit* LineEditC1A1; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; + void hideEvent ( QHideEvent * ); + void erasePreview(); + QFrame* createButtonFrame( QWidget* ); + QFrame* createMainFrame ( QWidget* ); + bool isValid( const bool ) const; + void reset(); + void updateButtons(); -private slots: +private: - void ConstructorsClicked(int constructorId); - void ClickOnOk(); - void ClickOnCancel(); - void ClickOnApply(); - void SetEditCurrentArgument() ; - void SelectionIntoArgument() ; - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; - void ValueChangedInSpinBox( double newValue ) ; - -protected: - QGridLayout* SMESHGUI_MoveNodesDlgLayout; - QGridLayout* GroupConstructorsLayout; - QGridLayout* GroupButtonsLayout; - QGridLayout* GroupC1Layout; - QGridLayout* GroupCoordinatesLayout; + QPushButton* myOkBtn; + QPushButton* myApplyBtn; + QPushButton* myCloseBtn; + + QLineEdit* myId; + SMESHGUI_SpinBox* myX; + SMESHGUI_SpinBox* myY; + SMESHGUI_SpinBox* myZ; + + SALOME_Selection* mySelection; + + SALOME_Actor* myPreviewActor; + SMESH_Actor* myMeshActor; + bool myBusy; }; #endif // DIALOGBOX_MOVE_NODES_H diff --git a/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx b/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx new file mode 100755 index 000000000..da81e169e --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_MultiEditDlg.cxx @@ -0,0 +1,1123 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_MultiEditDlg.cxx +// Author : Sergey LITONIN +// Module : SMESH + +#include "SMESHGUI_MultiEditDlg.h" +#include "SMESHGUI_FilterDlg.h" +#include "SMESHGUI_Filter.h" + +#include "SMESHGUI.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_MeshUtils.h" + +#include "QAD_Desktop.h" +#include "QAD_RightFrame.h" + +#include "VTKViewer_ViewFrame.h" + +#include "SMESH_Actor.h" +#include "SMDS_Mesh.hxx" +#include "SMDS_MeshElement.hxx" + +#include "SALOME_Selection.h" +#include "SALOME_ListIteratorOfListIO.hxx" +#include "VTKViewer_InteractorStyleSALOME.h" + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SPACING 5 +#define MARGIN 10 + +/* + Class : SMESHGUI_MultiEditDlg + Description : Description : Inversion of the diagonal of a pseudo-quadrangle formed by + 2 neighboring triangles with 1 common edge +*/ + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::SMESHGUI_MultiEditDlg +// Purpose : Constructor +//======================================================================= +SMESHGUI_MultiEditDlg::SMESHGUI_MultiEditDlg( QWidget* theParent, + SALOME_Selection* theSelection, + const int theMode, + const char* theName ) +: QDialog( theParent, theName, false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + myFilterDlg = 0; + mySubmeshFilter = new SMESH_TypeFilter( SUBMESH ); + myGroupFilter = new SMESH_TypeFilter( GROUP ); + + myFilterType = theMode; + QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); + + QFrame* aMainFrame = createMainFrame ( this ); + QFrame* aBtnFrame = createButtonFrame( this ); + + aDlgLay->addWidget( aMainFrame ); + aDlgLay->addWidget( aBtnFrame ); + + aDlgLay->setStretchFactor( aMainFrame, 1 ); + aDlgLay->setStretchFactor( aBtnFrame, 0 ); + Init( theSelection ) ; +} + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::createMainFrame +// Purpose : Create frame containing dialog's input fields +//======================================================================= +QFrame* SMESHGUI_MultiEditDlg::createMainFrame( QWidget* theParent ) +{ + QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Horizontal, theParent ); + aMainGrp->setFrameStyle( QFrame::NoFrame ); + aMainGrp->setInsideMargin( 0 ); + + QPixmap aPix( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr( "ICON_SELECT" ) ) ); + + // "Selected cells" group + mySelGrp = new QGroupBox( 1, Qt::Horizontal, aMainGrp ); + QFrame* aFrame = new QFrame( mySelGrp ); + + myListBox = new QListBox( aFrame ); + myListBox->setSelectionMode( QListBox::Extended ); + myListBox->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding) ); +// myListBox->setColumnMode( QListBox::FitToHeight ); + + myFilterBtn = new QPushButton( tr( "FILTER" ) , aFrame ); + myAddBtn = new QPushButton( tr( "ADD" ) , aFrame ); + myRemoveBtn = new QPushButton( tr( "REMOVE" ) , aFrame ); + mySortBtn = new QPushButton( tr( "SORT_LIST" ), aFrame ); + + QGridLayout* aLay = new QGridLayout( aFrame, 5, 2, 0, 5 ); + aLay->addMultiCellWidget( myListBox, 0, 4, 0, 0 ); + aLay->addWidget( myFilterBtn, 0, 1 ); + aLay->addWidget( myAddBtn, 1, 1 ); + aLay->addWidget( myRemoveBtn, 2, 1 ); + aLay->addWidget( mySortBtn, 3, 1 ); + + QSpacerItem* aSpacer = new QSpacerItem( 0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding ); + aLay->addItem( aSpacer, 4, 1 ); + + myToAllChk = new QCheckBox( tr( "TO_ALL" ), mySelGrp ); + + // "Select from" group + QGroupBox* aGrp = new QGroupBox( 3, Qt::Horizontal, tr( "SELECT_FROM" ), aMainGrp ); + + mySubmeshChk = new QCheckBox( tr( "SMESH_SUBMESH" ), aGrp ); + mySubmeshBtn = new QPushButton( aGrp ); + mySubmesh = new QLineEdit( aGrp ); + mySubmeshBtn->setPixmap( aPix ); + + myGroupChk = new QCheckBox( tr( "GROUP" ), aGrp ); + myGroupBtn = new QPushButton( aGrp ); + myGroup = new QLineEdit( aGrp ); + myGroupBtn->setPixmap( aPix ); + + return aMainGrp; +} + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::createButtonFrame +// Purpose : Create frame containing buttons +//======================================================================= +QFrame* SMESHGUI_MultiEditDlg::createButtonFrame( QWidget* theParent ) +{ + QFrame* aFrame = new QFrame( theParent ); + aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken ); + + myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), aFrame ); + myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), aFrame ); + myCloseBtn = new QPushButton( tr( "SMESH_BUT_CLOSE" ), aFrame ); + + QSpacerItem* aSpacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); + + QHBoxLayout* aLay = new QHBoxLayout( aFrame, MARGIN, SPACING ); + + aLay->addWidget( myOkBtn ); + aLay->addWidget( myApplyBtn ); + aLay->addItem( aSpacer); + aLay->addWidget( myCloseBtn ); + + return aFrame; +} + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::isValid +// Purpose : Verify validity of input data +//======================================================================= +bool SMESHGUI_MultiEditDlg::isValid( const bool /*theMess*/ ) const +{ + return (!myMesh->_is_nil() && + (myListBox->count() > 0 || (myToAllChk->isChecked() && myActor))); +} + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::~SMESHGUI_MultiEditDlg +// Purpose : Destructor +//======================================================================= +SMESHGUI_MultiEditDlg::~SMESHGUI_MultiEditDlg() +{ + if ( myFilterDlg != 0 ) + { + myFilterDlg->reparent( 0, QPoint() ); + delete myFilterDlg; + } +} + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::Init +// Purpose : Init dialog fields, connect signals and slots, show dialog +//======================================================================= +void SMESHGUI_MultiEditDlg::Init( SALOME_Selection* theSelection ) +{ + SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); + mySelection = theSelection; + aSMESHGUI->SetActiveDialogBox( ( QDialog* )this ) ; + myListBox->clear(); + myIds.Clear(); + myBusy = false; + myActor = 0; + emit ListContensChanged(); + + // main buttons + connect( myOkBtn, SIGNAL( clicked() ), SLOT( onOk() ) ); + connect( myCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ) ; + connect( myApplyBtn, SIGNAL( clicked() ), SLOT( onApply() ) ); + + // selection and SMESHGUI + connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); + connect( aSMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( onDeactivate() ) ); + connect( aSMESHGUI, SIGNAL( SignalCloseAllDialogs() ), SLOT( onClose() ) ); + + // dialog controls + connect( myFilterBtn, SIGNAL( clicked() ), SLOT( onFilterBtn() ) ); + connect( myAddBtn , SIGNAL( clicked() ), SLOT( onAddBtn() ) ); + connect( myRemoveBtn, SIGNAL( clicked() ), SLOT( onRemoveBtn() ) ); + connect( mySortBtn , SIGNAL( clicked() ), SLOT( onSortListBtn() ) ); + + connect( mySubmeshChk, SIGNAL( stateChanged( int ) ), SLOT( onSubmeshChk() ) ); + connect( myGroupChk , SIGNAL( stateChanged( int ) ), SLOT( onGroupChk() ) ); + connect( myToAllChk , SIGNAL( stateChanged( int ) ), SLOT( onToAllChk() ) ); + + connect( myListBox, SIGNAL( selectionChanged() ), SLOT( onListSelectionChanged() ) ); + + onSelectionDone(); + + // set selection mode + setSelectionMode(); + updateButtons(); +} + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::onOk +// Purpose : SLOT called when "Ok" button pressed. +// Assign filters VTK viewer and close dialog +//======================================================================= +void SMESHGUI_MultiEditDlg::onOk() +{ + if ( onApply() ) + onClose(); +} + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::getIds +// Purpose : Retrive identifiers from list box +//======================================================================= +SMESH::long_array_var SMESHGUI_MultiEditDlg::getIds() +{ + SMESH::long_array_var anIds = new SMESH::long_array; + + if ( myToAllChk->isChecked() ) + { + myIds.Clear(); + if ( myActor != 0 ) + { + TVisualObjPtr aVisualObj = myActor->GetObject(); + vtkUnstructuredGrid* aGrid = aVisualObj->GetUnstructuredGrid(); + if ( aGrid != 0 ) + { + for ( int i = 0, n = aGrid->GetNumberOfCells(); i < n; i++ ) + { + vtkCell* aCell = aGrid->GetCell( i ); + if ( aCell != 0 ) + { + int nbNodes = aCell->GetNumberOfPoints(); + if ( nbNodes == 3 && myFilterType == SMESHGUI_TriaFilter || + nbNodes == 4 && myFilterType == SMESHGUI_QuadFilter || + ( nbNodes == 4 || nbNodes == 3 ) && myFilterType == SMESHGUI_UnknownFilter ) + { + int anObjId = aVisualObj->GetElemObjId( i ); + myIds.Add( anObjId ); + } + } + } + } + } + } + + anIds->length( myIds.Extent() ); + TColStd_MapIteratorOfMapOfInteger anIter( myIds ); + for ( int i = 0; anIter.More(); anIter.Next() ) + { + anIds[ i++ ] = anIter.Key(); + } + return anIds._retn(); +} + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::onClose +// Purpose : SLOT called when "Close" button pressed. Close dialog +//======================================================================= +void SMESHGUI_MultiEditDlg::onClose() +{ + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + disconnect( mySelection, 0, this, 0 ); + disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); + SMESHGUI::GetSMESHGUI()->ResetState(); + + SMESH::RemoveFilter(SMESHGUI_EdgeFilter); + SMESH::RemoveFilter(SMESHGUI_FaceFilter); + SMESH::RemoveFilter(SMESHGUI_QuadFilter); + SMESH::RemoveFilter(SMESHGUI_TriaFilter); + SMESH::SetPickable(); + + mySelection->ClearIObjects(); + mySelection->ClearFilters(); + + reject(); +} + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::onSelectionDone +// Purpose : SLOT called when selection changed +//======================================================================= +void SMESHGUI_MultiEditDlg::onSelectionDone() +{ + if ( myBusy || !isEnabled() ) return; + myBusy = true; + + int nbSel = mySelection->IObjectCount(); + myListBox->clearSelection(); + + if ( mySubmeshChk->isChecked() || myGroupChk->isChecked() ) + { + QLineEdit* aNameEdit = mySubmeshChk->isChecked() ? mySubmesh : myGroup; + int nbSel = mySelection->IObjectCount(); + if ( nbSel == 1 ) + { + Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject(); + anIO.IsNull() ? aNameEdit->clear() : aNameEdit->setText( anIO->getName() ); + + if ( mySubmeshChk->isChecked() ) + { + SMESH::SMESH_subMesh_var aSubMesh = + SMESH::IObjectToInterface( anIO ); + if ( !aSubMesh->_is_nil() ) + myMesh = aSubMesh->GetFather(); + } + else + { + SMESH::SMESH_GroupBase_var aGroup = + SMESH::IObjectToInterface( anIO ); + if ( !aGroup->_is_nil() ) + myMesh = aGroup->GetMesh(); + } + } + else if ( nbSel > 1 ) + { + QString aStr = mySubmeshChk->isChecked() ? + tr( "SMESH_SUBMESH_SELECTED" ) : tr( "SMESH_GROUP_SELECTED" ); + aNameEdit->setText( aStr.arg( nbSel ) ); + } + else + aNameEdit->clear(); + } + else if ( nbSel == 1 ) + { + QString aListStr = ""; + int aNbItems = SMESH::GetNameOfSelectedElements(mySelection, aListStr); + if ( aNbItems > 0 ) + { + QStringList anElements = QStringList::split(" ", aListStr); + QListBoxItem* anItem = 0; + for ( QStringList::iterator it = anElements.begin(); it != anElements.end(); ++it) + { + anItem = myListBox->findItem( *it, Qt::ExactMatch ); + if (anItem) myListBox->setSelected( anItem, true ); + } + } + + myMesh = SMESH::GetMeshByIO( mySelection->firstIObject() ); + } + + if ( nbSel == 1 ) { + myActor = SMESH::FindActorByEntry(mySelection->firstIObject()->getEntry()); + if (!myActor) + myActor = SMESH::FindActorByObject( myMesh ); + VTKViewer_InteractorStyleSALOME* aStyle = SMESH::GetInteractorStyle(); + Handle(VTKViewer_Filter) aFilter1 = aStyle->GetFilter( myFilterType ); + Handle(VTKViewer_Filter) aFilter2 = aStyle->GetFilter( SMESHGUI_FaceFilter ); + if ( !aFilter1.IsNull() ) + aFilter1->SetActor( myActor ); + if ( !aFilter2.IsNull() ) + aFilter2->SetActor( myActor ); + if ( myActor ) + SMESH::SetPickable(myActor); + } + myBusy = false; + + updateButtons(); +} + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::onDeactivate +// Purpose : SLOT called when dialog must be deativated +//======================================================================= +void SMESHGUI_MultiEditDlg::onDeactivate() +{ + setEnabled( false ); +} + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::enterEvent +// Purpose : Event filter +//======================================================================= +void SMESHGUI_MultiEditDlg::enterEvent( QEvent* ) +{ + if ( !isEnabled() ) { + SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); + setEnabled( true ); + setSelectionMode(); + } +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_MultiEditDlg::closeEvent( QCloseEvent* e ) +{ + onClose() ; +} +//======================================================================= +//function : hideEvent +//purpose : caused by ESC key +//======================================================================= + +void SMESHGUI_MultiEditDlg::hideEvent ( QHideEvent * e ) +{ + if ( !isMinimized() ) + onClose(); +} + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::onFilterBtn +// Purpose : SLOT. Called when "Filter" button pressed. +// Start "Selection filters" dialog +//======================================================================= +void SMESHGUI_MultiEditDlg::onFilterBtn() +{ + if ( myFilterDlg == 0 ) + { + myFilterDlg = new SMESHGUI_FilterDlg( (QWidget*)parent(), SMESH::FACE ); + connect( myFilterDlg, SIGNAL( Accepted() ), SLOT( onFilterAccepted() ) ); + } + else + myFilterDlg->Init( SMESH::FACE ); + + myFilterDlg->SetSelection( mySelection ); + myFilterDlg->SetMesh( myMesh ); + myFilterDlg->SetSourceWg( myListBox ); + + myFilterDlg->show(); +} + +//================================================================================= +// function : onFilterAccepted() +// purpose : SLOT. Called when Filter dlg closed with OK button. +// Uncheck "Select submesh" and "Select group" checkboxes +//================================================================================= +void SMESHGUI_MultiEditDlg::onFilterAccepted() +{ + myIds.Clear(); + for ( int i = 0, n = myListBox->count(); i < n; i++ ) + myIds.Add( myListBox->text( i ).toInt() ); + + emit ListContensChanged(); + + if ( mySubmeshChk->isChecked() || myGroupChk->isChecked() ) + { + mySubmeshChk->blockSignals( true ); + myGroupChk->blockSignals( true ); + mySubmeshChk->setChecked( false ); + myGroupChk->setChecked( false ); + mySubmeshChk->blockSignals( false ); + myGroupChk->blockSignals( false ); + } + updateButtons(); +} + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::onAddBtn +// Purpose : Verify whether Id of element satisfies to filters from viewer +//======================================================================= +bool SMESHGUI_MultiEditDlg::isIdValid( const int theId ) const +{ + VTKViewer_InteractorStyleSALOME* aStyle = SMESH::GetInteractorStyle(); + Handle(SMESHGUI_Filter) aFilter1 = + Handle(SMESHGUI_Filter)::DownCast( aStyle->GetFilter( myFilterType ) ); + Handle(SMESHGUI_Filter) aFilter2 = + Handle(SMESHGUI_Filter)::DownCast( aStyle->GetFilter( SMESHGUI_FaceFilter ) ); + return ( aFilter1.IsNull() || aFilter1->IsObjValid( theId ) ) && + ( aFilter2.IsNull() || aFilter2->IsObjValid( theId ) ); +} + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::onAddBtn +// Purpose : SLOT. Called when "Add" button pressed. +// Add selected in viewer entities in list box +//======================================================================= +void SMESHGUI_MultiEditDlg::onAddBtn() +{ + int nbSelected = mySelection->IObjectCount(); + if ( nbSelected == 0 ) + return; + + TColStd_IndexedMapOfInteger toBeAdded; + + if ( !mySubmeshChk->isChecked() && !myGroupChk->isChecked() ) + { + if ( nbSelected == 1 ) + SMESH::GetSelected( mySelection, toBeAdded ); + } + else if ( mySubmeshChk->isChecked() ) + { + SALOME_ListIteratorOfListIO anIter( mySelection->StoredIObjects() ); + for ( ; anIter.More(); anIter.Next() ) + { + SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface( anIter.Value() ); + if ( !aSubMesh->_is_nil() ) + { + if ( aSubMesh->GetFather()->GetId() == myMesh->GetId() ) + { + SMESH::long_array_var anIds = aSubMesh->GetElementsId(); + for ( int i = 0, n = anIds->length(); i < n; i++ ) + { + if ( isIdValid( anIds[ i ] ) ) + toBeAdded.Add( anIds[ i ] ); + } + } + } + } + } + else if ( myGroupChk->isChecked() ) + { + SALOME_ListIteratorOfListIO anIter( mySelection->StoredIObjects() ); + for ( ; anIter.More(); anIter.Next() ) + { + SMESH::SMESH_GroupBase_var aGroup = + SMESH::IObjectToInterface( anIter.Value() ); + if ( !aGroup->_is_nil() && aGroup->GetType() == SMESH::FACE ) + { + if ( aGroup->GetMesh()->GetId() == myMesh->GetId() ) + { + SMESH::long_array_var anIds = aGroup->GetListOfID(); + for ( int i = 0, n = anIds->length(); i < n; i++ ) + { + if ( isIdValid( anIds[ i ] ) ) + toBeAdded.Add( anIds[ i ] ); + } + } + } + } + } + + myBusy = true; + bool isGroupOrSubmesh = ( mySubmeshChk->isChecked() || myGroupChk->isChecked() ); + mySubmeshChk->setChecked( false ); + myGroupChk->setChecked( false ); + for( int i = 1; i <= toBeAdded.Extent(); i++ ) + if ( myIds.Add( toBeAdded(i) ) ) { + QListBoxItem * item = new QListBoxText( QString( "%1" ).arg( toBeAdded(i) )); + myListBox->insertItem( item ); + myListBox->setSelected( item, true ); + } + myBusy = false; + + emit ListContensChanged(); + + if ( isGroupOrSubmesh ) + onListSelectionChanged(); + + updateButtons(); +} + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::updateButtons +// Purpose : Enable/disable buttons of dialog in accordance with current state +//======================================================================= +void SMESHGUI_MultiEditDlg::updateButtons() +{ + bool isOk = isValid(false); + myOkBtn->setEnabled( isOk ); + myApplyBtn->setEnabled( isOk ); + + bool isListBoxNonEmpty = myListBox->count() > 0; + bool isToAll = myToAllChk->isChecked(); + myFilterBtn->setEnabled( !isToAll ); + myRemoveBtn->setEnabled( isListBoxNonEmpty && !isToAll ); + mySortBtn->setEnabled( isListBoxNonEmpty &&!isToAll ); + + if ( isToAll || + myMesh->_is_nil() || + mySelection->IObjectCount() != 1 || + (SMESH::IObjectToInterface( mySelection->firstIObject() )->_is_nil() && + SMESH::IObjectToInterface( mySelection->firstIObject() )->_is_nil() && + SMESH::IObjectToInterface( mySelection->firstIObject() )->_is_nil()) ) + myAddBtn->setEnabled( false ); + else + myAddBtn->setEnabled( true ); + + mySubmeshChk->setEnabled( !isToAll ); + mySubmeshBtn->setEnabled( mySubmeshChk->isChecked() ); + mySubmesh->setEnabled( mySubmeshChk->isChecked() ); + + myGroupChk->setEnabled( !isToAll ); + myGroupBtn->setEnabled( myGroupChk->isChecked() ); + myGroup->setEnabled( myGroupChk->isChecked() ); + + if ( !mySubmeshChk->isChecked() ) + mySubmesh->clear(); + if ( !myGroupChk->isChecked() ) + myGroup->clear(); + +} + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::onRemoveBtn +// Purpose : SLOT. Called when "Remove" button pressed. +// Remove selected in list box entities +//======================================================================= +void SMESHGUI_MultiEditDlg::onRemoveBtn() +{ + myBusy = true; + + for ( int i = 0, n = myListBox->count(); i < n; i++ ) + { + for ( int i = myListBox->count(); i > 0; i--) { + if ( myListBox->isSelected( i - 1 ) ) + { + int anId = myListBox->text( i - 1 ).toInt(); + myIds.Remove( anId ); + myIds.Remove( anId ); + myListBox->removeItem( i-1 ); + } + } + } + myBusy = false; + + emit ListContensChanged(); + updateButtons(); +} + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::onSortListBtn +// Purpose : SLOT. Called when "Sort list" button pressed. +// Sort entities of list box +//======================================================================= +void SMESHGUI_MultiEditDlg::onSortListBtn() +{ + myBusy = true; + + int i, k = myListBox->count(); + if ( k > 0 ) + { + QStringList aSelected; + std::vector anArray( k ); + QListBoxItem* anItem; + for ( anItem = myListBox->firstItem(), i = 0; anItem != 0; anItem = anItem->next(), i++) + { + anArray[ i ] = anItem->text().toInt(); + if ( anItem->isSelected() ) + aSelected.append( anItem->text() ); + } + + std::sort( anArray.begin(), anArray.end() ); + myListBox->clear(); + for ( i = 0; i < k; i++ ) + myListBox->insertItem( QString::number( anArray[ i ] ) ); + + for ( QStringList::iterator it = aSelected.begin(); it != aSelected.end(); ++it ) + { + anItem = myListBox->findItem( *it, Qt::ExactMatch ); + if ( anItem ) + myListBox->setSelected( anItem, true ); + } + } + myBusy = false; +} + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::onListSelectionChanged +// Purpose : SLOT. Called when selection in list box changed. +// Highlight in selected entities +//======================================================================= +void SMESHGUI_MultiEditDlg::onListSelectionChanged() +{ + if ( myActor == 0 || myBusy ) + return; + + if ( mySubmeshChk->isChecked() || myGroupChk->isChecked() ) + return; + + SMESH_Actor * anActor = SMESH::FindActorByObject( myMesh ); + if ( !anActor ) + anActor = myActor; + TVisualObjPtr anObj = anActor->GetObject(); + + TColStd_MapOfInteger anIndexes; + for ( QListBoxItem* anItem = myListBox->firstItem(); anItem != 0; anItem = anItem->next() ) + { + if ( anItem->isSelected() ) + { + int anId = anItem->text().toInt(); + if ( anObj->GetElemVTKId( anId ) >= 0 ) // avoid exception in hilight + anIndexes.Add(anId); + } + } + + mySelection->ClearIObjects(); + mySelection->AddOrRemoveIndex( anActor->getIO(), anIndexes, false, false ); + mySelection->AddIObject( anActor->getIO() ); +} + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::onSubmeshChk +// Purpose : SLOT. Called when state of "SubMesh" check box changed. +// Activate/deactivate selection of submeshes +//======================================================================= +void SMESHGUI_MultiEditDlg::onSubmeshChk() +{ + bool isChecked = mySubmeshChk->isChecked(); + mySubmeshBtn->setEnabled( isChecked ); + mySubmesh->setEnabled( isChecked ); + if ( !isChecked ) + mySubmesh->clear(); + if ( isChecked && myGroupChk->isChecked() ) + myGroupChk->setChecked( false ); + + setSelectionMode(); +} + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::onGroupChk +// Purpose : SLOT. Called when state of "Group" check box changed. +// Activate/deactivate selection of groupes +//======================================================================= +void SMESHGUI_MultiEditDlg::onGroupChk() +{ + bool isChecked = myGroupChk->isChecked(); + myGroupBtn->setEnabled( isChecked ); + myGroup->setEnabled( isChecked ); + if ( !isChecked ) + myGroup->clear(); + if ( isChecked && mySubmeshChk->isChecked() ) + mySubmeshChk->setChecked( false ); + + setSelectionMode(); +} + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::onToAllChk +// Purpose : SLOT. Called when state of "Apply to all" check box changed. +// Activate/deactivate selection +//======================================================================= +void SMESHGUI_MultiEditDlg::onToAllChk() +{ + bool isChecked = myToAllChk->isChecked(); + + if ( isChecked ) + myListBox->clear(); + + myIds.Clear(); + + emit ListContensChanged(); + + updateButtons(); + setSelectionMode(); + + if ( myActor ) + mySelection->AddIObject( myActor->getIO(), true ); +} + + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::setSelectionMode +// Purpose : Set selection mode +//======================================================================= +void SMESHGUI_MultiEditDlg::setSelectionMode() +{ + mySelection->ClearIObjects(); + mySelection->ClearFilters(); + + if ( mySubmeshChk->isChecked() ) + { + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection, true ); + mySelection->AddFilter( mySubmeshFilter ); + } + else if ( myGroupChk->isChecked() ) + { + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection, true ); + mySelection->AddFilter( myGroupFilter ); + } + else + { + QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true ); + if ( myFilterType == SMESHGUI_TriaFilter ) + SMESH::SetFilter( new SMESHGUI_TriangleFilter() ); + else if ( myFilterType == SMESHGUI_QuadFilter ) + SMESH::SetFilter( new SMESHGUI_QuadrangleFilter() ); + } +} + +//======================================================================= +// name : SMESHGUI_MultiEditDlg::onApply +// Purpose : SLOT. Called when "Apply" button clicked. +//======================================================================= +bool SMESHGUI_MultiEditDlg::onApply() +{ + if ( SMESHGUI::GetSMESHGUI()->ActiveStudyLocked() ) + return false; + if ( !isValid( true ) ) + return false; + + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + if ( aMeshEditor->_is_nil() ) + return false; + + SMESH::long_array_var anIds = getIds(); + + bool aResult = process( aMeshEditor, anIds.inout() ); + if ( aResult ) + { + if ( myActor ) + { + mySelection->ClearIObjects(); + SMESH::UpdateView(); + mySelection->AddIObject( myActor->getIO(), false ); + } + + myListBox->clear(); + myIds.Clear(); + emit ListContensChanged(); + + updateButtons(); + } + + return aResult; +} + +/* + Class : SMESHGUI_ChangeOrientationDlg + Description : Modification of orientation of faces +*/ + +SMESHGUI_ChangeOrientationDlg::SMESHGUI_ChangeOrientationDlg( QWidget* theParent, + SALOME_Selection* theSelection, + const char* theName ) +: SMESHGUI_MultiEditDlg( theParent, theSelection, SMESHGUI_UnknownFilter, theName ) +{ + setCaption( tr( "CAPTION" ) ); +} + +SMESHGUI_ChangeOrientationDlg::~SMESHGUI_ChangeOrientationDlg() +{ +} + +bool SMESHGUI_ChangeOrientationDlg::process( SMESH::SMESH_MeshEditor_ptr theEditor, + const SMESH::long_array& theIds ) +{ + return theEditor->Reorient( theIds ); +} + +/* + Class : SMESHGUI_UnionOfTrianglesDlg + Description : Construction of quadrangles by automatic association of triangles +*/ + +SMESHGUI_UnionOfTrianglesDlg::SMESHGUI_UnionOfTrianglesDlg( QWidget* theParent, + SALOME_Selection* theSelection, + const char* theName ) +: SMESHGUI_MultiEditDlg( theParent, theSelection, SMESHGUI_TriaFilter, theName ) +{ + setCaption( tr( "CAPTION" ) ); +} + +SMESHGUI_UnionOfTrianglesDlg::~SMESHGUI_UnionOfTrianglesDlg() +{ +} + +bool SMESHGUI_UnionOfTrianglesDlg::process( SMESH::SMESH_MeshEditor_ptr theEditor, + const SMESH::long_array& theIds ) +{ + return theEditor->TriToQuad(theIds, SMESH::NumericalFunctor::_nil(), 1. ); +} + +/* + Class : SMESHGUI_CuttingOfQuadsDlg + Description : Construction of quadrangles by automatic association of triangles +*/ + +SMESHGUI_CuttingOfQuadsDlg::SMESHGUI_CuttingOfQuadsDlg( QWidget* theParent, + SALOME_Selection* theSelection, + const char* theName ) +: SMESHGUI_MultiEditDlg( theParent, theSelection, SMESHGUI_QuadFilter, theName ) +{ + + setCaption( tr( "CAPTION" ) ); + myPreviewActor = 0; + + myUseDiagChk = new QCheckBox( tr( "USE_DIAGONAL_2_4" ), mySelGrp ); + myPreviewChk = new QCheckBox( tr( "PREVIEW" ), mySelGrp ); + + connect( myPreviewChk, SIGNAL( stateChanged( int ) ), this, SLOT( onPreviewChk() ) ); + connect( myUseDiagChk, SIGNAL( stateChanged( int ) ), this, SLOT( onPreviewChk() ) ); + connect( this, SIGNAL( ListContensChanged() ), this, SLOT( onPreviewChk() ) ); +} + +SMESHGUI_CuttingOfQuadsDlg::~SMESHGUI_CuttingOfQuadsDlg() +{ +} + +void SMESHGUI_CuttingOfQuadsDlg::onClose() +{ + erasePreview(); + SMESHGUI_MultiEditDlg::onClose(); +} + +bool SMESHGUI_CuttingOfQuadsDlg::process( SMESH::SMESH_MeshEditor_ptr theEditor, + const SMESH::long_array& theIds ) +{ + return theEditor->SplitQuad( theIds, !myUseDiagChk->isChecked() ); +} + +void SMESHGUI_CuttingOfQuadsDlg::onPreviewChk() +{ + myPreviewChk->isChecked() ? displayPreview() : erasePreview(); +} + +void SMESHGUI_CuttingOfQuadsDlg::erasePreview() +{ + if ( myPreviewActor == 0 ) + return; + + if ( VTKViewer_ViewFrame* vf = SMESH::GetCurrentVtkView() ) + { + vf->RemoveActor(myPreviewActor); + vf->Repaint(); + } + myPreviewActor->Delete(); + myPreviewActor = 0; +} + +void SMESHGUI_CuttingOfQuadsDlg::displayPreview() +{ + if ( myActor == 0 ) + return; + + if ( myPreviewActor != 0 ) + erasePreview(); + + // get Ids of elements + SMESH::long_array_var anElemIds = getIds(); + if ( getIds()->length() == 0 ) + return; + + SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh(); + if ( aMesh == 0 ) + return; + + bool isDiag24 = myUseDiagChk->isChecked(); + + //Create grid + vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New(); + + vtkIdType aNbCells = anElemIds->length() * 2; + vtkIdType aCellsSize = 4 * aNbCells; + vtkCellArray* aConnectivity = vtkCellArray::New(); + aConnectivity->Allocate( aCellsSize, 0 ); + + vtkPoints* aPoints = vtkPoints::New(); + aPoints->SetNumberOfPoints( anElemIds->length() * 4 ); + + vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New(); + aCellTypesArray->SetNumberOfComponents( 1 ); + aCellTypesArray->Allocate( aNbCells * aCellTypesArray->GetNumberOfComponents() ); + + vtkIdList *anIdList = vtkIdList::New(); + anIdList->SetNumberOfIds( 3 ); + + TColStd_DataMapOfIntegerInteger anIdToVtk; + + int aNodes[ 4 ]; + int nbPoints = -1; + for ( int i = 0, n = anElemIds->length(); i < n; i++ ) + { + const SMDS_MeshElement* anElem = aMesh->FindElement( anElemIds[ i ] ); + if ( anElem == 0 || anElem->NbNodes() != 4 ) + continue; + + SMDS_ElemIteratorPtr anIter = anElem->nodesIterator(); + int k = 0; + while( anIter->more() ) + if ( const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next() ) + { + if ( !anIdToVtk.IsBound( aNode->GetID() ) ) + { + aPoints->SetPoint( ++nbPoints, aNode->X(), aNode->Y(), aNode->Z() ); + anIdToVtk.Bind( aNode->GetID(), nbPoints ); + } + + aNodes[ k++ ] = aNode->GetID(); + } + + if ( k != 4 ) + continue; + + if ( !isDiag24 ) + { + anIdList->SetId( 0, anIdToVtk( aNodes[ 0 ] ) ); + anIdList->SetId( 1, anIdToVtk( aNodes[ 1 ] ) ); + anIdList->SetId( 2, anIdToVtk( aNodes[ 2 ] ) ); + aConnectivity->InsertNextCell( anIdList ); + aCellTypesArray->InsertNextValue( VTK_TRIANGLE ); + + anIdList->SetId( 0, anIdToVtk( aNodes[ 2 ] ) ); + anIdList->SetId( 1, anIdToVtk( aNodes[ 3 ] ) ); + anIdList->SetId( 2, anIdToVtk( aNodes[ 0 ] ) ); + aConnectivity->InsertNextCell( anIdList ); + aCellTypesArray->InsertNextValue( VTK_TRIANGLE ); + } + else + { + anIdList->SetId( 0, anIdToVtk( aNodes[ 1 ] ) ); + anIdList->SetId( 1, anIdToVtk( aNodes[ 2 ] ) ); + anIdList->SetId( 2, anIdToVtk( aNodes[ 3 ] ) ); + aConnectivity->InsertNextCell( anIdList ); + aCellTypesArray->InsertNextValue( VTK_TRIANGLE ); + + anIdList->SetId( 0, anIdToVtk( aNodes[ 3 ] ) ); + anIdList->SetId( 1, anIdToVtk( aNodes[ 0 ] ) ); + anIdList->SetId( 2, anIdToVtk( aNodes[ 1 ] ) ); + aConnectivity->InsertNextCell( anIdList ); + aCellTypesArray->InsertNextValue( VTK_TRIANGLE ); + } + } + + vtkIntArray* aCellLocationsArray = vtkIntArray::New(); + aCellLocationsArray->SetNumberOfComponents( 1 ); + aCellLocationsArray->SetNumberOfTuples( aNbCells ); + + aConnectivity->InitTraversal(); + for( vtkIdType idType = 0, *pts, npts; aConnectivity->GetNextCell( npts, pts ); idType++ ) + aCellLocationsArray->SetValue( idType, aConnectivity->GetTraversalLocation( npts ) ); + + aGrid->SetPoints( aPoints ); + aGrid->SetCells( aCellTypesArray, aCellLocationsArray,aConnectivity ); + + // Create and display actor + vtkDataSetMapper* aMapper = vtkDataSetMapper::New(); + aMapper->SetInput( aGrid ); + + myPreviewActor = SALOME_Actor::New(); + myPreviewActor->PickableOff(); + myPreviewActor->SetMapper( aMapper ); + + vtkProperty* aProp = vtkProperty::New(); + aProp->SetRepresentationToWireframe(); + aProp->SetColor( 250, 0, 250 ); + aProp->SetLineWidth( myActor->GetLineWidth() + 1 ); + myPreviewActor->SetProperty( aProp ); + + SMESH::GetCurrentVtkView()->AddActor( myPreviewActor ); + SMESH::GetCurrentVtkView()->Repaint(); + + aProp->Delete(); + aPoints->Delete(); + aConnectivity->Delete(); + aGrid->Delete(); + aMapper->Delete(); + anIdList->Delete(); + aCellTypesArray->Delete(); + aCellLocationsArray->Delete(); +} + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SMESHGUI/SMESHGUI_MultiEditDlg.h b/src/SMESHGUI/SMESHGUI_MultiEditDlg.h new file mode 100755 index 000000000..a35f51758 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_MultiEditDlg.h @@ -0,0 +1,209 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_MultiEditDlg.h +// Author : Sergey LITONIN +// Module : SMESH + + +#ifndef SMESHGUI_MultiEditDlg_H +#define SMESHGUI_MultiEditDlg_H + +#include +#include "SMESH_TypeFilter.hxx" +#include + +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +class QCloseEvent; +class SMESHGUI_FilterDlg; +class QCheckBox; +class QGroupBox; +class QListBox; +class QFrame; +class QLineEdit; +class SMESHGUI_SpinBox; +class QPushButton; +class SALOME_Selection; +class SMESH_Actor; +class SALOME_Actor; + +/* + Class : SMESHGUI_MultiEditDlg + Description : Base class for dialogs of diagonal inversion and + union of two neighboring triangles +*/ + +class SMESHGUI_MultiEditDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_MultiEditDlg( QWidget*, + SALOME_Selection*, + const int, + const char* = 0 ); + virtual ~SMESHGUI_MultiEditDlg(); + + void Init( SALOME_Selection* ) ; + +signals: + void ListContensChanged(); + +protected slots: + + void onOk(); + virtual bool onApply(); + virtual void onClose(); + + void onDeactivate(); + void onSelectionDone(); + + void onFilterBtn(); + void onAddBtn(); + void onRemoveBtn(); + void onSortListBtn(); + void onListSelectionChanged(); + void onSubmeshChk(); + void onGroupChk(); + virtual void onToAllChk(); + void onFilterAccepted(); + +protected: + + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; + void hideEvent ( QHideEvent * ); /* ESC key */ + QFrame* createButtonFrame( QWidget* ); + QFrame* createMainFrame ( QWidget* ); + bool isValid( const bool ) const; + SMESH::long_array_var getIds(); + void updateButtons(); + void setSelectionMode(); + virtual bool isIdValid( const int theID ) const; + virtual bool process( SMESH::SMESH_MeshEditor_ptr, const SMESH::long_array& ) = 0; + +protected: + + QPushButton* myOkBtn; + QPushButton* myApplyBtn; + QPushButton* myCloseBtn; + SALOME_Selection* mySelection; + SMESH::SMESH_Mesh_var myMesh; + SMESH_Actor* myActor; + + QGroupBox* mySelGrp; + + QListBox* myListBox; + QPushButton* myFilterBtn; + QPushButton* myAddBtn; + QPushButton* myRemoveBtn; + QPushButton* mySortBtn; + + QCheckBox* myToAllChk; + + QCheckBox* mySubmeshChk; + QPushButton* mySubmeshBtn; + QLineEdit* mySubmesh; + + QCheckBox* myGroupChk; + QPushButton* myGroupBtn; + QLineEdit* myGroup; + + SMESHGUI_FilterDlg* myFilterDlg; + TColStd_MapOfInteger myIds; + int myFilterType; + Handle(SMESH_TypeFilter) mySubmeshFilter; + Handle(SMESH_TypeFilter) myGroupFilter; + bool myBusy; +}; + +/* + Class : SMESHGUI_ChangeOrientationDlg + Description : Modification of orientation of faces +*/ +class SMESHGUI_ChangeOrientationDlg : public SMESHGUI_MultiEditDlg +{ + Q_OBJECT + +public: + SMESHGUI_ChangeOrientationDlg( QWidget*, + SALOME_Selection*, + const char* = 0 ); + virtual ~SMESHGUI_ChangeOrientationDlg(); + +protected: + + virtual bool process( SMESH::SMESH_MeshEditor_ptr, const SMESH::long_array& ); +}; + +/* + Class : SMESHGUI_UnionOfTrianglesDlg + Description : Construction of quadrangles by automatic association of triangles +*/ +class SMESHGUI_UnionOfTrianglesDlg : public SMESHGUI_MultiEditDlg +{ + Q_OBJECT + +public: + SMESHGUI_UnionOfTrianglesDlg( QWidget*, + SALOME_Selection*, + const char* = 0 ); + virtual ~SMESHGUI_UnionOfTrianglesDlg(); + +protected: + + virtual bool process( SMESH::SMESH_MeshEditor_ptr, const SMESH::long_array& ); +}; + +/* + Class : SMESHGUI_CuttingOfQuadsDlg + Description : Construction of quadrangles by automatic association of triangles +*/ +class SMESHGUI_CuttingOfQuadsDlg : public SMESHGUI_MultiEditDlg +{ + Q_OBJECT + +public: + SMESHGUI_CuttingOfQuadsDlg( QWidget*, + SALOME_Selection*, + const char* = 0 ); + virtual ~SMESHGUI_CuttingOfQuadsDlg(); + +protected: + virtual bool process( SMESH::SMESH_MeshEditor_ptr, const SMESH::long_array& ); + +protected slots: + virtual void onClose(); + void onPreviewChk(); + +private: + void displayPreview(); + void erasePreview(); + +private: + QCheckBox* myUseDiagChk; + SALOME_Actor* myPreviewActor; + QCheckBox* myPreviewChk; +}; + +#endif diff --git a/src/SMESHGUI/SMESHGUI_NodesDlg.cxx b/src/SMESHGUI/SMESHGUI_NodesDlg.cxx index 5ae62afc1..872c2015f 100644 --- a/src/SMESHGUI/SMESHGUI_NodesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_NodesDlg.cxx @@ -26,27 +26,39 @@ // Module : SMESH // $Header$ -using namespace std; #include "SMESHGUI_NodesDlg.h" + #include "SMESHGUI.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_MeshUtils.h" + +#include "SMESHGUI_VTKUtils.h" +#include "SMESH_ActorUtils.h" + +#include "VTKViewer_ViewFrame.h" +#include "SALOME_Actor.h" + #include "SMESHGUI_SpinBox.h" #include "QAD_Application.h" #include "QAD_Desktop.h" -#include "utilities.h" +#include "QAD_WaitCursor.h" #include "QAD_MessageBox.h" #include "SMESH_Actor.h" -#include -#include +#include "SMDS_Mesh.hxx" +#include "SMDS_MeshNode.hxx" // VTK Includes -#include -#include -#include -#include +#include #include -#include +#include +#include +#include +#include +#include +#include +#include // QT Includes #include @@ -65,6 +77,150 @@ using namespace std; #include #include +#include "utilities.h" + +using namespace std; + + +namespace SMESH{ + + void AddNode(SMESH::SMESH_Mesh_ptr theMesh, float x, float y, float z){ + QAD_WaitCursor wc; + try{ + SALOMEDS::SObject_var aSobj = SMESH::FindSObject(theMesh); + CORBA::String_var anEntry = aSobj->GetID(); + SMESH::SMESH_MeshEditor_var aMeshEditor = theMesh->GetMeshEditor(); + aMeshEditor->AddNode(x,y,z); + SALOMEDS::Study_var aStudy = GetActiveStudyDocument(); + CORBA::Long anId = aStudy->StudyId(); + if(TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,anEntry.in())){ + aVisualObj->Update(true); + } + }catch(SALOME::SALOME_Exception& exc) { + INFOS("Follow exception was cought:\n\t"<getActiveStudyFrame()), + myViewFrame(GetVtkViewFrame(theStudy->getActiveStudyFrame())) + { + vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New(); + + // Create points + myPoints = vtkPoints::New(); + myPoints->SetNumberOfPoints( 1 ); + myPoints->SetPoint(0,0.0,0.0,0.0); + + // Create cells + vtkIdList *anIdList = vtkIdList::New(); + anIdList->SetNumberOfIds( 1 ); + + vtkCellArray *aCells = vtkCellArray::New(); + aCells->Allocate( 2, 0 ); + + vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New(); + aCellTypesArray->SetNumberOfComponents( 1 ); + aCellTypesArray->Allocate( 1 ); + + anIdList->SetId( 0, 0 ); + aCells->InsertNextCell( anIdList ); + aCellTypesArray->InsertNextValue( VTK_VERTEX ); + + vtkIntArray* aCellLocationsArray = vtkIntArray::New(); + aCellLocationsArray->SetNumberOfComponents( 1 ); + aCellLocationsArray->SetNumberOfTuples( 1 ); + + aCells->InitTraversal(); + vtkIdType npts; + aCellLocationsArray->SetValue( 0, aCells->GetTraversalLocation( npts ) ); + + aGrid->SetCells( aCellTypesArray, aCellLocationsArray, aCells ); + + aGrid->SetPoints( myPoints ); + aGrid->SetCells( aCellTypesArray, aCellLocationsArray,aCells ); + aCellLocationsArray->Delete(); + aCellTypesArray->Delete(); + aCells->Delete(); + anIdList->Delete(); + + // Create and display actor + myMapper = vtkDataSetMapper::New(); + myMapper->SetInput( aGrid ); + aGrid->Delete(); + + myPreviewActor = SALOME_Actor::New(); + myPreviewActor->SetInfinitive(true); + myPreviewActor->VisibilityOff(); + myPreviewActor->PickableOff(); + myPreviewActor->SetMapper( myMapper ); + + vtkProperty* aProp = vtkProperty::New(); + aProp->SetRepresentationToPoints(); + + float anRGB[3]; + anRGB[0] = GetFloat("SMESH:SettingsNodeColorRed",0)/255.; + anRGB[1] = GetFloat("SMESH:SettingsNodeColorGreen",255)/255.; + anRGB[2] = GetFloat("SMESH:SettingsNodeColorBlue",0)/255.; + aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); + + float aPointSize = GetFloat("SMESH:SettingsNodesSize",3); + aProp->SetPointSize(aPointSize); + + myPreviewActor->SetProperty( aProp ); + aProp->Delete(); + + myViewFrame->AddActor( myPreviewActor ); + + } + + + void SetPosition(float x, float y, float z){ + myPoints->SetPoint(0,x,y,z); + myPoints->Modified(); + SetVisibility(true); + } + + + void SetVisibility(bool theVisibility){ + myPreviewActor->SetVisibility(theVisibility); + RepaintCurrentView(); + } + + + ~TNodeSimulation(){ + if(FindVtkViewFrame(myStudy,myStudyFrame)){ + myViewFrame->RemoveActor(myPreviewActor); + } + myPreviewActor->Delete(); + + myMapper->RemoveAllInputs(); + myMapper->Delete(); + + myPoints->Delete(); + } + + }; + +} + //================================================================================= // class : SMESHGUI_NodesDlg() @@ -75,9 +231,11 @@ SMESHGUI_NodesDlg::SMESHGUI_NodesDlg( QWidget* parent, SALOME_Selection* Sel, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | + Qt::WDestructiveClose) { - + mySimulation = new SMESH::TNodeSimulation(SMESH::GetActiveStudy()); + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_NODE"))); if ( !name ) setName( "SMESHGUI_NodesDlg" ); @@ -178,7 +336,9 @@ SMESHGUI_NodesDlg::SMESHGUI_NodesDlg( QWidget* parent, // purpose : Destructor //======================================================================= SMESHGUI_NodesDlg::~SMESHGUI_NodesDlg() -{} +{ + delete mySimulation; +} //================================================================================= @@ -210,14 +370,14 @@ void SMESHGUI_NodesDlg::Init(SALOME_Selection* Sel) connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ); connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - connect( SpinBox_X, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - connect( SpinBox_Y, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - connect( SpinBox_Z, SIGNAL ( valueChanged( double) ), this, SLOT( ValueChangedInSpinBox( double) ) ) ; - - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - connect( myMeshGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - /* to close dialog if study change */ - connect( myMeshGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + connect( SpinBox_X, SIGNAL ( valueChanged(double) ), SLOT( ValueChangedInSpinBox(double) )) ; + connect( SpinBox_Y, SIGNAL ( valueChanged(double) ), SLOT( ValueChangedInSpinBox(double) )) ; + connect( SpinBox_Z, SIGNAL ( valueChanged(double) ), SLOT( ValueChangedInSpinBox(double) )) ; + + connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( SelectionIntoArgument() )); + connect( myMeshGUI, SIGNAL ( SignalDeactivateActiveDialog() ), SLOT( DeactivateActiveDialog() )) ; + /* to close dialog if study frame change */ + connect( myMeshGUI, SIGNAL ( SignalStudyFrameChanged() ), SLOT( ClickOnCancel() ) ) ; /* Move widget on the botton right corner of main widget */ int x, y ; @@ -225,6 +385,10 @@ void SMESHGUI_NodesDlg::Init(SALOME_Selection* Sel) this->move( x, y ) ; this->show() ; + // set selection mode + SMESH::SetPointRepresentation(true); + QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + SelectionIntoArgument(); } @@ -234,12 +398,13 @@ void SMESHGUI_NodesDlg::Init(SALOME_Selection* Sel) //================================================================================= void SMESHGUI_NodesDlg::ValueChangedInSpinBox( double newValue ) { - double vx = SpinBox_X->GetValue() ; - double vy = SpinBox_Y->GetValue() ; - double vz = SpinBox_Z->GetValue() ; - myMeshGUI->DisplaySimulationNode( myMesh, vx, vy, vz ); - //myMeshGUI->ViewNodes(); + if(!myMesh->_is_nil()){ + double vx = SpinBox_X->GetValue() ; + double vy = SpinBox_Y->GetValue() ; + double vz = SpinBox_Z->GetValue() ; + mySimulation->SetPosition(vx,vy,vz); + } return ; } @@ -249,32 +414,54 @@ void SMESHGUI_NodesDlg::ValueChangedInSpinBox( double newValue ) //================================================================================= void SMESHGUI_NodesDlg::ClickOnOk() { - this->ClickOnApply() ; - this->ClickOnCancel() ; - - return ; + if ( ClickOnApply() ) + ClickOnCancel() ; } //======================================================================= // function : ClickOnApply() // purpose : //======================================================================= -void SMESHGUI_NodesDlg::ClickOnApply() +bool SMESHGUI_NodesDlg::ClickOnApply() { - if ( myMeshGUI->GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) { - return; + if (myMeshGUI->ActiveStudyLocked()) + return false; + + if ( myMesh->_is_nil() ) { + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + tr("SMESH_WRN_WARNING"), + tr("MESH_IS_NOT_SELECTED"), + tr("SMESH_BUT_OK")); + return false; } - - if ( Constructor1->isChecked() ) { - /* Recup args and call method */ - double x = SpinBox_X->GetValue() ; - double y = SpinBox_Y->GetValue() ; - double z = SpinBox_Z->GetValue() ; - myMeshGUI->EraseSimulationActors() ; - myMeshGUI->AddNode( myMesh, x, y, z ) ; - myMeshGUI->ViewNodes(); - mySelection->ClearIObjects(); + + /* Recup args and call method */ + double x = SpinBox_X->GetValue() ; + double y = SpinBox_Y->GetValue() ; + double z = SpinBox_Z->GetValue() ; + mySimulation->SetVisibility(false); + SMESH::AddNode(myMesh,x,y,z) ; + SMESH::SetPointRepresentation(true); + + // select myMesh + if ( mySelection->IObjectCount() != 1 ) { + if(VTKViewer_ViewFrame* aViewFrame = SMESH::GetCurrentVtkView()) { + vtkActorCollection *aCollection = aViewFrame->getRenderer()->GetActors(); + aCollection->InitTraversal(); + while(vtkActor *anAct = aCollection->GetNextActor()){ + if(SMESH_Actor *anActor = dynamic_cast(anAct)) + if(anActor->hasIO()) + if(SMESH_MeshObj *aMeshObj = dynamic_cast(anActor->GetObject().get())) + if(myMesh->_is_equivalent( aMeshObj->GetMeshServer() )) + { + mySelection->ClearIObjects(); + mySelection->AddIObject( anActor->getIO(), false ); + break; + } + } + } } + return true; } @@ -284,10 +471,12 @@ void SMESHGUI_NodesDlg::ClickOnApply() //======================================================================= void SMESHGUI_NodesDlg::ClickOnCancel() { + mySelection->ClearIObjects(); + mySimulation->SetVisibility(false); + SMESH::SetPointRepresentation(false); QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); disconnect( mySelection, 0, this, 0 ); - myMeshGUI->ResetState() ; - myMeshGUI->EraseSimulationActors() ; + myMeshGUI->ResetState(); reject() ; return ; } @@ -299,64 +488,34 @@ void SMESHGUI_NodesDlg::ClickOnCancel() //================================================================================= void SMESHGUI_NodesDlg::SelectionIntoArgument() { - int nbSel = mySelection->IObjectCount(); - if(nbSel != 1) { - SpinBox_X->SetValue(0.0) ; - SpinBox_Y->SetValue(0.0) ; - SpinBox_Z->SetValue(0.0) ; - return; - } - - Standard_Boolean res; - myMesh = myMeshGUI->ConvertIOinMesh( mySelection->firstIObject(), res ); - if (!res) { - SpinBox_X->SetValue(0.0) ; - SpinBox_Y->SetValue(0.0) ; - SpinBox_Z->SetValue(0.0) ; - return ; - } - - if ( mySelection->SelectionMode() != NodeSelection ) { - SpinBox_X->SetValue(0.0) ; - SpinBox_Y->SetValue(0.0) ; - SpinBox_Z->SetValue(0.0) ; - QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), - tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_OK") ); + if ( !GroupConstructors->isEnabled() ) return; - } - QString aString = ""; - int nbNodes = myMeshGUI->GetNameOfSelectedNodes(mySelection, aString) ; - if(nbNodes != 1) { - SpinBox_X->SetValue(0.0) ; - SpinBox_Y->SetValue(0.0) ; - SpinBox_Z->SetValue(0.0) ; - return ; - } - - if ( nbNodes == 1 ) { - TColStd_MapOfInteger myMapIndex; - mySelection->GetIndex( mySelection->firstIObject(), myMapIndex); - TColStd_MapIteratorOfMapOfInteger ite( myMapIndex ); - int idNodes[1]; - for ( ; ite.More(); ite.Next() ) { - idNodes[0] = ite.Key(); + mySimulation->SetVisibility(false); + SMESH::SetPointRepresentation(true); + + if(mySelection->IObjectCount() == 1){ + Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject(); + if(anIO->hasEntry()){ + myMesh = SMESH::GetMeshByIO(anIO); + if(myMesh->_is_nil()) return; + QString aText; + if(SMESH::GetNameOfSelectedNodes( mySelection, aText ) == 1){ + if(SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh.in())){ + if(SMDS_Mesh* aMesh = anActor->GetObject()->GetMesh()){ + if(const SMDS_MeshNode* aNode = aMesh->FindNode(aText.toInt())){ + SpinBox_X->SetValue( aNode->X() ); + SpinBox_Y->SetValue( aNode->Y() ) ; + SpinBox_Z->SetValue( aNode->Z() ) ; + } + } + } + } + mySimulation->SetPosition(SpinBox_X->GetValue(), + SpinBox_Y->GetValue(), + SpinBox_Z->GetValue()); } - - Standard_Boolean result; - SMESH_Actor* ac = myMeshGUI->FindActor( myMesh, result, true ); - vtkUnstructuredGrid* ugrid = vtkUnstructuredGrid::SafeDownCast( ac->GetUnstructuredGrid() ); - float *p0 = ugrid->GetPoint(idNodes[0]); - - SpinBox_X->SetValue( p0[0] ) ; - SpinBox_Y->SetValue( p0[1] ) ; - SpinBox_Z->SetValue( p0[2] ) ; - - myMeshGUI->DisplaySimulationNode( myMesh, p0[0], p0[1], p0[2] ); - // myMeshGUI->ViewNodes(); - } - - return ; + } } @@ -367,9 +526,18 @@ void SMESHGUI_NodesDlg::SelectionIntoArgument() void SMESHGUI_NodesDlg::closeEvent(QCloseEvent* e) { this->ClickOnCancel() ; /* same than click on cancel button */ - return ; } +//======================================================================= +//function : hideEvent +//purpose : caused by ESC key +//======================================================================= + +void SMESHGUI_NodesDlg::hideEvent ( QHideEvent * e ) +{ + if ( !isMinimized() ) + ClickOnCancel(); +} //================================================================================= // function : enterEvent() @@ -377,10 +545,8 @@ void SMESHGUI_NodesDlg::closeEvent(QCloseEvent* e) //================================================================================= void SMESHGUI_NodesDlg::enterEvent( QEvent* e) { - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; - return ; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog() ; } @@ -394,11 +560,10 @@ void SMESHGUI_NodesDlg::DeactivateActiveDialog() GroupConstructors->setEnabled(false) ; GroupCoordinates->setEnabled(false) ; GroupButtons->setEnabled(false) ; - myMeshGUI->EraseSimulationActors() ; + mySimulation->SetVisibility(false) ; myMeshGUI->ResetState() ; myMeshGUI->SetActiveDialogBox(0) ; } - return ; } @@ -412,5 +577,9 @@ void SMESHGUI_NodesDlg::ActivateThisDialog( ) GroupConstructors->setEnabled(true) ; GroupCoordinates->setEnabled(true) ; GroupButtons->setEnabled(true) ; - return ; + + SMESH::SetPointRepresentation(true); + QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + + SelectionIntoArgument(); } diff --git a/src/SMESHGUI/SMESHGUI_NodesDlg.h b/src/SMESHGUI/SMESHGUI_NodesDlg.h index d35d1c6fa..8cf17d17d 100644 --- a/src/SMESHGUI/SMESHGUI_NodesDlg.h +++ b/src/SMESHGUI/SMESHGUI_NodesDlg.h @@ -47,6 +47,10 @@ class QRadioButton; class SMESHGUI; class SMESHGUI_SpinBox; +namespace SMESH{ + struct TNodeSimulation; +} + // IDL Headers #include #include CORBA_SERVER_HEADER(SMESH_Mesh) @@ -73,10 +77,12 @@ private : SMESHGUI* myMeshGUI ; SMESH::SMESH_Mesh_var myMesh; + SMESH::TNodeSimulation* mySimulation; void Init(SALOME_Selection* Sel) ; void enterEvent(QEvent* e); void closeEvent(QCloseEvent* e) ; + void hideEvent ( QHideEvent * ); /* ESC key */ QButtonGroup* GroupConstructors; QRadioButton* Constructor1; @@ -98,7 +104,7 @@ private slots: void ClickOnOk(); void ClickOnCancel(); - void ClickOnApply(); + bool ClickOnApply(); void DeactivateActiveDialog() ; void ActivateThisDialog() ; void SelectionIntoArgument() ; diff --git a/src/SMESHGUI/SMESHGUI_OrientationElementsDlg.cxx b/src/SMESHGUI/SMESHGUI_OrientationElementsDlg.cxx deleted file mode 100644 index 92b7101a5..000000000 --- a/src/SMESHGUI/SMESHGUI_OrientationElementsDlg.cxx +++ /dev/null @@ -1,372 +0,0 @@ -// SMESH SMESHGUI : GUI for SMESH component -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMESHGUI_OrientationElementsDlg.cxx -// Author : Nicolas REJNERI -// Module : SMESH -// $Header$ - -using namespace std; -#include "SMESHGUI_OrientationElementsDlg.h" - -#include "SMESHGUI.h" -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "QAD_MessageBox.h" -#include "utilities.h" - -// QT Includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -//================================================================================= -// class : SMESHGUI_OrientationElementsDlg() -// purpose : -//================================================================================= -SMESHGUI_OrientationElementsDlg::SMESHGUI_OrientationElementsDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, - bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) -{ - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_MESH_ORIENTATION"))); - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); - - if ( !name ) - setName( "SMESHGUI_OrientationElementsDlg" ); - resize( 303, 185 ); - setCaption( tr( "SMESH_ORIENTATION_ELEMENTS_TITLE" ) ); - setSizeGripEnabled( TRUE ); - SMESHGUI_OrientationElementsDlgLayout = new QGridLayout( this ); - SMESHGUI_OrientationElementsDlgLayout->setSpacing( 6 ); - SMESHGUI_OrientationElementsDlgLayout->setMargin( 11 ); - - /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - GroupConstructors->setTitle( tr( "SMESH_ELEMENTS" ) ); - GroupConstructors->setExclusive( TRUE ); - GroupConstructors->setColumnLayout(0, Qt::Vertical ); - GroupConstructors->layout()->setSpacing( 0 ); - GroupConstructors->layout()->setMargin( 0 ); - GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); - GroupConstructorsLayout->setAlignment( Qt::AlignTop ); - GroupConstructorsLayout->setSpacing( 6 ); - GroupConstructorsLayout->setMargin( 11 ); - Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); - Constructor1->setText( tr( "" ) ); - Constructor1->setPixmap( image0 ); - Constructor1->setChecked( TRUE ); - Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); - Constructor1->setMinimumSize( QSize( 50, 0 ) ); - GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupConstructorsLayout->addItem( spacer, 0, 1 ); - SMESHGUI_OrientationElementsDlgLayout->addWidget( GroupConstructors, 0, 0 ); - - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); - GroupButtons->setTitle( tr( "" ) ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer_9, 0, 2 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - SMESHGUI_OrientationElementsDlgLayout->addWidget( GroupButtons, 2, 0 ); - - /***************************************************************/ - GroupC1 = new QGroupBox( this, "GroupC1" ); - GroupC1->setTitle( tr( "SMESH_ORIENTATION" ) ); - GroupC1->setMinimumSize( QSize( 0, 0 ) ); - GroupC1->setFrameShape( QGroupBox::Box ); - GroupC1->setFrameShadow( QGroupBox::Sunken ); - GroupC1->setColumnLayout(0, Qt::Vertical ); - GroupC1->layout()->setSpacing( 0 ); - GroupC1->layout()->setMargin( 0 ); - GroupC1Layout = new QGridLayout( GroupC1->layout() ); - GroupC1Layout->setAlignment( Qt::AlignTop ); - GroupC1Layout->setSpacing( 6 ); - GroupC1Layout->setMargin( 11 ); - TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); - TextLabelC1A1->setText( tr( "SMESH_ID_ELEMENTS" ) ); - TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A1->setFrameShape( QLabel::NoFrame ); - TextLabelC1A1->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); - SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); - SelectButtonC1A1->setText( tr( "" ) ); - SelectButtonC1A1->setPixmap( image1 ); - SelectButtonC1A1->setToggleButton( FALSE ); - GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); - LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); - GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); - SMESHGUI_OrientationElementsDlgLayout->addWidget( GroupC1, 1, 0 ); - - Init(Sel) ; /* Initialisations */ -} - -//================================================================================= -// function : ~SMESHGUI_OrientationElementsDlg() -// purpose : Destroys the object and frees any allocated resources -//================================================================================= -SMESHGUI_OrientationElementsDlg::~SMESHGUI_OrientationElementsDlg() -{ - // no need to delete child widgets, Qt does it all for us -} - - -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void SMESHGUI_OrientationElementsDlg::Init( SALOME_Selection* Sel ) -{ - - GroupC1->show(); - myConstructorId = 0 ; - Constructor1->setChecked( TRUE ); - myEditCurrentArgument = LineEditC1A1 ; - mySelection = Sel; - this->myOkElements = false ; - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; - - /* signals and slots connections */ - connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); - connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; - connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); - connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); - - connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; - connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); - /* to close dialog if study change */ - connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - - /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ - - SelectionIntoArgument(); - - return ; -} - - -//================================================================================= -// function : ConstructorsClicked() -// purpose : Radio button management -//================================================================================= -void SMESHGUI_OrientationElementsDlg::ConstructorsClicked(int constructorId) -{ - return ; -} - - -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -void SMESHGUI_OrientationElementsDlg::ClickOnApply() -{ - switch(myConstructorId) - { - case 0 : - { - if(myOkElements) { - mySMESHGUI->OrientationElements( myMesh, myMapIndex ) ; - mySelection->ClearIObjects(); - } - break ; - } - } - return ; -} - -//================================================================================= -// function : ClickOnOk() -// purpose : -//================================================================================= -void SMESHGUI_OrientationElementsDlg::ClickOnOk() -{ - this->ClickOnApply() ; - this->ClickOnCancel() ; - - return ; -} - -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void SMESHGUI_OrientationElementsDlg::ClickOnCancel() -{ - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); - disconnect( mySelection, 0, this, 0 ); - mySMESHGUI->ResetState() ; - reject() ; - return ; -} - - -//================================================================================= -// function : SelectionIntoArgument() -// purpose : Called when selection as changed or other case -//================================================================================= -void SMESHGUI_OrientationElementsDlg::SelectionIntoArgument() -{ - myEditCurrentArgument->setText("") ; - myOkElements = false; - QString aString = ""; - - int nbSel = mySelection->IObjectCount(); - if(nbSel != 1) - return; - - int nbElements = mySMESHGUI->GetNameOfSelectedElements(mySelection, aString) ; - if(nbElements < 1) - return ; - - if ( mySelection->SelectionMode() != FaceSelection ) { - QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), - tr ("SMESH_WRN_SELECTIONMODE_ELEMENTS"), tr ("SMESH_BUT_OK") ); - return; - } - - myEditCurrentArgument->setText(aString) ; - Standard_Boolean res; - myMesh = mySMESHGUI->ConvertIOinMesh( mySelection->firstIObject(), res ); - if (!res) - return ; - - mySelection->GetIndex( mySelection->firstIObject(), myMapIndex); - myOkElements = true ; - return ; -} - - -//================================================================================= -// function : SetEditCurrentArgument() -// purpose : -//================================================================================= -void SMESHGUI_OrientationElementsDlg::SetEditCurrentArgument() -{ - QPushButton* send = (QPushButton*)sender(); - switch (myConstructorId) - { - case 0: /* default constructor */ - { - if(send == SelectButtonC1A1) { - LineEditC1A1->setFocus() ; - myEditCurrentArgument = LineEditC1A1; - } - SelectionIntoArgument() ; - break; - } - } - return ; -} - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void SMESHGUI_OrientationElementsDlg::DeactivateActiveDialog() -{ - if ( GroupConstructors->isEnabled() ) { - GroupConstructors->setEnabled(false) ; - GroupC1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; - } - return ; -} - - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void SMESHGUI_OrientationElementsDlg::ActivateThisDialog() -{ - /* Emit a signal to deactivate the active dialog */ - mySMESHGUI->EmitSignalDeactivateDialog() ; - GroupConstructors->setEnabled(true) ; - GroupC1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; - return ; -} - - -//================================================================================= -// function : enterEvent() -// purpose : -//================================================================================= -void SMESHGUI_OrientationElementsDlg::enterEvent(QEvent* e) -{ - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; - return ; -} - - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void SMESHGUI_OrientationElementsDlg::closeEvent( QCloseEvent* e ) -{ - /* same than click on cancel button */ - this->ClickOnCancel() ; - return ; -} - - diff --git a/src/SMESHGUI/SMESHGUI_PatternUtils.cxx b/src/SMESHGUI/SMESHGUI_PatternUtils.cxx new file mode 100644 index 000000000..e552b9d7d --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_PatternUtils.cxx @@ -0,0 +1,32 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + + +#include "SMESHGUI_PatternUtils.h" +#include "SMESHGUI_SMESHGenUtils.h" + + +namespace SMESH{ + + SMESH::SMESH_Pattern_var GetPattern() + { + return GetSMESHGen()->GetPattern(); + } + +} diff --git a/src/SMESHGUI/SMESHGUI_PatternUtils.h b/src/SMESHGUI/SMESHGUI_PatternUtils.h new file mode 100644 index 000000000..fb09d01d9 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_PatternUtils.h @@ -0,0 +1,34 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#ifndef SMESHGUI_PatternUtils_HeaderFile +#define SMESHGUI_PatternUtils_HeaderFile + +#include "SALOMEconfig.h" +#include CORBA_SERVER_HEADER(SMESH_Pattern) + + +namespace SMESH{ + + SMESH::SMESH_Pattern_var GetPattern(); + +} + + +#endif diff --git a/src/SMESHGUI/SMESHGUI_PatternWidget.cxx b/src/SMESHGUI/SMESHGUI_PatternWidget.cxx new file mode 100644 index 000000000..80614980c --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_PatternWidget.cxx @@ -0,0 +1,171 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_PatternWidget.cxx +// Author : Michael ZORIN +// Module : SMESH +// $Header: + +#include "SMESHGUI_PatternWidget.h" + +//Qt includes +#include +#include + + +//================================================================================= +// class : SMESHGUI_PatternWidget() +// purpose : +//================================================================================= +SMESHGUI_PatternWidget::SMESHGUI_PatternWidget( QWidget* parent, const char* name, WFlags fl ) + : QFrame( parent, name, WStyle_Customize) +{ + myMinU = myMinV = myMaxU = myMaxV = 0; + setMinimumHeight(150); + repaint(); +} + + + +//================================================================================= +// function : ~SMESHGUI_PatternWidget() +// purpose : +//================================================================================= +SMESHGUI_PatternWidget::~SMESHGUI_PatternWidget() +{ +} + + +//================================================================================= +// function : SMESHGUI_PatternWidget::SetPoints +// purpose : +//================================================================================= +void SMESHGUI_PatternWidget::SetPoints( PointVector thePoints, QValueVector theKeys, ConnectivityVector theConnections ) +{ + myPoints = thePoints; + myKeys = theKeys; + myConnections = theConnections; + + if (!thePoints.size()) + return; + + myMinU = myMaxU = (thePoints[0]).x; + myMinV = myMaxV = (thePoints[0]).y; + double x, y; + + for (int i = 1; i < thePoints.size(); i++) + { + x = (thePoints[i]).x; + y = (thePoints[i]).y; + + if ( myMinU > x ) + myMinU = x; + if ( myMaxU < x) + myMaxU = x; + if ( myMinV > y ) + myMinV = y; + if ( myMaxV < y) + myMaxV = y; + } + + repaint(); +} + +static const int Shift = 4; // shift of the point number from point +static const int Border = 20; + +//================================================================================= +// function : SMESHGUI_PatternWidget::paintEvent +// purpose : +//================================================================================= +void SMESHGUI_PatternWidget::paintEvent( QPaintEvent * ) +{ + QPainter paint( this ); + paint.setBrush (Qt::SolidPattern ); + + //Draw points + const int aRadius = 3; // radius of a point + + for (int i = 0; i < myKeys.size() && i < myPoints.size(); i++) + { + SMESH::PointStruct aPoint = myPoints[ myKeys[i] ]; + QPoint aQPnt = MapCoords( aPoint.x, aPoint.y); + + paint.drawPie( aQPnt.x() - aRadius, aQPnt.y() - aRadius, aRadius*2, aRadius*2, 5760, 5760 ); + paint.drawText( aQPnt.x() + Shift, aQPnt.y() - Shift, QString::number( i+1 ) ); + } + + //Draw lines + for (int i = 0; i < myConnections.size(); i++) + { + QValueVector aCVector = myConnections[i]; + + if ( aCVector.size() == 0 ) + continue; + + SMESH::PointStruct aPoint = myPoints[ aCVector[0] ]; + const QPoint aBeginPnt = MapCoords( aPoint.x, aPoint.y); + QPoint aFirstPnt = aBeginPnt, aSecondPnt; + + for (int j = 1; j < aCVector.size(); j++) + { + aPoint = myPoints[ aCVector[j] ]; + aSecondPnt = MapCoords( aPoint.x, aPoint.y); + paint.drawLine(aFirstPnt, aSecondPnt); + aFirstPnt = aSecondPnt; + } + + paint.drawLine(aBeginPnt, aSecondPnt); + } +} + + +//================================================================================= +// function : SMESHGUI_PatternWidget::MapCoords +// purpose : +//================================================================================= +QPoint SMESHGUI_PatternWidget::MapCoords( const double u, const double v ) +{ + int aWidth = width() - 2*Border; + int aHeight = height() - 2*Border; + + double aUBound = myMaxU - myMinU; + double aVBound = myMaxV - myMinV; + + double aUScale = aWidth/aUBound; + double aVScale = aHeight/aVBound; + + double aScale; + aUScale <= aVScale ? aScale = aUScale : aScale = aVScale; + + double aUMiddle = ( myMaxU + myMinU )/2; + double aVMiddle = ( myMaxV + myMinV )/2; + + int x = int( aWidth/2 + (u - aUMiddle)*aScale + Border - Shift); + + int y = int( aHeight/2 + (aVMiddle - v)*aScale + Border + Shift); + + QPoint aPoint = QPoint(x, y); + + return aPoint; +} diff --git a/src/SMESHGUI/SMESHGUI_PatternWidget.h b/src/SMESHGUI/SMESHGUI_PatternWidget.h new file mode 100644 index 000000000..ddab7433b --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_PatternWidget.h @@ -0,0 +1,74 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_PatternWidget.h +// Author : Michael ZORIN +// Module : SMESH +// $Header: + +#ifndef WIDGET_PATTERN_H +#define WIDGET_PATTERN_H + +#include +#include + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +typedef QValueVector PointVector; +typedef QValueVector< QValueVector > ConnectivityVector; + +class QPoint; + +//================================================================================= +// class : SMESHGUI_PatternWidget +// purpose : +//================================================================================= +class SMESHGUI_PatternWidget : public QFrame +{ + Q_OBJECT + +public: + SMESHGUI_PatternWidget( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); + + ~SMESHGUI_PatternWidget(); + + void SetPoints( PointVector thePoints, QValueVector theKeys, ConnectivityVector theConnections ); + +private : + PointVector myPoints; + QValueVector myKeys; + ConnectivityVector myConnections; + + double myMinU, myMaxU, myMinV, myMaxV; + +private slots: + +protected: + void paintEvent( QPaintEvent * ); + QPoint MapCoords( const double u, const double v ); +}; + +#endif // WIDGET_PATTERN_H + diff --git a/src/SMESHGUI/SMESHGUI_PrecisionDlg.cxx b/src/SMESHGUI/SMESHGUI_PrecisionDlg.cxx new file mode 100755 index 000000000..2255978a6 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_PrecisionDlg.cxx @@ -0,0 +1,221 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_PrecisionDlg.cxx +// Author : Sergey LITONIN +// Module : SMESH + +#include "SMESHGUI_PrecisionDlg.h" +#include "QAD_Config.h" +#include "SMESHGUI.h" +#include "SMESHGUI_VTKUtils.h" + +#include +#include +#include +#include +#include +#include + +#define SPACING 5 +#define MARGIN 10 +#define DEFAULT_VAL 10 +#define RANGE 128 + +/* + Class : SMESHGUI_PrecisionDlg + Description : Dialog to specify precision of mesh quality controls +*/ + +//======================================================================= +// name : SMESHGUI_PrecisionDlg::SMESHGUI_PrecisionDlg +// Purpose : Constructor +//======================================================================= +SMESHGUI_PrecisionDlg::SMESHGUI_PrecisionDlg( QWidget* theParent ) +: QDialog( theParent, "SMESHGUI_PrecisionDlg", true, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + setCaption( tr( "CAPTION" ) ); + + QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); + + QFrame* aMainFrame = createMainFrame ( this ); + QFrame* aBtnFrame = createButtonFrame( this ); + + aDlgLay->addWidget( aMainFrame ); + aDlgLay->addWidget( aBtnFrame ); + + aDlgLay->setStretchFactor( aMainFrame, 1 ); + + setMinimumWidth( (int)( QFontMetrics( font() ).width( tr( "CAPTION" ) ) * 1.5 ) ); + + Init(); + +} + +//======================================================================= +// name : SMESHGUI_PrecisionDlg::~SMESHGUI_PrecisionDlg +// Purpose : Destructor +//======================================================================= +SMESHGUI_PrecisionDlg::~SMESHGUI_PrecisionDlg() +{ +} + +//======================================================================= +// name : SMESHGUI_PrecisionDlg::createButtonFrame +// Purpose : Create frame containing buttons +//======================================================================= +QFrame* SMESHGUI_PrecisionDlg::createButtonFrame( QWidget* theParent ) +{ + QGroupBox* aGrp = new QGroupBox( 1, Qt::Vertical, theParent ); + aGrp->setFrameStyle( QFrame::NoFrame ); + aGrp->setInsideMargin( 0 ); + + myOKBtn = new QPushButton( tr( "SMESH_BUT_OK" ), aGrp ); + + QLabel* aLbl = new QLabel( aGrp ); + aLbl->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + myCancelBtn = new QPushButton( tr( "SMESH_BUT_CANCEL" ), aGrp ); + + connect( myOKBtn, SIGNAL( clicked() ), SLOT( onOk() ) ); + connect( myCancelBtn, SIGNAL( clicked() ), SLOT( onClose() ) ); + + return aGrp; +} + +//======================================================================= +// name : SMESHGUI_PrecisionDlg:: createMainFrame +// Purpose : Create frame containing dialog's input fields +//======================================================================= +QFrame* SMESHGUI_PrecisionDlg::createMainFrame( QWidget* theParent ) +{ + QGroupBox* aGrp = new QGroupBox( 2, Qt::Horizontal, theParent ); + new QLabel( tr( "PRECISION" ), aGrp ); + mySpinBox = new QSpinBox( 0, RANGE, 1, aGrp ); + myNotUseChk = new QCheckBox( tr( "NOT_USE" ), aGrp ); + + connect( myNotUseChk, SIGNAL( toggled( bool ) ), SLOT( onNotUse() ) ); + + return aGrp; +} + +//======================================================================= +// name : SMESHGUI_PrecisionDlg::Init +// Purpose : Initialize dialog fields +//======================================================================= +void SMESHGUI_PrecisionDlg::Init() +{ + if ( QAD_CONFIG->hasSetting( "SMESH:ControlsPrecision" ) ) + { + QString aStr = QAD_CONFIG->getSetting( "SMESH:ControlsPrecision" ); + bool isOk = false; + int aVal = aStr.toInt( &isOk ); + mySpinBox->setValue( isOk ? aVal : DEFAULT_VAL ); + myNotUseChk->setChecked( !isOk ); + } + else + { + mySpinBox->setValue( DEFAULT_VAL ); + myNotUseChk->setChecked( true ); + } + + onNotUse(); + + SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); + aSMESHGUI->SetActiveDialogBox( ( QDialog* )this ) ; + connect( aSMESHGUI, SIGNAL( SignalCloseAllDialogs() ), SLOT( onClose() ) ); +} + +//======================================================================= +// name : SMESHGUI_PrecisionDlg::onOk +// Purpose : SLOT. Called when OK button pressed +//======================================================================= +void SMESHGUI_PrecisionDlg::onOk() +{ + if ( myNotUseChk->isChecked() ) + { + QAD_CONFIG->removeSettings( "SMESH:ControlsPrecision" ); + SMESH::SetControlsPrecision( -1 ); + } + else + { + mySpinBox->clearFocus(); + int aVal = mySpinBox->value(); + QAD_CONFIG->addSetting( "SMESH:ControlsPrecision", QString( "%1" ).arg( aVal ) ); + SMESH::SetControlsPrecision( aVal ); + } + + disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); + SMESHGUI::GetSMESHGUI()->ResetState() ; + accept(); +} + +//======================================================================= +// name : SMESHGUI_PrecisionDlg::onClose +// Purpose : SLOT. Called when "Cancel" button pressed +//======================================================================= +void SMESHGUI_PrecisionDlg::onClose() +{ + disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); + reject(); +} + +//================================================================================= +// function : SMESHGUI_PrecisionDlg::closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_PrecisionDlg::closeEvent( QCloseEvent* ) +{ + onClose(); +} + +//======================================================================= +// name : SMESHGUI_PrecisionDlg::onClose +// Purpose : SLOT. Called when state of "Do not use" check box changed +//======================================================================= +void SMESHGUI_PrecisionDlg::onNotUse() +{ + mySpinBox->setEnabled( !myNotUseChk->isChecked() ); +} + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SMESHGUI/SMESHGUI_PrecisionDlg.h b/src/SMESHGUI/SMESHGUI_PrecisionDlg.h new file mode 100755 index 000000000..c37809963 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_PrecisionDlg.h @@ -0,0 +1,96 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_PrecisionDlg.h +// Author : Sergey LITONIN +// Module : SMESH + + +#ifndef SMESHGUI_PrecisionDlg_H +#define SMESHGUI_PrecisionDlg_H + +#include + +class QSpinBox; +class QPushButton; +class QCheckBox; +class QFrame; + +/* + Class : SMESHGUI_PrecisionDlg + Description : Dialog to specify precision of mesh quality controls +*/ + +class SMESHGUI_PrecisionDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_PrecisionDlg( QWidget* parent ); + + virtual ~SMESHGUI_PrecisionDlg(); + + void Init(); + +private slots: + + void onOk(); + void onClose(); + void onNotUse(); + +private: + + QFrame* createButtonFrame( QWidget* ); + QFrame* createMainFrame( QWidget* ); + void closeEvent( QCloseEvent* ); + +private: + + QSpinBox* mySpinBox; + QPushButton* myOKBtn; + QPushButton* myCancelBtn; + QCheckBox* myNotUseChk; + +}; + +#endif + + + + + + + + + + + + + + + + + + + + diff --git a/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx b/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx index 1989d2c14..b55413f09 100644 --- a/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_Preferences_ScalarBarDlg.cxx @@ -26,9 +26,10 @@ // Module : SMESH // $Header$ -using namespace std; #include "SMESHGUI_Preferences_ScalarBarDlg.h" + #include "SMESHGUI.h" +#include "SMESHGUI_VTKUtils.h" #include #include @@ -46,6 +47,7 @@ using namespace std; #include #include +#include #include "QAD_SpinBoxDbl.h" #include "QAD_Config.h" @@ -66,6 +68,8 @@ using namespace std; #define DEF_HOR_H 0.12 #define DEF_HOR_W 0.60 +using namespace std; + // Only one instance is allowed SMESHGUI_Preferences_ScalarBarDlg* SMESHGUI_Preferences_ScalarBarDlg::myDlg = 0; @@ -497,7 +501,7 @@ bool SMESHGUI_Preferences_ScalarBarDlg::onApply() double aMin = myMinEdit->text().toDouble(); double aMax = myMaxEdit->text().toDouble(); myScalarBarActor->GetLookupTable()->SetRange( aMin, aMax ); - SMESHGUI::GetSMESHGUI()->UpdateView(); + SMESH::RepaintCurrentView(); } else { // Scalar Bar preferences @@ -593,9 +597,8 @@ void SMESHGUI_Preferences_ScalarBarDlg::onSelectionChanged() if ( mySelection->IObjectCount() == 1 ) { Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject(); if( anIO->hasEntry() ) { - Standard_Boolean isOk; - SMESH_Actor* anActor = SMESHGUI::GetSMESHGUI()->FindActorByEntry( anIO->getEntry(), isOk, true ); - if ( isOk && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) { + SMESH_Actor* anActor = SMESH::FindActorByEntry(anIO->getEntry()); + if ( anActor && anActor->GetScalarBarActor() && anActor->GetControlMode() != SMESH_Actor::eNone ) { myActor = anActor; vtkScalarBarActor* myScalarBarActor = myActor->GetScalarBarActor(); diff --git a/src/SMESHGUI/SMESHGUI_Preferences_SelectionDlg.cxx b/src/SMESHGUI/SMESHGUI_Preferences_SelectionDlg.cxx index 1f041af2e..087739f47 100644 --- a/src/SMESHGUI/SMESHGUI_Preferences_SelectionDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_Preferences_SelectionDlg.cxx @@ -26,7 +26,6 @@ // Module : SMESH // $Header$ -using namespace std; #include "SMESHGUI_Preferences_SelectionDlg.h" #include "SMESHGUI.h" @@ -40,6 +39,8 @@ using namespace std; #include #include +using namespace std; + //================================================================================= // class : SMESHGUI_LineEdit // purpose : @@ -303,5 +304,6 @@ void SMESHGUI_Preferences_SelectionDlg::SetPrecision(int type, double value) double SMESHGUI_Preferences_SelectionDlg::GetPrecision(int type) { if (type > 0 && type <= 2) - return myPrecision[type-1]->text().toDouble(); + return myPrecision[type-1]->text().toDouble(); + return 0; } diff --git a/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx b/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx index fd3e5e427..18a63d2be 100644 --- a/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.cxx @@ -26,10 +26,16 @@ // Module : SMESH // $Header$ -using namespace std; #include "SMESHGUI_RemoveElementsDlg.h" #include "SMESHGUI.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_MeshUtils.h" +#include "SMESHGUI_IdValidator.h" +#include "SMESH_Actor.h" +#include "SMDS_Mesh.hxx" + #include "QAD_Application.h" #include "QAD_Desktop.h" #include "QAD_MessageBox.h" @@ -49,6 +55,7 @@ using namespace std; #include #include +using namespace std; //================================================================================= // class : SMESHGUI_RemoveElementsDlg() @@ -145,6 +152,7 @@ SMESHGUI_RemoveElementsDlg::SMESHGUI_RemoveElementsDlg( QWidget* parent, const c SelectButtonC1A1->setToggleButton( FALSE ); GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + LineEditC1A1->setValidator( new SMESHGUI_IdValidator( this, "validator" )); GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); SMESHGUI_RemoveElementsDlgLayout->addWidget( GroupC1, 1, 0 ); @@ -172,10 +180,13 @@ void SMESHGUI_RemoveElementsDlg::Init( SALOME_Selection* Sel ) myConstructorId = 0 ; Constructor1->setChecked( TRUE ); myEditCurrentArgument = LineEditC1A1 ; + mySelection = Sel; - this->myOkElements = false ; + myNbOkElements = false ; mySMESHGUI = SMESHGUI::GetSMESHGUI() ; mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + myActor = 0; + myBusy = false; /* signals and slots connections */ connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); @@ -188,6 +199,8 @@ void SMESHGUI_RemoveElementsDlg::Init( SALOME_Selection* Sel ) connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); /* to close dialog if study change */ connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + connect( myEditCurrentArgument, SIGNAL( textChanged( const QString& )), + SLOT( onTextChange( const QString& ))); /* Move widget on the botton right corner of main widget */ int x, y ; @@ -195,7 +208,9 @@ void SMESHGUI_RemoveElementsDlg::Init( SALOME_Selection* Sel ) this->move( x, y ) ; this->show() ; /* displays Dialog */ - return ; + QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + + SelectionIntoArgument(); } @@ -215,18 +230,33 @@ void SMESHGUI_RemoveElementsDlg::ConstructorsClicked(int constructorId) //================================================================================= void SMESHGUI_RemoveElementsDlg::ClickOnApply() { - switch(myConstructorId) - { - case 0 : - { - if(myOkElements) { - mySMESHGUI->RemoveElements( myMesh, myMapIndex ) ; - mySelection->ClearIObjects(); - } - break ; - } + if (mySMESHGUI->ActiveStudyLocked()) + return; + if ( myNbOkElements ) { + QStringList aListId = QStringList::split( " ", myEditCurrentArgument->text(), false); + SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array; + anArrayOfIdeces->length( aListId.count() ); + for ( int i = 0; i < aListId.count(); i++ ) + anArrayOfIdeces[i] = aListId[ i ].toInt(); + + bool aResult = false; + try + { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + aResult = aMeshEditor->RemoveElements(anArrayOfIdeces.inout()) ; } - return ; + catch( ... ) + { + } + + if ( aResult ) + { + Handle(SALOME_InteractiveObject) anIO = myActor->getIO(); + mySelection->ClearIObjects(); + SMESH::UpdateView(); + mySelection->AddIObject( anIO, false ); + } + } } //================================================================================= @@ -247,6 +277,7 @@ void SMESHGUI_RemoveElementsDlg::ClickOnOk() //================================================================================= void SMESHGUI_RemoveElementsDlg::ClickOnCancel() { + mySelection->ClearIObjects(); QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); disconnect( mySelection, 0, this, 0 ); mySMESHGUI->ResetState() ; @@ -255,39 +286,102 @@ void SMESHGUI_RemoveElementsDlg::ClickOnCancel() } +//======================================================================= +//function : onTextChange +//purpose : +//======================================================================= + +void SMESHGUI_RemoveElementsDlg::onTextChange(const QString& theNewText) +{ + if ( myBusy ) return; + myBusy = true; + + myNbOkElements = 0; + + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + + // hilight entered elements + SMDS_Mesh* aMesh = 0; + if ( myActor ) + aMesh = myActor->GetObject()->GetMesh(); + if ( aMesh ) { + + mySelection->ClearIObjects(); + mySelection->AddIObject( myActor->getIO() ); + + QStringList aListId = QStringList::split( " ", theNewText, false); + for ( int i = 0; i < aListId.count(); i++ ) { + const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() ); + if ( e ) { + if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() )) + mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true); + myNbOkElements++; + } + } + + if ( myNbOkElements ) { + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); + } + } + + myBusy = false; +} + //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection as changed or other case //================================================================================= void SMESHGUI_RemoveElementsDlg::SelectionIntoArgument() { - myEditCurrentArgument->setText("") ; - myOkElements = false; - QString aString = ""; + if ( myBusy ) return; + + // clear + + myNbOkElements = false; + myActor = 0; + + myBusy = true; + myEditCurrentArgument->setText( "" ); + myBusy = false; + + if ( !GroupButtons->isEnabled() ) // inactive + return; + + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + + // get selected mesh int nbSel = mySelection->IObjectCount(); if(nbSel != 1) return; - int nbElements = mySMESHGUI->GetNameOfSelectedElements(mySelection, aString) ; - if(nbElements < 1) - return ; - - if ( mySelection->SelectionMode() != CellSelection ) { - QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), - tr ("SMESH_WRN_SELECTIONMODE_ELEMENTS"), tr ("SMESH_BUT_OK") ); + myMesh = SMESH::GetMeshByIO( mySelection->firstIObject() ); + if ( myMesh->_is_nil() ) return; - } - myEditCurrentArgument->setText(aString) ; - Standard_Boolean res; - myMesh = mySMESHGUI->ConvertIOinMesh( mySelection->firstIObject(), res ); - if (!res) + myActor = SMESH::FindActorByEntry( mySelection->firstIObject()->getEntry() ); + if ( !myActor ) + return; + + // get selected nodes + + QString aString = ""; + int nbElems = SMESH::GetNameOfSelectedElements(mySelection, aString) ; + if(nbElems < 1) return ; + myBusy = true; + myEditCurrentArgument->setText( aString ); + myBusy = false; - mySelection->GetIndex( mySelection->firstIObject(), myMapIndex); - myOkElements = true ; - return ; + // OK + + myNbOkElements = nbElems; + + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); } @@ -336,10 +430,12 @@ void SMESHGUI_RemoveElementsDlg::ActivateThisDialog() { /* Emit a signal to deactivate the active dialog */ mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; GroupC1->setEnabled(true) ; GroupButtons->setEnabled(true) ; - return ; + + QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); } @@ -349,10 +445,8 @@ void SMESHGUI_RemoveElementsDlg::ActivateThisDialog() //================================================================================= void SMESHGUI_RemoveElementsDlg::enterEvent(QEvent* e) { - if ( GroupConstructors->isEnabled() ) - return ; - ActivateThisDialog() ; - return ; + if ( !GroupConstructors->isEnabled() ) + ActivateThisDialog() ; } @@ -367,4 +461,13 @@ void SMESHGUI_RemoveElementsDlg::closeEvent( QCloseEvent* e ) return ; } +//======================================================================= +//function : hideEvent +//purpose : caused by ESC key +//======================================================================= +void SMESHGUI_RemoveElementsDlg::hideEvent ( QHideEvent * e ) +{ + if ( !isMinimized() ) + ClickOnCancel(); +} diff --git a/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.h b/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.h index 9930235c9..e18ad584b 100644 --- a/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.h +++ b/src/SMESHGUI/SMESHGUI_RemoveElementsDlg.h @@ -35,9 +35,6 @@ #include #include -// Open CASCADE Includes -#include - class QVBoxLayout; class QHBoxLayout; class QGridLayout; @@ -48,6 +45,7 @@ class QLineEdit; class QPushButton; class QRadioButton; class SMESHGUI; +class SMESH_Actor; // IDL Headers #include @@ -70,15 +68,17 @@ private: void Init( SALOME_Selection* Sel ) ; void closeEvent( QCloseEvent* e ) ; void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void hideEvent ( QHideEvent * ); /* ESC key */ SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ SALOME_Selection* mySelection ; /* User shape selection */ - bool myOkElements ; /* to check when arguments is defined */ + int myNbOkElements ; /* to check when arguments is defined */ int myConstructorId ; /* Current constructor id = radio button id */ QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + bool myBusy; SMESH::SMESH_Mesh_var myMesh; - TColStd_MapOfInteger myMapIndex; + SMESH_Actor* myActor; QButtonGroup* GroupConstructors; QRadioButton* Constructor1; @@ -101,6 +101,7 @@ private slots: void SelectionIntoArgument() ; void DeactivateActiveDialog() ; void ActivateThisDialog() ; + void onTextChange(const QString&); protected: QGridLayout* SMESHGUI_RemoveElementsDlgLayout; diff --git a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx index 68ba6b863..3990a51b0 100644 --- a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.cxx @@ -26,10 +26,16 @@ // Module : SMESH // $Header$ -using namespace std; #include "SMESHGUI_RemoveNodesDlg.h" #include "SMESHGUI.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_MeshUtils.h" +#include "SMESHGUI_IdValidator.h" +#include "SMESH_Actor.h" +#include "SMDS_Mesh.hxx" + #include "QAD_Application.h" #include "QAD_Desktop.h" #include "QAD_MessageBox.h" @@ -49,6 +55,7 @@ using namespace std; #include #include +using namespace std; //================================================================================= // class : SMESHGUI_RemoveNodesDlg() @@ -56,7 +63,9 @@ using namespace std; //================================================================================= SMESHGUI_RemoveNodesDlg::SMESHGUI_RemoveNodesDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | + Qt::WDestructiveClose), + myBusy( false ) { QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_REM_NODE"))); QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); @@ -145,6 +154,7 @@ SMESHGUI_RemoveNodesDlg::SMESHGUI_RemoveNodesDlg( QWidget* parent, const char* n SelectButtonC1A1->setToggleButton( FALSE ); GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); + LineEditC1A1->setValidator( new SMESHGUI_IdValidator( this, "validator" )); GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); SMESHGUI_RemoveNodesDlgLayout->addWidget( GroupC1, 1, 0 ); @@ -167,14 +177,16 @@ SMESHGUI_RemoveNodesDlg::~SMESHGUI_RemoveNodesDlg() //================================================================================= void SMESHGUI_RemoveNodesDlg::Init( SALOME_Selection* Sel ) { + myBusy = false; GroupC1->show(); myConstructorId = 0 ; Constructor1->setChecked( TRUE ); myEditCurrentArgument = LineEditC1A1 ; mySelection = Sel; - this->myOkNodes = false ; - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + myNbOkNodes = 0 ; + myActor = 0; + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; /* signals and slots connections */ @@ -188,6 +200,8 @@ void SMESHGUI_RemoveNodesDlg::Init( SALOME_Selection* Sel ) connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); /* to close dialog if study change */ connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + connect( myEditCurrentArgument, SIGNAL( textChanged( const QString& )), + SLOT( onTextChange( const QString& ))); /* Move widget on the botton right corner of main widget */ int x, y ; @@ -195,6 +209,9 @@ void SMESHGUI_RemoveNodesDlg::Init( SALOME_Selection* Sel ) this->move( x, y ) ; this->show() ; /* displays Dialog */ + SMESH::SetPointRepresentation(true); + QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + SelectionIntoArgument(); return ; } @@ -216,20 +233,37 @@ void SMESHGUI_RemoveNodesDlg::ConstructorsClicked(int constructorId) //================================================================================= void SMESHGUI_RemoveNodesDlg::ClickOnApply() { - switch(myConstructorId) - { - case 0 : - { - if(myOkNodes) { - mySMESHGUI->EraseSimulationActors(); - mySMESHGUI->RemoveNodes( myMesh, myMapIndex ) ; - mySMESHGUI->ViewNodes(); - mySelection->ClearIObjects(); - } - break ; - } + if (mySMESHGUI->ActiveStudyLocked()) + return; + + if ( myNbOkNodes ) + { + QStringList aListId = QStringList::split( " ", myEditCurrentArgument->text(), false); + SMESH::long_array_var anArrayOfIdeces = new SMESH::long_array; + anArrayOfIdeces->length( aListId.count() ); + for ( int i = 0; i < aListId.count(); i++ ) + anArrayOfIdeces[i] = aListId[ i ].toInt(); + + bool aResult = false; + try + { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + aResult = aMeshEditor->RemoveNodes(anArrayOfIdeces.inout()) ; } - return ; + catch( ... ) + { + } + + if ( aResult ) + { + Handle(SALOME_InteractiveObject) anIO = myActor->getIO(); + mySelection->ClearIObjects(); + SMESH::UpdateView(); + mySelection->AddIObject( anIO, false ); + } + + SMESH::SetPointRepresentation(true); + } } //================================================================================= @@ -251,14 +285,57 @@ void SMESHGUI_RemoveNodesDlg::ClickOnOk() //================================================================================= void SMESHGUI_RemoveNodesDlg::ClickOnCancel() { + mySelection->ClearIObjects(); + SMESH::SetPointRepresentation(false); QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); disconnect( mySelection, 0, this, 0 ); mySMESHGUI->ResetState() ; - mySMESHGUI->EraseSimulationActors(); reject() ; return ; } +//======================================================================= +//function : onTextChange +//purpose : +//======================================================================= + +void SMESHGUI_RemoveNodesDlg::onTextChange(const QString& theNewText) +{ + if ( myBusy ) return; + myBusy = true; + + myNbOkNodes = 0; + + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + + // hilight entered nodes + SMDS_Mesh* aMesh = 0; + if ( myActor ) + aMesh = myActor->GetObject()->GetMesh(); + if ( aMesh ) { + + mySelection->ClearIObjects(); + mySelection->AddIObject( myActor->getIO() ); + + QStringList aListId = QStringList::split( " ", theNewText, false); + for ( int i = 0; i < aListId.count(); i++ ) { + const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ); + if ( n ) { + if ( !mySelection->IsIndexSelected( myActor->getIO(), n->GetID() )) + mySelection->AddOrRemoveIndex (myActor->getIO(), n->GetID(), true); + myNbOkNodes++; + } + } + + if ( myNbOkNodes ) { + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); + } + } + + myBusy = false; +} //================================================================================= // function : SelectionIntoArgument() @@ -266,34 +343,53 @@ void SMESHGUI_RemoveNodesDlg::ClickOnCancel() //================================================================================= void SMESHGUI_RemoveNodesDlg::SelectionIntoArgument() { - myEditCurrentArgument->setText("") ; - myOkNodes = false; - QString aString = ""; + if ( myBusy ) return; + + // clear + + myNbOkNodes = false; + myActor = 0; + + myBusy = true; + myEditCurrentArgument->setText( "" ); + myBusy = false; + + if ( !GroupButtons->isEnabled() ) // inactive + return; + + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + + // get selected mesh int nbSel = mySelection->IObjectCount(); if(nbSel != 1) - return ; + return; - int nbNodes = mySMESHGUI->GetNameOfSelectedNodes(mySelection, aString) ; - if(nbNodes < 1) - return ; - - if ( mySelection->SelectionMode() != NodeSelection ){ - QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), - tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_OK") ); + myMesh = SMESH::GetMeshByIO( mySelection->firstIObject() ); + if ( myMesh->_is_nil() ) return; - } - myEditCurrentArgument->setText(aString) ; - Standard_Boolean res; - myMesh = mySMESHGUI->ConvertIOinMesh( mySelection->firstIObject(), res ); - if (!res) + myActor = SMESH::FindActorByEntry( mySelection->firstIObject()->getEntry() ); + if ( !myActor ) + return; + + // get selected nodes + + QString aString = ""; + int nbNodes = SMESH::GetNameOfSelectedNodes(mySelection, aString) ; + if(nbNodes < 1) return ; + myBusy = true; + myEditCurrentArgument->setText( aString ); + myBusy = false; - mySelection->GetIndex( mySelection->firstIObject(), myMapIndex); + // OK - myOkNodes = true ; - return ; + myNbOkNodes = true; + + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); } @@ -329,7 +425,6 @@ void SMESHGUI_RemoveNodesDlg::DeactivateActiveDialog() GroupConstructors->setEnabled(false) ; GroupC1->setEnabled(false) ; GroupButtons->setEnabled(false) ; - mySMESHGUI->EraseSimulationActors() ; mySMESHGUI->ResetState() ; mySMESHGUI->SetActiveDialogBox(0) ; } @@ -350,7 +445,11 @@ void SMESHGUI_RemoveNodesDlg::ActivateThisDialog() GroupButtons->setEnabled(true) ; mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; - return ; + + SMESH::SetPointRepresentation(true); + QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + + SelectionIntoArgument(); } @@ -379,3 +478,13 @@ void SMESHGUI_RemoveNodesDlg::closeEvent( QCloseEvent* e ) } +//======================================================================= +//function : hideEvent +//purpose : caused by ESC key +//======================================================================= + +void SMESHGUI_RemoveNodesDlg::hideEvent ( QHideEvent * e ) +{ + if ( !isMinimized() ) + ClickOnCancel(); +} diff --git a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.h b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.h index 1906c4602..d40edccf8 100644 --- a/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.h +++ b/src/SMESHGUI/SMESHGUI_RemoveNodesDlg.h @@ -36,7 +36,7 @@ #include // Open CASCADE Includes -#include +#include class QVBoxLayout; class QHBoxLayout; @@ -48,6 +48,7 @@ class QLineEdit; class QPushButton; class QRadioButton; class SMESHGUI; +class SMESH_Actor; // IDL Headers #include @@ -70,15 +71,17 @@ private: void Init( SALOME_Selection* Sel ) ; void closeEvent( QCloseEvent* e ) ; void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void hideEvent ( QHideEvent * ); /* ESC key */ SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ SALOME_Selection* mySelection ; /* User shape selection */ - bool myOkNodes ; /* to check when arguments is defined */ + int myNbOkNodes ; /* to check when arguments is defined */ int myConstructorId ; /* Current constructor id = radio button id */ QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + bool myBusy; SMESH::SMESH_Mesh_var myMesh; - TColStd_MapOfInteger myMapIndex; + SMESH_Actor* myActor; QButtonGroup* GroupConstructors; QRadioButton* Constructor1; @@ -101,6 +104,7 @@ private slots: void SelectionIntoArgument() ; void DeactivateActiveDialog() ; void ActivateThisDialog() ; + void onTextChange(const QString&); protected: QGridLayout* SMESHGUI_RemoveNodesDlgLayout; diff --git a/src/SMESHGUI/SMESHGUI_AddFaceDlg.cxx b/src/SMESHGUI/SMESHGUI_RenumberingDlg.cxx similarity index 59% rename from src/SMESHGUI/SMESHGUI_AddFaceDlg.cxx rename to src/SMESHGUI/SMESHGUI_RenumberingDlg.cxx index b294f9368..35b9df5ef 100644 --- a/src/SMESHGUI/SMESHGUI_AddFaceDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RenumberingDlg.cxx @@ -21,21 +21,26 @@ // // // -// File : SMESHGUI_AddFaceDlg.cxx +// File : SMESHGUI_RenumberingDlg.cxx // Author : Nicolas REJNERI // Module : SMESH // $Header$ -using namespace std; -#include "SMESHGUI_AddFaceDlg.h" +#include "SMESHGUI_RenumberingDlg.h" #include "SMESHGUI.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESH_Actor.h" +#include "SMDS_Mesh.hxx" + #include "QAD_Application.h" #include "QAD_Desktop.h" #include "QAD_MessageBox.h" #include "utilities.h" // QT Includes +#include #include #include #include @@ -43,51 +48,49 @@ using namespace std; #include #include #include -#include -#include -#include -#include #include -#include +using namespace std; //================================================================================= -// class : SMESHGUI_AddFaceDlg() +// class : SMESHGUI_RenumberingDlg() // purpose : //================================================================================= -SMESHGUI_AddFaceDlg::SMESHGUI_AddFaceDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, - int nbNodes, bool modal, WFlags fl ) - : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +SMESHGUI_RenumberingDlg::SMESHGUI_RenumberingDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, + const int unit, bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | + Qt::WDestructiveClose) { - myNodes = nbNodes; - QPixmap image0; - if ( myNodes == 3 ) - image0 = QPixmap(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_TRIANGLE"))); - else if ( myNodes == 4 ) - image0 = QPixmap(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_QUADRANGLE"))); - - QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); + myUnit = unit; if ( !name ) - setName( "SMESHGUI_AddFaceDlg" ); - resize( 303, 185 ); - if ( myNodes == 3 ) - setCaption( tr( "SMESH_ADD_TRIANGLE_TITLE" ) ); - else if ( myNodes == 4 ) - setCaption( tr( "SMESH_ADD_QUADRANGLE_TITLE" ) ); + setName( "SMESHGUI_RenumberingDlg" ); + resize( 303, 185 ); + - setSizeGripEnabled( TRUE ); - SMESHGUI_AddFaceDlgLayout = new QGridLayout( this ); - SMESHGUI_AddFaceDlgLayout->setSpacing( 6 ); - SMESHGUI_AddFaceDlgLayout->setMargin( 11 ); + QPixmap image0; + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); - /***************************************************************/ - GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); - if ( myNodes == 3 ) - GroupConstructors->setTitle( tr( "SMESH_TRIANGLE" ) ); - else if ( myNodes == 4 ) - GroupConstructors->setTitle( tr( "SMESH_QUADRANGLE" ) ); + if (unit == 0) { + image0 = QPixmap(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_RENUMBERING_NODES"))); + setCaption( tr( "SMESH_RENUMBERING_NODES_TITLE" ) ); + } + else if (unit == 1) { + image0 = QPixmap(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_RENUMBERING_ELEMENTS"))); + setCaption( tr( "SMESH_RENUMBERING_ELEMENTS_TITLE" ) ); + } + setSizeGripEnabled( TRUE ); + SMESHGUI_RenumberingDlgLayout = new QGridLayout( this ); + SMESHGUI_RenumberingDlgLayout->setSpacing( 6 ); + SMESHGUI_RenumberingDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + if (unit == 0) + GroupConstructors->setTitle( tr( "SMESH_NODES" ) ); + else if (unit == 1) + GroupConstructors->setTitle( tr( "SMESH_ELEMENTS" ) ); GroupConstructors->setExclusive( TRUE ); GroupConstructors->setColumnLayout(0, Qt::Vertical ); GroupConstructors->layout()->setSpacing( 0 ); @@ -105,9 +108,9 @@ SMESHGUI_AddFaceDlg::SMESHGUI_AddFaceDlg( QWidget* parent, const char* name, SAL GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); GroupConstructorsLayout->addItem( spacer, 0, 1 ); - SMESHGUI_AddFaceDlgLayout->addWidget( GroupConstructors, 0, 0 ); - - /***************************************************************/ + SMESHGUI_RenumberingDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ GroupButtons = new QGroupBox( this, "GroupButtons" ); GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); GroupButtons->setTitle( tr( "" ) ); @@ -133,55 +136,47 @@ SMESHGUI_AddFaceDlg::SMESHGUI_AddFaceDlg( QWidget* parent, const char* name, SAL buttonOk->setAutoDefault( TRUE ); buttonOk->setDefault( TRUE ); GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - SMESHGUI_AddFaceDlgLayout->addWidget( GroupButtons, 2, 0 ); - - /***************************************************************/ - GroupC1 = new QGroupBox( this, "GroupC1" ); - if ( myNodes == 3 ) - GroupC1->setTitle( tr( "SMESH_ADD_TRIANGLE" ) ); - else if ( myNodes == 4 ) - GroupC1->setTitle( tr( "SMESH_ADD_QUADRANGLE" ) ); - - GroupC1->setMinimumSize( QSize( 0, 0 ) ); - GroupC1->setFrameShape( QGroupBox::Box ); - GroupC1->setFrameShadow( QGroupBox::Sunken ); - GroupC1->setColumnLayout(0, Qt::Vertical ); - GroupC1->layout()->setSpacing( 0 ); - GroupC1->layout()->setMargin( 0 ); - GroupC1Layout = new QGridLayout( GroupC1->layout() ); - GroupC1Layout->setAlignment( Qt::AlignTop ); - GroupC1Layout->setSpacing( 6 ); - GroupC1Layout->setMargin( 11 ); - TextLabelC1A1 = new QLabel( GroupC1, "TextLabelC1A1" ); - TextLabelC1A1->setText( tr( "SMESH_ID_NODES" ) ); - TextLabelC1A1->setMinimumSize( QSize( 50, 0 ) ); - TextLabelC1A1->setFrameShape( QLabel::NoFrame ); - TextLabelC1A1->setFrameShadow( QLabel::Plain ); - GroupC1Layout->addWidget( TextLabelC1A1, 0, 0 ); - SelectButtonC1A1 = new QPushButton( GroupC1, "SelectButtonC1A1" ); - SelectButtonC1A1->setText( tr( "" ) ); - SelectButtonC1A1->setPixmap( image1 ); - SelectButtonC1A1->setToggleButton( FALSE ); - GroupC1Layout->addWidget( SelectButtonC1A1, 0, 1 ); - LineEditC1A1 = new QLineEdit( GroupC1, "LineEditC1A1" ); - GroupC1Layout->addWidget( LineEditC1A1, 0, 2 ); - - Reverse = new QCheckBox( GroupC1, "Reverse" ); - Reverse->setText( tr( "SMESH_REVERSE" ) ); - GroupC1Layout->addWidget( Reverse, 1, 0 ); - - SMESHGUI_AddFaceDlgLayout->addWidget( GroupC1, 1, 0 ); - + SMESHGUI_RenumberingDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupMesh = new QGroupBox( this, "GroupMesh" ); + GroupMesh->setTitle( tr( "SMESH_RENUMBERING" ) ); + GroupMesh->setMinimumSize( QSize( 0, 0 ) ); + GroupMesh->setFrameShape( QGroupBox::Box ); + GroupMesh->setFrameShadow( QGroupBox::Sunken ); + GroupMesh->setColumnLayout(0, Qt::Vertical ); + GroupMesh->layout()->setSpacing( 0 ); + GroupMesh->layout()->setMargin( 0 ); + GroupMeshLayout = new QGridLayout( GroupMesh->layout() ); + GroupMeshLayout->setAlignment( Qt::AlignTop ); + GroupMeshLayout->setSpacing( 6 ); + GroupMeshLayout->setMargin( 11 ); + TextLabelMesh = new QLabel( GroupMesh, "TextLabelMesh" ); + TextLabelMesh->setText( tr( "SMESH_MESH" ) ); + TextLabelMesh->setMinimumSize( QSize( 50, 0 ) ); + TextLabelMesh->setFrameShape( QLabel::NoFrame ); + TextLabelMesh->setFrameShadow( QLabel::Plain ); + GroupMeshLayout->addWidget( TextLabelMesh, 0, 0 ); + SelectButton = new QPushButton( GroupMesh, "SelectButton" ); + SelectButton->setText( tr( "" ) ); + SelectButton->setPixmap( image1 ); + SelectButton->setToggleButton( FALSE ); + GroupMeshLayout->addWidget( SelectButton, 0, 1 ); + LineEditMesh = new QLineEdit( GroupMesh, "LineEditMesh" ); + LineEditMesh->setReadOnly( true ); + GroupMeshLayout->addWidget( LineEditMesh, 0, 2 ); + SMESHGUI_RenumberingDlgLayout->addWidget( GroupMesh, 1, 0 ); + Init(Sel) ; /* Initialisations */ } //================================================================================= -// function : ~SMESHGUI_AddFaceDlg() +// function : ~SMESHGUI_RenumberingDlg() // purpose : Destroys the object and frees any allocated resources //================================================================================= -SMESHGUI_AddFaceDlg::~SMESHGUI_AddFaceDlg() +SMESHGUI_RenumberingDlg::~SMESHGUI_RenumberingDlg() { - // no need to delete child widgets, Qt does it all for us + // no need to delete child widgets, Qt does it all for us } @@ -189,43 +184,44 @@ SMESHGUI_AddFaceDlg::~SMESHGUI_AddFaceDlg() // function : Init() // purpose : //================================================================================= -void SMESHGUI_AddFaceDlg::Init( SALOME_Selection* Sel ) +void SMESHGUI_RenumberingDlg::Init( SALOME_Selection* Sel ) { - GroupC1->show(); + GroupMesh->show(); myConstructorId = 0 ; Constructor1->setChecked( TRUE ); - myEditCurrentArgument = LineEditC1A1 ; mySelection = Sel; - this->myOkNodes = false ; - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ); + + myMesh = SMESH::SMESH_Mesh::_nil(); + + myMeshFilter = new SMESH_TypeFilter( MESH ); /* signals and slots connections */ connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); - - connect( SelectButtonC1A1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + + connect( SelectButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); /* to close dialog if study change */ connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - - connect( Reverse, SIGNAL(stateChanged(int)), SLOT(CheckBox(int)) ); - - reverse = false; - + /* Move widget on the botton right corner of main widget */ int x, y ; mySMESHGUI->DefineDlgPosition( this, x, y ) ; this->move( x, y ) ; this->show() ; /* displays Dialog */ - + + myEditCurrentArgument = LineEditMesh ; + LineEditMesh->setFocus(); + mySelection->ClearFilters() ; + mySelection->AddFilter( myMeshFilter ) ; + SelectionIntoArgument(); - - return ; } @@ -233,7 +229,7 @@ void SMESHGUI_AddFaceDlg::Init( SALOME_Selection* Sel ) // function : ConstructorsClicked() // purpose : Radio button management //================================================================================= -void SMESHGUI_AddFaceDlg::ConstructorsClicked(int constructorId) +void SMESHGUI_RenumberingDlg::ConstructorsClicked(int constructorId) { return ; } @@ -243,47 +239,71 @@ void SMESHGUI_AddFaceDlg::ConstructorsClicked(int constructorId) // function : ClickOnApply() // purpose : //================================================================================= -void SMESHGUI_AddFaceDlg::ClickOnApply() +void SMESHGUI_RenumberingDlg::ClickOnApply() { - switch(myConstructorId) - { - case 0 : - { - if(myOkNodes) { - mySMESHGUI->EraseSimulationActors(); - mySMESHGUI->AddFace( myMesh, myMapIndex, reverse ) ; - mySMESHGUI->ViewNodes(); - mySelection->ClearIObjects(); + if (mySMESHGUI->ActiveStudyLocked()) + return; + + if ( !myMesh->_is_nil()) + { + bool aResult = false; + try + { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + SMESH_Actor* anActor = SMESH::FindActorByObject(myMesh); + bool isUnitsLabeled = false; + + if (myUnit == 0 && anActor) { + isUnitsLabeled = anActor->GetPointsLabeled(); + if (isUnitsLabeled) anActor->SetPointsLabeled(false); + } + else if (myUnit == 1 && anActor) { + isUnitsLabeled = anActor->GetCellsLabeled(); + if (isUnitsLabeled) anActor->SetCellsLabeled(false); + } + + QApplication::setOverrideCursor(Qt::waitCursor); + if (myUnit == 0) { + aMeshEditor->RenumberNodes(); + if (isUnitsLabeled && anActor) anActor->SetPointsLabeled(true); + } + else if (myUnit == 1) { + aMeshEditor->RenumberElements(); + if (isUnitsLabeled && anActor) anActor->SetCellsLabeled(true); + } + QApplication::restoreOverrideCursor(); } - break ; - } + catch( ... ) + { + } + + mySelection->ClearIObjects(); + SMESH::UpdateView(); } - return ; } //================================================================================= // function : ClickOnOk() // purpose : //================================================================================= -void SMESHGUI_AddFaceDlg::ClickOnOk() +void SMESHGUI_RenumberingDlg::ClickOnOk() { - this->ClickOnApply() ; - this->ClickOnCancel() ; - return ; + ClickOnApply() ; + ClickOnCancel() ; } + //================================================================================= // function : ClickOnCancel() // purpose : //================================================================================= -void SMESHGUI_AddFaceDlg::ClickOnCancel() +void SMESHGUI_RenumberingDlg::ClickOnCancel() { - QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + mySelection->ClearIObjects(); + mySelection->ClearFilters(); disconnect( mySelection, 0, this, 0 ); mySMESHGUI->ResetState() ; - mySMESHGUI->EraseSimulationActors(); reject() ; - return ; } @@ -291,45 +311,34 @@ void SMESHGUI_AddFaceDlg::ClickOnCancel() // function : SelectionIntoArgument() // purpose : Called when selection as changed or other case //================================================================================= -void SMESHGUI_AddFaceDlg::SelectionIntoArgument() +void SMESHGUI_RenumberingDlg::SelectionIntoArgument() { - myEditCurrentArgument->setText("") ; - myOkNodes = false; - QString aString = ""; - - int nbSel = mySelection->IObjectCount(); - if(nbSel != 1) + if ( !GroupButtons->isEnabled() ) // inactive return; - - int nbNodes = mySMESHGUI->GetNameOfSelectedNodes(mySelection, aString) ; - if(nbNodes < 1) - return ; - if ( mySelection->SelectionMode() != NodeSelection ) { - QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("SMESH_WRN_WARNING"), - tr ("SMESH_WRN_SELECTIONMODE_NODES"), tr ("SMESH_BUT_OK") ); - return; - } + QString aString = ""; + + int nbSel = SMESH::GetNameOfSelectedIObjects(mySelection, aString) ; - myEditCurrentArgument->setText(aString) ; - Standard_Boolean res; - myMesh = mySMESHGUI->ConvertIOinMesh( mySelection->firstIObject(), res ); - if (!res) - return ; - - mySelection->GetIndex( mySelection->firstIObject(), myMapIndex ); - - if ( myNodes == 3 && nbNodes == 3 ) { - mySMESHGUI->DisplaySimulationTriangle(myMesh, myMapIndex, reverse); - myOkNodes = true ; - } else if ( myNodes == 4 && nbNodes == 4 ) { - mySMESHGUI->DisplaySimulationQuadrangle(myMesh, myMapIndex, reverse); - myOkNodes = true ; - } else { - // mySMESHGUI->EraseSimulationActors(); - myOkNodes = false ; + if ( myEditCurrentArgument == LineEditMesh ) { + // mesh + if ( nbSel != 1 ) { + myMesh = SMESH::SMESH_Mesh::_nil(); + aString = ""; + } + else { + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject() ; + myMesh = SMESH::IObjectToInterface(IO) ; + if( myMesh->_is_nil() ) + aString = ""; + } } - return ; + + myEditCurrentArgument->setText(aString) ; + + bool isEnabled = (!myMesh->_is_nil()); + buttonOk->setEnabled( isEnabled ); + buttonApply->setEnabled( isEnabled ); } @@ -337,39 +346,36 @@ void SMESHGUI_AddFaceDlg::SelectionIntoArgument() // function : SetEditCurrentArgument() // purpose : //================================================================================= -void SMESHGUI_AddFaceDlg::SetEditCurrentArgument() +void SMESHGUI_RenumberingDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); switch (myConstructorId) { case 0: /* default constructor */ { - if(send == SelectButtonC1A1) { - LineEditC1A1->setFocus() ; - myEditCurrentArgument = LineEditC1A1; + if(send == SelectButton) { + LineEditMesh->setFocus() ; + myEditCurrentArgument = LineEditMesh; } SelectionIntoArgument() ; break; } } - return ; } //================================================================================= // function : DeactivateActiveDialog() // purpose : //================================================================================= -void SMESHGUI_AddFaceDlg::DeactivateActiveDialog() +void SMESHGUI_RenumberingDlg::DeactivateActiveDialog() { - if ( GroupConstructors->isEnabled() ) { + if ( GroupConstructors->isEnabled() ) { GroupConstructors->setEnabled(false) ; - GroupC1->setEnabled(false) ; + GroupMesh->setEnabled(false) ; GroupButtons->setEnabled(false) ; - mySMESHGUI->EraseSimulationActors() ; mySMESHGUI->ResetState() ; mySMESHGUI->SetActiveDialogBox(0) ; } - return ; } @@ -377,14 +383,16 @@ void SMESHGUI_AddFaceDlg::DeactivateActiveDialog() // function : ActivateThisDialog() // purpose : //================================================================================= -void SMESHGUI_AddFaceDlg::ActivateThisDialog() +void SMESHGUI_RenumberingDlg::ActivateThisDialog() { /* Emit a signal to deactivate the active dialog */ mySMESHGUI->EmitSignalDeactivateDialog() ; GroupConstructors->setEnabled(true) ; - GroupC1->setEnabled(true) ; + GroupMesh->setEnabled(true) ; GroupButtons->setEnabled(true) ; - return ; + + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + SelectionIntoArgument(); } @@ -392,12 +400,11 @@ void SMESHGUI_AddFaceDlg::ActivateThisDialog() // function : enterEvent() // purpose : //================================================================================= -void SMESHGUI_AddFaceDlg::enterEvent(QEvent* e) +void SMESHGUI_RenumberingDlg::enterEvent(QEvent* e) { if ( GroupConstructors->isEnabled() ) return ; ActivateThisDialog() ; - return ; } @@ -405,28 +412,20 @@ void SMESHGUI_AddFaceDlg::enterEvent(QEvent* e) // function : closeEvent() // purpose : //================================================================================= -void SMESHGUI_AddFaceDlg::closeEvent( QCloseEvent* e ) +void SMESHGUI_RenumberingDlg::closeEvent( QCloseEvent* e ) { /* same than click on cancel button */ this->ClickOnCancel() ; - return ; } -void SMESHGUI_AddFaceDlg::CheckBox( int state ) -{ - if( Reverse->isOn() ) reverse = true; - else reverse = false; +//======================================================================= +//function : hideEvent +//purpose : caused by ESC key +//======================================================================= - if ( myOkNodes == false ) - return; - - if ( state >= 0 ) { - mySMESHGUI->EraseSimulationActors(); - if ( myNodes == 3 ) - mySMESHGUI->DisplaySimulationTriangle( myMesh, myMapIndex, reverse); - else if ( myNodes == 4 ) { - mySMESHGUI->DisplaySimulationQuadrangle( myMesh, myMapIndex, reverse); - } - } +void SMESHGUI_RenumberingDlg::hideEvent ( QHideEvent * e ) +{ + if ( !isMinimized() ) + ClickOnCancel(); } diff --git a/src/SMESHGUI/SMESHGUI_AddEdgeDlg.h b/src/SMESHGUI/SMESHGUI_RenumberingDlg.h similarity index 74% rename from src/SMESHGUI/SMESHGUI_AddEdgeDlg.h rename to src/SMESHGUI/SMESHGUI_RenumberingDlg.h index 579cf2533..be6bb435c 100644 --- a/src/SMESHGUI/SMESHGUI_AddEdgeDlg.h +++ b/src/SMESHGUI/SMESHGUI_RenumberingDlg.h @@ -21,25 +21,22 @@ // // // -// File : SMESHGUI_AddEdgeDlg.h -// Author : Nicolas REJNERI +// File : SMESHGUI_RenumberingDlg.h +// Author : Michael ZORIN // Module : SMESH -// $Header$ +// $Header: -#ifndef DIALOGBOX_ADD_EDGE_H -#define DIALOGBOX_ADD_EDGE_H +#ifndef DIALOGBOX_RENUMBERING_H +#define DIALOGBOX_RENUMBERING_H #include "SALOME_Selection.h" +#include "SMESH_TypeFilter.hxx" // QT Includes -#include #include // Open CASCADE Includes -#include -class QVBoxLayout; -class QHBoxLayout; class QGridLayout; class QButtonGroup; class QGroupBox; @@ -47,7 +44,6 @@ class QLabel; class QLineEdit; class QPushButton; class QRadioButton; -class QCheckBox; class SMESHGUI; // IDL Headers @@ -55,44 +51,43 @@ class SMESHGUI; #include CORBA_SERVER_HEADER(SMESH_Mesh) //================================================================================= -// class : SMESHGUI_AddEdgeDlg -// purpose : +// class : SMESHGUI_RenumberingDlg +// purpose : If the unit == 0 nodes will be renumbered, if the unit == 1 the elements will. //================================================================================= -class SMESHGUI_AddEdgeDlg : public QDialog +class SMESHGUI_RenumberingDlg : public QDialog { Q_OBJECT public: - SMESHGUI_AddEdgeDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); - ~SMESHGUI_AddEdgeDlg(); + SMESHGUI_RenumberingDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, const int unit = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_RenumberingDlg(); private: void Init( SALOME_Selection* Sel ) ; void closeEvent( QCloseEvent* e ) ; void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ - + void hideEvent ( QHideEvent * ); /* ESC key */ + SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ SALOME_Selection* mySelection ; /* User shape selection */ - bool myOkNodes ; /* to check when arguments is defined */ - - int myNodes ; int myConstructorId ; /* Current constructor id = radio button id */ QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + int myUnit; SMESH::SMESH_Mesh_var myMesh; - TColStd_MapOfInteger myMapIndex; - + Handle(SMESH_TypeFilter) myMeshFilter; + QButtonGroup* GroupConstructors; QRadioButton* Constructor1; QGroupBox* GroupButtons; QPushButton* buttonOk; QPushButton* buttonCancel; QPushButton* buttonApply; - QGroupBox* GroupC1; - QLabel* TextLabelC1A1; - QPushButton* SelectButtonC1A1; - QLineEdit* LineEditC1A1; + QGroupBox* GroupMesh; + QLabel* TextLabelMesh; + QPushButton* SelectButton; + QLineEdit* LineEditMesh; private slots: @@ -104,12 +99,12 @@ private slots: void SelectionIntoArgument() ; void DeactivateActiveDialog() ; void ActivateThisDialog() ; - + protected: - QGridLayout* SMESHGUI_AddEdgeDlgLayout; + QGridLayout* SMESHGUI_RenumberingDlgLayout; QGridLayout* GroupConstructorsLayout; QGridLayout* GroupButtonsLayout; - QGridLayout* GroupC1Layout; + QGridLayout* GroupMeshLayout; }; -#endif // DIALOGBOX_ADD_EDGE_H +#endif // DIALOGBOX_RENUMBERING_H diff --git a/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx b/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx new file mode 100644 index 000000000..9b7be8bb4 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx @@ -0,0 +1,917 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_RevolutionDlg.cxx +// Author : Michael ZORIN +// Module : SMESH +// $Header: + +#include "SMESHGUI_RevolutionDlg.h" +#include "SMESHGUI.h" +#include "SMESHGUI_SpinBox.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_MeshUtils.h" +#include "SMESHGUI_IdValidator.h" +#include "SMESH_Actor.h" +#include "SMESH_TypeFilter.hxx" +#include "SMDS_Mesh.hxx" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +//================================================================================= +// class : SMESHGUI_RevolutionDlg() +// purpose : +//================================================================================= +SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, + bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | + Qt::WDestructiveClose) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_EDGE"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_TRIANGLE"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); + + if ( !name ) + setName( "SMESHGUI_RevolutionDlg" ); + resize( 303, 185 ); + setCaption( tr( "REVOLUTION_AROUND_AXIS" ) ); + setSizeGripEnabled( TRUE ); + SMESHGUI_RevolutionDlgLayout = new QGridLayout( this ); + SMESHGUI_RevolutionDlgLayout->setSpacing( 6 ); + SMESHGUI_RevolutionDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "SMESH_REVOLUTION" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" ); + RadioButton1->setText( tr( "" ) ); + RadioButton1->setPixmap( image0 ); + GroupConstructorsLayout->addWidget( RadioButton1, 0, 0 ); + RadioButton2= new QRadioButton( GroupConstructors, "RadioButton2" ); + RadioButton2->setText( tr( "" ) ); + RadioButton2->setPixmap( image1 ); + GroupConstructorsLayout->addWidget( RadioButton2, 0, 2 ); + SMESHGUI_RevolutionDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_RevolutionDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupArguments = new QGroupBox( this, "GroupArguments" ); + GroupArguments->setTitle( tr( "REVOLUTION_1D" ) ); + GroupArguments->setColumnLayout(0, Qt::Vertical ); + GroupArguments->layout()->setSpacing( 0 ); + GroupArguments->layout()->setMargin( 0 ); + GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() ); + GroupArgumentsLayout->setAlignment( Qt::AlignTop ); + GroupArgumentsLayout->setSpacing( 6 ); + GroupArgumentsLayout->setMargin( 11 ); + + // Controls for elements selection + TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" ); + TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) ); + TextLabelElements->setFixedWidth(74); + GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 ); + + SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" ); + SelectElementsButton->setText( tr( "" ) ); + SelectElementsButton->setPixmap( image2 ); + SelectElementsButton->setToggleButton( FALSE ); + GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 ); + + LineEditElements = new QLineEdit( GroupArguments, "LineEditElements" ); + LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" )); + GroupArgumentsLayout->addWidget( LineEditElements, 0, 2 ); + + // Control for the whole mesh selection + CheckBoxMesh = new QCheckBox( GroupArguments, "CheckBoxMesh" ); + CheckBoxMesh->setText( tr( "SMESH_SELECT_WHOLE_MESH" ) ); + GroupArgumentsLayout->addMultiCellWidget( CheckBoxMesh, 1, 1, 0, 3 ); + + // Controls for axis defining + GroupAxis = new QGroupBox( GroupArguments, "GroupAxis" ); + GroupAxis->setTitle( tr( "SMESH_AXIS" ) ); + GroupAxis->setColumnLayout(0, Qt::Vertical ); + GroupAxis->layout()->setSpacing( 0 ); + GroupAxis->layout()->setMargin( 0 ); + QGridLayout* GroupAxisLayout = new QGridLayout( GroupAxis->layout() ); + GroupAxisLayout->setAlignment( Qt::AlignTop ); + GroupAxisLayout->setSpacing( 6 ); + GroupAxisLayout->setMargin( 11 ); + + TextLabelPoint = new QLabel( GroupAxis, "TextLabelPoint" ); + TextLabelPoint->setText( tr( "SMESH_POINT" ) ); + GroupAxisLayout->addWidget( TextLabelPoint, 0, 0 ); + + SelectPointButton = new QPushButton( GroupAxis, "SelectPointButton" ); + SelectPointButton->setPixmap( image2 ); + GroupAxisLayout->addWidget( SelectPointButton, 0, 1 ); + + TextLabelX = new QLabel( GroupAxis, "TextLabelX" ); + TextLabelX->setText( tr( "SMESH_X" ) ); + GroupAxisLayout->addWidget( TextLabelX, 0, 2 ); + + SpinBox_X = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_X"); + GroupAxisLayout->addWidget( SpinBox_X, 0, 3 ); + + TextLabelY = new QLabel( GroupAxis, "TextLabelY" ); + TextLabelY->setText( tr( "SMESH_Y" ) ); + GroupAxisLayout->addWidget( TextLabelY, 0, 4 ); + + SpinBox_Y = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_Y"); + GroupAxisLayout->addWidget( SpinBox_Y, 0, 5 ); + + TextLabelZ = new QLabel( GroupAxis, "TextLabelZ" ); + TextLabelZ->setText( tr( "SMESH_Z" ) ); + GroupAxisLayout->addWidget( TextLabelZ, 0, 6 ); + + SpinBox_Z = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_Z"); + GroupAxisLayout->addWidget( SpinBox_Z, 0, 7 ); + + TextLabelVector = new QLabel( GroupAxis, "TextLabelVector" ); + TextLabelVector->setText( tr( "SMESH_VECTOR" ) ); + GroupAxisLayout->addWidget( TextLabelVector, 1, 0 ); + + SelectVectorButton = new QPushButton( GroupAxis, "SelectVectorButton" ); + SelectVectorButton->setPixmap( image2 ); + GroupAxisLayout->addWidget( SelectVectorButton, 1, 1 ); + + TextLabelDX = new QLabel( GroupAxis, "TextLabelDX" ); + TextLabelDX->setText( tr( "SMESH_DX" ) ); + GroupAxisLayout->addWidget( TextLabelDX, 1, 2 ); + + SpinBox_DX = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DX"); + GroupAxisLayout->addWidget( SpinBox_DX, 1, 3 ); + + TextLabelDY = new QLabel( GroupAxis, "TextLabelDY" ); + TextLabelDY->setText( tr( "SMESH_DY" ) ); + GroupAxisLayout->addWidget( TextLabelDY, 1, 4 ); + + SpinBox_DY = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DY"); + GroupAxisLayout->addWidget( SpinBox_DY, 1, 5 ); + + TextLabelDZ = new QLabel( GroupAxis, "TextLabelDZ" ); + TextLabelDZ->setText( tr( "SMESH_DZ" ) ); + GroupAxisLayout->addWidget( TextLabelDZ, 1, 6 ); + + SpinBox_DZ = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DZ"); + GroupAxisLayout->addWidget( SpinBox_DZ, 1, 7 ); + + GroupArgumentsLayout->addMultiCellWidget( GroupAxis, 2, 2, 0, 3 ); + + // Controls for angle defining + TextLabelAngle = new QLabel( GroupArguments, "TextLabelAngle" ); + TextLabelAngle->setText( tr( "SMESH_ANGLE" ) ); + GroupArgumentsLayout->addMultiCellWidget( TextLabelAngle, 3, 3, 0, 1 ); + + SpinBox_Angle = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Angle"); + GroupArgumentsLayout->addWidget( SpinBox_Angle, 3, 2 ); + + // Controls for nb. steps defining + TextLabelNbSteps = new QLabel( GroupArguments, "TextLabelNbSteps" ); + TextLabelNbSteps->setText( tr( "SMESH_NUMBEROFSTEPS" ) ); + GroupArgumentsLayout->addMultiCellWidget( TextLabelNbSteps, 4, 4, 0, 1 ); + + SpinBox_NbSteps = new QSpinBox(GroupArguments, "SpinBox_NbSteps"); + GroupArgumentsLayout->addWidget( SpinBox_NbSteps, 4, 2 ); + + // Controls for tolerance defining + TextLabelTolerance = new QLabel( GroupArguments, "TextLabelTolerance" ); + TextLabelTolerance->setText( tr( "SMESH_TOLERANCE" ) ); + GroupArgumentsLayout->addMultiCellWidget( TextLabelTolerance, 5, 5, 0, 1 ); + + SpinBox_Tolerance = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Tolerance"); + GroupArgumentsLayout->addWidget( SpinBox_Tolerance, 5, 2 ); + + SMESHGUI_RevolutionDlgLayout->addWidget( GroupArguments, 1, 0 ); + + /* Initialisations */ + SpinBox_X->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox_Y->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox_Z->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox_DX->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox_DY->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox_DZ->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + + SpinBox_Angle->RangeStepAndValidator( -999999.999, +999999.999, 5.0, 3 ); + + QIntValidator* anIntValidator = new QIntValidator(SpinBox_NbSteps); + SpinBox_NbSteps->setValidator(anIntValidator); + SpinBox_NbSteps->setRange( 1, 999999 ); + + SpinBox_Tolerance->RangeStepAndValidator( 0.0, +999999.999, 0.1, 6 ); + + GroupArguments->show(); + RadioButton1->setChecked( TRUE ); + mySelection = Sel; + + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + // Costruction of the logical filter + SMESH_ListOfFilter aListOfFilters; + Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); + if ( !aMeshOrSubMeshFilter.IsNull() ) + aListOfFilters.Append( aMeshOrSubMeshFilter ); + Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP ); + if ( !aSmeshGroupFilter.IsNull() ) + aListOfFilters.Append( aSmeshGroupFilter ); + + myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR ); + + Init(); + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectPointButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectVectorButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + + connect( SpinBox_DX, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) ); + connect( SpinBox_DY, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) ); + connect( SpinBox_DZ, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) ); + + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + /* to close dialog if study change */ + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + connect( LineEditElements, SIGNAL( textChanged( const QString& )), + SLOT( onTextChange( const QString& ))); + connect( CheckBoxMesh, SIGNAL( toggled( bool )), + SLOT( onSelectMesh( bool ))); + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + ConstructorsClicked(0); +} + +//================================================================================= +// function : ~SMESHGUI_RevolutionDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_RevolutionDlg::~SMESHGUI_RevolutionDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_RevolutionDlg::Init( bool ResetControls ) +{ + myBusy = false; + + myEditCurrentArgument = 0; + LineEditElements->clear(); + myElementsId = ""; + myNbOkElements = 0 ; + + myActor = 0; + myMesh = SMESH::SMESH_Mesh::_nil(); + + if( ResetControls ) + { + SpinBox_X->SetValue(0.0); + SpinBox_Y->SetValue(0.0); + SpinBox_Z->SetValue(0.0); + SpinBox_DX->SetValue(0.0); + SpinBox_DY->SetValue(0.0); + SpinBox_DZ->SetValue(0.0); + + SpinBox_Angle->SetValue(45); + SpinBox_NbSteps->setValue(1); + SpinBox_Tolerance->SetValue(1e-05); + + CheckBoxMesh->setChecked(false); + onSelectMesh( false ); + } +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_RevolutionDlg::ConstructorsClicked(int constructorId) +{ + disconnect(mySelection, 0, this, 0); + + Selection_Mode aSelMode = ActorSelection; + + switch(constructorId) + { + case 0 : + { + GroupArguments->setTitle( tr( "REVOLUTION_1D" ) ); + aSelMode = EdgeSelection; + break; + } + case 1 : + { + GroupArguments->setTitle( tr( "REVOLUTION_2D" ) ); + aSelMode = FaceSelection; + break; + } + } + + if (myEditCurrentArgument != (QWidget*)LineEditElements) + SMESH::SetPointRepresentation(false); + + if (!CheckBoxMesh->isChecked()) + QAD_Application::getDesktop()->SetSelectionMode( aSelMode, true ); + + myEditCurrentArgument = (QWidget*)LineEditElements; + LineEditElements->setFocus(); + + if (CheckBoxMesh->isChecked()) + onSelectMesh(true); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_RevolutionDlg::ClickOnApply() +{ + if (mySMESHGUI->ActiveStudyLocked()) + return; + + if ( myNbOkElements && IsAxisOk()) + { + QStringList aListElementsId = QStringList::split( " ", myElementsId, false); + + SMESH::long_array_var anElementsId = new SMESH::long_array; + + anElementsId->length( aListElementsId.count() ); + for ( int i = 0; i < aListElementsId.count(); i++ ) + anElementsId[i] = aListElementsId[i].toInt(); + + SMESH::AxisStruct anAxis; + + anAxis.x = SpinBox_X->GetValue(); + anAxis.y = SpinBox_Y->GetValue(); + anAxis.z = SpinBox_Z->GetValue();; + anAxis.vx = SpinBox_DX->GetValue(); + anAxis.vy = SpinBox_DY->GetValue(); + anAxis.vz = SpinBox_DZ->GetValue(); + + double anAngle = (SpinBox_Angle->GetValue())*PI/180; + long aNbSteps = (long)SpinBox_NbSteps->value(); + double aTolerance = SpinBox_Tolerance->GetValue(); + + try + { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + QApplication::setOverrideCursor(Qt::waitCursor); + aMeshEditor->RotationSweep(anElementsId.inout(), anAxis, anAngle, aNbSteps, aTolerance); + QApplication::restoreOverrideCursor(); + } + catch( ... ) + { + } + + mySelection->ClearIObjects(); + SMESH::UpdateView(); + Init( false); + ConstructorsClicked( GetConstructorId() ); + } +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_RevolutionDlg::ClickOnOk() +{ + ClickOnApply() ; + ClickOnCancel() ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_RevolutionDlg::ClickOnCancel() +{ + mySelection->ClearFilters(); + mySelection->ClearIObjects(); + SMESH::SetPointRepresentation(false); + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + reject() ; +} + +//======================================================================= +//function : onTextChange +//purpose : +//======================================================================= + +void SMESHGUI_RevolutionDlg::onTextChange(const QString& theNewText) +{ + QLineEdit* send = (QLineEdit*)sender(); + + if ( myBusy ) return; + myBusy = true; + + if (send == LineEditElements) + myNbOkElements = 0; + + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + + // hilight entered elements + SMDS_Mesh* aMesh = 0; + if ( myActor ) + aMesh = myActor->GetObject()->GetMesh(); + + if ( aMesh ) { + mySelection->ClearIObjects(); + mySelection->AddIObject( myActor->getIO() ); + + QStringList aListId = QStringList::split( " ", theNewText, false); + + if (send == LineEditElements) { + for ( int i = 0; i < aListId.count(); i++ ) { + const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() ); + if ( e ) { + if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() )) + mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true); + myNbOkElements++; + } + } + myElementsId = theNewText; + } + } + + if ( myNbOkElements && IsAxisOk() ) { + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); + } + + myBusy = false; +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void SMESHGUI_RevolutionDlg::SelectionIntoArgument() +{ + if ( myBusy ) return; + + // clear + myActor = 0; + QString aString = ""; + + myBusy = true; + if (myEditCurrentArgument == (QWidget*)LineEditElements) + { + LineEditElements->setText( aString ); + myNbOkElements = 0; + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + } + myBusy = false; + + if ( !GroupButtons->isEnabled() ) // inactive + return; + + // get selected mesh + int nbSel = mySelection->IObjectCount(); + if(nbSel != 1) + return; + + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + myMesh = SMESH::GetMeshByIO(IO); + if(myMesh->_is_nil()) + return; + myActor = SMESH::FindActorByObject(myMesh); + if (!myActor) + return; + + int aNbUnits = 0; + + if (myEditCurrentArgument == (QWidget*)LineEditElements) + { + myElementsId = ""; + + if (CheckBoxMesh->isChecked()) + { + SMESH::GetNameOfSelectedIObjects(mySelection, aString); + + int aConstructorId = GetConstructorId(); + + if(!SMESH::IObjectToInterface(IO)->_is_nil()) //MESH + { + // get IDs from mesh + SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); + if (!aSMDSMesh) + return; + + if (aConstructorId == 0) + { + SMDS_EdgeIteratorPtr anIter = aSMDSMesh->edgesIterator(); + + while ( anIter->more() ) + { + const SMDS_MeshEdge * edge = anIter->next(); + if ( edge ) { + myElementsId += QString(" %1").arg(edge->GetID()); + aNbUnits++; + } + } + } + else if (aConstructorId == 1) + { + SMDS_FaceIteratorPtr anIter = aSMDSMesh->facesIterator(); + while ( anIter->more() ) + { + const SMDS_MeshFace * face = anIter->next(); + if ( face ) { + myElementsId += QString(" %1").arg(face->GetID()); + aNbUnits++; + } + } + } + } + else if (!SMESH::IObjectToInterface(IO)->_is_nil()) //SUBMESH + { + // get submesh + SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(IO) ; + + // get IDs from submesh + SMESH::long_array_var anElementsIds = new SMESH::long_array; + if (aConstructorId == 0) + anElementsIds = aSubMesh->GetElementsByType(SMESH::EDGE); + else if (aConstructorId == 1) + anElementsIds = aSubMesh->GetElementsByType(SMESH::FACE); + + for ( int i = 0; i < anElementsIds->length(); i++ ) + myElementsId += QString(" %1").arg(anElementsIds[i]); + aNbUnits = anElementsIds->length(); + } + else // GROUP + { + // get smesh group + SMESH::SMESH_GroupBase_var aGroup = + SMESH::IObjectToInterface(IO); + if (aGroup->_is_nil()) + return; + + if ( (aConstructorId == 0 && aGroup->GetType()!= SMESH::EDGE) || + (aConstructorId == 1 && aGroup->GetType()!= SMESH::FACE) ) + return; + + // get IDs from smesh group + SMESH::long_array_var anElementsIds = new SMESH::long_array; + anElementsIds = aGroup->GetListOfID(); + for ( int i = 0; i < anElementsIds->length(); i++ ) + myElementsId += QString(" %1").arg(anElementsIds[i]); + aNbUnits = anElementsIds->length(); + } + } + else + { + aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString) ; + myElementsId = aString; + } + + if(aNbUnits < 1) + return ; + + myNbOkElements = true; + } + else + { + aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString); + if(aNbUnits != 1) + return; + + SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh(); + if (!aMesh) + return; + + 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()); + } + } + + myBusy = true; + if (myEditCurrentArgument == (QWidget*)LineEditElements) + LineEditElements->setText( aString ); + myBusy = false; + + // OK + if(myNbOkElements && IsAxisOk()) + { + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); + } +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void SMESHGUI_RevolutionDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + disconnect( mySelection, 0, this, 0 ); + mySelection->ClearIObjects(); + mySelection->ClearFilters(); + + if(send == SelectElementsButton) { + myEditCurrentArgument = (QWidget*)LineEditElements; + SMESH::SetPointRepresentation(false); + if (CheckBoxMesh->isChecked()) + { + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter); + } + else + { + int aConstructorId = GetConstructorId(); + if (aConstructorId == 0) + QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true ); + else if (aConstructorId == 1) + QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true ); + } + } + else if (send == SelectPointButton) + { + myEditCurrentArgument = (QWidget*)SpinBox_X; + SMESH::SetPointRepresentation(true); + QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + } + else if (send == SelectVectorButton) + { + myEditCurrentArgument = (QWidget*)SpinBox_DX; + SMESH::SetPointRepresentation(true); + QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + } + + myEditCurrentArgument->setFocus(); + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + SelectionIntoArgument() ; +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_RevolutionDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupArguments->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + mySMESHGUI->ResetState() ; + mySMESHGUI->SetActiveDialogBox(0) ; + } +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_RevolutionDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupArguments->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + ConstructorsClicked(GetConstructorId()); + SelectionIntoArgument(); +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_RevolutionDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_RevolutionDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; + return ; +} + + +//======================================================================= +//function : hideEvent +//purpose : caused by ESC key +//======================================================================= + +void SMESHGUI_RevolutionDlg::hideEvent ( QHideEvent * e ) +{ + if ( !isMinimized() ) + ClickOnCancel(); +} + + +//================================================================================= +// function : GetConstructorId() +// purpose : +//================================================================================= +int SMESHGUI_RevolutionDlg::GetConstructorId() +{ + if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL ) + return GroupConstructors->id( GroupConstructors->selected() ); + return -1; +} + + +//================================================================================= +// function : IsAxisOk() +// purpose : +//================================================================================= +bool SMESHGUI_RevolutionDlg::IsAxisOk() +{ + return (SpinBox_DX->GetValue() != 0 || + SpinBox_DY->GetValue() != 0 || + SpinBox_DZ->GetValue() != 0); +} + + +//================================================================================= +// function : onVectorChanged() +// purpose : +//================================================================================= +void SMESHGUI_RevolutionDlg::onVectorChanged() +{ + if (IsAxisOk()) + { + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); + } + else + { + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + } +} + + +//======================================================================= +//function : onSelectMesh +//purpose : +//======================================================================= +void SMESHGUI_RevolutionDlg::onSelectMesh ( bool toSelectMesh ) +{ + if (toSelectMesh) + TextLabelElements->setText( tr( "SMESH_NAME" ) ); + else + TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) ); + + if (myEditCurrentArgument != LineEditElements) + { + LineEditElements->clear(); + return; + } + + mySelection->ClearFilters() ; + SMESH::SetPointRepresentation(false); + + if (toSelectMesh) + { + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter); + LineEditElements->setReadOnly(true); + } + else + { + int aConstructorId = GetConstructorId(); + if (aConstructorId == 0) + QAD_Application::getDesktop()->SetSelectionMode( EdgeSelection, true ); + else if (aConstructorId == 0) + QAD_Application::getDesktop()->SetSelectionMode( FaceSelection, true ); + + LineEditElements->setReadOnly(false); + onTextChange(LineEditElements->text()); + } + + SelectionIntoArgument(); +} diff --git a/src/SMESHGUI/SMESHGUI_RevolutionDlg.h b/src/SMESHGUI/SMESHGUI_RevolutionDlg.h new file mode 100644 index 000000000..6b55513e3 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_RevolutionDlg.h @@ -0,0 +1,147 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_RevolutionDlg.h +// Author : Michael ZORIN +// Module : SMESH +// $Header: + +#ifndef DIALOGBOX_REVOLUTION_H +#define DIALOGBOX_REVOLUTION_H + +#include "SALOME_Selection.h" +#include "SMESH_LogicalFilter.hxx" +// QT Includes +#include + +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class QCheckBox; +class QSpinBox; +class SMESHGUI_SpinBox; +class SMESHGUI; +class SMESH_Actor; +class SMESHGUI_SpinBox; + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) + + +//================================================================================= +// class : SMESHGUI_RevolutionDlg +// purpose : +//================================================================================= +class SMESHGUI_RevolutionDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_RevolutionDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_RevolutionDlg(); + +private: + + void Init( bool ResetControls = true ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void hideEvent ( QHideEvent * ); /* ESC key */ + int GetConstructorId(); + bool IsAxisOk(); + + SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + int myNbOkElements ; /* to check when elements are defined */ + QString myElementsId; + QWidget* myEditCurrentArgument; /* Current argument */ + + bool myBusy; + SMESH::SMESH_Mesh_var myMesh; + SMESH_Actor* myActor; + Handle(SMESH_LogicalFilter) myMeshOrSubMeshOrGroupFilter; + + QButtonGroup* GroupConstructors; + QRadioButton* RadioButton1; + QRadioButton* RadioButton2; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + QGroupBox* GroupArguments; + QGroupBox* GroupAxis; + QLabel* TextLabelElements; + QPushButton* SelectElementsButton; + QLineEdit* LineEditElements; + QCheckBox* CheckBoxMesh; + + QLabel* TextLabelPoint; + QPushButton* SelectPointButton; + QLabel* TextLabelX; + SMESHGUI_SpinBox* SpinBox_X; + QLabel* TextLabelY; + SMESHGUI_SpinBox* SpinBox_Y; + QLabel* TextLabelZ; + SMESHGUI_SpinBox* SpinBox_Z; + QLabel* TextLabelVector; + QPushButton* SelectVectorButton; + QLabel* TextLabelDX; + SMESHGUI_SpinBox* SpinBox_DX; + QLabel* TextLabelDY; + SMESHGUI_SpinBox* SpinBox_DY; + QLabel* TextLabelDZ; + SMESHGUI_SpinBox* SpinBox_DZ; + + QLabel* TextLabelAngle; + SMESHGUI_SpinBox* SpinBox_Angle; + QLabel* TextLabelNbSteps; + QSpinBox* SpinBox_NbSteps; + QLabel* TextLabelTolerance; + SMESHGUI_SpinBox* SpinBox_Tolerance; + + private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + void onTextChange(const QString&); + void onVectorChanged(); + void onSelectMesh(bool toSelectMesh); + +protected: + QGridLayout* SMESHGUI_RevolutionDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupArgumentsLayout; +}; + +#endif // DIALOGBOX_REVOLUTION_H diff --git a/src/SMESHGUI/SMESHGUI_RotationDlg.cxx b/src/SMESHGUI/SMESHGUI_RotationDlg.cxx new file mode 100644 index 000000000..e8ae9052e --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_RotationDlg.cxx @@ -0,0 +1,831 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_RotationDlg.cxx +// Author : Michael ZORIN +// Module : SMESH +// $Header: + +#include "SMESHGUI_RotationDlg.h" + +#include "SMESHGUI.h" +#include "SMESHGUI_SpinBox.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_MeshUtils.h" +#include "SMESHGUI_IdValidator.h" +#include "SMESH_Actor.h" +#include "SMESH_TypeFilter.hxx" +#include "SMDS_Mesh.hxx" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +//================================================================================= +// class : SMESHGUI_RotationDlg() +// purpose : +//================================================================================= +SMESHGUI_RotationDlg::SMESHGUI_RotationDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, + bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | + Qt::WDestructiveClose) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_ROTATION"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); + + if ( !name ) + setName( "SMESHGUI_RotationDlg" ); + resize( 303, 185 ); + setCaption( tr( "SMESH_ROTATION_TITLE" ) ); + setSizeGripEnabled( TRUE ); + SMESHGUI_RotationDlgLayout = new QGridLayout( this ); + SMESHGUI_RotationDlgLayout->setSpacing( 6 ); + SMESHGUI_RotationDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) ); + GroupConstructors->setTitle( tr( "SMESH_ROTATION" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" ); + RadioButton1->setText( tr( "" ) ); + RadioButton1->setPixmap( image0 ); + RadioButton1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, RadioButton1->sizePolicy().hasHeightForWidth() ) ); + RadioButton1->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( RadioButton1, 0, 0 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer, 0, 1 ); + SMESHGUI_RotationDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_RotationDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupArguments = new QGroupBox( this, "GroupArguments" ); + GroupArguments->setTitle( tr( "SMESH_ARGUMENTS" ) ); + GroupArguments->setColumnLayout(0, Qt::Vertical ); + GroupArguments->layout()->setSpacing( 0 ); + GroupArguments->layout()->setMargin( 0 ); + GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() ); + GroupArgumentsLayout->setAlignment( Qt::AlignTop ); + GroupArgumentsLayout->setSpacing( 6 ); + GroupArgumentsLayout->setMargin( 11 ); + + // Controls for elements selection + TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" ); + TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) ); + TextLabelElements->setFixedWidth(74); + GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 ); + + SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" ); + SelectElementsButton->setText( tr( "" ) ); + SelectElementsButton->setPixmap( image1 ); + SelectElementsButton->setToggleButton( FALSE ); + GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 ); + + LineEditElements = new QLineEdit( GroupArguments, "LineEditElements" ); + LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" )); + GroupArgumentsLayout->addWidget( LineEditElements, 0, 2 ); + + // Control for the whole mesh selection + CheckBoxMesh = new QCheckBox( GroupArguments, "CheckBoxMesh" ); + CheckBoxMesh->setText( tr( "SMESH_SELECT_WHOLE_MESH" ) ); + GroupArgumentsLayout->addMultiCellWidget( CheckBoxMesh, 1, 1, 0, 2 ); + + // Controls for axis defining + GroupAxis = new QGroupBox( GroupArguments, "GroupAxis" ); + GroupAxis->setTitle( tr( "SMESH_AXIS" ) ); + GroupAxis->setColumnLayout(0, Qt::Vertical ); + GroupAxis->layout()->setSpacing( 0 ); + GroupAxis->layout()->setMargin( 0 ); + QGridLayout* GroupAxisLayout = new QGridLayout( GroupAxis->layout() ); + GroupAxisLayout->setAlignment( Qt::AlignTop ); + GroupAxisLayout->setSpacing( 6 ); + GroupAxisLayout->setMargin( 11 ); + + TextLabelPoint = new QLabel( GroupAxis, "TextLabelPoint" ); + TextLabelPoint->setText( tr( "SMESH_POINT" ) ); + GroupAxisLayout->addWidget( TextLabelPoint, 0, 0 ); + + SelectPointButton = new QPushButton( GroupAxis, "SelectPointButton" ); + SelectPointButton->setPixmap( image1 ); + GroupAxisLayout->addWidget( SelectPointButton, 0, 1 ); + + TextLabelX = new QLabel( GroupAxis, "TextLabelX" ); + TextLabelX->setText( tr( "SMESH_X" ) ); + GroupAxisLayout->addWidget( TextLabelX, 0, 2 ); + + SpinBox_X = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_X"); + GroupAxisLayout->addWidget( SpinBox_X, 0, 3 ); + + TextLabelY = new QLabel( GroupAxis, "TextLabelY" ); + TextLabelY->setText( tr( "SMESH_Y" ) ); + GroupAxisLayout->addWidget( TextLabelY, 0, 4 ); + + SpinBox_Y = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_Y"); + GroupAxisLayout->addWidget( SpinBox_Y, 0, 5 ); + + TextLabelZ = new QLabel( GroupAxis, "TextLabelZ" ); + TextLabelZ->setText( tr( "SMESH_Z" ) ); + GroupAxisLayout->addWidget( TextLabelZ, 0, 6 ); + + SpinBox_Z = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_Z"); + GroupAxisLayout->addWidget( SpinBox_Z, 0, 7 ); + + TextLabelVector = new QLabel( GroupAxis, "TextLabelVector" ); + TextLabelVector->setText( tr( "SMESH_VECTOR" ) ); + GroupAxisLayout->addWidget( TextLabelVector, 1, 0 ); + + SelectVectorButton = new QPushButton( GroupAxis, "SelectVectorButton" ); + SelectVectorButton->setPixmap( image1 ); + GroupAxisLayout->addWidget( SelectVectorButton, 1, 1 ); + + TextLabelDX = new QLabel( GroupAxis, "TextLabelDX" ); + TextLabelDX->setText( tr( "SMESH_DX" ) ); + GroupAxisLayout->addWidget( TextLabelDX, 1, 2 ); + + SpinBox_DX = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DX"); + GroupAxisLayout->addWidget( SpinBox_DX, 1, 3 ); + + TextLabelDY = new QLabel( GroupAxis, "TextLabelDY" ); + TextLabelDY->setText( tr( "SMESH_DY" ) ); + GroupAxisLayout->addWidget( TextLabelDY, 1, 4 ); + + SpinBox_DY = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DY"); + GroupAxisLayout->addWidget( SpinBox_DY, 1, 5 ); + + TextLabelDZ = new QLabel( GroupAxis, "TextLabelDZ" ); + TextLabelDZ->setText( tr( "SMESH_DZ" ) ); + GroupAxisLayout->addWidget( TextLabelDZ, 1, 6 ); + + SpinBox_DZ = new SMESHGUI_SpinBox( GroupAxis, "SpinBox_DZ"); + GroupAxisLayout->addWidget( SpinBox_DZ, 1, 7 ); + + GroupArgumentsLayout->addMultiCellWidget( GroupAxis, 2, 2, 0, 2 ); + + // Controls for angle defining + TextLabelAngle = new QLabel( GroupArguments, "TextLabelAngle" ); + TextLabelAngle->setText( tr( "SMESH_ANGLE" ) ); + GroupArgumentsLayout->addMultiCellWidget( TextLabelAngle, 3, 3, 0, 1 ); + + SpinBox_Angle = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_Angle"); + GroupArgumentsLayout->addWidget( SpinBox_Angle, 3, 2 ); + + // Controls for "Create a copy" option + CheckBoxCopy = new QCheckBox( GroupArguments, "CheckBoxCopy" ); + CheckBoxCopy->setText( tr( "SMESH_CREATE_COPY" ) ); + GroupArgumentsLayout->addMultiCellWidget( CheckBoxCopy, 4, 4, 0, 2 ); + + + SMESHGUI_RotationDlgLayout->addWidget( GroupArguments, 1, 0 ); + + /* Initialisations */ + SpinBox_X->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox_Y->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox_Z->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox_DX->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox_DY->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox_DZ->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + + SpinBox_Angle->RangeStepAndValidator( -999999.999, +999999.999, 5.0, 3 ); + + GroupArguments->show(); + myConstructorId = 0 ; + RadioButton1->setChecked( TRUE ); + mySelection = Sel; + + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + // Costruction of the logical filter + SMESH_ListOfFilter aListOfFilters; + Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); + if ( !aMeshOrSubMeshFilter.IsNull() ) + aListOfFilters.Append( aMeshOrSubMeshFilter ); + Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP ); + if ( !aSmeshGroupFilter.IsNull() ) + aListOfFilters.Append( aSmeshGroupFilter ); + + myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR ); + + Init(); + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectPointButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectVectorButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + + connect( SpinBox_DX, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) ); + connect( SpinBox_DY, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) ); + connect( SpinBox_DZ, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) ); + + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + /* to close dialog if study change */ + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + connect( LineEditElements, SIGNAL( textChanged( const QString& )), + SLOT( onTextChange( const QString& ))); + connect( CheckBoxMesh, SIGNAL( toggled( bool )), + SLOT( onSelectMesh( bool ))); + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + ConstructorsClicked(0); + resize(0,0); +} + +//================================================================================= +// function : ~SMESHGUI_RotationDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_RotationDlg::~SMESHGUI_RotationDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_RotationDlg::Init( bool ResetControls ) +{ + myBusy = false; + + myEditCurrentArgument = (QWidget*)LineEditElements; + LineEditElements->setFocus(); + myElementsId = ""; + myNbOkElements = 0 ; + + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + + myActor = 0; + myMesh = SMESH::SMESH_Mesh::_nil(); + + if( ResetControls ) + { + SpinBox_X->SetValue(0.0); + SpinBox_Y->SetValue(0.0); + SpinBox_Z->SetValue(0.0); + SpinBox_DX->SetValue(0.0); + SpinBox_DY->SetValue(0.0); + SpinBox_DZ->SetValue(0.0); + + SpinBox_Angle->SetValue(45); + + CheckBoxCopy->setChecked(false); + CheckBoxMesh->setChecked(false); + } + + onSelectMesh(CheckBoxMesh->isChecked()); +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_RotationDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_RotationDlg::ClickOnApply() +{ + if (mySMESHGUI->ActiveStudyLocked()) + return; + + if ( myNbOkElements && IsAxisOk()) + { + QStringList aListElementsId = QStringList::split( " ", myElementsId, false); + + SMESH::long_array_var anElementsId = new SMESH::long_array; + + anElementsId->length( aListElementsId.count() ); + for ( int i = 0; i < aListElementsId.count(); i++ ) + anElementsId[i] = aListElementsId[i].toInt(); + + SMESH::AxisStruct anAxis; + + anAxis.x = SpinBox_X->GetValue(); + anAxis.y = SpinBox_Y->GetValue(); + anAxis.z = SpinBox_Z->GetValue();; + anAxis.vx = SpinBox_DX->GetValue(); + anAxis.vy = SpinBox_DY->GetValue(); + anAxis.vz = SpinBox_DZ->GetValue(); + + double anAngle = (SpinBox_Angle->GetValue())*PI/180; + bool toCreateCopy = CheckBoxCopy->isChecked(); + + try + { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + QApplication::setOverrideCursor(Qt::waitCursor); + aMeshEditor->Rotate(anElementsId.inout(), anAxis, anAngle, toCreateCopy); + QApplication::restoreOverrideCursor(); + } + catch( ... ) + { + } + + mySelection->ClearIObjects(); + SMESH::UpdateView(); + Init( false ); + } +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_RotationDlg::ClickOnOk() +{ + ClickOnApply(); + ClickOnCancel(); +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_RotationDlg::ClickOnCancel() +{ + mySelection->ClearFilters(); + mySelection->ClearIObjects(); + SMESH::SetPointRepresentation(false); + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + reject() ; +} + +//======================================================================= +//function : onTextChange +//purpose : +//======================================================================= + +void SMESHGUI_RotationDlg::onTextChange(const QString& theNewText) +{ + QLineEdit* send = (QLineEdit*)sender(); + + if ( myBusy ) return; + myBusy = true; + + if (send == LineEditElements) + myNbOkElements = 0; + + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + + // hilight entered elements + SMDS_Mesh* aMesh = 0; + if ( myActor ) + aMesh = myActor->GetObject()->GetMesh(); + + if ( aMesh ) { + + mySelection->ClearIObjects(); + mySelection->AddIObject( myActor->getIO() ); + + QStringList aListId = QStringList::split( " ", theNewText, false); + + if (send == LineEditElements) { + for ( int i = 0; i < aListId.count(); i++ ) { + const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() ); + if ( e ) { + if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() )) + mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true); + myNbOkElements++; + } + } + myElementsId = theNewText; + } + } + + if ( myNbOkElements && IsAxisOk()) { + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); + } + + myBusy = false; +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void SMESHGUI_RotationDlg::SelectionIntoArgument() +{ + if ( myBusy ) return; + + // clear + + myActor = 0; + QString aString = ""; + + myBusy = true; + if (myEditCurrentArgument == (QWidget*)LineEditElements) + { + LineEditElements->setText( aString ); + myNbOkElements = 0; + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + } + myBusy = false; + + if ( !GroupButtons->isEnabled() ) // inactive + return; + + // get selected mesh + int nbSel = mySelection->IObjectCount(); + if(nbSel != 1) + return; + + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + myMesh = SMESH::GetMeshByIO( mySelection->firstIObject() ); + if(myMesh->_is_nil()) + return; + myActor = SMESH::FindActorByObject(myMesh); + if (!myActor) + return; + + int aNbUnits = 0; + + if (myEditCurrentArgument == (QWidget*)LineEditElements) + { + myElementsId = ""; + + if (CheckBoxMesh->isChecked()) + { + SMESH::GetNameOfSelectedIObjects(mySelection, aString); + + if(!SMESH::IObjectToInterface(IO)->_is_nil()) //MESH + { + // get IDs from mesh + SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); + if (!aSMDSMesh) + return; + + for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ ) + { + const SMDS_MeshElement * e = aSMDSMesh->FindElement( i ); + if ( e ) { + myElementsId += QString(" %1").arg(i); + aNbUnits++; + } + } + } + else if (!SMESH::IObjectToInterface(IO)->_is_nil()) //SUBMESH + { + // get submesh + SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(IO) ; + + // get IDs from submesh + SMESH::long_array_var anElementsIds = new SMESH::long_array; + anElementsIds = aSubMesh->GetElementsId(); + for ( int i = 0; i < anElementsIds->length(); i++ ) + myElementsId += QString(" %1").arg(anElementsIds[i]); + aNbUnits = anElementsIds->length(); + } + else // GROUP + { + // get smesh group + SMESH::SMESH_GroupBase_var aGroup = + SMESH::IObjectToInterface(IO); + if (aGroup->_is_nil()) + return; + + // get IDs from smesh group + SMESH::long_array_var anElementsIds = new SMESH::long_array; + anElementsIds = aGroup->GetListOfID(); + for ( int i = 0; i < anElementsIds->length(); i++ ) + myElementsId += QString(" %1").arg(anElementsIds[i]); + aNbUnits = anElementsIds->length(); + } + } + else + { + aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString) ; + myElementsId = aString; + } + + if(aNbUnits < 1) + return ; + + myNbOkElements = true; + } + else + { + aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString); + if(aNbUnits != 1) + return; + + SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh(); + if (!aMesh) + return; + + 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()); + } + } + + myBusy = true; + if (myEditCurrentArgument == (QWidget*)LineEditElements) + LineEditElements->setText( aString ); + myBusy = false; + + // OK + + if(myNbOkElements && IsAxisOk()) + { + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); + } +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void SMESHGUI_RotationDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + disconnect( mySelection, 0, this, 0 ); + mySelection->ClearIObjects(); + mySelection->ClearFilters(); + + switch (myConstructorId) + { + case 0: /* default constructor */ + { + if(send == SelectElementsButton) { + myEditCurrentArgument = (QWidget*)LineEditElements; + SMESH::SetPointRepresentation(false); + if (CheckBoxMesh->isChecked()) + { + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter); + } + else + QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + } + else if (send == SelectPointButton) + { + myEditCurrentArgument = (QWidget*)SpinBox_X; + SMESH::SetPointRepresentation(true); + QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + } + else if (send == SelectVectorButton) + { + myEditCurrentArgument = (QWidget*)SpinBox_DX; + SMESH::SetPointRepresentation(true); + QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + } + break; + } + } + + myEditCurrentArgument->setFocus(); + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + SelectionIntoArgument() ; +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_RotationDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupArguments->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + mySMESHGUI->ResetState() ; + mySMESHGUI->SetActiveDialogBox(0) ; + } +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_RotationDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupArguments->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + SelectionIntoArgument(); +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_RotationDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_RotationDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; +} + + +//======================================================================= +//function : hideEvent +//purpose : caused by ESC key +//======================================================================= + +void SMESHGUI_RotationDlg::hideEvent ( QHideEvent * e ) +{ + if ( !isMinimized() ) + ClickOnCancel(); +} + + +//======================================================================= +//function : onSelectMesh +//purpose : +//======================================================================= +void SMESHGUI_RotationDlg::onSelectMesh ( bool toSelectMesh ) +{ + if (toSelectMesh) + TextLabelElements->setText( tr( "SMESH_NAME" ) ); + else + TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) ); + + if (myEditCurrentArgument != LineEditElements) + { + LineEditElements->clear(); + return; + } + + mySelection->ClearFilters() ; + SMESH::SetPointRepresentation(false); + + if (toSelectMesh) + { + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter); + LineEditElements->setReadOnly(true); + } + else + { + QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + LineEditElements->setReadOnly(false); + onTextChange(LineEditElements->text()); + } + + SelectionIntoArgument(); +} + + +//================================================================================= +// function : IsAxisOk() +// purpose : +//================================================================================= +bool SMESHGUI_RotationDlg::IsAxisOk() +{ + return (SpinBox_DX->GetValue() != 0 || + SpinBox_DY->GetValue() != 0 || + SpinBox_DZ->GetValue() != 0); +} + + +//================================================================================= +// function : onVectorChanged() +// purpose : +//================================================================================= +void SMESHGUI_RotationDlg::onVectorChanged() +{ + if (IsAxisOk()) + { + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); + } + else + { + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + } +} diff --git a/src/SMESHGUI/SMESHGUI_RotationDlg.h b/src/SMESHGUI/SMESHGUI_RotationDlg.h new file mode 100644 index 000000000..7901d1ed9 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_RotationDlg.h @@ -0,0 +1,143 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_RotationDlg.h +// Author : Michael ZORIN +// Module : SMESH +// $Header: + +#ifndef DIALOGBOX_ROTATION_H +#define DIALOGBOX_ROTATION_H + +#include "SALOME_Selection.h" +#include "SMESH_LogicalFilter.hxx" + +// QT Includes +#include + +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class QCheckBox; +class SMESHGUI_SpinBox; +class SMESHGUI; +class SMESH_Actor; +class SMESHGUI_SpinBox; + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) + + +//================================================================================= +// class : SMESHGUI_RotationDlg +// purpose : +//================================================================================= +class SMESHGUI_RotationDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_RotationDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_RotationDlg(); + +private: + + void Init( bool ResetControls = true ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void hideEvent ( QHideEvent * ); /* ESC key */ + bool IsAxisOk(); + + SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + int myNbOkElements ; /* to check when elements are defined */ + QString myElementsId; + + QWidget* myEditCurrentArgument; /* Current LineEdit */ + int myConstructorId; + bool myBusy; + SMESH::SMESH_Mesh_var myMesh; + SMESH_Actor* myActor; + Handle(SMESH_LogicalFilter) myMeshOrSubMeshOrGroupFilter; + + QButtonGroup* GroupConstructors; + QRadioButton* RadioButton1; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + QGroupBox* GroupArguments; + QGroupBox* GroupAxis; + QLabel* TextLabelElements; + QPushButton* SelectElementsButton; + QLineEdit* LineEditElements; + QCheckBox* CheckBoxMesh; + + QLabel* TextLabelPoint; + QPushButton* SelectPointButton; + QLabel* TextLabelX; + SMESHGUI_SpinBox* SpinBox_X; + QLabel* TextLabelY; + SMESHGUI_SpinBox* SpinBox_Y; + QLabel* TextLabelZ; + SMESHGUI_SpinBox* SpinBox_Z; + QLabel* TextLabelVector; + QPushButton* SelectVectorButton; + QLabel* TextLabelDX; + SMESHGUI_SpinBox* SpinBox_DX; + QLabel* TextLabelDY; + SMESHGUI_SpinBox* SpinBox_DY; + QLabel* TextLabelDZ; + SMESHGUI_SpinBox* SpinBox_DZ; + + QLabel* TextLabelAngle; + SMESHGUI_SpinBox* SpinBox_Angle; + QCheckBox* CheckBoxCopy; + + private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + void onTextChange(const QString&); + void onSelectMesh(bool toSelectMesh); + void onVectorChanged(); + +protected: + QGridLayout* SMESHGUI_RotationDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupArgumentsLayout; +}; + +#endif // DIALOGBOX_ROTATION_H diff --git a/src/SMDS/SMDS_MeshNodeIDFactory.cxx b/src/SMESHGUI/SMESHGUI_SMESHGenUtils.cxx similarity index 63% rename from src/SMDS/SMDS_MeshNodeIDFactory.cxx rename to src/SMESHGUI/SMESHGUI_SMESHGenUtils.cxx index 2286cf472..ddfe9fbd8 100644 --- a/src/SMDS/SMDS_MeshNodeIDFactory.cxx +++ b/src/SMESHGUI/SMESHGUI_SMESHGenUtils.cxx @@ -1,5 +1,3 @@ -// SMESH SMDS : implementaion of Salome mesh data structure -// // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS // @@ -17,23 +15,29 @@ // 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMDS_MeshNodeIDFactory.cxx -// Author : Jean-Michel BOULCOURT -// Module : SMESH +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -using namespace std; -#include "SMDS_MeshNodeIDFactory.ixx" -//======================================================================= -//function : SMDS_MeshNodeIDFactory -//purpose : -//======================================================================= +#include "QAD_Desktop.h" -SMDS_MeshNodeIDFactory::SMDS_MeshNodeIDFactory() : SMDS_MeshIDFactory() +#include "SMESHGUI_SMESHGenUtils.h" + +#include "SALOMEconfig.h" +#include CORBA_CLIENT_HEADER(SALOMEDS) + +namespace SMESH { -} + SMESH::SMESH_Gen_var GetSMESHGen() + { + static SMESH::SMESH_Gen_var aSMESHGen; + if(CORBA::is_nil(aSMESHGen)){ + if(QAD_Desktop* aDesktop = QAD_Application::getDesktop()){ + Engines::Component_var aComponent = aDesktop->getEngine("FactoryServer","SMESH"); + aSMESHGen = SMESH::SMESH_Gen::_narrow(aComponent); + } + } + return aSMESHGen; + } + +} diff --git a/src/SMESHGUI/SMESHGUI_SMESHGenUtils.h b/src/SMESHGUI/SMESHGUI_SMESHGenUtils.h new file mode 100644 index 000000000..54a8d4374 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_SMESHGenUtils.h @@ -0,0 +1,35 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#ifndef SMESHGUI_SMESHGenUtils_HeaderFile +#define SMESHGUI_SMESHGenUtils_HeaderFile + +#include "SALOMEconfig.h" +#include CORBA_SERVER_HEADER(SMESH_Gen) + + +namespace SMESH +{ + + SMESH::SMESH_Gen_var GetSMESHGen(); + +} + + +#endif diff --git a/src/SMESHGUI/SMESHGUI_SewingDlg.cxx b/src/SMESHGUI/SMESHGUI_SewingDlg.cxx new file mode 100644 index 000000000..0cfe1f643 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_SewingDlg.cxx @@ -0,0 +1,886 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_SewingDlg.cxx +// Author : Michael ZORIN +// Module : SMESH +// $Header: + +#include "SMESHGUI_SewingDlg.h" + +#include "SMESHGUI.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_IdValidator.h" +#include "SMESH_Actor.h" +#include "SMDS_Mesh.hxx" + +#include "GEOMBase.h" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +//================================================================================= +// class : SMESHGUI_SewingDlg() +// purpose : +//================================================================================= +SMESHGUI_SewingDlg::SMESHGUI_SewingDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, + bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | + Qt::WDestructiveClose) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SEWING_FREEBORDERS"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SEWING_CONFORM_FREEBORDERS"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SEWING_BORDERTOSIDE"))); + QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SEWING_SIDEELEMENTS"))); + QPixmap image4(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); + + if ( !name ) + setName( "SMESHGUI_SewingDlg" ); + resize( 303, 185 ); + setCaption( tr( "SMESH_SEWING" ) ); + setSizeGripEnabled( TRUE ); + SMESHGUI_SewingDlgLayout = new QGridLayout( this ); + SMESHGUI_SewingDlgLayout->setSpacing( 6 ); + SMESHGUI_SewingDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) ); + GroupConstructors->setTitle( tr( "SMESH_SEWING" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + QHBoxLayout* RBLayout = new QHBoxLayout( 0, 0, 6, "Layout2"); + RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" ); + RadioButton1->setText( tr( "" ) ); + RadioButton1->setPixmap( image0 ); + RBLayout->addWidget( RadioButton1); + RadioButton2= new QRadioButton( GroupConstructors, "RadioButton2" ); + RadioButton2->setText( tr( "" ) ); + RadioButton2->setPixmap( image1 ); + RBLayout->addWidget( RadioButton2); + RadioButton3= new QRadioButton( GroupConstructors, "RadioButton3" ); + RadioButton3->setText( tr( "" ) ); + RadioButton3->setPixmap( image2 ); + RBLayout->addWidget( RadioButton3); + RadioButton4= new QRadioButton( GroupConstructors, "RadioButton4" ); + RadioButton4->setText( tr( "" ) ); + RadioButton4->setPixmap( image3 ); + RBLayout->addWidget( RadioButton4); + GroupConstructorsLayout->addLayout( RBLayout, 0, 0 ); + SMESHGUI_SewingDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_SewingDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupArguments = new QGroupBox( this, "GroupArguments" ); + GroupArguments->setColumnLayout(0, Qt::Vertical ); + GroupArguments->layout()->setSpacing( 0 ); + GroupArguments->layout()->setMargin( 0 ); + GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() ); + GroupArgumentsLayout->setAlignment( Qt::AlignTop ); + GroupArgumentsLayout->setSpacing( 6 ); + GroupArgumentsLayout->setMargin( 11 ); + + // First subgroup + SubGroup1 = new QGroupBox( GroupArguments, "SubGroup1" ); + SubGroup1->setColumnLayout(0, Qt::Vertical ); + SubGroup1->layout()->setSpacing( 0 ); + SubGroup1->layout()->setMargin( 0 ); + QGridLayout* SubGroup1Layout = new QGridLayout( SubGroup1->layout() ); + SubGroup1Layout->setAlignment( Qt::AlignTop ); + SubGroup1Layout->setSpacing( 6 ); + SubGroup1Layout->setMargin( 11 ); + + // Controls of the first subgroup + TextLabel1 = new QLabel( SubGroup1, "TextLabel1" ); + TextLabel1->setFixedWidth(104); + SubGroup1Layout->addWidget( TextLabel1, 0, 0 ); + + SelectButton1 = new QPushButton( SubGroup1, "SelectButton1" ); + SelectButton1->setPixmap( image4 ); + SubGroup1Layout->addWidget( SelectButton1, 0, 1 ); + + LineEdit1 = new QLineEdit( SubGroup1, "LineEdit1" ); + SubGroup1Layout->addWidget( LineEdit1, 0, 2 ); + + TextLabel2 = new QLabel( SubGroup1, "TextLabel2" ); + SubGroup1Layout->addWidget( TextLabel2, 1, 0 ); + + SelectButton2 = new QPushButton( SubGroup1, "SelectButton2" ); + SelectButton2->setPixmap( image4 ); + SubGroup1Layout->addWidget( SelectButton2, 1, 1 ); + + LineEdit2 = new QLineEdit( SubGroup1, "LineEdit2" ); + SubGroup1Layout->addWidget( LineEdit2, 1, 2 ); + + TextLabel3 = new QLabel( SubGroup1, "TextLabel3" ); + SubGroup1Layout->addWidget( TextLabel3, 2, 0 ); + + SelectButton3 = new QPushButton( SubGroup1, "SelectButton3" ); + SelectButton3->setPixmap( image4 ); + SubGroup1Layout->addWidget( SelectButton3, 2, 1 ); + + LineEdit3 = new QLineEdit( SubGroup1, "LineEdit3" ); + SubGroup1Layout->addWidget( LineEdit3, 2, 2 ); + + + // Second subgroup + SubGroup2 = new QGroupBox( GroupArguments, "SubGroup2" ); + SubGroup2->setColumnLayout(0, Qt::Vertical ); + SubGroup2->layout()->setSpacing( 0 ); + SubGroup2->layout()->setMargin( 0 ); + QGridLayout* SubGroup2Layout = new QGridLayout( SubGroup2->layout() ); + SubGroup2Layout->setAlignment( Qt::AlignTop ); + SubGroup2Layout->setSpacing( 6 ); + SubGroup2Layout->setMargin( 11 ); + + // Controls of the first subgroup + TextLabel4 = new QLabel( SubGroup2, "TextLabel4" ); + SubGroup2Layout->addWidget( TextLabel4, 0, 0 ); + + SelectButton4 = new QPushButton( SubGroup2, "SelectButton4" ); + SelectButton4->setPixmap( image4 ); + SubGroup2Layout->addWidget( SelectButton4, 0, 1 ); + + LineEdit4 = new QLineEdit( SubGroup2, "LineEdit4" ); + SubGroup2Layout->addWidget( LineEdit4, 0, 2 ); + + TextLabel5 = new QLabel( SubGroup2, "TextLabel5" ); + SubGroup2Layout->addWidget( TextLabel5, 1, 0 ); + + SelectButton5 = new QPushButton( SubGroup2, "SelectButton5" ); + SelectButton5->setPixmap( image4 ); + SubGroup2Layout->addWidget( SelectButton5, 1, 1 ); + + LineEdit5 = new QLineEdit( SubGroup2, "LineEdit5" ); + SubGroup2Layout->addWidget( LineEdit5, 1, 2 ); + + TextLabel6 = new QLabel( SubGroup2, "TextLabel6" ); + SubGroup2Layout->addWidget( TextLabel6, 2, 0 ); + + SelectButton6 = new QPushButton( SubGroup2, "SelectButton6" ); + SelectButton6->setPixmap( image4 ); + SubGroup2Layout->addWidget( SelectButton6, 2, 1 ); + + LineEdit6 = new QLineEdit( SubGroup2, "LineEdit6" ); + SubGroup2Layout->addWidget( LineEdit6, 2, 2 ); + + + // Add subgroups to the group of arguments + GroupArgumentsLayout->addWidget( SubGroup1, 0, 0 ); + GroupArgumentsLayout->addWidget( SubGroup2, 1, 0 ); + + // Control for the merging equal elements + CheckBoxMerge = new QCheckBox( GroupArguments, "CheckBoxMerge" ); + CheckBoxMerge->setText( tr( "MERGE_EQUAL_ELEMENTS" ) ); + GroupArgumentsLayout->addWidget( CheckBoxMerge, 2, 0 ); + + + SMESHGUI_SewingDlgLayout->addWidget( GroupArguments, 1, 0 ); + + /* Initialisations */ + GroupArguments->show(); + RadioButton1->setChecked( TRUE ); + mySelection = Sel; + + LineEdit2->setValidator( new SMESHGUI_IdValidator( this, "validator", 1)); + LineEdit3->setValidator( new SMESHGUI_IdValidator( this, "validator", 1)); + LineEdit5->setValidator( new SMESHGUI_IdValidator( this, "validator", 1)); + LineEdit6->setValidator( new SMESHGUI_IdValidator( this, "validator", 1)); + + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + Init(); + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( SelectButton1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectButton2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectButton3, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectButton4, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectButton5, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectButton6, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + /* to close dialog if study change */ + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + connect( LineEdit1, SIGNAL( textChanged( const QString& )), SLOT( onTextChange( const QString& ))); + connect( LineEdit2, SIGNAL( textChanged( const QString& )), SLOT( onTextChange( const QString& ))); + connect( LineEdit3, SIGNAL( textChanged( const QString& )), SLOT( onTextChange( const QString& ))); + connect( LineEdit4, SIGNAL( textChanged( const QString& )), SLOT( onTextChange( const QString& ))); + connect( LineEdit5, SIGNAL( textChanged( const QString& )), SLOT( onTextChange( const QString& ))); + connect( LineEdit6, SIGNAL( textChanged( const QString& )), SLOT( onTextChange( const QString& ))); + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + ConstructorsClicked(0); + resize(0,0); +} + +//================================================================================= +// function : ~SMESHGUI_SewingDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_SewingDlg::~SMESHGUI_SewingDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_SewingDlg::Init() +{ + myBusy = false; + + myEditCurrentArgument = LineEdit1; + LineEdit1->setFocus(); + myActor = 0; + myMesh = SMESH::SMESH_Mesh::_nil(); + CheckBoxMerge->setChecked(false); + SelectionIntoArgument(); +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_SewingDlg::ConstructorsClicked(int constructorId) +{ + disconnect(mySelection, 0, this, 0); + mySelection->ClearIObjects(); + LineEdit1->setText(""); + LineEdit2->setText(""); + LineEdit3->setText(""); + LineEdit4->setText(""); + LineEdit5->setText(""); + LineEdit6->setText(""); + myOk1 = myOk2 = myOk3 = myOk4 = myOk5 = myOk6 = false; + myEditCurrentArgument = LineEdit1; + myEditCurrentArgument->setFocus(); + + if (!TextLabel5->isEnabled()) + { + TextLabel5->setEnabled(true); + SelectButton5->setEnabled(true); + LineEdit5->setEnabled(true); + } + else if (!TextLabel6->isEnabled()) + { + TextLabel6->setEnabled(true); + SelectButton6->setEnabled(true); + LineEdit6->setEnabled(true); + } + + switch(constructorId) + { + case 0 : + { + GroupArguments->setTitle( tr( "SEW_FREE_BORDERS" ) ); + SubGroup1->setTitle( tr( "BORDER_1" ) ); + SubGroup2->setTitle( tr( "BORDER_2" ) ); + + break; + } + case 1 : + { + GroupArguments->setTitle( tr( "SEW_CONFORM_FREE_BORDERS" ) ); + SubGroup1->setTitle( tr( "BORDER_1" ) ); + SubGroup2->setTitle( tr( "BORDER_2" ) ); + + TextLabel6->setEnabled(false); + SelectButton6->setEnabled(false); + LineEdit6->setEnabled(false); + + myOk6 = true; + + break; + } + case 2 : + { + GroupArguments->setTitle( tr( "SEW_BORDER_TO_SIDE" ) ); + SubGroup1->setTitle( tr( "BORDER" ) ); + SubGroup2->setTitle( tr( "SIDE" ) ); + + TextLabel5->setEnabled(false); + SelectButton5->setEnabled(false); + LineEdit5->setEnabled(false); + + myOk5 = true; + + break; + } + case 3 : + { + GroupArguments->setTitle( tr( "SEW_SIDE_ELEMENTS" ) ); + SubGroup1->setTitle( tr( "SIDE_1" ) ); + SubGroup2->setTitle( tr( "SIDE_2" ) ); + + TextLabel1->setText( tr( "SMESH_ID_ELEMENTS" ) ); + TextLabel2->setText( tr( "NODE1_TO_MERGE" ) ); + TextLabel3->setText( tr( "NODE2_TO_MERGE" ) ); + TextLabel4->setText( tr( "SMESH_ID_ELEMENTS" ) ); + TextLabel5->setText( tr( "NODE1_TO_MERGE" ) ); + TextLabel6->setText( tr( "NODE2_TO_MERGE" ) ); + + LineEdit1->setValidator( new SMESHGUI_IdValidator( this, "validator")); + LineEdit4->setValidator( new SMESHGUI_IdValidator( this, "validator")); + + SMESH::SetPointRepresentation(false); + QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + break; + } + } + + if (constructorId != 3) + { + TextLabel1->setText( tr( "FIRST_NODE_ID" ) ); + TextLabel2->setText( tr( "SECOND_NODE_ID" ) ); + TextLabel3->setText( tr( "LAST_NODE_ID" ) ); + TextLabel4->setText( tr( "FIRST_NODE_ID" ) ); + TextLabel5->setText( tr( "SECOND_NODE_ID" ) ); + TextLabel6->setText( tr( "LAST_NODE_ID" ) ); + + LineEdit1->setValidator( new SMESHGUI_IdValidator( this, "validator", 1)); + LineEdit4->setValidator( new SMESHGUI_IdValidator( this, "validator", 1)); + + SMESH::SetPointRepresentation(true); + QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + } + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool SMESHGUI_SewingDlg::ClickOnApply() +{ + if (mySMESHGUI->ActiveStudyLocked()) + return false; + + bool aResult = false; + + if ( IsValid() ) + { + bool toMerge = CheckBoxMerge->isChecked(); + + try + { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + QApplication::setOverrideCursor(Qt::waitCursor); + + int aConstructorId = GetConstructorId(); + SMESH::SMESH_MeshEditor::Sew_Error anError; + + if (aConstructorId == 0) + anError = aMeshEditor->SewFreeBorders(LineEdit1->text().toLong(), + LineEdit2->text().toLong(), + LineEdit3->text().toLong(), + LineEdit4->text().toLong(), + LineEdit5->text().toLong(), + LineEdit6->text().toLong()); + else if (aConstructorId == 1) + anError = aMeshEditor->SewConformFreeBorders(LineEdit1->text().toLong(), + LineEdit2->text().toLong(), + LineEdit3->text().toLong(), + LineEdit4->text().toLong(), + LineEdit5->text().toLong()); + else if (aConstructorId == 2) + anError = aMeshEditor->SewBorderToSide(LineEdit1->text().toLong(), + LineEdit2->text().toLong(), + LineEdit3->text().toLong(), + LineEdit4->text().toLong(), + LineEdit6->text().toLong()); + else if (aConstructorId == 3) + { + QStringList aListElementsId1 = QStringList::split( " ", LineEdit1->text(), false); + QStringList aListElementsId2 = QStringList::split( " ", LineEdit4->text(), false); + + SMESH::long_array_var anElementsId1 = new SMESH::long_array; + SMESH::long_array_var anElementsId2 = new SMESH::long_array; + + anElementsId1->length( aListElementsId1.count() ); + anElementsId2->length( aListElementsId2.count() ); + + for ( int i = 0; i < aListElementsId1.count(); i++ ) + anElementsId1[i] = aListElementsId1[i].toInt(); + for ( int i = 0; i < aListElementsId2.count(); i++ ) + anElementsId2[i] = aListElementsId2[i].toInt(); + + anError = aMeshEditor->SewSideElements(anElementsId1.inout(), + anElementsId2.inout(), + LineEdit2->text().toLong(), + LineEdit5->text().toLong(), + LineEdit3->text().toLong(), + LineEdit6->text().toLong()); + } + aResult = ( anError == SMESH::SMESH_MeshEditor::SEW_OK ); + + if (toMerge && aResult) + aMeshEditor->MergeEqualElements(); + + QApplication::restoreOverrideCursor(); + + if ( !aResult ) { + QString msg = tr(QString("ERROR_%1").arg(anError)); + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + tr("SMESH_WRN_WARNING"),msg,tr("SMESH_BUT_OK")); + } + } + catch( ... ) + { + } + + if ( aResult ) + { + Handle(SALOME_InteractiveObject) anIO = myActor->getIO(); + mySelection->ClearIObjects(); + SMESH::UpdateView(); + mySelection->AddIObject( anIO, false ); + Init(); + ConstructorsClicked(GetConstructorId()); + } + } + + return aResult; +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_SewingDlg::ClickOnOk() +{ + if( ClickOnApply()) + ClickOnCancel() ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_SewingDlg::ClickOnCancel() +{ + mySelection->ClearIObjects(); + SMESH::SetPointRepresentation(false); + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + reject() ; +} + +//======================================================================= +//function : onTextChange +//purpose : +//======================================================================= + +void SMESHGUI_SewingDlg::onTextChange(const QString& theNewText) +{ + QLineEdit* send = (QLineEdit*)sender(); + + if ( myBusy ) return; + myBusy = true; + + if (send) + myEditCurrentArgument = send; + + if (send == LineEdit1) + myOk1 = false; + else if (send == LineEdit2) + myOk2 = false; + else if (send == LineEdit3) + myOk3 = false; + else if (send == LineEdit4) + myOk4 = false; + else if (send == LineEdit5) + myOk5 = false; + else if (send == LineEdit6) + myOk6 = false; + + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + + // hilight entered elements/nodes + SMDS_Mesh* aMesh = 0; + + if ( myActor ) + aMesh = myActor->GetObject()->GetMesh(); + else + send->clear(); + + if ( aMesh ) { + mySelection->ClearIObjects(); + mySelection->AddIObject( myActor->getIO() ); + + if (GetConstructorId() != 3 || (send != LineEdit1 && send != LineEdit4)) + { + SMESH::SetPointRepresentation(true); + QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + + const SMDS_MeshNode * n = aMesh->FindNode( theNewText.toInt() ); + if ( n ) { + if ( !mySelection->IsIndexSelected( myActor->getIO(), n->GetID() )) + mySelection->AddOrRemoveIndex (myActor->getIO(), n->GetID(), true); + + if (send == LineEdit1) + myOk1 = true; + else if (send == LineEdit2) + myOk2 = true; + else if (send == LineEdit3) + myOk3 = true; + else if (send == LineEdit4) + myOk4 = true; + else if (send == LineEdit5) + myOk5 = true; + else if (send == LineEdit6) + myOk6 = true; + } + } + else + { + SMESH::SetPointRepresentation(false); + QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + + QStringList aListId = QStringList::split( " ", theNewText, false); + + bool isEvenOneExists = false; + + for ( int i = 0; i < aListId.count(); i++ ) { + const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() ); + if ( e ) { + if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() )) + mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true); + if (!isEvenOneExists) + isEvenOneExists = true; + } + } + + if (isEvenOneExists) + { + if (send == LineEdit1) + myOk1 = true; + else if(send == LineEdit4) + myOk4 = true; + } + else + send->clear(); + } + } + + if ( IsValid() ) { + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); + } + + myBusy = false; +} + + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void SMESHGUI_SewingDlg::SelectionIntoArgument(bool isSelectionChanged) +{ + if ( myBusy ) return; + + // clear + if (isSelectionChanged) + myActor = 0; + + QString aString = ""; + + myBusy = true; + myEditCurrentArgument->setText( aString ); + myBusy = false; + + if ( !GroupButtons->isEnabled() ) // inactive + return; + + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + + // get selected mesh + int nbSel = mySelection->IObjectCount(); + if(nbSel != 1) + return; + + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + myMesh = SMESH::IObjectToInterface(IO) ; + myActor = SMESH::FindActorByEntry( mySelection->firstIObject()->getEntry() ); + + if (myMesh->_is_nil() || !myActor) + return; + + // get selected elements/nodes + + int aNbUnits = 0; + + if (GetConstructorId() != 3 || (myEditCurrentArgument != LineEdit1 && myEditCurrentArgument != LineEdit4)) + { + aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString); + if(aNbUnits != 1) + return; + } + else + { + aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString); + if(aNbUnits < 1) + return; + } + + myBusy = true; + myEditCurrentArgument->setText( aString ); + myBusy = false; + + // OK + if (myEditCurrentArgument == LineEdit1) + myOk1 = true; + else if(myEditCurrentArgument == LineEdit2) + myOk2 = true; + else if(myEditCurrentArgument == LineEdit3) + myOk3 = true; + else if(myEditCurrentArgument == LineEdit4) + myOk4 = true; + else if(myEditCurrentArgument == LineEdit5) + myOk5 = true; + else if(myEditCurrentArgument == LineEdit6) + myOk6 = true; + + if(IsValid()) + { + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); + } +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void SMESHGUI_SewingDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + disconnect( mySelection, 0, this, 0 ); + mySelection->ClearIObjects(); + + if(send == SelectButton1) { + myEditCurrentArgument = LineEdit1; + myOk1 = false; + } + else if (send == SelectButton2) { + myEditCurrentArgument = LineEdit2; + myOk2 = false; + } + else if (send == SelectButton3) { + myEditCurrentArgument = LineEdit3; + myOk3 = false; + } + else if (send == SelectButton4) { + myEditCurrentArgument = LineEdit4; + myOk4 = false; + } + else if (send == SelectButton5) { + myEditCurrentArgument = LineEdit5; + myOk5 = false; + } + else if (send == SelectButton6) { + myEditCurrentArgument = LineEdit6; + myOk6 = false; + } + + if (GetConstructorId() != 3 || (send != SelectButton1 && send != SelectButton4)) + { + SMESH::SetPointRepresentation(true); + QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + } + else + { + SMESH::SetPointRepresentation(false); + QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + } + + myEditCurrentArgument->setFocus(); + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + SelectionIntoArgument(false) ; +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_SewingDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupArguments->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + mySMESHGUI->ResetState() ; + mySMESHGUI->SetActiveDialogBox(0) ; + } +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_SewingDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupArguments->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + ConstructorsClicked(GetConstructorId()); + SelectionIntoArgument(); +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_SewingDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_SewingDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; +} + + +//======================================================================= +//function : hideEvent +//purpose : caused by ESC key +//======================================================================= + +void SMESHGUI_SewingDlg::hideEvent ( QHideEvent * e ) +{ + if ( !isMinimized() ) + ClickOnCancel(); +} + + +//================================================================================= +// function : GetConstructorId() +// purpose : +//================================================================================= +int SMESHGUI_SewingDlg::GetConstructorId() +{ + if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL ) + return GroupConstructors->id( GroupConstructors->selected() ); + return -1; +} + + +//================================================================================= +// function : GetConstructorId() +// purpose : +//================================================================================= +bool SMESHGUI_SewingDlg::IsValid() +{ + return (myOk1 && myOk2 && myOk3 && myOk4 && myOk5 && myOk6); +} diff --git a/src/SMESHGUI/SMESHGUI_DiagonalInversionDlg.h b/src/SMESHGUI/SMESHGUI_SewingDlg.h similarity index 58% rename from src/SMESHGUI/SMESHGUI_DiagonalInversionDlg.h rename to src/SMESHGUI/SMESHGUI_SewingDlg.h index 87c6d181b..b5433bb2d 100644 --- a/src/SMESHGUI/SMESHGUI_DiagonalInversionDlg.h +++ b/src/SMESHGUI/SMESHGUI_SewingDlg.h @@ -21,25 +21,19 @@ // // // -// File : SMESHGUI_DiagonalInversionDlg.h -// Author : Damien COQUERET +// File : SMESHGUI_SewingDlg.h +// Author : Michael ZORIN // Module : SMESH -// $Header$ +// $Header: -#ifndef DIALOGBOX_DIAGONAL_INVERSION_H -#define DIALOGBOX_DIAGONAL_INVERSION_H +#ifndef DIALOGBOX_SEWING_H +#define DIALOGBOX_SEWING_H #include "SALOME_Selection.h" // QT Includes -#include #include -// Open CASCADE Includes -#include - -class QVBoxLayout; -class QHBoxLayout; class QGridLayout; class QButtonGroup; class QGroupBox; @@ -47,66 +41,94 @@ class QLabel; class QLineEdit; class QPushButton; class QRadioButton; +class QCheckBox; class SMESHGUI; +class SMESH_Actor; // IDL Headers #include #include CORBA_SERVER_HEADER(SMESH_Mesh) + //================================================================================= -// class : SMESHGUI_DiagonalInversionDlg +// class : SMESHGUI_SewingDlg // purpose : //================================================================================= -class SMESHGUI_DiagonalInversionDlg : public QDialog +class SMESHGUI_SewingDlg : public QDialog { Q_OBJECT public: - SMESHGUI_DiagonalInversionDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); - ~SMESHGUI_DiagonalInversionDlg(); + SMESHGUI_SewingDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_SewingDlg(); private: - void Init( SALOME_Selection* Sel ) ; + void Init() ; void closeEvent( QCloseEvent* e ) ; void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ - + void hideEvent ( QHideEvent * ); /* ESC key */ + int GetConstructorId(); + bool IsValid(); + SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ SALOME_Selection* mySelection ; /* User shape selection */ - bool myOkElements ; /* to check when arguments is defined */ - int myConstructorId ; /* Current constructor id = radio button id */ + int myOk1, myOk2, myOk3, myOk4, myOk5, myOk6; QLineEdit* myEditCurrentArgument; /* Current LineEdit */ - - SMESH::SMESH_Mesh_var myMesh; - TColStd_MapOfInteger myMapIndex; + bool myBusy; + SMESH::SMESH_Mesh_var myMesh; + SMESH_Actor* myActor; + QButtonGroup* GroupConstructors; - QRadioButton* Constructor1; + QRadioButton* RadioButton1; + QRadioButton* RadioButton2; + QRadioButton* RadioButton3; + QRadioButton* RadioButton4; QGroupBox* GroupButtons; QPushButton* buttonOk; QPushButton* buttonCancel; QPushButton* buttonApply; - QGroupBox* GroupC1; - QLabel* TextLabelC1A1; - QPushButton* SelectButtonC1A1; - QLineEdit* LineEditC1A1; - + QGroupBox* GroupArguments; + QGroupBox* SubGroup1; + QGroupBox* SubGroup2; + QLabel* TextLabel1; + QLabel* TextLabel2; + QLabel* TextLabel3; + QLabel* TextLabel4; + QLabel* TextLabel5; + QLabel* TextLabel6; + QPushButton* SelectButton1; + QPushButton* SelectButton2; + QPushButton* SelectButton3; + QPushButton* SelectButton4; + QPushButton* SelectButton5; + QPushButton* SelectButton6; + QLineEdit* LineEdit1; + QLineEdit* LineEdit2; + QLineEdit* LineEdit3; + QLineEdit* LineEdit4; + QLineEdit* LineEdit5; + QLineEdit* LineEdit6; + QCheckBox* CheckBoxMerge; + private slots: void ConstructorsClicked(int constructorId); void ClickOnOk(); void ClickOnCancel(); - void ClickOnApply(); + bool ClickOnApply(); void SetEditCurrentArgument() ; - void SelectionIntoArgument() ; + void SelectionIntoArgument(bool isSelectionChanged = true) ; void DeactivateActiveDialog() ; void ActivateThisDialog() ; - + void onTextChange(const QString&); + protected: - QGridLayout* SMESHGUI_DiagonalInversionDlgLayout; + QGridLayout* SMESHGUI_SewingDlgLayout; QGridLayout* GroupConstructorsLayout; QGridLayout* GroupButtonsLayout; - QGridLayout* GroupC1Layout; + QGridLayout* GroupArgumentsLayout; }; -#endif // DIALOGBOX_DIAGONAL_INVERSION_H +#endif // DIALOGBOX_SEWING_H diff --git a/src/SMESHGUI/SMESHGUI_SingleEditDlg.cxx b/src/SMESHGUI/SMESHGUI_SingleEditDlg.cxx new file mode 100755 index 000000000..b25953d4c --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_SingleEditDlg.cxx @@ -0,0 +1,544 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_SingleEditDlg.cxx +// Author : Sergey LITONIN +// Module : SMESH + +#include "SMESHGUI_SingleEditDlg.h" + +#include "QAD_Desktop.h" + +#include "SMESHGUI.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_MeshUtils.h" + +#include "SMESHGUI_SpinBox.h" + +#include "utilities.h" +#include "SALOME_Selection.h" +#include "SMESH_Actor.h" +#include "SMDS_Mesh.hxx" + +#include +#include +#include +#include +#include +#include +#include +#include + + +#define SPACING 5 +#define MARGIN 10 + + +/* + Class : SMESHGUI_DiagValidator + Description : validate munual input of edge like "id1-id2" +*/ +class SMESHGUI_DiagValidator: public QValidator +{ + public: + + SMESHGUI_DiagValidator(QWidget * parent, const char * name = 0): + QValidator(parent,name) {} + + State validate ( QString & text, int & pos) const + { + text.stripWhiteSpace(); + text.replace( QRegExp("[^0-9]+"), "-" ); + if ( text == "-" ) + text = ""; + int ind = text.find( QRegExp("-[0-9]+-")); + if ( ind > 0 ) { // leave only two ids + ind = text.find( '-', ind + 1 ); + if ( ind > 0 ) + text.truncate( ind ); + } + if ( pos > text.length() ) + pos = text.length(); + return Acceptable; + } +}; + +/* + Class : SMESHGUI_SingleEditDlg + Description : Inversion of the diagonal of a pseudo-quadrangle formed by + 2 neighboring triangles with 1 common edge +*/ + +//======================================================================= +// name : SMESHGUI_SingleEditDlg::SMESHGUI_SingleEditDlg +// Purpose : Constructor +//======================================================================= +SMESHGUI_SingleEditDlg::SMESHGUI_SingleEditDlg( QWidget* theParent, + SALOME_Selection* theSelection, + const char* theName ) +: QDialog( theParent, theName, false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ + //setCaption( tr( "CAPTION" ) ); + + QVBoxLayout* aDlgLay = new QVBoxLayout( this, MARGIN, SPACING ); + + QFrame* aMainFrame = createMainFrame ( this ); + QFrame* aBtnFrame = createButtonFrame( this ); + + aDlgLay->addWidget( aMainFrame ); + aDlgLay->addWidget( aBtnFrame ); + + aDlgLay->setStretchFactor( aMainFrame, 1 ); + + Init( theSelection ) ; +} + +//======================================================================= +// name : SMESHGUI_SingleEditDlg::createMainFrame +// Purpose : Create frame containing dialog's input fields +//======================================================================= +QFrame* SMESHGUI_SingleEditDlg::createMainFrame( QWidget* theParent ) +{ + QGroupBox* aMainGrp = new QGroupBox( 1, Qt::Vertical, tr( "EDGE_BETWEEN" ), theParent ); + + QPixmap aPix( QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr( "ICON_SELECT" ) ) ); + + new QLabel( tr( "SMESH_EDGE" ), aMainGrp ); + ( new QPushButton( aMainGrp ) )->setPixmap( aPix ); + myEdge = new QLineEdit( aMainGrp ); + myEdge->setValidator( new SMESHGUI_DiagValidator( this, "validator" )); + + return aMainGrp; +} + +//======================================================================= +// name : SMESHGUI_SingleEditDlg::createButtonFrame +// Purpose : Create frame containing buttons +//======================================================================= +QFrame* SMESHGUI_SingleEditDlg::createButtonFrame( QWidget* theParent ) +{ + QFrame* aFrame = new QFrame( theParent ); + aFrame->setFrameStyle( QFrame::Box | QFrame::Sunken ); + + myOkBtn = new QPushButton( tr( "SMESH_BUT_OK" ), aFrame ); + myApplyBtn = new QPushButton( tr( "SMESH_BUT_APPLY" ), aFrame ); + myCloseBtn = new QPushButton( tr( "SMESH_BUT_CLOSE" ), aFrame ); + + QSpacerItem* aSpacer = new QSpacerItem( 0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum ); + + QHBoxLayout* aLay = new QHBoxLayout( aFrame, MARGIN, SPACING ); + + aLay->addWidget( myOkBtn ); + aLay->addWidget( myApplyBtn ); + aLay->addItem( aSpacer); + aLay->addWidget( myCloseBtn ); + + return aFrame; +} + +//======================================================================= +// name : SMESHGUI_SingleEditDlg::isValid +// Purpose : Verify validity of input data +//======================================================================= +bool SMESHGUI_SingleEditDlg::isValid( const bool theMess ) const +{ + int id1, id2; + return getNodeIds( myEdge->text(), id1, id2 ); +} + +//======================================================================= +// name : SMESHGUI_SingleEditDlg::getNodeIds +// Purpose : Retrieve node ids from string +//======================================================================= +bool SMESHGUI_SingleEditDlg::getNodeIds( const QString& theStr, int& theId1, int& theId2 ) const +{ + if ( !theStr.contains( '-' ) ) + return false; + + bool ok1, ok2; + QString str1 = theStr.section( '-', 0, 0, QString::SectionSkipEmpty ); + QString str2 = theStr.section( '-', 1, 1, QString::SectionSkipEmpty ); + theId1 = str1.toInt( &ok1 ); + theId2 = str2.toInt( &ok2 ); + + return ok1 & ok2; +} + +//======================================================================= +// name : SMESHGUI_SingleEditDlg::~SMESHGUI_SingleEditDlg +// Purpose : Destructor +//======================================================================= +SMESHGUI_SingleEditDlg::~SMESHGUI_SingleEditDlg() +{ +} + +//======================================================================= +// name : SMESHGUI_SingleEditDlg::Init +// Purpose : Init dialog fields, connect signals and slots, show dialog +//======================================================================= +void SMESHGUI_SingleEditDlg::Init( SALOME_Selection* theSelection ) +{ + mySelection = theSelection; + SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI(); + aSMESHGUI->SetActiveDialogBox( ( QDialog* )this ) ; + myBusy = false; + myActor = 0; + + // main buttons + connect( myOkBtn, SIGNAL( clicked() ), SLOT( onOk() ) ); + connect( myCloseBtn, SIGNAL( clicked() ), SLOT( onClose() ) ) ; + connect( myApplyBtn, SIGNAL( clicked() ), SLOT( onApply() ) ); + + // selection and SMESHGUI + connect( mySelection, SIGNAL( currentSelectionChanged() ), SLOT( onSelectionDone() ) ); + connect( aSMESHGUI, SIGNAL( SignalDeactivateActiveDialog() ), SLOT( onDeactivate() ) ); + connect( aSMESHGUI, SIGNAL( SignalCloseAllDialogs() ), SLOT( onClose() ) ); + connect( myEdge, SIGNAL( textChanged(const QString&)), SLOT( onTextChange(const QString&))); + + myOkBtn->setEnabled( false ); + myApplyBtn->setEnabled( false ); + setEnabled( true ); + + int x, y ; + aSMESHGUI->DefineDlgPosition( this, x, y ); + this->move( x, y ); + this->show(); + + // set selection mode + QAD_Application::getDesktop()->SetSelectionMode( EdgeOfCellSelection, true ); + + onSelectionDone(); + + return; +} + +//======================================================================= +// name : SMESHGUI_SingleEditDlg::onOk +// Purpose : SLOT called when "Ok" button pressed. +// Assign filters VTK viewer and close dialog +//======================================================================= +void SMESHGUI_SingleEditDlg::onOk() +{ + if ( onApply() ) + onClose(); +} + +//======================================================================= +// name : SMESHGUI_SingleEditDlg::onClose +// Purpose : SLOT called when "Close" button pressed. Close dialog +//======================================================================= +void SMESHGUI_SingleEditDlg::onClose() +{ + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + mySelection->ClearIObjects(); + disconnect( mySelection, 0, this, 0 ); + disconnect( SMESHGUI::GetSMESHGUI(), 0, this, 0 ); + SMESHGUI::GetSMESHGUI()->ResetState() ; + reject(); +} + +//======================================================================= +//function : findTriangles +//purpose : find triangles sharing theNode1-theNode2 link +// THIS IS A PIECE OF SMESH_MeshEditor.cxx +// TO DO: make it available in SMDS for ex. +//======================================================================= + +static bool findTriangles(const SMDS_MeshNode * theNode1, + const SMDS_MeshNode * theNode2, + const SMDS_MeshElement*& theTria1, + const SMDS_MeshElement*& theTria2) +{ + if ( !theNode1 || !theNode2 ) return false; + + theTria1 = theTria2 = 0; + + set< const SMDS_MeshElement* > emap; + SMDS_ElemIteratorPtr it = theNode1->GetInverseElementIterator(); + while (it->more()) { + const SMDS_MeshElement* elem = it->next(); + if ( elem->GetType() == SMDSAbs_Face && elem->NbNodes() == 3 ) + emap.insert( elem ); + } + it = theNode2->GetInverseElementIterator(); + while (it->more()) { + const SMDS_MeshElement* elem = it->next(); + if ( elem->GetType() == SMDSAbs_Face && + emap.find( elem ) != emap.end() ) + if ( theTria1 ) { + theTria2 = elem; + break; + } else { + theTria1 = elem; + } + } + return ( theTria1 && theTria2 ); +} + +//======================================================================= +//function : onTextChange +//purpose : +//======================================================================= + +void SMESHGUI_SingleEditDlg::onTextChange( const QString& theNewText ) +{ + if ( myBusy ) return; + + myOkBtn->setEnabled( false ); + myApplyBtn->setEnabled( false ); + + // hilight entered edge + SMDS_Mesh* aMesh = 0; + if ( myActor ) + aMesh = myActor->GetObject()->GetMesh(); + if ( aMesh ) { + + myBusy = true; // block onSelectionDone() + mySelection->ClearIObjects(); + mySelection->AddIObject( myActor->getIO() ); + myBusy = false; + + QStringList aListId = QStringList::split( "-", theNewText, false); + if ( aListId.count() != 2 ) + return; + const SMDS_MeshNode* a2Nodes[2]; + bool allOk = true; + int i; + for ( i = 0; i < aListId.count(); i++ ) { + const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ); + if ( n ) + a2Nodes[ i ] = n; + else + allOk = false; + } + + // find a triangle and an edge nb + const SMDS_MeshElement* tria[2]; + if (allOk && + a2Nodes[0] != a2Nodes[1] && + findTriangles( a2Nodes[0], + a2Nodes[1], + tria[0], + tria[1])) { + myBusy = true; // block onSelectionDone() + mySelection->AddOrRemoveIndex (myActor->getIO(), tria[0]->GetID(), true, false); + + const SMDS_MeshNode* a3Nodes [3]; + SMDS_ElemIteratorPtr it; + int edgeInd = 2; + for (i = 0, it = tria[0]->nodesIterator(); it->more(); i++ ) { + a3Nodes[ i ] = static_cast( it->next() ); + if ( i > 0 ) + if (( a3Nodes[ i ] == a2Nodes[ 0 ] && a3Nodes[ i - 1] == a2Nodes[ 1 ] ) || + ( a3Nodes[ i ] == a2Nodes[ 1 ] && a3Nodes[ i - 1] == a2Nodes[ 0 ] ) ) { + edgeInd = i - 1; + break; + } + } + + mySelection->AddOrRemoveIndex( myActor->getIO(), -edgeInd-1, true, true ); + myBusy = false; + + myOkBtn->setEnabled( true ); + myApplyBtn->setEnabled( true ); + } + } +} +//======================================================================= +// name : SMESHGUI_SingleEditDlg::onSelectionDone +// Purpose : SLOT called when selection changed +//======================================================================= +void SMESHGUI_SingleEditDlg::onSelectionDone() +{ + if ( myBusy ) return; + + int anId1 = 0, anId2 = 0; + + myOkBtn->setEnabled( false ); + myApplyBtn->setEnabled( false ); + + if ( mySelection->IObjectCount() != 1 ) + { + myEdge->clear(); + return; + } + + myActor = SMESH::FindActorByEntry( mySelection->firstIObject()->getEntry() ); + SMDS_Mesh* aMesh = 0; + if ( myActor ) + aMesh = myActor->GetObject()->GetMesh(); + if ( !aMesh ) + return; + + if (SMESH::GetEdgeNodes( mySelection, anId1, anId2 ) >= 1 ) { + QString aText = QString( "%1-%2" ).arg( anId1 ).arg( anId2 ); + myBusy = true; + myEdge->setText( aText ); + myBusy = false; + + const SMDS_MeshElement* tria[2]; + if ( findTriangles( aMesh->FindNode( anId1 ), aMesh->FindNode( anId2 ), tria[0],tria[1])) + { + myOkBtn->setEnabled( true ); + myApplyBtn->setEnabled( true ); + } + } + else + myEdge->clear(); +} + +//======================================================================= +// name : SMESHGUI_SingleEditDlg::onDeactivate +// Purpose : SLOT called when dialog must be deativated +//======================================================================= +void SMESHGUI_SingleEditDlg::onDeactivate() +{ + setEnabled( false ); +} + +//======================================================================= +// name : SMESHGUI_SingleEditDlg::enterEvent +// Purpose : Event filter +//======================================================================= +void SMESHGUI_SingleEditDlg::enterEvent( QEvent* ) +{ + if ( !isEnabled() ) { + SMESHGUI::GetSMESHGUI()->EmitSignalDeactivateDialog(); + // set selection mode + QAD_Application::getDesktop()->SetSelectionMode( EdgeOfCellSelection, true ); + setEnabled( true ); + } +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_SingleEditDlg::closeEvent( QCloseEvent* e ) +{ + onClose() ; +} +//======================================================================= +//function : hideEvent +//purpose : caused by ESC key +//======================================================================= + +void SMESHGUI_SingleEditDlg::hideEvent ( QHideEvent * e ) +{ + if ( !isMinimized() ) + onClose(); +} + +//================================================================================= +// function : onApply +// purpose : SLOT. Called when apply button is pressed +//================================================================================= +bool SMESHGUI_SingleEditDlg::onApply() +{ + if (SMESHGUI::GetSMESHGUI()->ActiveStudyLocked()) + return false; + // verify validity of input data + if ( !isValid( true ) ) + return false; + + // get mesh, actor and nodes + SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO( mySelection->firstIObject() ); + + if ( aMesh->_is_nil() ) + { + QMessageBox::information( SMESHGUI::GetSMESHGUI()->GetDesktop(), + tr( "SMESH_ERROR" ), tr( "SMESHG_NO_MESH" ), QMessageBox::Ok ); + return false; + } + + SMESH::SMESH_MeshEditor_var aMeshEditor = aMesh->GetMeshEditor(); + int anId1= 0, anId2 = 0; + if ( aMeshEditor->_is_nil() || !getNodeIds( myEdge->text(), anId1, anId2 ) ) + return false; + + // perform operation + bool aResult = process( aMeshEditor.in(), anId1, anId2 ); + + // update actor + if ( aResult ) + { + Handle(SALOME_InteractiveObject) anIO = mySelection->firstIObject(); + mySelection->ClearIObjects(); + SMESH::UpdateView(); + mySelection->AddIObject( anIO, false ); + } + + return aResult; +} + +/* + Class : SMESHGUI_TrianglesInversionDlg + Description : Inversion of the diagonal of a pseudo-quadrangle formed by + 2 neighboring triangles with 1 common edge +*/ + +SMESHGUI_TrianglesInversionDlg::SMESHGUI_TrianglesInversionDlg( QWidget* theParent, + SALOME_Selection* theSelection, + const char* theName ) +: SMESHGUI_SingleEditDlg( theParent, theSelection, theName ) +{ + setCaption( tr( "CAPTION" ) ); +} + +SMESHGUI_TrianglesInversionDlg::~SMESHGUI_TrianglesInversionDlg() +{ +} + +bool SMESHGUI_TrianglesInversionDlg::process( + SMESH::SMESH_MeshEditor_ptr theMeshEditor, const int theId1, const int theId2 ) +{ + return theMeshEditor->InverseDiag( theId1, theId2 ); +} + +/* + Class : SMESHGUI_UnionOfTwoTrianglesDlg + Description : Construction of a quadrangle by deletion of the + common border of 2 neighboring triangles +*/ + +SMESHGUI_UnionOfTwoTrianglesDlg::SMESHGUI_UnionOfTwoTrianglesDlg( QWidget* theParent, + SALOME_Selection* theSelection, + const char* theName ) +: SMESHGUI_SingleEditDlg( theParent, theSelection, theName ) +{ + setCaption( tr( "CAPTION" ) ); +} + +SMESHGUI_UnionOfTwoTrianglesDlg::~SMESHGUI_UnionOfTwoTrianglesDlg() +{ +} + +bool SMESHGUI_UnionOfTwoTrianglesDlg::process( + SMESH::SMESH_MeshEditor_ptr theMeshEditor, const int theId1, const int theId2 ) +{ + return theMeshEditor->DeleteDiag( theId1, theId2 ); +} + diff --git a/src/SMESHGUI/SMESHGUI_SingleEditDlg.h b/src/SMESHGUI/SMESHGUI_SingleEditDlg.h new file mode 100755 index 000000000..9aed20635 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_SingleEditDlg.h @@ -0,0 +1,129 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_SingleEditDlg.h +// Author : Sergey LITONIN +// Module : SMESH + + +#ifndef SMESHGUI_SingleEditDlg_H +#define SMESHGUI_SingleEditDlg_H + +#include + +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) + +class QCloseEvent; +class QFrame; +class QLineEdit; +class SMESHGUI_SpinBox; +class QPushButton; +class SALOME_Selection; +class SMESH_Actor; + +/* + Class : SMESHGUI_SingleEditDlg + Description : Base class for dialogs of diagonal inversion and + union of two neighboring triangles +*/ + +class SMESHGUI_SingleEditDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_SingleEditDlg( QWidget*, SALOME_Selection*, const char* = 0 ); + virtual ~SMESHGUI_SingleEditDlg(); + + void Init( SALOME_Selection* ) ; + +protected slots: + + void onOk(); + virtual bool onApply(); + void onClose(); + + void onDeactivate(); + + void onSelectionDone(); + void onTextChange(const QString&); + +protected: + + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; + void hideEvent ( QHideEvent * ); /* ESC key */ + QFrame* createButtonFrame( QWidget* ); + QFrame* createMainFrame ( QWidget* ); + bool isValid( const bool ) const; + bool getNodeIds( const QString&, int&, int& ) const; + virtual bool process( SMESH::SMESH_MeshEditor_ptr, const int, const int ) = 0; + +protected: + + bool myBusy; + QPushButton* myOkBtn; + QPushButton* myApplyBtn; + QPushButton* myCloseBtn; + QLineEdit* myEdge; + SALOME_Selection* mySelection; + SMESH_Actor* myActor; + +}; + +/* + Class : SMESHGUI_TrianglesInversionDlg + Description : Inversion of the diagonal of a pseudo-quadrangle formed by + 2 neighboring triangles with 1 common edge +*/ +class SMESHGUI_TrianglesInversionDlg : public SMESHGUI_SingleEditDlg +{ + Q_OBJECT + +public: + SMESHGUI_TrianglesInversionDlg( QWidget*, SALOME_Selection*, const char* = 0 ); + virtual ~SMESHGUI_TrianglesInversionDlg(); + +protected: + + virtual bool process( SMESH::SMESH_MeshEditor_ptr, const int, const int ); +}; + +/* + Class : SMESHGUI_UnionOfTwoTrianglesDlg + Description : Construction of a quadrangle by deletion of the + common border of 2 neighboring triangles +*/ +class SMESHGUI_UnionOfTwoTrianglesDlg : public SMESHGUI_SingleEditDlg +{ + Q_OBJECT + +public: + SMESHGUI_UnionOfTwoTrianglesDlg( QWidget*, SALOME_Selection*, const char* = 0 ); + virtual ~SMESHGUI_UnionOfTwoTrianglesDlg(); + +protected: + + virtual bool process( SMESH::SMESH_MeshEditor_ptr, const int, const int ); +}; + +#endif diff --git a/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx b/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx new file mode 100644 index 000000000..dbbdfd30b --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_SmoothingDlg.cxx @@ -0,0 +1,729 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_SmoothingDlg.cxx +// Author : Michael ZORIN +// Module : SMESH +// $Header: + +#include "SMESHGUI_SmoothingDlg.h" + +#include "SMESHGUI.h" +#include "SMESHGUI_SpinBox.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_MeshUtils.h" +#include "SMESHGUI_IdValidator.h" +#include "SMESH_Actor.h" +#include "SMESH_TypeFilter.hxx" +#include "SMDS_Mesh.hxx" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +//================================================================================= +// class : SMESHGUI_SmoothingDlg() +// purpose : +//================================================================================= +SMESHGUI_SmoothingDlg::SMESHGUI_SmoothingDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, + bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | + Qt::WDestructiveClose) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_SMOOTHING"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); + + if ( !name ) + setName( "SMESHGUI_SmoothingDlg" ); + resize( 303, 185 ); + setCaption( tr( "SMESH_SMOOTHING" ) ); + setSizeGripEnabled( TRUE ); + SMESHGUI_SmoothingDlgLayout = new QGridLayout( this ); + SMESHGUI_SmoothingDlgLayout->setSpacing( 6 ); + SMESHGUI_SmoothingDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setTitle( tr( "SMESH_SMOOTHING" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + Constructor1 = new QRadioButton( GroupConstructors, "Constructor1" ); + Constructor1->setText( tr( "" ) ); + Constructor1->setPixmap( image0 ); + Constructor1->setChecked( TRUE ); + Constructor1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)0, Constructor1->sizePolicy().hasHeightForWidth() ) ); + Constructor1->setMinimumSize( QSize( 50, 0 ) ); + GroupConstructorsLayout->addWidget( Constructor1, 0, 0 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupConstructorsLayout->addItem( spacer, 0, 1 ); + SMESHGUI_SmoothingDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_SmoothingDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupArguments = new QGroupBox( this, "GroupArguments" ); + GroupArguments->setTitle( tr( "SMESH_ARGUMENTS" ) ); + GroupArguments->setColumnLayout(0, Qt::Vertical ); + GroupArguments->layout()->setSpacing( 0 ); + GroupArguments->layout()->setMargin( 0 ); + GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() ); + GroupArgumentsLayout->setAlignment( Qt::AlignTop ); + GroupArgumentsLayout->setSpacing( 6 ); + GroupArgumentsLayout->setMargin( 11 ); + + // Controls for elements selection + TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" ); + TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) ); + GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 ); + + SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" ); + SelectElementsButton->setText( tr( "" ) ); + SelectElementsButton->setPixmap( image1 ); + SelectElementsButton->setToggleButton( FALSE ); + GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 ); + + LineEditElements = new QLineEdit( GroupArguments, "LineEditElements" ); + LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" )); + GroupArgumentsLayout->addWidget( LineEditElements, 0, 2 ); + + // Control for the whole mesh selection + CheckBoxMesh = new QCheckBox( GroupArguments, "CheckBoxMesh" ); + CheckBoxMesh->setText( tr( "SMESH_SELECT_WHOLE_MESH" ) ); + GroupArgumentsLayout->addMultiCellWidget( CheckBoxMesh, 1, 1, 0, 2 ); + + // Controls for nodes selection + TextLabelNodes = new QLabel( GroupArguments, "TextLabelNodes" ); + TextLabelNodes->setText( tr( "FIXED_NODES_IDS" ) ); + GroupArgumentsLayout->addWidget( TextLabelNodes, 2, 0 ); + + SelectNodesButton = new QPushButton( GroupArguments, "SelectNodesButton" ); + SelectNodesButton->setText( tr( "" ) ); + SelectNodesButton->setPixmap( image1 ); + SelectNodesButton->setToggleButton( FALSE ); + GroupArgumentsLayout->addWidget( SelectNodesButton, 2, 1 ); + + LineEditNodes = new QLineEdit( GroupArguments, "LineEditNodes" ); + LineEditNodes->setValidator( new SMESHGUI_IdValidator( this, "validator" )); + GroupArgumentsLayout->addWidget( LineEditNodes, 2, 2 ); + + // Controls for method selection + TextLabelMethod = new QLabel( GroupArguments, "TextLabelMethod" ); + TextLabelMethod->setText( tr( "METHOD" ) ); + GroupArgumentsLayout->addMultiCellWidget( TextLabelMethod, 3, 3, 0, 1 ); + + ComboBoxMethod = new QComboBox( GroupArguments, "ComboBoxMethod" ); + GroupArgumentsLayout->addWidget( ComboBoxMethod, 3, 2 ); + + // Controls for iteration limit defining + TextLabelLimit = new QLabel( GroupArguments, "TextLabelLimit" ); + TextLabelLimit->setText( tr( "ITERATION_LIMIT" ) ); + GroupArgumentsLayout->addMultiCellWidget( TextLabelLimit, 4, 4, 0, 1 ); + + SpinBox_IterationLimit = new QSpinBox(GroupArguments, "SpinBox_IterationLimit"); + GroupArgumentsLayout->addWidget( SpinBox_IterationLimit, 4, 2 ); + + // Controls for max. aspect ratio defining + TextLabelAspectRatio = new QLabel( GroupArguments, "TextLabelAspectRatio" ); + TextLabelAspectRatio->setText( tr( "MAX_ASPECT_RATIO" ) ); + GroupArgumentsLayout->addMultiCellWidget( TextLabelAspectRatio, 5, 5, 0, 1 ); + + SpinBox_AspectRatio = new SMESHGUI_SpinBox(GroupArguments, "SpinBox_AspectRatio"); + GroupArgumentsLayout->addWidget( SpinBox_AspectRatio, 5, 2 ); + + + SMESHGUI_SmoothingDlgLayout->addWidget( GroupArguments, 1, 0 ); + + /* Initialisations */ + ComboBoxMethod->insertItem(tr("LAPLACIAN")); + ComboBoxMethod->insertItem(tr("CENTROIDAL")); + + QIntValidator* anIntValidator = new QIntValidator(SpinBox_IterationLimit); + SpinBox_IterationLimit->setValidator(anIntValidator); + SpinBox_IterationLimit->setRange( 1, 999999 ); + SpinBox_AspectRatio->RangeStepAndValidator( 0.0, +999999.999, 0.1, 3 ); + + GroupArguments->show(); + myConstructorId = 0 ; + Constructor1->setChecked( TRUE ); + mySelection = Sel; + + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + // Costruction of the logical filter + SMESH_ListOfFilter aListOfFilters; + Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); + if ( !aMeshOrSubMeshFilter.IsNull() ) + aListOfFilters.Append( aMeshOrSubMeshFilter ); + Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP ); + if ( !aSmeshGroupFilter.IsNull() ) + aListOfFilters.Append( aSmeshGroupFilter ); + + myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR ); + + Init(); + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectNodesButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + /* to close dialog if study change */ + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + connect( LineEditElements, SIGNAL( textChanged( const QString& )), + SLOT( onTextChange( const QString& ))); + connect( LineEditNodes, SIGNAL( textChanged( const QString& )), + SLOT( onTextChange( const QString& ))); + connect( CheckBoxMesh, SIGNAL( toggled( bool )), + SLOT( onSelectMesh( bool ))); + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ +} + +//================================================================================= +// function : ~SMESHGUI_SmoothingDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_SmoothingDlg::~SMESHGUI_SmoothingDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_SmoothingDlg::Init() +{ + myBusy = false; + + ComboBoxMethod->setCurrentItem(0); + + SpinBox_IterationLimit->setValue(20); + SpinBox_AspectRatio->SetValue(1.1); + + myEditCurrentArgument = LineEditElements; + LineEditElements->setFocus(); + myElementsId = ""; + myNbOkElements = 0 ; + myNbOkNodes = 0 ; + myActor = 0; + myMesh = SMESH::SMESH_Mesh::_nil(); + + CheckBoxMesh->setChecked(false); + onSelectMesh( false ); +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_SmoothingDlg::ConstructorsClicked(int constructorId) +{ + return ; +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_SmoothingDlg::ClickOnApply() +{ + if (mySMESHGUI->ActiveStudyLocked()) + return; + + if ( myNbOkElements && (myNbOkNodes || LineEditNodes->text().stripWhiteSpace().isEmpty())) + { + QStringList aListElementsId = QStringList::split( " ", myElementsId, false); + QStringList aListNodesId = QStringList::split( " ", LineEditNodes->text(), false); + + SMESH::long_array_var anElementsId = new SMESH::long_array; + SMESH::long_array_var aNodesId = new SMESH::long_array; + + anElementsId->length( aListElementsId.count() ); + for ( int i = 0; i < aListElementsId.count(); i++ ) + anElementsId[i] = aListElementsId[i].toInt(); + + if (myNbOkNodes) + { + aNodesId->length( aListNodesId.count() ); + for ( int i = 0; i < aListNodesId.count(); i++ ) + aNodesId[i] = aListNodesId[i].toInt(); + } + else + anElementsId->length(0); + + long anIterationLimit = (long)SpinBox_IterationLimit->value(); + double aMaxAspectRatio = SpinBox_AspectRatio->GetValue(); + + SMESH::SMESH_MeshEditor::Smooth_Method aMethod = SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH; + if (ComboBoxMethod->currentItem() > 0) + aMethod = SMESH::SMESH_MeshEditor::CENTROIDAL_SMOOTH; + + bool aResult = false; + try + { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + QApplication::setOverrideCursor(Qt::waitCursor); + aResult = aMeshEditor->Smooth(anElementsId.inout(), aNodesId.inout(), anIterationLimit, aMaxAspectRatio, aMethod); + QApplication::restoreOverrideCursor(); + } + catch( ... ) + { + } + + if ( aResult ) + { + Handle(SALOME_InteractiveObject) anIO = myActor->getIO(); + mySelection->ClearIObjects(); + SMESH::UpdateView(); + mySelection->AddIObject( anIO, false ); + Init(); + } + } + +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_SmoothingDlg::ClickOnOk() +{ + ClickOnApply() ; + ClickOnCancel() ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_SmoothingDlg::ClickOnCancel() +{ + mySelection->ClearFilters(); + mySelection->ClearIObjects(); + SMESH::SetPointRepresentation(false); + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + reject() ; +} + +//======================================================================= +//function : onTextChange +//purpose : +//======================================================================= + +void SMESHGUI_SmoothingDlg::onTextChange(const QString& theNewText) +{ + QLineEdit* send = (QLineEdit*)sender(); + + if ( myBusy ) return; + myBusy = true; + + if (send == LineEditElements) + myNbOkElements = 0; + else if (send == LineEditNodes) + myNbOkNodes = 0; + + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + + // hilight entered elements/nodes + SMDS_Mesh* aMesh = 0; + if ( myActor ) + aMesh = myActor->GetObject()->GetMesh(); + + if ( aMesh ) { + mySelection->ClearIObjects(); + mySelection->AddIObject( myActor->getIO() ); + + QStringList aListId = QStringList::split( " ", theNewText, false); + + if (send == LineEditElements) { + for ( int i = 0; i < aListId.count(); i++ ) { + const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() ); + if ( e ) { + if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() )) + mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true); + myNbOkElements++; + } + } + myElementsId = theNewText; + } + else if (send == LineEditNodes) { + for ( int i = 0; i < aListId.count(); i++ ) { + const SMDS_MeshNode * n = aMesh->FindNode( aListId[ i ].toInt() ); + if ( n ) { + if ( !mySelection->IsIndexSelected( myActor->getIO(), n->GetID() )) + mySelection->AddOrRemoveIndex (myActor->getIO(), n->GetID(), true); + myNbOkNodes++; + } + } + } + } + + if ( myNbOkElements && (myNbOkNodes || LineEditNodes->text().stripWhiteSpace().isEmpty()) ) { + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); + } + + myBusy = false; +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void SMESHGUI_SmoothingDlg::SelectionIntoArgument() +{ + if ( myBusy ) return; + + // clear + myActor = 0; + QString aString = ""; + + myBusy = true; + if (myEditCurrentArgument == (QWidget*)LineEditElements) + { + LineEditElements->setText( aString ); + myNbOkElements = 0; + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + } + myBusy = false; + + if ( !GroupButtons->isEnabled() ) // inactive + return; + + // get selected mesh + + int nbSel = mySelection->IObjectCount(); + if(nbSel != 1) + return; + + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + myMesh = SMESH::GetMeshByIO(IO); + if(myMesh->_is_nil()) + return; + myActor = SMESH::FindActorByObject(myMesh); + if (!myActor) + return; + + int aNbUnits = 0; + + if (myEditCurrentArgument == LineEditElements) + { + myElementsId = ""; + + if (CheckBoxMesh->isChecked()) + { + SMESH::GetNameOfSelectedIObjects(mySelection, aString); + + if(!SMESH::IObjectToInterface(IO)->_is_nil()) //MESH + { + // get IDs from mesh + SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); + if (!aSMDSMesh) + return; + + for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ ) + { + const SMDS_MeshElement * e = aSMDSMesh->FindElement( i ); + if ( e ) { + myElementsId += QString(" %1").arg(i); + aNbUnits++; + } + } + } + else if (!SMESH::IObjectToInterface(IO)->_is_nil()) //SUBMESH + { + // get submesh + SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(IO) ; + + // get IDs from submesh + SMESH::long_array_var anElementsIds = new SMESH::long_array; + anElementsIds = aSubMesh->GetElementsId(); + for ( int i = 0; i < anElementsIds->length(); i++ ) + myElementsId += QString(" %1").arg(anElementsIds[i]); + aNbUnits = anElementsIds->length(); + } + else // GROUP + { + // get smesh group + SMESH::SMESH_GroupBase_var aGroup + = SMESH::IObjectToInterface(IO); + if (aGroup->_is_nil()) + return; + + // get IDs from smesh group + SMESH::long_array_var anElementsIds = new SMESH::long_array; + anElementsIds = aGroup->GetListOfID(); + for ( int i = 0; i < anElementsIds->length(); i++ ) + myElementsId += QString(" %1").arg(anElementsIds[i]); + aNbUnits = anElementsIds->length(); + } + } + else + { + aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString) ; + myElementsId = aString; + } + } + else if (myEditCurrentArgument == LineEditNodes && !myMesh->_is_nil() && myActor) + { + myNbOkNodes = 0; + aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString) ; + } + + if(aNbUnits < 1) + return ; + + myBusy = true; + myEditCurrentArgument->setText( aString ); + myBusy = false; + + // OK + if (myEditCurrentArgument == LineEditElements) + myNbOkElements = true; + else if (myEditCurrentArgument == LineEditNodes) + myNbOkNodes = true; + + if (myNbOkElements) + { + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); + } +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void SMESHGUI_SmoothingDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + switch (myConstructorId) + { + case 0: /* default constructor */ + { + disconnect( mySelection, 0, this, 0 ); + mySelection->ClearIObjects(); + mySelection->ClearFilters(); + + if(send == SelectElementsButton) { + myEditCurrentArgument = LineEditElements; + SMESH::SetPointRepresentation(false); + if (CheckBoxMesh->isChecked()) + { + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter); + } + else + QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + } + else if (send == SelectNodesButton) + { + myEditCurrentArgument = LineEditNodes; + SMESH::SetPointRepresentation(true); + QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + } + + myEditCurrentArgument->setFocus(); + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + SelectionIntoArgument() ; + break; + } + } +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_SmoothingDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupArguments->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + mySMESHGUI->ResetState() ; + mySMESHGUI->SetActiveDialogBox(0) ; + } +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_SmoothingDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupArguments->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + SelectionIntoArgument(); +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_SmoothingDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_SmoothingDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; +} + + +//======================================================================= +//function : hideEvent +//purpose : caused by ESC key +//======================================================================= + +void SMESHGUI_SmoothingDlg::hideEvent ( QHideEvent * e ) +{ + if ( !isMinimized() ) + ClickOnCancel(); +} + + +//======================================================================= +//function : onSelectMesh +//purpose : +//======================================================================= +void SMESHGUI_SmoothingDlg::onSelectMesh ( bool toSelectMesh ) +{ + if (toSelectMesh) + TextLabelElements->setText( tr( "SMESH_NAME" ) ); + else + TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) ); + + if (myEditCurrentArgument != LineEditElements) + { + LineEditElements->clear(); + return; + } + + mySelection->ClearFilters() ; + SMESH::SetPointRepresentation(false); + + if (toSelectMesh) + { + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter); + LineEditElements->setReadOnly(true); + } + else + { + QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + LineEditElements->setReadOnly(false); + onTextChange(LineEditElements->text()); + } + + SelectionIntoArgument(); +} diff --git a/src/SMESHGUI/SMESHGUI_AddVolumeDlg.h b/src/SMESHGUI/SMESHGUI_SmoothingDlg.h similarity index 61% rename from src/SMESHGUI/SMESHGUI_AddVolumeDlg.h rename to src/SMESHGUI/SMESHGUI_SmoothingDlg.h index b0642e7d5..fafade3f3 100644 --- a/src/SMESHGUI/SMESHGUI_AddVolumeDlg.h +++ b/src/SMESHGUI/SMESHGUI_SmoothingDlg.h @@ -21,25 +21,19 @@ // // // -// File : SMESHGUI_AddVolumeDlg.h -// Author : Nicolas REJNERI +// File : SMESHGUI_SmoothingDlg.h +// Author : Michael ZORIN // Module : SMESH -// $Header$ +// $Header: -#ifndef DIALOGBOX_ADD_VOLUME_H -#define DIALOGBOX_ADD_VOLUME_H +#ifndef DIALOGBOX_SMOOTHING_H +#define DIALOGBOX_SMOOTHING_H #include "SALOME_Selection.h" - +#include "SMESH_LogicalFilter.hxx" // QT Includes -#include #include -// Open CASCADE Includes -#include - -class QVBoxLayout; -class QHBoxLayout; class QGridLayout; class QButtonGroup; class QGroupBox; @@ -47,54 +41,72 @@ class QLabel; class QLineEdit; class QPushButton; class QRadioButton; +class QComboBox; class QCheckBox; +class QSpinBox; +class SMESHGUI_SpinBox; class SMESHGUI; +class SMESH_Actor; + // IDL Headers #include #include CORBA_SERVER_HEADER(SMESH_Mesh) + //================================================================================= -// class : SMESHGUI_AddVolumeDlg +// class : SMESHGUI_SmoothingDlg // purpose : //================================================================================= -class SMESHGUI_AddVolumeDlg : public QDialog +class SMESHGUI_SmoothingDlg : public QDialog { Q_OBJECT public: - SMESHGUI_AddVolumeDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, - int nbNode = 4, bool modal = FALSE, WFlags fl = 0 ); - ~SMESHGUI_AddVolumeDlg(); + SMESHGUI_SmoothingDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_SmoothingDlg(); private: - void Init( SALOME_Selection* Sel ) ; + void Init() ; void closeEvent( QCloseEvent* e ) ; void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void hideEvent ( QHideEvent * ); /* ESC key */ SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ SALOME_Selection* mySelection ; /* User shape selection */ - bool myOkNodes ; /* to check when arguments is defined */ - - int myNodes ; + QString myElementsId; + int myNbOkElements ; /* to check when elements are defined */ + int myNbOkNodes ; /* to check when fixed nodes are defined */ int myConstructorId ; /* Current constructor id = radio button id */ QLineEdit* myEditCurrentArgument; /* Current LineEdit */ + bool myBusy; SMESH::SMESH_Mesh_var myMesh; - TColStd_MapOfInteger myMapIndex; - + SMESH_Actor* myActor; + Handle(SMESH_LogicalFilter) myMeshOrSubMeshOrGroupFilter; + QButtonGroup* GroupConstructors; QRadioButton* Constructor1; QGroupBox* GroupButtons; QPushButton* buttonOk; QPushButton* buttonCancel; QPushButton* buttonApply; - QGroupBox* GroupC1; - QLabel* TextLabelC1A1; - QPushButton* SelectButtonC1A1; - QLineEdit* LineEditC1A1; - + QGroupBox* GroupArguments; + QLabel* TextLabelElements; + QPushButton* SelectElementsButton; + QLineEdit* LineEditElements; + QCheckBox* CheckBoxMesh; + QLabel* TextLabelNodes; + QPushButton* SelectNodesButton; + QLineEdit* LineEditNodes; + QLabel* TextLabelMethod; + QComboBox* ComboBoxMethod; + QLabel* TextLabelLimit; + QSpinBox* SpinBox_IterationLimit; + QLabel* TextLabelAspectRatio; + SMESHGUI_SpinBox* SpinBox_AspectRatio; + private slots: void ConstructorsClicked(int constructorId); @@ -105,12 +117,14 @@ private slots: void SelectionIntoArgument() ; void DeactivateActiveDialog() ; void ActivateThisDialog() ; + void onTextChange(const QString&); + void onSelectMesh(bool toSelectMesh); protected: - QGridLayout* SMESHGUI_AddVolumeDlgLayout; + QGridLayout* SMESHGUI_SmoothingDlgLayout; QGridLayout* GroupConstructorsLayout; QGridLayout* GroupButtonsLayout; - QGridLayout* GroupC1Layout; + QGridLayout* GroupArgumentsLayout; }; -#endif // DIALOGBOX_ADD_VOLUME_H +#endif // DIALOGBOX_SMOOTHING_H diff --git a/src/SMESHGUI/SMESHGUI_SpinBox.cxx b/src/SMESHGUI/SMESHGUI_SpinBox.cxx index 6b0d19ca1..017b37b33 100644 --- a/src/SMESHGUI/SMESHGUI_SpinBox.cxx +++ b/src/SMESHGUI/SMESHGUI_SpinBox.cxx @@ -26,11 +26,13 @@ // Module : SMESH // $Header$ -using namespace std; #include "SMESHGUI_SpinBox.h" #include "SMESHGUI.h" + #include +using namespace std; + //================================================================================= // class : SMESHGUI_SpinBox() // purpose : constructor of specific widget accepting floats in double precision. diff --git a/src/SMESHGUI/SMESHGUI_StudyAPI.cxx b/src/SMESHGUI/SMESHGUI_StudyAPI.cxx deleted file mode 100644 index 65605ad92..000000000 --- a/src/SMESHGUI/SMESHGUI_StudyAPI.cxx +++ /dev/null @@ -1,457 +0,0 @@ -// SMESH SMESHGUI : GUI for SMESH component -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMESHGUI_StudyAPI.cxx -// Author : Yves FRICAUD -// Module : SMESH -// $Header: - -using namespace std; -#include "SMESHGUI_StudyAPI.h" -#include "utilities.h" -#include "Utils_ORB_INIT.hxx" -#include "Utils_SINGLETON.hxx" - -#include "QAD_MessageBox.h" -#include "QAD_Desktop.h" -#include "QAD_Application.h" - -// QT Includes -#include - -// Open CASCADE Includes -#include "Standard_CString.hxx" - -static CORBA::ORB_var _orb; - -// Tags definition -long Tag_HypothesisRoot = 1; -long Tag_AlgorithmsRoot = 2; - -long Tag_RefOnShape = 1; -long Tag_RefOnAppliedHypothesis = 2; -long Tag_RefOnAppliedAlgorithms = 3; - -long Tag_SubMeshOnVertex = 4; -long Tag_SubMeshOnEdge = 5; -long Tag_SubMeshOnFace = 6; -long Tag_SubMeshOnSolid = 7; -long Tag_SubMeshOnCompound = 8; - - - -static char* IORToString (CORBA::Object_ptr obj) -{ - // MESSAGE ( " IORToString " << _orb->object_to_string(obj) ) - return _orb->object_to_string(obj); -} - -CORBA::Object_ptr SMESHGUI_StudyAPI::StringToIOR (const char* IOR) -{ - // MESSAGE ( " StringToIOR " << _orb->string_to_object(IOR) ) - return _orb->string_to_object(IOR); -} -//======================================================================= -// function : -// purpose : Constructor -//======================================================================= -SMESHGUI_StudyAPI::SMESHGUI_StudyAPI () -{ -} - -SMESHGUI_StudyAPI::SMESHGUI_StudyAPI ( SALOMEDS::Study_ptr aStudy, - SMESH::SMESH_Gen_ptr CompMesh) -{ - setOrb(); - Update( aStudy ); -} - -//======================================================================= -// function : -// purpose : Destructor -//======================================================================= -SMESHGUI_StudyAPI::~SMESHGUI_StudyAPI () -{ -} - -//======================================================================= -// function : -// purpose : Update -//======================================================================= -void SMESHGUI_StudyAPI::Update(SALOMEDS::Study_ptr aStudy) -{ - myStudy = SALOMEDS::Study::_duplicate( aStudy ); - myStudyBuilder = aStudy->NewBuilder(); -} - -//======================================================================= -// function : SetShape -// purpose : -//======================================================================= -void SMESHGUI_StudyAPI::SetShape (SALOMEDS::SObject_ptr SO_MorSM, - SALOMEDS::SObject_ptr SO_GeomShape ) -{ - // NRI : Temporary added - if ( myStudy->GetProperties()->IsLocked() ) { - return; - } - // NRI - SALOMEDS::SObject_var SO = myStudyBuilder->NewObjectToTag (SO_MorSM, Tag_RefOnShape); - myStudyBuilder->Addreference (SO,SO_GeomShape); -} - -//======================================================================= -// function : GetShapeOnMeshOrSubMesh -// purpose : -//======================================================================= -GEOM::GEOM_Shape_ptr SMESHGUI_StudyAPI::GetShapeOnMeshOrSubMesh(SALOMEDS::SObject_ptr SO_Mesh_Or_SubMesh) -{ - // NRI : Temporary added - if ( myStudy->GetProperties()->IsLocked() ) { - return GEOM::GEOM_Shape::_nil(); - } - // NRI - - if ( SO_Mesh_Or_SubMesh->_is_nil() ) - return GEOM::GEOM_Shape::_nil(); - - GEOM::GEOM_Shape_var Shape; - SALOMEDS::SObject_var aSO, aGeom; - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - if ( SO_Mesh_Or_SubMesh->FindSubObject( Tag_RefOnShape, aSO ) ) { - if ( aSO->ReferencedObject(aGeom) ) { - if (aGeom->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - return GEOM::GEOM_Shape::_narrow( _orb->string_to_object(anIOR->Value()) ); - } - } - } - return GEOM::GEOM_Shape::_nil(); -} - -//======================================================================= -// function : AddSubMeshOnShape -// purpose : -//======================================================================= -SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::AddSubMeshOnShape (SALOMEDS::SObject_ptr SO_Mesh, - SMESH::SMESH_subMesh_ptr SM, - GEOM::shape_type ST) -{ - // NRI : Temporary added - if ( myStudy->GetProperties()->IsLocked() ) { - return SALOMEDS::SObject::_nil(); - } - // NRI - - long Tag_Shape ; - Standard_CString Name; - - if (ST == GEOM::SOLID) {Tag_Shape = Tag_SubMeshOnSolid; Name = strdup(QObject::tr("SMESH_MEN_SubMeshesOnSolid"));} - else if (ST == GEOM::FACE) {Tag_Shape = Tag_SubMeshOnFace; Name = strdup(QObject::tr("SMESH_MEN_SubMeshesOnFace"));} - else if (ST == GEOM::EDGE) {Tag_Shape = Tag_SubMeshOnEdge; Name = strdup(QObject::tr("SMESH_MEN_SubMeshesOnEdge"));} - else if (ST == GEOM::VERTEX){Tag_Shape = Tag_SubMeshOnVertex; Name = strdup(QObject::tr("SMESH_MEN_SubMeshesOnVertex"));} - else { - Tag_Shape = Tag_SubMeshOnCompound; Name = strdup(QObject::tr("SMESH_MEN_SubMeshesOnCompound")); - } - - SALOMEDS::SObject_var SubmeshesRoot; - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var anIOR; - SALOMEDS::AttributeSelectable_var aSelAttr; - - if (!SO_Mesh->FindSubObject (Tag_Shape,SubmeshesRoot )) { - SubmeshesRoot = myStudyBuilder->NewObjectToTag (SO_Mesh, Tag_Shape); - anAttr = myStudyBuilder->FindOrCreateAttribute(SubmeshesRoot, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue(Name); - anAttr = myStudyBuilder->FindOrCreateAttribute(SubmeshesRoot, "AttributeSelectable"); - aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); - aSelAttr->SetSelectable(false); - } - SALOMEDS::SObject_var SO = myStudyBuilder->NewObject (SubmeshesRoot); - anAttr = myStudyBuilder->FindOrCreateAttribute(SO, "AttributeIOR"); - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - anIOR->SetValue(IORToString(SM)); - return SALOMEDS::SObject::_narrow( SO ); -} - -//======================================================================= -// function : AddSubMeshOnShape -// purpose : -//======================================================================= -SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::AddSubMeshOnShape (SALOMEDS::SObject_ptr SO_Mesh, - SALOMEDS::SObject_ptr SO_GeomShape, - SMESH::SMESH_subMesh_ptr SM, - GEOM::shape_type ST) -{ - // NRI : Temporary added - if ( myStudy->GetProperties()->IsLocked() ) { - return SALOMEDS::SObject::_nil(); - } - // NRI - - SALOMEDS::SObject_var SO_SM = AddSubMeshOnShape (SO_Mesh,SM,ST); - SetShape (SO_SM,SO_GeomShape); - // SetShapeOnSubMesh (SO_SM,SO_GeomShape); - return SALOMEDS::SObject::_narrow( SO_SM ); -} - - -//======================================================================= -// function : SetHypothesis -// purpose : -//======================================================================= -void SMESHGUI_StudyAPI::SetHypothesis (SALOMEDS::SObject_ptr SO_MorSM, - SALOMEDS::SObject_ptr SO_Hypothesis) -{ - // NRI : Temporary added - if ( myStudy->GetProperties()->IsLocked() ) { - return; - } - // NRI - - //Find or Create Applied Hypothesis root - SALOMEDS::SObject_var AHR; - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeSelectable_var aSelAttr; - SALOMEDS::AttributePixMap_var aPixmap; - - if (!SO_MorSM->FindSubObject (Tag_RefOnAppliedHypothesis, AHR)) { - AHR = myStudyBuilder->NewObjectToTag (SO_MorSM, Tag_RefOnAppliedHypothesis); - anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue(QObject::tr("SMESH_MEN_APPLIED_HYPOTHESIS")); - anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributeSelectable"); - aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); - aSelAttr->SetSelectable(false); - anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributePixMap"); - aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); - aPixmap->SetPixMap( "ICON_SMESH_TREE_HYPO" ); - } - SALOMEDS::SObject_var SO = myStudyBuilder->NewObject(AHR); - myStudyBuilder->Addreference (SO,SO_Hypothesis); -} - -//======================================================================= -// function : SetAlgorithms -// purpose : -//======================================================================= -void SMESHGUI_StudyAPI::SetAlgorithms (SALOMEDS::SObject_ptr SO_MorSM, - SALOMEDS::SObject_ptr SO_Algorithms) -{ - // NRI : Temporary added - if ( myStudy->GetProperties()->IsLocked() ) { - return; - } - // NRI - - //Find or Create Applied Algorithms root - SALOMEDS::SObject_var AHR; - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeSelectable_var aSelAttr; - SALOMEDS::AttributePixMap_var aPixmap; - - if (!SO_MorSM->FindSubObject (Tag_RefOnAppliedAlgorithms, AHR)) { - AHR = myStudyBuilder->NewObjectToTag (SO_MorSM, Tag_RefOnAppliedAlgorithms); - anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue(QObject::tr("SMESH_MEN_APPLIED_ALGORIHTMS")); - anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributeSelectable"); - aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); - aSelAttr->SetSelectable(false); - anAttr = myStudyBuilder->FindOrCreateAttribute(AHR, "AttributePixMap"); - aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); - aPixmap->SetPixMap( "ICON_SMESH_TREE_ALGO" ); - } - SALOMEDS::SObject_var SO = myStudyBuilder->NewObject(AHR); - myStudyBuilder->Addreference (SO,SO_Algorithms); -} - - -//======================================================================= -// function : -// purpose : -//======================================================================= -SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::FindObject( CORBA::Object_ptr theObject ) -{ - // NRI : Temporary added - if ( myStudy->GetProperties()->IsLocked() ) { - return SALOMEDS::SObject::_nil(); - } - // NRI - if ( !CORBA::is_nil ( theObject ) ) { - string anIOR = IORToString( theObject ); - if ( anIOR != "" ) - return myStudy->FindObjectIOR( anIOR.c_str() ); - } - return SALOMEDS::SObject::_nil(); -} - -//======================================================================= -// function : -// purpose : -//======================================================================= -void SMESHGUI_StudyAPI::setOrb() -{ - try { - ORB_INIT &init = *SINGLETON_::Instance(); - ASSERT(SINGLETON_::IsAlreadyExisting()); - _orb = init( 0 , 0 ); - } catch (...) { - INFOS("internal error : orb not found"); - _orb = 0; - } - ASSERT(! CORBA::is_nil(_orb)); -} - -//======================================================================= -// function : -// purpose : -//======================================================================= -void SMESHGUI_StudyAPI::SetName( SALOMEDS::SObject_ptr SO, const char* Name ) -{ - // NRI : Temporary added - if ( myStudy->GetProperties()->IsLocked() ) { - return; - } - // NRI - - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - anAttr = myStudyBuilder->FindOrCreateAttribute(SO, "AttributeName"); - aName = SALOMEDS::AttributeName::_narrow(anAttr); - aName->SetValue(Name); -} - -//======================================================================= -// function : -// purpose : -//======================================================================= -void SMESHGUI_StudyAPI::UnSetHypothesis (SALOMEDS::SObject_ptr SO_Applied_Hypothesis) -{ - // NRI : Temporary added - if ( myStudy->GetProperties()->IsLocked() ) { - return; - } - // NRI - myStudyBuilder->RemoveObject(SO_Applied_Hypothesis); -} - -//======================================================================= -// function : -// purpose : -//======================================================================= -void SMESHGUI_StudyAPI::UnSetAlgorithm (SALOMEDS::SObject_ptr SO_Applied_Algorithm) -{ - // NRI : Temporary added - if ( myStudy->GetProperties()->IsLocked() ) { - return; - } - // NRI - myStudyBuilder->RemoveObject(SO_Applied_Algorithm); -} - -//======================================================================= -// function : -// purpose : -//======================================================================= -SALOMEDS::SObject_ptr SMESHGUI_StudyAPI::GetMeshOrSubmesh (SALOMEDS::SObject_ptr SO) -{ - // NRI : Temporary added - if ( myStudy->GetProperties()->IsLocked() ) { - return SALOMEDS::SObject::_nil(); - } - // NRI - - SALOMEDS::SObject_var MorSM,SB; - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var anIOR; - - if (SO->FindAttribute(anAttr, "AttributeIOR")) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - GEOM::GEOM_Shape_var Shape = GEOM::GEOM_Shape::_narrow( _orb->string_to_object(anIOR->Value()) ); - if (!Shape->_is_nil()) { - //It s a shape - MorSM = SO->GetFather(); - // MESSAGE ( " MorSM shape " << MorSM->GetID() ) - return SALOMEDS::SObject::_narrow( MorSM); - } - } - - if (SO->ReferencedObject(SB)) { - //It's Reference on Hypothesis or Algorithm - MorSM = SO->GetFather()->GetFather(); - // MESSAGE ( " MorSM reference " << MorSM->GetID() ) - return SALOMEDS::SObject::_narrow( MorSM); - } - // It's SMESH_MEN_APPLIED_HYPOTHESIS or SMESH_MEN_APPLIED_ALGORITHMS or SubMeshesOnFace etc... - MorSM = SO->GetFather(); - // MESSAGE ( " MorSM banniere " << MorSM->GetID() ) - return SALOMEDS::SObject::_narrow( MorSM); -} - -void SMESHGUI_StudyAPI::ModifiedMesh( SALOMEDS::SObject_ptr MorSM, bool right) -{ - // NRI : Temporary added - if ( myStudy->GetProperties()->IsLocked() ) { - return ; - } - // NRI - - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributePixMap_var aPixmap; - - anAttr = myStudyBuilder->FindOrCreateAttribute(MorSM, "AttributePixMap"); - aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); - if (right) { - aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH" ); - } else { - aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_WARN" ); - } - - int i = 1; - SALOMEDS::ChildIterator_var it = myStudy->NewChildIterator(MorSM); - for (; it->More();it->Next()) { - SALOMEDS::SObject_var Obj = it->Value(); - if ( i >= 4 ) { - int j = 1; - SALOMEDS::ChildIterator_var it1 = myStudy->NewChildIterator(Obj); - for (; it1->More();it1->Next()) { - SALOMEDS::SObject_var Obj1 = it1->Value(); - anAttr = myStudyBuilder->FindOrCreateAttribute(Obj1, "AttributePixMap"); - aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); - if (right) { - aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH" ); - } else { - aPixmap->SetPixMap( "ICON_SMESH_TREE_MESH_WARN" ); - } - } - } - i++; - } -} diff --git a/src/SMESHGUI/SMESHGUI_StudyAPI.h b/src/SMESHGUI/SMESHGUI_StudyAPI.h deleted file mode 100644 index 8cbb56f2b..000000000 --- a/src/SMESHGUI/SMESHGUI_StudyAPI.h +++ /dev/null @@ -1,98 +0,0 @@ -// SMESH SMESHGUI : GUI for SMESH component -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMESHGUI_StudyAPI.h -// Author : Yves FRICAUD -// Module : SMESH -// $Header: - -#ifndef _INCLUDE_SMESHGUI_StudyAPI_ -#define _INCLUDE_SMESHGUI_StudyAPI_ - -// IDL Headers -#include -#include CORBA_SERVER_HEADER(SMESH_Gen) -#include CORBA_SERVER_HEADER(SMESH_Mesh) -#include CORBA_SERVER_HEADER(SMESH_Hypothesis) -#include CORBA_SERVER_HEADER(GEOM_Shape) -#include CORBA_SERVER_HEADER(SALOMEDS) -#include CORBA_SERVER_HEADER(SALOMEDS_Attributes) -#include CORBA_SERVER_HEADER(SALOME_GenericObj) - -class SMESH_subMesh_ptr; - -class SMESHGUI_StudyAPI { - - public: - - SMESHGUI_StudyAPI (); - - SMESHGUI_StudyAPI ( SALOMEDS::Study_ptr aStudy, SMESH::SMESH_Gen_ptr Gen); - - ~SMESHGUI_StudyAPI (); - - // Adding in Study - CORBA::Object_ptr StringToIOR(const char* IOR); - - SALOMEDS::SObject_ptr AddNewMesh (SMESH::SMESH_Mesh_ptr M); - - SALOMEDS::SObject_ptr AddNewHypothesis (SMESH::SMESH_Hypothesis_ptr H); - SALOMEDS::SObject_ptr AddNewAlgorithms (SMESH::SMESH_Hypothesis_ptr H); - - SALOMEDS::SObject_ptr AddSubMeshOnShape (SALOMEDS::SObject_ptr SO_Mesh, SMESH::SMESH_subMesh_ptr SM, GEOM::shape_type ST); - - SALOMEDS::SObject_ptr AddSubMeshOnShape (SALOMEDS::SObject_ptr SO_Mesh, SALOMEDS::SObject_ptr SO_GeomShape, SMESH::SMESH_subMesh_ptr SM, GEOM::shape_type ST); - - void Update(SALOMEDS::Study_ptr aStudy); - - void ModifiedMesh( SALOMEDS::SObject_ptr MorSM, bool right); - - - void SetShape (SALOMEDS::SObject_ptr SO_Mesh_Or_SubMesh, SALOMEDS::SObject_ptr SO_GeomShape); - GEOM::GEOM_Shape_ptr GetShapeOnMeshOrSubMesh(SALOMEDS::SObject_ptr SO_Mesh_Or_SubMesh); - - void SetHypothesis (SALOMEDS::SObject_ptr SO_Mesh_Or_SubMesh, SALOMEDS::SObject_ptr SO_Hypothesis); - void SetAlgorithms (SALOMEDS::SObject_ptr SO_Mesh_Or_SubMesh, SALOMEDS::SObject_ptr SO_Algorithms); - - void UnSetHypothesis (SALOMEDS::SObject_ptr SO_Applied_Hypothesis); - void UnSetAlgorithm (SALOMEDS::SObject_ptr SO_Applied_Algorithm); - - void SetTagHypothesisRoot(); - - void SetName( SALOMEDS::SObject_ptr SO, const char* Name ) ; - - //Exploration - - SALOMEDS::SObject_ptr GetMeshOrSubmesh (SALOMEDS::SObject_ptr SO); - - SALOMEDS::SObject_ptr FindObject(CORBA::Object_ptr theObject); - - static void setOrb(); - - private: - //fields - SALOMEDS::Study_var myStudy; - SALOMEDS::StudyBuilder_var myStudyBuilder; -}; -#endif - diff --git a/src/SMESHGUI/SMESHGUI_Swig.cxx b/src/SMESHGUI/SMESHGUI_Swig.cxx index 1ab1cea6b..b82c7b32a 100644 --- a/src/SMESHGUI/SMESHGUI_Swig.cxx +++ b/src/SMESHGUI/SMESHGUI_Swig.cxx @@ -47,7 +47,6 @@ using namespace std; #include CORBA_SERVER_HEADER(SMESH_Gen) #include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_Hypothesis) -#include CORBA_SERVER_HEADER(GEOM_Shape) static CORBA::ORB_var _orb; @@ -94,12 +93,13 @@ void SMESH_Swig::Init(int studyID) SALOMEDS::AttributeName_var aName; SALOMEDS::AttributePixMap_var aPixmap; - SALOMEDS::SComponent_var father = myStudy->FindComponent("MESH"); + // See return value of SMESH::SMESH_Gen::ComponentDataType() + SALOMEDS::SComponent_var father = myStudy->FindComponent("SMESH"); if (father->_is_nil()) { bool aLocked = myStudy->GetProperties()->IsLocked(); if (aLocked) myStudy->GetProperties()->SetLocked(false); - father = myStudyBuilder->NewComponent("MESH"); + father = myStudyBuilder->NewComponent("SMESH"); anAttr = myStudyBuilder->FindOrCreateAttribute(father, "AttributeName"); aName = SALOMEDS::AttributeName::_narrow(anAttr); //NRI aName->SetValue(QObject::tr("SMESH_MEN_COMPONENT")); @@ -394,6 +394,9 @@ const char* SMESH_Swig::AddSubMesh(const char* SO_Mesh_Entry, const char* SM_IOR aSelAttr = SALOMEDS::AttributeSelectable::_narrow(anAttr); aSelAttr->SetSelectable(false); } + + free(Name); + SALOMEDS::SObject_var SO = myStudyBuilder->NewObject (SubmeshesRoot); anAttr = myStudyBuilder->FindOrCreateAttribute(SO, "AttributeIOR"); anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); diff --git a/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx b/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx new file mode 100644 index 000000000..d073f812f --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_SymmetryDlg.cxx @@ -0,0 +1,901 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_SymmetryDlg.cxx +// Author : Michael ZORIN +// Module : SMESH +// $Header: + +#include "SMESHGUI_SymmetryDlg.h" + +#include "SMESHGUI.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_MeshUtils.h" +#include "SMESHGUI_IdValidator.h" +#include "SMESHGUI_SpinBox.h" +#include "SMESH_Actor.h" +#include "SMESH_TypeFilter.hxx" +#include "SMDS_Mesh.hxx" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +//================================================================================= +// class : SMESHGUI_SymmetryDlg() +// purpose : +//================================================================================= +SMESHGUI_SymmetryDlg::SMESHGUI_SymmetryDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, + bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | + Qt::WDestructiveClose) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SYMMETRY_POINT"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SYMMETRY_AXIS"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_SYMMETRY_PLANE"))); + QPixmap image3(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); + + if ( !name ) + setName( "SMESHGUI_SymmetryDlg" ); + resize( 303, 185 ); + setCaption( tr( "SMESH_SYMMETRY" ) ); + setSizeGripEnabled( TRUE ); + SMESHGUI_SymmetryDlgLayout = new QGridLayout( this ); + SMESHGUI_SymmetryDlgLayout->setSpacing( 6 ); + SMESHGUI_SymmetryDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) ); + GroupConstructors->setTitle( tr( "SMESH_SYMMETRY" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + QHBoxLayout* RBLayout = new QHBoxLayout( 0, 0, 6, "Layout2"); + RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" ); + RadioButton1->setText( tr( "" ) ); + RadioButton1->setPixmap( image0 ); + RBLayout->addWidget( RadioButton1); + RadioButton2= new QRadioButton( GroupConstructors, "RadioButton2" ); + RadioButton2->setText( tr( "" ) ); + RadioButton2->setPixmap( image1 ); + RBLayout->addWidget( RadioButton2); + RadioButton3= new QRadioButton( GroupConstructors, "RadioButton3" ); + RadioButton3->setText( tr( "" ) ); + RadioButton3->setPixmap( image2 ); + RBLayout->addWidget( RadioButton3); + GroupConstructorsLayout->addLayout( RBLayout, 0, 0 ); + SMESHGUI_SymmetryDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_SymmetryDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupArguments = new QGroupBox( this, "GroupArguments" ); + GroupArguments->setTitle( tr( "SMESH_ARGUMENTS" ) ); + GroupArguments->setColumnLayout(0, Qt::Vertical ); + GroupArguments->layout()->setSpacing( 0 ); + GroupArguments->layout()->setMargin( 0 ); + GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() ); + GroupArgumentsLayout->setAlignment( Qt::AlignTop ); + GroupArgumentsLayout->setSpacing( 6 ); + GroupArgumentsLayout->setMargin( 11 ); + + // Controls for elements selection + TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" ); + TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) ); + TextLabelElements->setFixedWidth(74); + GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 ); + + SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" ); + SelectElementsButton->setText( tr( "" ) ); + SelectElementsButton->setPixmap( image3 ); + SelectElementsButton->setToggleButton( FALSE ); + GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 ); + + LineEditElements = new QLineEdit( GroupArguments, "LineEditElements" ); + LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" )); + GroupArgumentsLayout->addWidget( LineEditElements, 0, 2 ); + + // Control for the whole mesh selection + CheckBoxMesh = new QCheckBox( GroupArguments, "CheckBoxMesh" ); + CheckBoxMesh->setText( tr( "SMESH_SELECT_WHOLE_MESH" ) ); + GroupArgumentsLayout->addMultiCellWidget( CheckBoxMesh, 1, 1, 0, 2 ); + + // Controls for mirror selection + GroupMirror = new QGroupBox( GroupArguments, "GroupMirror" ); + GroupMirror->setColumnLayout(0, Qt::Vertical ); + GroupMirror->layout()->setSpacing( 0 ); + GroupMirror->layout()->setMargin( 0 ); + QGridLayout* GroupMirrorLayout = new QGridLayout( GroupMirror->layout() ); + GroupMirrorLayout->setAlignment( Qt::AlignTop ); + GroupMirrorLayout->setSpacing( 6 ); + GroupMirrorLayout->setMargin( 11 ); + + TextLabelPoint = new QLabel( GroupMirror, "TextLabelPoint" ); + TextLabelPoint->setText( tr( "SMESH_POINT" ) ); + GroupMirrorLayout->addWidget( TextLabelPoint, 0, 0 ); + + SelectPointButton = new QPushButton( GroupMirror, "SelectPointButton" ); + SelectPointButton->setPixmap( image3 ); + GroupMirrorLayout->addWidget( SelectPointButton, 0, 1 ); + + TextLabelX = new QLabel( GroupMirror, "TextLabelX" ); + TextLabelX->setText( tr( "SMESH_X" ) ); + GroupMirrorLayout->addWidget( TextLabelX, 0, 2 ); + + SpinBox_X = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_X"); + GroupMirrorLayout->addWidget( SpinBox_X, 0, 3 ); + + TextLabelY = new QLabel( GroupMirror, "TextLabelY" ); + TextLabelY->setText( tr( "SMESH_Y" ) ); + GroupMirrorLayout->addWidget( TextLabelY, 0, 4 ); + + SpinBox_Y = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_Y"); + GroupMirrorLayout->addWidget( SpinBox_Y, 0, 5 ); + + TextLabelZ = new QLabel( GroupMirror, "TextLabelZ" ); + TextLabelZ->setText( tr( "SMESH_Z" ) ); + GroupMirrorLayout->addWidget( TextLabelZ, 0, 6 ); + + SpinBox_Z = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_Z"); + GroupMirrorLayout->addWidget( SpinBox_Z, 0, 7 ); + + TextLabelVector = new QLabel( GroupMirror, "TextLabelVector" ); + GroupMirrorLayout->addWidget( TextLabelVector, 1, 0 ); + + SelectVectorButton = new QPushButton( GroupMirror, "SelectVectorButton" ); + SelectVectorButton->setPixmap( image3 ); + GroupMirrorLayout->addWidget( SelectVectorButton, 1, 1 ); + + TextLabelDX = new QLabel( GroupMirror, "TextLabelDX" ); + TextLabelDX->setText( tr( "SMESH_DX" ) ); + GroupMirrorLayout->addWidget( TextLabelDX, 1, 2 ); + + SpinBox_DX = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_DX"); + GroupMirrorLayout->addWidget( SpinBox_DX, 1, 3 ); + + TextLabelDY = new QLabel( GroupMirror, "TextLabelDY" ); + TextLabelDY->setText( tr( "SMESH_DY" ) ); + GroupMirrorLayout->addWidget( TextLabelDY, 1, 4 ); + + SpinBox_DY = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_DY"); + GroupMirrorLayout->addWidget( SpinBox_DY, 1, 5 ); + + TextLabelDZ = new QLabel( GroupMirror, "TextLabelDZ" ); + TextLabelDZ->setText( tr( "SMESH_DZ" ) ); + GroupMirrorLayout->addWidget( TextLabelDZ, 1, 6 ); + + SpinBox_DZ = new SMESHGUI_SpinBox( GroupMirror, "SpinBox_DZ"); + GroupMirrorLayout->addWidget( SpinBox_DZ, 1, 7 ); + + GroupArgumentsLayout->addMultiCellWidget( GroupMirror, 2, 2, 0, 2 ); + + // Controls for "Create a copy" option + CheckBoxCopy = new QCheckBox( GroupArguments, "CheckBoxCopy" ); + CheckBoxCopy->setText( tr( "SMESH_CREATE_COPY" ) ); + GroupArgumentsLayout->addMultiCellWidget( CheckBoxCopy, 3, 3, 0, 2 ); + + + SMESHGUI_SymmetryDlgLayout->addWidget( GroupArguments, 1, 0 ); + + /* Initialisations */ + SpinBox_X->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox_Y->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox_Z->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox_DX->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox_DY->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox_DZ->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + + GroupArguments->show(); + RadioButton1->setChecked( TRUE ); + mySelection = Sel; + + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + // Costruction of the logical filter + SMESH_ListOfFilter aListOfFilters; + Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); + if ( !aMeshOrSubMeshFilter.IsNull() ) + aListOfFilters.Append( aMeshOrSubMeshFilter ); + Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP ); + if ( !aSmeshGroupFilter.IsNull() ) + aListOfFilters.Append( aSmeshGroupFilter ); + + myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR ); + + Init(); + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectPointButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectVectorButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + + connect( SpinBox_DX, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) ); + connect( SpinBox_DY, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) ); + connect( SpinBox_DZ, SIGNAL( valueChanged( double )), this, SLOT(onVectorChanged() ) ); + + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + /* to close dialog if study change */ + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + connect( LineEditElements, SIGNAL( textChanged( const QString& )), + SLOT( onTextChange( const QString& ))); + connect( CheckBoxMesh, SIGNAL( toggled( bool )), + SLOT( onSelectMesh( bool ))); + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + ConstructorsClicked(0); + resize(0,0); +} + +//================================================================================= +// function : ~SMESHGUI_SymmetryDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_SymmetryDlg::~SMESHGUI_SymmetryDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_SymmetryDlg::Init( bool ResetControls ) +{ + myBusy = false; + + myEditCurrentArgument = 0; + LineEditElements->clear(); + myElementsId = ""; + myNbOkElements = 0 ; + + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + + myActor = 0; + myMesh = SMESH::SMESH_Mesh::_nil(); + + if( ResetControls ) + { + SpinBox_X->SetValue(0.0); + SpinBox_Y->SetValue(0.0); + SpinBox_Z->SetValue(0.0); + SpinBox_DX->SetValue(0.0); + SpinBox_DY->SetValue(0.0); + SpinBox_DZ->SetValue(0.0); + + CheckBoxCopy->setChecked(false); + CheckBoxMesh->setChecked(false); + onSelectMesh( false ); + } +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_SymmetryDlg::ConstructorsClicked(int constructorId) +{ + disconnect(mySelection, 0, this, 0); + + if (constructorId!=0 && !TextLabelVector->isVisible()) + { + TextLabelVector->show(); + SelectVectorButton->show(); + TextLabelDX->show(); + SpinBox_DX->show(); + TextLabelDY->show(); + SpinBox_DY->show(); + TextLabelDZ->show(); + SpinBox_DZ->show(); + } + + switch(constructorId) + { + case 0 : + { + GroupMirror->setTitle( tr( "SMESH_POINT" ) ); + + TextLabelVector->hide(); + SelectVectorButton->hide(); + TextLabelDX->hide(); + SpinBox_DX->hide(); + TextLabelDY->hide(); + SpinBox_DY->hide(); + TextLabelDZ->hide(); + SpinBox_DZ->hide(); + break; + } + case 1 : + { + GroupMirror->setTitle( tr( "SMESH_AXIS" ) ); + TextLabelVector->setText( tr( "SMESH_VECTOR" ) ); + break; + } + case 2 : + { + GroupMirror->setTitle( tr( "SMESH_PLANE" ) ); + TextLabelVector->setText( tr( "SMESH_NORMAL" ) ); + break; + } + } + + if (myEditCurrentArgument != (QWidget*)LineEditElements) + { + SMESH::SetPointRepresentation(false); + if (!CheckBoxMesh->isChecked()) + QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + } + + myEditCurrentArgument = (QWidget*)LineEditElements; + LineEditElements->setFocus(); + + if (CheckBoxMesh->isChecked()) + onSelectMesh(true); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_SymmetryDlg::ClickOnApply() +{ + if (mySMESHGUI->ActiveStudyLocked()) + return; + + if ( myNbOkElements && IsMirrorOk() ) + { + QStringList aListElementsId = QStringList::split( " ", myElementsId, false); + + SMESH::long_array_var anElementsId = new SMESH::long_array; + + anElementsId->length( aListElementsId.count() ); + for ( int i = 0; i < aListElementsId.count(); i++ ) + anElementsId[i] = aListElementsId[i].toInt(); + + SMESH::AxisStruct aMirror; + + aMirror.x = SpinBox_X->GetValue(); + aMirror.y = SpinBox_Y->GetValue(); + aMirror.z = SpinBox_Z->GetValue(); + if (GetConstructorId() == 0) + aMirror.vx = aMirror.vy = aMirror.vz = 0; + else + { + aMirror.vx = SpinBox_DX->GetValue(); + aMirror.vy = SpinBox_DY->GetValue(); + aMirror.vz = SpinBox_DZ->GetValue(); + } + + bool toCreateCopy = CheckBoxCopy->isChecked(); + + SMESH::SMESH_MeshEditor::MirrorType aMirrorType; + + if (GetConstructorId() == 0) + aMirrorType = SMESH::SMESH_MeshEditor::POINT; + if (GetConstructorId() == 1) + aMirrorType = SMESH::SMESH_MeshEditor::AXIS; + if (GetConstructorId() == 2) + aMirrorType = SMESH::SMESH_MeshEditor::PLANE; + + try + { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + QApplication::setOverrideCursor(Qt::waitCursor); + aMeshEditor->Mirror(anElementsId, aMirror, aMirrorType, toCreateCopy); + QApplication::restoreOverrideCursor(); + } + catch( ... ) + { + } + + mySelection->ClearIObjects(); + SMESH::UpdateView(); + Init( false ); + ConstructorsClicked( GetConstructorId() ); + } +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_SymmetryDlg::ClickOnOk() +{ + ClickOnApply() ; + ClickOnCancel() ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_SymmetryDlg::ClickOnCancel() +{ + mySelection->ClearFilters(); + mySelection->ClearIObjects(); + SMESH::SetPointRepresentation(false); + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + reject() ; +} + +//======================================================================= +//function : onTextChange +//purpose : +//======================================================================= + +void SMESHGUI_SymmetryDlg::onTextChange(const QString& theNewText) +{ + QLineEdit* send = (QLineEdit*)sender(); + + if ( myBusy ) return; + myBusy = true; + + if (send == LineEditElements) + myNbOkElements = 0; + + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + + // hilight entered elements + SMDS_Mesh* aMesh = 0; + if ( myActor ) + aMesh = myActor->GetObject()->GetMesh(); + + if ( aMesh ) { + + mySelection->ClearIObjects(); + mySelection->AddIObject( myActor->getIO() ); + + QStringList aListId = QStringList::split( " ", theNewText, false); + + if (send == LineEditElements) { + for ( int i = 0; i < aListId.count(); i++ ) { + const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() ); + if ( e ) { + if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() )) + mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true); + myNbOkElements++; + } + } + myElementsId = theNewText; + } + } + + if ( myNbOkElements && IsMirrorOk() ) { + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); + } + + myBusy = false; +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void SMESHGUI_SymmetryDlg::SelectionIntoArgument() +{ + if ( myBusy ) return; + + // clear + + myActor = 0; + QString aString = ""; + + myBusy = true; + if (myEditCurrentArgument == (QWidget*)LineEditElements) + { + LineEditElements->setText( aString ); + myNbOkElements = 0; + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + } + myBusy = false; + + if ( !GroupButtons->isEnabled() ) // inactive + return; + + // get selected mesh + int nbSel = mySelection->IObjectCount(); + if(nbSel != 1) + return; + + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + myMesh = SMESH::GetMeshByIO( mySelection->firstIObject() ); + if(myMesh->_is_nil()) + return; + myActor = SMESH::FindActorByObject(myMesh); + if (!myActor) + return; + + int aNbUnits = 0; + + if (myEditCurrentArgument == (QWidget*)LineEditElements) + { + myElementsId = ""; + + if (CheckBoxMesh->isChecked()) + { + SMESH::GetNameOfSelectedIObjects(mySelection, aString); + + if(!SMESH::IObjectToInterface(IO)->_is_nil()) //MESH + { + // get IDs from mesh + SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); + if (!aSMDSMesh) + return; + + for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ ) + { + const SMDS_MeshElement * e = aSMDSMesh->FindElement( i ); + if ( e ) { + myElementsId += QString(" %1").arg(i); + aNbUnits++; + } + } + } + else if (!SMESH::IObjectToInterface(IO)->_is_nil()) //SUBMESH + { + // get submesh + SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(IO) ; + + // get IDs from submesh + SMESH::long_array_var anElementsIds = new SMESH::long_array; + anElementsIds = aSubMesh->GetElementsId(); + for ( int i = 0; i < anElementsIds->length(); i++ ) + myElementsId += QString(" %1").arg(anElementsIds[i]); + aNbUnits = anElementsIds->length(); + } + else // GROUP + { + // get smesh group + SMESH::SMESH_GroupBase_var aGroup + = SMESH::IObjectToInterface(IO); + if (aGroup->_is_nil()) + return; + + // get IDs from smesh group + SMESH::long_array_var anElementsIds = new SMESH::long_array; + anElementsIds = aGroup->GetListOfID(); + for ( int i = 0; i < anElementsIds->length(); i++ ) + myElementsId += QString(" %1").arg(anElementsIds[i]); + aNbUnits = anElementsIds->length(); + } + } + else + { + aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString) ; + myElementsId = aString; + } + + if(aNbUnits < 1) + return ; + + myNbOkElements = true; + } + else + { + aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString); + if(aNbUnits != 1) + return; + + SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh(); + if (!aMesh) + return; + + 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()); + } + } + + myBusy = true; + if (myEditCurrentArgument == (QWidget*)LineEditElements) + LineEditElements->setText( aString ); + myBusy = false; + + // OK + if(myNbOkElements && IsMirrorOk()) + { + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); + } +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void SMESHGUI_SymmetryDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + disconnect( mySelection, 0, this, 0 ); + mySelection->ClearIObjects(); + mySelection->ClearFilters(); + + if(send == SelectElementsButton) { + myEditCurrentArgument = (QWidget*)LineEditElements; + SMESH::SetPointRepresentation(false); + if (CheckBoxMesh->isChecked()) + { + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter); + } + else + QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + } + else if (send == SelectPointButton) + { + myEditCurrentArgument = (QWidget*)SpinBox_X; + SMESH::SetPointRepresentation(true); + QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + } + else if (send == SelectVectorButton) + { + myEditCurrentArgument = (QWidget*)SpinBox_DX; + SMESH::SetPointRepresentation(true); + QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + } + + myEditCurrentArgument->setFocus(); + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + SelectionIntoArgument() ; +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_SymmetryDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupArguments->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + mySMESHGUI->ResetState() ; + mySMESHGUI->SetActiveDialogBox(0) ; + } +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_SymmetryDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupArguments->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + SelectionIntoArgument(); +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_SymmetryDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_SymmetryDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; +} + + +//======================================================================= +//function : hideEvent +//purpose : caused by ESC key +//======================================================================= + +void SMESHGUI_SymmetryDlg::hideEvent ( QHideEvent * e ) +{ + if ( !isMinimized() ) + ClickOnCancel(); +} + + +//======================================================================= +//function : onSelectMesh +//purpose : +//======================================================================= +void SMESHGUI_SymmetryDlg::onSelectMesh ( bool toSelectMesh ) +{ + if (toSelectMesh) + TextLabelElements->setText( tr( "SMESH_NAME" ) ); + else + TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) ); + + if (myEditCurrentArgument != LineEditElements) + { + LineEditElements->clear(); + return; + } + + mySelection->ClearFilters() ; + SMESH::SetPointRepresentation(false); + + if (toSelectMesh) + { + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter); + LineEditElements->setReadOnly(true); + } + else + { + QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + LineEditElements->setReadOnly(false); + onTextChange(LineEditElements->text()); + } + + SelectionIntoArgument(); +} + + +//================================================================================= +// function : GetConstructorId() +// purpose : +//================================================================================= +int SMESHGUI_SymmetryDlg::GetConstructorId() +{ + if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL ) + return GroupConstructors->id( GroupConstructors->selected() ); + return -1; +} + + +//================================================================================= +// function : IsAxisOk() +// purpose : +//================================================================================= +bool SMESHGUI_SymmetryDlg::IsMirrorOk() +{ + bool isOk = true; + + if (GetConstructorId() != 0) + isOk = SpinBox_DX->GetValue() != 0 || SpinBox_DY->GetValue() != 0 || SpinBox_DZ->GetValue() != 0; + + return isOk; +} + + +//================================================================================= +// function : onVectorChanged() +// purpose : +//================================================================================= +void SMESHGUI_SymmetryDlg::onVectorChanged() +{ + if (IsMirrorOk()) + { + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); + } + else + { + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + } +} diff --git a/src/SMESHGUI/SMESHGUI_SymmetryDlg.h b/src/SMESHGUI/SMESHGUI_SymmetryDlg.h new file mode 100644 index 000000000..c556b3493 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_SymmetryDlg.h @@ -0,0 +1,144 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_SymmetryDlg.h +// Author : Michael ZORIN +// Module : SMESH +// $Header: + +#ifndef DIALOGBOX_SYMMETRY_H +#define DIALOGBOX_SYMMETRY_H + +#include "SALOME_Selection.h" +#include "SMESH_LogicalFilter.hxx" + +// QT Includes +#include + +class QGridLayout; +class QHBoxLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class QCheckBox; +class SMESHGUI_SpinBox; +class SMESHGUI; +class SMESH_Actor; + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) + + +//================================================================================= +// class : SMESHGUI_SymmetryDlg +// purpose : +//================================================================================= +class SMESHGUI_SymmetryDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_SymmetryDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_SymmetryDlg(); + +private: + + void Init( bool ResetControls = true ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void hideEvent ( QHideEvent * ); /* ESC key */ + int GetConstructorId(); + bool IsMirrorOk(); + + SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + int myNbOkElements ; /* to check when elements are defined */ + QString myElementsId; + + QWidget* myEditCurrentArgument; /* Current LineEdit */ + + bool myBusy; + SMESH::SMESH_Mesh_var myMesh; + SMESH_Actor* myActor; + Handle(SMESH_LogicalFilter) myMeshOrSubMeshOrGroupFilter; + + QButtonGroup* GroupConstructors; + QRadioButton* RadioButton1; + QRadioButton* RadioButton2; + QRadioButton* RadioButton3; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + QGroupBox* GroupArguments; + QGroupBox* GroupMirror; + QLabel* TextLabelElements; + QPushButton* SelectElementsButton; + QLineEdit* LineEditElements; + QCheckBox* CheckBoxMesh; + + QLabel* TextLabelPoint; + QPushButton* SelectPointButton; + QLabel* TextLabelX; + SMESHGUI_SpinBox* SpinBox_X; + QLabel* TextLabelY; + SMESHGUI_SpinBox* SpinBox_Y; + QLabel* TextLabelZ; + SMESHGUI_SpinBox* SpinBox_Z; + QLabel* TextLabelVector; + QPushButton* SelectVectorButton; + QLabel* TextLabelDX; + SMESHGUI_SpinBox* SpinBox_DX; + QLabel* TextLabelDY; + SMESHGUI_SpinBox* SpinBox_DY; + QLabel* TextLabelDZ; + SMESHGUI_SpinBox* SpinBox_DZ; + + QCheckBox* CheckBoxCopy; + + private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + void onTextChange(const QString&); + void onSelectMesh(bool toSelectMesh); + void onVectorChanged(); + +protected: + QGridLayout* SMESHGUI_SymmetryDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupArgumentsLayout; +}; + +#endif // DIALOGBOX_SYMMETRY_H diff --git a/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx b/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx new file mode 100644 index 000000000..de761dd5f --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_TranslationDlg.cxx @@ -0,0 +1,834 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_TranslationDlg.cxx +// Author : Michael ZORIN +// Module : SMESH +// $Header: + +#include "SMESHGUI_TranslationDlg.h" + +#include "SMESHGUI.h" +#include "SMESHGUI_Utils.h" +#include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_MeshUtils.h" +#include "SMESHGUI_IdValidator.h" +#include "SMESHGUI_SpinBox.h" +#include "SMESH_Actor.h" +#include "SMESH_TypeFilter.hxx" +#include "SMDS_Mesh.hxx" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "QAD_MessageBox.h" +#include "utilities.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +//================================================================================= +// class : SMESHGUI_TranslationDlg() +// purpose : +//================================================================================= +SMESHGUI_TranslationDlg::SMESHGUI_TranslationDlg( QWidget* parent, const char* name, SALOME_Selection* Sel, + bool modal, WFlags fl ) + : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | + Qt::WDestructiveClose) +{ + QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_TRANSLATION_POINTS"))); + QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SMESH_TRANSLATION_VECTOR"))); + QPixmap image2(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_SELECT"))); + + if ( !name ) + setName( "SMESHGUI_TranslationDlg" ); + resize( 303, 185 ); + setCaption( tr( "SMESH_TRANSLATION" ) ); + setSizeGripEnabled( TRUE ); + SMESHGUI_TranslationDlgLayout = new QGridLayout( this ); + SMESHGUI_TranslationDlgLayout->setSpacing( 6 ); + SMESHGUI_TranslationDlgLayout->setMargin( 11 ); + + /***************************************************************/ + GroupConstructors = new QButtonGroup( this, "GroupConstructors" ); + GroupConstructors->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)5, (QSizePolicy::SizeType)0, 0, 0, GroupConstructors->sizePolicy().hasHeightForWidth() ) ); + GroupConstructors->setTitle( tr( "SMESH_TRANSLATION" ) ); + GroupConstructors->setExclusive( TRUE ); + GroupConstructors->setColumnLayout(0, Qt::Vertical ); + GroupConstructors->layout()->setSpacing( 0 ); + GroupConstructors->layout()->setMargin( 0 ); + GroupConstructorsLayout = new QGridLayout( GroupConstructors->layout() ); + GroupConstructorsLayout->setAlignment( Qt::AlignTop ); + GroupConstructorsLayout->setSpacing( 6 ); + GroupConstructorsLayout->setMargin( 11 ); + RadioButton1= new QRadioButton( GroupConstructors, "RadioButton1" ); + RadioButton1->setText( tr( "" ) ); + RadioButton1->setPixmap( image0 ); + GroupConstructorsLayout->addWidget( RadioButton1, 0, 0 ); + RadioButton2= new QRadioButton( GroupConstructors, "RadioButton2" ); + RadioButton2->setText( tr( "" ) ); + RadioButton2->setPixmap( image1 ); + GroupConstructorsLayout->addWidget( RadioButton2, 0, 2 ); + SMESHGUI_TranslationDlgLayout->addWidget( GroupConstructors, 0, 0 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) ); + GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); + GroupButtons->setTitle( tr( "" ) ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer_9 = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer_9, 0, 2 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + SMESHGUI_TranslationDlgLayout->addWidget( GroupButtons, 2, 0 ); + + /***************************************************************/ + GroupArguments = new QGroupBox( this, "GroupArguments" ); + GroupArguments->setTitle( tr( "SMESH_ARGUMENTS" ) ); + GroupArguments->setColumnLayout(0, Qt::Vertical ); + GroupArguments->layout()->setSpacing( 0 ); + GroupArguments->layout()->setMargin( 0 ); + GroupArgumentsLayout = new QGridLayout( GroupArguments->layout() ); + GroupArgumentsLayout->setAlignment( Qt::AlignTop ); + GroupArgumentsLayout->setSpacing( 6 ); + GroupArgumentsLayout->setMargin( 11 ); + + // Controls for elements selection + TextLabelElements = new QLabel( GroupArguments, "TextLabelElements" ); + TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) ); + TextLabelElements->setFixedWidth(74); + GroupArgumentsLayout->addWidget( TextLabelElements, 0, 0 ); + + SelectElementsButton = new QPushButton( GroupArguments, "SelectElementsButton" ); + SelectElementsButton->setText( tr( "" ) ); + SelectElementsButton->setPixmap( image2 ); + SelectElementsButton->setToggleButton( FALSE ); + GroupArgumentsLayout->addWidget( SelectElementsButton, 0, 1 ); + + LineEditElements = new QLineEdit( GroupArguments, "LineEditElements" ); + LineEditElements->setValidator( new SMESHGUI_IdValidator( this, "validator" )); + GroupArgumentsLayout->addMultiCellWidget( LineEditElements, 0, 0, 2, 7 ); + + // Control for the whole mesh selection + CheckBoxMesh = new QCheckBox( GroupArguments, "CheckBoxMesh" ); + CheckBoxMesh->setText( tr( "SMESH_SELECT_WHOLE_MESH" ) ); + GroupArgumentsLayout->addMultiCellWidget( CheckBoxMesh, 1, 1, 0, 7 ); + + // Controls for vector and points selection + TextLabel1 = new QLabel( GroupArguments, "TextLabel1" ); + GroupArgumentsLayout->addWidget( TextLabel1, 2, 0 ); + + SelectButton1 = new QPushButton( GroupArguments, "SelectButton1" ); + SelectButton1->setText( tr( "" ) ); + SelectButton1->setPixmap( image2 ); + SelectButton1->setToggleButton( FALSE ); + GroupArgumentsLayout->addWidget( SelectButton1, 2, 1 ); + + TextLabel1_1 = new QLabel( GroupArguments, "TextLabel1_1" ); + GroupArgumentsLayout->addWidget( TextLabel1_1, 2, 2 ); + + SpinBox1_1 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_1"); + GroupArgumentsLayout->addWidget( SpinBox1_1, 2, 3 ); + + TextLabel1_2 = new QLabel( GroupArguments, "TextLabel1_2" ); + GroupArgumentsLayout->addWidget( TextLabel1_2, 2, 4 ); + + SpinBox1_2 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_2"); + GroupArgumentsLayout->addWidget( SpinBox1_2, 2, 5 ); + + TextLabel1_3 = new QLabel( GroupArguments, "TextLabel1_3" ); + GroupArgumentsLayout->addWidget( TextLabel1_3, 2, 6 ); + + SpinBox1_3 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox1_3"); + GroupArgumentsLayout->addWidget( SpinBox1_3, 2, 7 ); + + TextLabel2 = new QLabel( GroupArguments, "TextLabel2" ); + TextLabel2->setText( tr( "SMESH_POINT_2" ) ); + GroupArgumentsLayout->addWidget( TextLabel2, 3, 0 ); + + SelectButton2 = new QPushButton( GroupArguments, "SelectButton2" ); + SelectButton2->setText( tr( "" ) ); + SelectButton2->setPixmap( image2 ); + SelectButton2->setToggleButton( FALSE ); + GroupArgumentsLayout->addWidget( SelectButton2, 3, 1 ); + + TextLabel2_1 = new QLabel( GroupArguments, "TextLabel2_1" ); + TextLabel2_1->setText( tr( "SMESH_X" ) ); + GroupArgumentsLayout->addWidget( TextLabel2_1, 3, 2 ); + + SpinBox2_1 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_1"); + GroupArgumentsLayout->addWidget( SpinBox2_1, 3, 3 ); + + TextLabel2_2 = new QLabel( GroupArguments, "TextLabel2_2" ); + TextLabel2_2->setText( tr( "SMESH_Y" ) ); + GroupArgumentsLayout->addWidget( TextLabel2_2, 3, 4 ); + + SpinBox2_2 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_2"); + GroupArgumentsLayout->addWidget( SpinBox2_2, 3, 5 ); + + TextLabel2_3 = new QLabel( GroupArguments, "TextLabel2_3" ); + TextLabel2_3->setText( tr( "SMESH_Z" ) ); + GroupArgumentsLayout->addWidget( TextLabel2_3, 3, 6 ); + + SpinBox2_3 = new SMESHGUI_SpinBox(GroupArguments, "SpinBox2_3"); + GroupArgumentsLayout->addWidget( SpinBox2_3, 3, 7 ); + + // Controls for "Create a copy" option + CheckBoxCopy = new QCheckBox( GroupArguments, "CheckBoxCopy" ); + CheckBoxCopy->setText( tr( "SMESH_CREATE_COPY" ) ); + GroupArgumentsLayout->addMultiCellWidget( CheckBoxCopy, 4, 4, 0, 2 ); + + + SMESHGUI_TranslationDlgLayout->addWidget( GroupArguments, 1, 0 ); + + /* Initialisations */ + SpinBox1_1->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox1_2->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox1_3->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox2_1->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox2_2->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + SpinBox2_3->RangeStepAndValidator( -999999.999, +999999.999, 10.0, 3 ); + + GroupArguments->show(); + RadioButton1->setChecked( TRUE ); + mySelection = Sel; + + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + // Costruction of the logical filter + SMESH_ListOfFilter aListOfFilters; + Handle(SMESH_TypeFilter) aMeshOrSubMeshFilter = new SMESH_TypeFilter( MESHorSUBMESH ); + if ( !aMeshOrSubMeshFilter.IsNull() ) + aListOfFilters.Append( aMeshOrSubMeshFilter ); + Handle(SMESH_TypeFilter) aSmeshGroupFilter = new SMESH_TypeFilter( GROUP ); + if ( !aSmeshGroupFilter.IsNull() ) + aListOfFilters.Append( aSmeshGroupFilter ); + + myMeshOrSubMeshOrGroupFilter = new SMESH_LogicalFilter( aListOfFilters, SMESH_LogicalFilter::LO_OR ); + + Init(); + + /* signals and slots connections */ + connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); + connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( ClickOnCancel() ) ) ; + connect( buttonApply, SIGNAL( clicked() ), this, SLOT(ClickOnApply() ) ); + connect( GroupConstructors, SIGNAL(clicked(int) ), SLOT( ConstructorsClicked(int) ) ); + + connect( SelectElementsButton, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectButton1, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + connect( SelectButton2, SIGNAL (clicked() ), this, SLOT( SetEditCurrentArgument() ) ) ; + + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + /* to close dialog if study change */ + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + connect( LineEditElements, SIGNAL( textChanged( const QString& )), + SLOT( onTextChange( const QString& ))); + connect( CheckBoxMesh, SIGNAL( toggled( bool )), + SLOT( onSelectMesh( bool ))); + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ + + ConstructorsClicked(0); +} + +//================================================================================= +// function : ~SMESHGUI_TranslationDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +SMESHGUI_TranslationDlg::~SMESHGUI_TranslationDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void SMESHGUI_TranslationDlg::Init( bool ResetControls ) +{ + myBusy = false; + + myEditCurrentArgument = 0; + LineEditElements->clear(); + myElementsId = ""; + myNbOkElements = 0; + + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + + myActor = 0; + myMesh = SMESH::SMESH_Mesh::_nil(); + + if( ResetControls ) + { + SpinBox1_1->SetValue(0.0); + SpinBox1_2->SetValue(0.0); + SpinBox1_3->SetValue(0.0); + SpinBox2_1->SetValue(0.0); + SpinBox2_2->SetValue(0.0); + SpinBox2_3->SetValue(0.0); + + CheckBoxCopy->setChecked(false); + CheckBoxMesh->setChecked(false); + onSelectMesh( false ); + } +} + + +//================================================================================= +// function : ConstructorsClicked() +// purpose : Radio button management +//================================================================================= +void SMESHGUI_TranslationDlg::ConstructorsClicked(int constructorId) +{ + disconnect(mySelection, 0, this, 0); + + switch(constructorId) + { + case 0 : + { + TextLabel1->setText( tr( "SMESH_POINT_1" ) ); + TextLabel1_1->setText( tr( "SMESH_X" ) ); + TextLabel1_2->setText( tr( "SMESH_Y" ) ); + TextLabel1_3->setText( tr( "SMESH_Z" ) ); + + SelectButton1->show(); + TextLabel2->show(); + SelectButton2->show(); + TextLabel2_1->show(); + SpinBox2_1->show(); + TextLabel2_2->show(); + SpinBox2_2->show(); + TextLabel2_3->show(); + SpinBox2_3->show(); + break; + } + case 1 : + { + TextLabel1->setText( tr( "SMESH_VECTOR" ) ); + TextLabel1_1->setText( tr( "SMESH_DX" ) ); + TextLabel1_2->setText( tr( "SMESH_DY" ) ); + TextLabel1_3->setText( tr( "SMESH_DZ" ) ); + + SelectButton1->hide(); + TextLabel2->hide(); + SelectButton2->hide(); + TextLabel2_1->hide(); + SpinBox2_1->hide(); + TextLabel2_2->hide(); + SpinBox2_2->hide(); + TextLabel2_3->hide(); + SpinBox2_3->hide(); + break; + } + } + + if (myEditCurrentArgument != (QWidget*)LineEditElements) + { + SMESH::SetPointRepresentation(false); + if (!CheckBoxMesh->isChecked()) + QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + } + + myEditCurrentArgument = (QWidget*)LineEditElements; + LineEditElements->setFocus(); + + if (CheckBoxMesh->isChecked()) + onSelectMesh(true); + + connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); +} + + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +void SMESHGUI_TranslationDlg::ClickOnApply() +{ + if (mySMESHGUI->ActiveStudyLocked()) + return; + + if ( myNbOkElements) + { + QStringList aListElementsId = QStringList::split( " ", myElementsId, false); + + SMESH::long_array_var anElementsId = new SMESH::long_array; + + anElementsId->length( aListElementsId.count() ); + for ( int i = 0; i < aListElementsId.count(); i++ ) + anElementsId[i] = aListElementsId[i].toInt(); + + SMESH::DirStruct aVector; + if(GetConstructorId() == 0) + { + aVector.PS.x = SpinBox2_1->GetValue() - SpinBox1_1->GetValue(); + aVector.PS.y = SpinBox2_2->GetValue() - SpinBox1_2->GetValue(); + aVector.PS.z = SpinBox2_3->GetValue() - SpinBox1_3->GetValue(); + } + else if(GetConstructorId() == 1) + { + aVector.PS.x = SpinBox1_1->GetValue(); + aVector.PS.y = SpinBox1_2->GetValue(); + aVector.PS.z = SpinBox1_3->GetValue(); + } + + bool toCreateCopy = CheckBoxCopy->isChecked(); + + try + { + SMESH::SMESH_MeshEditor_var aMeshEditor = myMesh->GetMeshEditor(); + QApplication::setOverrideCursor(Qt::waitCursor); + aMeshEditor->Translate(anElementsId.inout(), aVector, toCreateCopy); + QApplication::restoreOverrideCursor(); + } + catch( ... ) + { + } + + mySelection->ClearIObjects(); + SMESH::UpdateView(); + Init( false ); + ConstructorsClicked( GetConstructorId() ); + } +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void SMESHGUI_TranslationDlg::ClickOnOk() +{ + ClickOnApply() ; + ClickOnCancel() ; +} + + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void SMESHGUI_TranslationDlg::ClickOnCancel() +{ + mySelection->ClearFilters(); + mySelection->ClearIObjects(); + SMESH::SetPointRepresentation(false); + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + disconnect( mySelection, 0, this, 0 ); + mySMESHGUI->ResetState() ; + reject() ; +} + +//======================================================================= +//function : onTextChange +//purpose : +//======================================================================= + +void SMESHGUI_TranslationDlg::onTextChange(const QString& theNewText) +{ + QLineEdit* send = (QLineEdit*)sender(); + + if ( myBusy ) return; + myBusy = true; + + if (send == LineEditElements) + myNbOkElements = 0; + + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + + // hilight entered elements + SMDS_Mesh* aMesh = 0; + if ( myActor ) + aMesh = myActor->GetObject()->GetMesh(); + + if ( aMesh ) { + mySelection->ClearIObjects(); + mySelection->AddIObject( myActor->getIO() ); + + QStringList aListId = QStringList::split( " ", theNewText, false); + + if (send == LineEditElements) { + for ( int i = 0; i < aListId.count(); i++ ) { + const SMDS_MeshElement * e = aMesh->FindElement( aListId[ i ].toInt() ); + if ( e ) { + if ( !mySelection->IsIndexSelected( myActor->getIO(), e->GetID() )) + mySelection->AddOrRemoveIndex (myActor->getIO(), e->GetID(), true); + myNbOkElements++; + } + } + myElementsId = theNewText; + } + } + + if ( myNbOkElements ) { + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); + } + + myBusy = false; +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void SMESHGUI_TranslationDlg::SelectionIntoArgument() +{ + if ( myBusy ) return; + + // clear + myActor = 0; + QString aString = ""; + + myBusy = true; + if (myEditCurrentArgument == (QWidget*)LineEditElements) + { + LineEditElements->setText( aString ); + myNbOkElements = 0; + buttonOk->setEnabled( false ); + buttonApply->setEnabled( false ); + } + myBusy = false; + + if ( !GroupButtons->isEnabled() ) // inactive + return; + + // get selected mesh + + int nbSel = mySelection->IObjectCount(); + if(nbSel != 1) + return; + + Handle(SALOME_InteractiveObject) IO = mySelection->firstIObject(); + myMesh = SMESH::GetMeshByIO(IO); + if(myMesh->_is_nil()) + return; + myActor = SMESH::FindActorByObject(myMesh); + if (!myActor) + return; + + int aNbUnits = 0; + + if (myEditCurrentArgument == (QWidget*)LineEditElements) + { + myElementsId = ""; + + if (CheckBoxMesh->isChecked()) + { + SMESH::GetNameOfSelectedIObjects(mySelection, aString); + + if(!SMESH::IObjectToInterface(IO)->_is_nil()) //MESH + { + // get IDs from mesh + SMDS_Mesh* aSMDSMesh = myActor->GetObject()->GetMesh(); + if (!aSMDSMesh) + return; + + for (int i = aSMDSMesh->MinElementID(); i <= aSMDSMesh->MaxElementID(); i++ ) + { + const SMDS_MeshElement * e = aSMDSMesh->FindElement( i ); + if ( e ) { + myElementsId += QString(" %1").arg(i); + aNbUnits++; + } + } + } + else if (!SMESH::IObjectToInterface(IO)->_is_nil()) //SUBMESH + { + // get submesh + SMESH::SMESH_subMesh_var aSubMesh = SMESH::IObjectToInterface(IO) ; + + // get IDs from submesh + SMESH::long_array_var anElementsIds = new SMESH::long_array; + anElementsIds = aSubMesh->GetElementsId(); + for ( int i = 0; i < anElementsIds->length(); i++ ) + myElementsId += QString(" %1").arg(anElementsIds[i]); + aNbUnits = anElementsIds->length(); + } + else // GROUP + { + // get smesh group + SMESH::SMESH_GroupBase_var aGroup = + SMESH::IObjectToInterface(IO); + if (aGroup->_is_nil()) + return; + + // get IDs from smesh group + SMESH::long_array_var anElementsIds = new SMESH::long_array; + anElementsIds = aGroup->GetListOfID(); + for ( int i = 0; i < anElementsIds->length(); i++ ) + myElementsId += QString(" %1").arg(anElementsIds[i]); + aNbUnits = anElementsIds->length(); + } + } + else + { + aNbUnits = SMESH::GetNameOfSelectedElements(mySelection, aString) ; + myElementsId = aString; + } + + if(aNbUnits < 1) + return ; + + myNbOkElements = true; + } + else { + aNbUnits = SMESH::GetNameOfSelectedNodes(mySelection, aString); + if(aNbUnits != 1) + return; + + SMDS_Mesh* aMesh = myActor->GetObject()->GetMesh(); + if (!aMesh) + return; + + 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*)SpinBox1_1) + { + SpinBox1_1->SetValue(x); + SpinBox1_2->SetValue(y); + SpinBox2_3->SetValue(z); + } + else if (myEditCurrentArgument == (QWidget*)SpinBox2_1) + { + SpinBox2_1->SetValue(x); + SpinBox2_2->SetValue(y); + SpinBox2_3->SetValue(z); + } + } + + myBusy = true; + if (myEditCurrentArgument == (QWidget*)LineEditElements) + LineEditElements->setText( aString ); + myBusy = false; + + // OK + if(myNbOkElements) + { + buttonOk->setEnabled( true ); + buttonApply->setEnabled( true ); + } +} + + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void SMESHGUI_TranslationDlg::SetEditCurrentArgument() +{ + QPushButton* send = (QPushButton*)sender(); + + disconnect( mySelection, 0, this, 0 ); + mySelection->ClearIObjects(); + mySelection->ClearFilters(); + + if(send == SelectElementsButton) { + myEditCurrentArgument = (QWidget*)LineEditElements; + SMESH::SetPointRepresentation(false); + if (CheckBoxMesh->isChecked()) + { + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter); + } + else + QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + } + else if (send == SelectButton1) + { + myEditCurrentArgument = (QWidget*)SpinBox1_1; + SMESH::SetPointRepresentation(true); + QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + } + else if (send == SelectButton2) + { + myEditCurrentArgument = (QWidget*)SpinBox2_1; + SMESH::SetPointRepresentation(true); + QAD_Application::getDesktop()->SetSelectionMode( NodeSelection, true ); + } + + myEditCurrentArgument->setFocus(); + connect( mySelection, SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) ); + SelectionIntoArgument() ; +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void SMESHGUI_TranslationDlg::DeactivateActiveDialog() +{ + if ( GroupConstructors->isEnabled() ) { + GroupConstructors->setEnabled(false) ; + GroupArguments->setEnabled(false) ; + GroupButtons->setEnabled(false) ; + mySMESHGUI->ResetState() ; + mySMESHGUI->SetActiveDialogBox(0) ; + } +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void SMESHGUI_TranslationDlg::ActivateThisDialog() +{ + /* Emit a signal to deactivate the active dialog */ + mySMESHGUI->EmitSignalDeactivateDialog() ; + GroupConstructors->setEnabled(true) ; + GroupArguments->setEnabled(true) ; + GroupButtons->setEnabled(true) ; + + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; + + QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + SelectionIntoArgument(); +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void SMESHGUI_TranslationDlg::enterEvent(QEvent* e) +{ + if ( GroupConstructors->isEnabled() ) + return ; + ActivateThisDialog() ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void SMESHGUI_TranslationDlg::closeEvent( QCloseEvent* e ) +{ + /* same than click on cancel button */ + this->ClickOnCancel() ; +} + + +//======================================================================= +//function : hideEvent +//purpose : caused by ESC key +//======================================================================= + +void SMESHGUI_TranslationDlg::hideEvent ( QHideEvent * e ) +{ + if ( !isMinimized() ) + ClickOnCancel(); +} + + +//======================================================================= +//function : onSelectMesh +//purpose : +//======================================================================= +void SMESHGUI_TranslationDlg::onSelectMesh ( bool toSelectMesh ) +{ + if (toSelectMesh) + TextLabelElements->setText( tr( "SMESH_NAME" ) ); + else + TextLabelElements->setText( tr( "SMESH_ID_ELEMENTS" ) ); + + if (myEditCurrentArgument != LineEditElements) + { + LineEditElements->clear(); + return; + } + + mySelection->ClearFilters() ; + SMESH::SetPointRepresentation(false); + + if (toSelectMesh) + { + QAD_Application::getDesktop()->SetSelectionMode( ActorSelection ); + mySelection->AddFilter(myMeshOrSubMeshOrGroupFilter); + LineEditElements->setReadOnly(true); + } + else + { + QAD_Application::getDesktop()->SetSelectionMode( CellSelection, true ); + LineEditElements->setReadOnly(false); + onTextChange(LineEditElements->text()); + } + + SelectionIntoArgument(); +} + + +//================================================================================= +// function : GetConstructorId() +// purpose : +//================================================================================= +int SMESHGUI_TranslationDlg::GetConstructorId() +{ + if ( GroupConstructors != NULL && GroupConstructors->selected() != NULL ) + return GroupConstructors->id( GroupConstructors->selected() ); + return -1; +} diff --git a/src/SMESHGUI/SMESHGUI_TranslationDlg.h b/src/SMESHGUI/SMESHGUI_TranslationDlg.h new file mode 100644 index 000000000..b53e8948f --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_TranslationDlg.h @@ -0,0 +1,137 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_TranslationDlg.h +// Author : Michael ZORIN +// Module : SMESH +// $Header: + +#ifndef DIALOGBOX_TRANSLATION_H +#define DIALOGBOX_TRANSLATION_H + +#include "SALOME_Selection.h" +#include "SMESH_LogicalFilter.hxx" + +// QT Includes +#include + +class QGridLayout; +class QButtonGroup; +class QGroupBox; +class QLabel; +class QLineEdit; +class QPushButton; +class QRadioButton; +class QCheckBox; +class SMESHGUI; +class SMESHGUI_SpinBox; +class SMESH_Actor; + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(SMESH_Mesh) + + +//================================================================================= +// class : SMESHGUI_TranslationDlg +// purpose : +//================================================================================= +class SMESHGUI_TranslationDlg : public QDialog +{ + Q_OBJECT + +public: + SMESHGUI_TranslationDlg( QWidget* parent = 0, const char* name = 0, SALOME_Selection* Sel = 0, bool modal = FALSE, WFlags fl = 0 ); + ~SMESHGUI_TranslationDlg(); + +private: + + void Init( bool ResetControls = true ) ; + void closeEvent( QCloseEvent* e ) ; + void enterEvent ( QEvent * ) ; /* mouse enter the QWidget */ + void hideEvent ( QHideEvent * ); /* ESC key */ + int GetConstructorId(); + + SMESHGUI* mySMESHGUI ; /* Current SMESHGUI object */ + SALOME_Selection* mySelection ; /* User shape selection */ + QString myElementsId; + int myNbOkElements ; /* to check when elements are defined */ + + QWidget* myEditCurrentArgument; + + bool myBusy; + SMESH::SMESH_Mesh_var myMesh; + SMESH_Actor* myActor; + Handle(SMESH_LogicalFilter) myMeshOrSubMeshOrGroupFilter; + + QButtonGroup* GroupConstructors; + QRadioButton* RadioButton1; + QRadioButton* RadioButton2; + QGroupBox* GroupButtons; + QPushButton* buttonOk; + QPushButton* buttonCancel; + QPushButton* buttonApply; + QGroupBox* GroupArguments; + QLabel* TextLabelElements; + QPushButton* SelectElementsButton; + QLineEdit* LineEditElements; + QCheckBox* CheckBoxMesh; + QLabel* TextLabel1; + QPushButton* SelectButton1; + QLabel* TextLabel1_1; + SMESHGUI_SpinBox* SpinBox1_1; + QLabel* TextLabel1_2; + SMESHGUI_SpinBox* SpinBox1_2; + QLabel* TextLabel1_3; + SMESHGUI_SpinBox* SpinBox1_3; + QLabel* TextLabel2; + QPushButton* SelectButton2; + QLabel* TextLabel2_1; + SMESHGUI_SpinBox* SpinBox2_1; + QLabel* TextLabel2_2; + SMESHGUI_SpinBox* SpinBox2_2; + QLabel* TextLabel2_3; + SMESHGUI_SpinBox* SpinBox2_3; + QCheckBox* CheckBoxCopy; + + private slots: + + void ConstructorsClicked(int constructorId); + void ClickOnOk(); + void ClickOnCancel(); + void ClickOnApply(); + void SetEditCurrentArgument() ; + void SelectionIntoArgument() ; + void DeactivateActiveDialog() ; + void ActivateThisDialog() ; + void onTextChange(const QString&); + void onSelectMesh(bool toSelectMesh); + +protected: + QGridLayout* SMESHGUI_TranslationDlgLayout; + QGridLayout* GroupConstructorsLayout; + QGridLayout* GroupButtonsLayout; + QGridLayout* GroupArgumentsLayout; +}; + +#endif // DIALOGBOX_TRANSLATION_H diff --git a/src/SMESHGUI/SMESHGUI_TransparencyDlg.cxx b/src/SMESHGUI/SMESHGUI_TransparencyDlg.cxx index f42405abc..c7fc33a56 100644 --- a/src/SMESHGUI/SMESHGUI_TransparencyDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_TransparencyDlg.cxx @@ -26,9 +26,10 @@ // Module : SMESH // $Header$ -using namespace std; #include "SMESHGUI_TransparencyDlg.h" + #include "SMESHGUI.h" +#include "SMESHGUI_VTKUtils.h" // QT Includes #include @@ -38,7 +39,6 @@ using namespace std; #include #include "VTKViewer_ViewFrame.h" -#include "VTKViewer_RenderWindowInteractor.h" #include "QAD_RightFrame.h" #include "QAD_WaitCursor.h" #include "SALOME_ListIteratorOfListIO.hxx" @@ -46,29 +46,7 @@ using namespace std; #include "SALOME_Selection.h" #include "SALOME_InteractiveObject.hxx" -static SMESH_Actor* FindActorByEntry(const char* theEntry) -{ - QAD_Study* aStudy = SMESHGUI::GetSMESHGUI()->GetActiveStudy(); - QAD_StudyFrame *aStudyFrame = aStudy->getActiveStudyFrame(); - VTKViewer_ViewFrame* aViewFrame = dynamic_cast( aStudyFrame->getRightFrame()->getViewFrame() ); - - if(aViewFrame){ - vtkRenderer *aRenderer = aViewFrame->getRenderer(); - vtkActorCollection *aCollection = aRenderer->GetActors(); - aCollection->InitTraversal(); - while(vtkActor *anAct = aCollection->GetNextActor()){ - if(SMESH_Actor *anActor = dynamic_cast(anAct)){ - if(anActor->hasIO()){ - Handle(SALOME_InteractiveObject) anIO = anActor->getIO(); - if(anIO->hasEntry() && strcmp(anIO->getEntry(),theEntry) == 0){ - return anActor; - } - } - } - } - } - return NULL; -} +using namespace std; //================================================================================= // class : SMESHGUI_TransparencyDlg() @@ -201,7 +179,7 @@ void SMESHGUI_TransparencyDlg::SetTransparency() SALOME_ListIteratorOfListIO It( mySelection->StoredIObjects() ); for( ;It.More(); It.Next() ) { Handle(SALOME_InteractiveObject) IOS = It.Value(); - SMESH_Actor* anActor = FindActorByEntry(IOS->getEntry()); + SMESH_Actor* anActor = SMESH::FindActorByEntry(IOS->getEntry()); if ( anActor ) anActor->SetOpacity( opacity ); } @@ -230,7 +208,7 @@ void SMESHGUI_TransparencyDlg::onSelectionChanged() if ( mySelection->IObjectCount() == 1 ) { Handle(SALOME_InteractiveObject) FirstIOS = mySelection->firstIObject(); if( !FirstIOS.IsNull() ) { - SMESH_Actor* anActor = FindActorByEntry( FirstIOS->getEntry() ); + SMESH_Actor* anActor = SMESH::FindActorByEntry( FirstIOS->getEntry() ); if ( anActor ) opacity = int( anActor->GetOpacity() * 100. + 0.5 ); } @@ -241,7 +219,7 @@ void SMESHGUI_TransparencyDlg::onSelectionChanged() for ( ; It.More(); It.Next() ) { Handle(SALOME_InteractiveObject) IO = It.Value(); if( !IO.IsNull() ) { - SMESH_Actor* anActor = FindActorByEntry( IO->getEntry() ); + SMESH_Actor* anActor = SMESH::FindActorByEntry( IO->getEntry() ); if ( anActor ) { int op = int( anActor->GetOpacity() * 100. + 0.5 ); if ( setOp < 0 ) diff --git a/src/SMESHGUI/SMESHGUI_Utils.cxx b/src/SMESHGUI/SMESHGUI_Utils.cxx new file mode 100644 index 000000000..e55790515 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_Utils.cxx @@ -0,0 +1,196 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + + +#include + +#include "SMESHGUI_Utils.h" + +#include "QAD_Desktop.h" + +#include "SALOMEconfig.h" +#include CORBA_CLIENT_HEADER(GEOM_Gen) +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) + +#include "utilities.h" + +using namespace std; + +namespace SMESH{ + + QAD_Study* GetActiveStudy(){ + if(QAD_Desktop* aDesktop = QAD_Application::getDesktop()) + return aDesktop->getActiveStudy(); + return NULL; + } + + + QAD_StudyFrame* GetActiveStudyFrame(){ + if(QAD_Study* aStudy = GetActiveStudy()) + return aStudy->getActiveStudyFrame(); + return NULL; + } + + + SALOMEDS::Study_var GetActiveStudyDocument(){ + if(QAD_Study* aStudy = GetActiveStudy()) + return aStudy->getStudyDocument(); + return SALOMEDS::Study::_nil(); + } + + + SALOMEDS::SObject_var FindSObject(CORBA::Object_ptr theObject){ + if(!CORBA::is_nil(theObject)){ + SALOMEDS::Study_var aStudy = GetActiveStudyDocument(); + CORBA::String_var anIOR = aStudy->ConvertObjectToIOR(theObject); + if(strcmp(anIOR.in(),"") != 0) + return aStudy->FindObjectIOR(anIOR); + } + return SALOMEDS::SObject::_nil(); + } + + + void SetName(SALOMEDS::SObject_ptr theSObject, const char* theName){ + using namespace SALOMEDS; + Study_var aStudy = GetActiveStudyDocument(); + if(aStudy->GetProperties()->IsLocked()) + return; + StudyBuilder_var aBuilder = aStudy->NewBuilder(); + GenericAttribute_var anAttr = aBuilder->FindOrCreateAttribute(theSObject,"AttributeName"); + AttributeName_var aName = AttributeName::_narrow(anAttr); + if(!aName->_is_nil()) + aName->SetValue(theName); + } + + void SetValue(SALOMEDS::SObject_ptr theSObject, const char* theValue){ + using namespace SALOMEDS; + Study_var aStudy = GetActiveStudyDocument(); + if(aStudy->GetProperties()->IsLocked()) + return; + StudyBuilder_var aBuilder = aStudy->NewBuilder(); + GenericAttribute_var anAttr = aBuilder->FindOrCreateAttribute(theSObject,"AttributeComment"); + AttributeComment_var aComment = AttributeComment::_narrow(anAttr); + if(!aComment->_is_nil()) + aComment->SetValue(theValue); + } + + + CORBA::Object_var SObjectToObject(SALOMEDS::SObject_ptr theSObject, + SALOMEDS::Study_ptr theStudy) + { + if(!theSObject->_is_nil()){ + SALOMEDS::GenericAttribute_var anAttr; + if(theSObject->FindAttribute(anAttr, "AttributeIOR")){ + SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + CORBA::String_var aVal = anIOR->Value(); + return theStudy->ConvertIORToObject(aVal.in()); + } + } + return CORBA::Object::_nil(); + } + + + CORBA::Object_var SObjectToObject(SALOMEDS::SObject_ptr theSObject){ + SALOMEDS::Study_var aStudy = GetActiveStudyDocument(); + return SObjectToObject(theSObject,aStudy); + } + + + CORBA::Object_var IObjectToObject(const Handle(SALOME_InteractiveObject)& theIO){ + if(!theIO.IsNull()){ + if(theIO->hasEntry()){ + SALOMEDS::Study_var aStudy = GetActiveStudyDocument(); + SALOMEDS::SObject_var anObj = aStudy->FindObjectID(theIO->getEntry()); + return SObjectToObject(anObj,aStudy); + } + } + return CORBA::Object::_nil(); + } + + + CORBA::Object_var IORToObject(const char* theIOR){ + SALOMEDS::Study_var aStudy = GetActiveStudyDocument(); + return aStudy->ConvertIORToObject(theIOR); + } + + + int GetNameOfSelectedIObjects(SALOME_Selection* theSel, QString& theName) + { + int aNbSel = theSel->IObjectCount(); + if (aNbSel == 1) { + Handle(SALOME_InteractiveObject) anIObject = theSel->firstIObject(); + theName = anIObject->getName(); + }else{ + theName = QObject::tr("SMESH_OBJECTS_SELECTED").arg(aNbSel); + } + return aNbSel; + } + + + SALOMEDS::SObject_var GetMeshOrSubmesh(SALOMEDS::SObject_ptr theSObject){ + GEOM::GEOM_Object_var aShape = SObjectToInterface(theSObject); + if(!aShape->_is_nil()){ //It s a shape + return theSObject->GetFather(); + } + SALOMEDS::SObject_var aSObject; + if(theSObject->ReferencedObject(aSObject)){ + aSObject = theSObject->GetFather(); + return aSObject->GetFather(); + } + return theSObject->GetFather(); + } + + + void ModifiedMesh(SALOMEDS::SObject_ptr theSObject, bool theIsRight) + { + SALOMEDS::Study_var aStudy = GetActiveStudyDocument(); + if(aStudy->GetProperties()->IsLocked()) + return ; + + SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder(); + SALOMEDS::GenericAttribute_var anAttr = + aBuilder->FindOrCreateAttribute(theSObject,"AttributePixMap"); + SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + if(theIsRight){ + aPixmap->SetPixMap("ICON_SMESH_TREE_MESH"); + }else{ + aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_WARN"); + } + + SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(theSObject); + for (int i = 1; anIter->More(); anIter->Next(), i++) { + SALOMEDS::SObject_var aSObj = anIter->Value(); + if(i >= 4){ + SALOMEDS::ChildIterator_var anIter1 = aStudy->NewChildIterator(aSObj); + for(; anIter1->More(); anIter1->Next()){ + SALOMEDS::SObject_var aSObj1 = anIter1->Value(); + anAttr = aBuilder->FindOrCreateAttribute(aSObj1,"AttributePixMap"); + aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr); + if(theIsRight){ + aPixmap->SetPixMap("ICON_SMESH_TREE_MESH"); + }else{ + aPixmap->SetPixMap("ICON_SMESH_TREE_MESH_WARN"); + } + } + } + } + } + + +} diff --git a/src/SMESHGUI/SMESHGUI_Utils.h b/src/SMESHGUI/SMESHGUI_Utils.h new file mode 100644 index 000000000..ab468bf32 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_Utils.h @@ -0,0 +1,99 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#ifndef SMESHGUI_Utils_HeaderFile +#define SMESHGUI_Utils_HeaderFile + +#include "SALOME_InteractiveObject.hxx" + +class QString; + +class QAD_Study; +class QAD_StudyFrame; +class SALOME_Selection; + +#include "SALOMEconfig.h" +#include CORBA_CLIENT_HEADER(SALOMEDS) + + +namespace SMESH{ + + QAD_Study* GetActiveStudy(); + + QAD_StudyFrame* GetActiveStudyFrame(); + + SALOMEDS::Study_var GetActiveStudyDocument(); + + SALOMEDS::SObject_var FindSObject(CORBA::Object_ptr theObject); + + + void SetName(SALOMEDS::SObject_ptr theSObject, const char* theName); + void SetValue(SALOMEDS::SObject_ptr theSObject, const char* theValue); + + + CORBA::Object_var SObjectToObject(SALOMEDS::SObject_ptr theSObject, + SALOMEDS::Study_ptr theStudy); + + CORBA::Object_var SObjectToObject(SALOMEDS::SObject_ptr theSObject); + + + template typename TInterface::_var_type + SObjectToInterface(SALOMEDS::SObject_ptr theSObject) + { + CORBA::Object_var anObj = SObjectToObject(theSObject); + if(!CORBA::is_nil(anObj)) + return TInterface::_narrow(anObj); + return TInterface::_nil(); + } + + + CORBA::Object_var IObjectToObject(const Handle(SALOME_InteractiveObject)& theIO); + + template typename TInterface::_var_type + IObjectToInterface(const Handle(SALOME_InteractiveObject)& theIO) + { + CORBA::Object_var anObj = IObjectToObject(theIO); + if(!CORBA::is_nil(anObj)) + return TInterface::_narrow(anObj); + return TInterface::_nil(); + } + + + CORBA::Object_var IORToObject(const char* theIOR); + + template typename TInterface::_var_type + IORToInterface(const char* theIOR) + { + CORBA::Object_var anObj = IORToObject(theIOR); + if(!CORBA::is_nil(anObj)) + return TInterface::_narrow(anObj); + return TInterface::_nil(); + } + + + int GetNameOfSelectedIObjects(SALOME_Selection* theSel, QString& theName); + + SALOMEDS::SObject_var GetMeshOrSubmesh(SALOMEDS::SObject_ptr theSObject); + + void ModifiedMesh(SALOMEDS::SObject_ptr theSObject, bool theIsRight); + +} + + +#endif diff --git a/src/SMESHGUI/SMESHGUI_VTKUtils.cxx b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx new file mode 100644 index 000000000..42e6db261 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_VTKUtils.cxx @@ -0,0 +1,653 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + + +#include "SMESHGUI_VTKUtils.h" +#include "SMESHGUI_Utils.h" + +#include +#include + +#include + +#include "QAD_Config.h" +#include "QAD_Desktop.h" +#include "QAD_Study.h" +#include "QAD_Settings.h" +#include "QAD_RightFrame.h" + +#include "SALOME_Selection.h" +#include "SALOME_ListIteratorOfListIO.hxx" + +#include "VTKViewer_ViewFrame.h" +#include "VTKViewer_RenderWindow.h" +#include "VTKViewer_InteractorStyleSALOME.h" +#include "VTKViewer_RenderWindowInteractor.h" + +#include "utilities.h" + +#include "SALOMEconfig.h" +#include CORBA_CLIENT_HEADER(SMESH_Gen) +#include CORBA_CLIENT_HEADER(SMESH_Mesh) +#include CORBA_CLIENT_HEADER(SMESH_Group) +#include CORBA_CLIENT_HEADER(SMESH_Hypothesis) +#include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) + +#include "SMESH_Actor.h" + +using namespace std; + +namespace SMESH{ + + typedef map TVisualObjCont; + static TVisualObjCont VISUAL_OBJ_CONT; + + TVisualObjPtr GetVisualObj(int theStudyId, const char* theEntry){ + TVisualObjPtr aVisualObj; + try{ + TVisualObjCont::key_type aKey(theStudyId,theEntry); + TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.find(aKey); + if(anIter != VISUAL_OBJ_CONT.end()){ + aVisualObj = anIter->second; + }else{ + SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); + SALOMEDS::SObject_var aSObj = aStudy->FindObjectID(theEntry); + if(!CORBA::is_nil(aSObj)){ + SALOMEDS::GenericAttribute_var anAttr; + if(aSObj->FindAttribute(anAttr,"AttributeIOR")){ + SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); + CORBA::String_var aVal = anIOR->Value(); + CORBA::Object_var anObj = aStudy->ConvertIORToObject(aVal.in()); + if(!CORBA::is_nil(anObj)){ + //Try narrow to SMESH_Mesh interafce + SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(anObj); + if(!aMesh->_is_nil()){ + aVisualObj.reset(new SMESH_MeshObj(aMesh)); + aVisualObj->Update(); + TVisualObjCont::value_type aValue(aKey,aVisualObj); + VISUAL_OBJ_CONT.insert(aValue); + return aVisualObj; + } + //Try narrow to SMESH_Group interafce + SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(anObj); + if(!aGroup->_is_nil()){ + SALOMEDS::SObject_var aFatherSObj = aSObj->GetFather(); + if(aFatherSObj->_is_nil()) return aVisualObj; + aFatherSObj = aFatherSObj->GetFather(); + if(aFatherSObj->_is_nil()) return aVisualObj; + CORBA::String_var anEntry = aFatherSObj->GetID(); + TVisualObjPtr aVisObj = GetVisualObj(theStudyId,anEntry.in()); + if(SMESH_MeshObj* aMeshObj = dynamic_cast(aVisObj.get())){ + aVisualObj.reset(new SMESH_GroupObj(aGroup,aMeshObj)); + aVisualObj->Update(); + TVisualObjCont::value_type aValue(aKey,aVisualObj); + VISUAL_OBJ_CONT.insert(aValue); + return aVisualObj; + } + } + //Try narrow to SMESH_subMesh interafce + SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(anObj); + if(!aSubMesh->_is_nil()){ + SALOMEDS::SObject_var aFatherSObj = aSObj->GetFather(); + if(aFatherSObj->_is_nil()) return aVisualObj; + aFatherSObj = aFatherSObj->GetFather(); + if(aFatherSObj->_is_nil()) return aVisualObj; + CORBA::String_var anEntry = aFatherSObj->GetID(); + TVisualObjPtr aVisObj = GetVisualObj(theStudyId,anEntry.in()); + if(SMESH_MeshObj* aMeshObj = dynamic_cast(aVisObj.get())){ + aVisualObj.reset(new SMESH_subMeshObj(aSubMesh,aMeshObj)); + aVisualObj->Update(); + TVisualObjCont::value_type aValue(aKey,aVisualObj); + VISUAL_OBJ_CONT.insert(aValue); + return aVisualObj; + } + } + } + } + } + } + }catch(...){ + INFOS("GetMeshObj - There is no SMESH_Mesh object for the SALOMEDS::Strudy and Entry!!!"); + } + return aVisualObj; + } + + + VTKViewer_ViewFrame* FindVtkViewFrame(QAD_Study* theStudy, + QAD_StudyFrame* theStudyFrame) + { + QList& aStudies = + QAD_Application::getDesktop()->getActiveApp()->getStudies(); + if(aStudies.containsRef(theStudy)){ + const QList& aStudyFrames = theStudy->getStudyFrames(); + if(aStudyFrames.containsRef(theStudyFrame)){ + return GetVtkViewFrame(theStudyFrame); + } + } + return NULL; + } + + + VTKViewer_ViewFrame* GetVtkViewFrame(QAD_StudyFrame* theStudyFrame){ + QAD_ViewFrame* aViewFrame = theStudyFrame->getRightFrame()->getViewFrame(); + return dynamic_cast(aViewFrame); + } + + + VTKViewer_ViewFrame* GetCurrentVtkView(){ + return GetVtkViewFrame(GetActiveStudy()->getActiveStudyFrame()); + } + + + SMESH_Actor* FindActorByEntry(QAD_StudyFrame *theStudyFrame, + const char* theEntry) + { + if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(theStudyFrame)){ + vtkRenderer *aRenderer = aViewFrame->getRenderer(); + vtkActorCollection *aCollection = aRenderer->GetActors(); + aCollection->InitTraversal(); + while(vtkActor *anAct = aCollection->GetNextActor()){ + if(SMESH_Actor *anActor = dynamic_cast(anAct)){ + if(anActor->hasIO()){ + Handle(SALOME_InteractiveObject) anIO = anActor->getIO(); + if(anIO->hasEntry() && strcmp(anIO->getEntry(),theEntry) == 0){ + return anActor; + } + } + } + } + } + return NULL; + } + + + SMESH_Actor* FindActorByEntry(const char* theEntry){ + return FindActorByEntry(GetActiveStudy()->getActiveStudyFrame(),theEntry); + } + + + SMESH_Actor* FindActorByObject(CORBA::Object_ptr theObject){ + if(!CORBA::is_nil(theObject)){ + SALOMEDS::Study_var aStudy = GetActiveStudyDocument(); + CORBA::String_var anIOR = aStudy->ConvertObjectToIOR(theObject); + SALOMEDS::SObject_var aSObject = aStudy->FindObjectIOR(anIOR.in()); + if(!aSObject->_is_nil()){ + CORBA::String_var anEntry = aSObject->GetID(); + return FindActorByEntry(anEntry.in()); + } + } + return NULL; + } + + + SMESH_Actor* CreateActor(SALOMEDS::Study_ptr theStudy, + const char* theEntry, + int theIsClear) + { + SMESH_Actor *anActor = NULL; + CORBA::Long anId = theStudy->StudyId(); + if(TVisualObjPtr aVisualObj = GetVisualObj(anId,theEntry)){ + SALOMEDS::SObject_var aSObj = theStudy->FindObjectID(theEntry); + if(!aSObj->_is_nil()){ + SALOMEDS::GenericAttribute_var anAttr; + if(aSObj->FindAttribute(anAttr,"AttributeName")){ + SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); + CORBA::String_var aVal = aName->Value(); + string aNameVal = aVal.in(); + anActor = SMESH_Actor::New(aVisualObj,theEntry,aNameVal.c_str(),theIsClear); + } + } + } + return anActor; + } + + + void DisplayActor(QAD_StudyFrame *theStudyFrame, SMESH_Actor* theActor){ + if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(theStudyFrame)){ + aViewFrame->AddActor(theActor); + aViewFrame->Repaint(); + } + } + + + void RemoveActor(QAD_StudyFrame *theStudyFrame, SMESH_Actor* theActor){ + if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(theStudyFrame)){ + aViewFrame->RemoveActor(theActor); + aViewFrame->Repaint(); + } + } + + + void FitAll(){ + if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(GetActiveStudy()->getActiveStudyFrame())){ + aViewFrame->onViewFitAll(); + aViewFrame->Repaint(); + } + } + + vtkRenderer* GetCurrentRenderer(){ + if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(GetActiveStudy()->getActiveStudyFrame())) + return aViewFrame->getRenderer(); + return NULL; + } + + void RepaintCurrentView(){ + if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(GetActiveStudy()->getActiveStudyFrame())){ + aViewFrame->getRW()->getRenderWindow()->Render(); + //aViewFrame->Repaint(); + } + } + + + void UpdateView(QAD_StudyFrame *theStudyFrame, EDisplaing theAction, const char* theEntry) + { + if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(theStudyFrame)){ + vtkRenderer *aRenderer = aViewFrame->getRenderer(); + vtkActorCollection *aCollection = aRenderer->GetActors(); + aCollection->InitTraversal(); + switch(theAction){ + case eDisplayAll: { + while(vtkActor *anAct = aCollection->GetNextActor()){ + if(SMESH_Actor *anActor = dynamic_cast(anAct)){ + anActor->SetVisibility(true); + } + } + break; + } + case eDisplayOnly: + case eEraseAll: { + while(vtkActor *anAct = aCollection->GetNextActor()){ + if(SMESH_Actor *anActor = dynamic_cast(anAct)){ + anActor->SetVisibility(false); + } + } + } + default: { + if(SMESH_Actor *anActor = FindActorByEntry(theStudyFrame,theEntry)){ + switch(theAction) { + case eDisplay: + case eDisplayOnly: + anActor->SetVisibility(true); + break; + case eErase: + anActor->SetVisibility(false); + break; + } + } else { + switch(theAction){ + case eDisplay: + case eDisplayOnly:{ + QAD_Study* aStudy = theStudyFrame->getStudy(); + SALOMEDS::Study_var aDocument = aStudy->getStudyDocument(); + if((anActor = CreateActor(aDocument,theEntry,true))) { + DisplayActor(theStudyFrame,anActor); + FitAll(); + } + break; + } + } + } + } + } + } + } + + + void UpdateView(EDisplaing theAction, const char* theEntry){ + QAD_Study* aStudy = GetActiveStudy(); + QAD_StudyFrame *aStudyFrame = aStudy->getActiveStudyFrame(); + UpdateView(aStudyFrame,theAction,theEntry); + } + + void UpdateView(){ + if(VTKViewer_ViewFrame* aViewFrame = SMESH::GetCurrentVtkView()){ + SALOME_Selection *aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection()); + if(aSel->IObjectCount() == 0){ + vtkRenderer* aRenderer = aViewFrame->getRenderer(); + vtkActorCollection *aCollection = aRenderer->GetActors(); + aCollection->InitTraversal(); + while(vtkActor *anAct = aCollection->GetNextActor()){ + if(SMESH_Actor *anActor = dynamic_cast(anAct)){ + if(anActor->hasIO()) + Update(anActor->getIO(),anActor->GetVisibility()); + } + } + }else{ + SALOME_ListIteratorOfListIO anIter(aSel->StoredIObjects()); + for(; anIter.More(); anIter.Next()){ + Handle(SALOME_InteractiveObject) anIO = anIter.Value(); + Update(anIO,true); + } + } + RepaintCurrentView(); + } + } + + + void Update(const Handle(SALOME_InteractiveObject)& theIO, + bool theDisplay) + { + SALOMEDS::Study_var aStudy = GetActiveStudyDocument(); + CORBA::Long anId = aStudy->StudyId(); + TVisualObjPtr aVisualObj = SMESH::GetVisualObj(anId,theIO->getEntry()); + aVisualObj->Update(); + if ( theDisplay ) + UpdateView(SMESH::eDisplay,theIO->getEntry()); + } + + + void UpdateSelectionProp() { + QAD_Study* aStudy = GetActiveStudy(); + QList aFrameList = aStudy->getStudyFrames(); + + QString SCr, SCg, SCb; + SCr = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorRed"); + SCg = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorGreen"); + SCb = QAD_CONFIG->getSetting("SMESH:SettingsSelectColorBlue"); + QColor aHiColor = Qt::white; + if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) + aHiColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); + + SCr = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorRed"); + SCg = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorGreen"); + SCb = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectColorBlue"); + QColor aSelColor = Qt::yellow; + if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) + aSelColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); + QString SW = QAD_CONFIG->getSetting("SMESH:SettingsItemSelectWidth"); + if (SW.isEmpty()) SW = "5"; + + SCr = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorRed"); + SCg = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorGreen"); + SCb = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectColorBlue"); + QColor aPreColor = Qt::cyan; + if (!SCr.isEmpty() && !SCg.isEmpty() && !SCb.isEmpty()) + aPreColor = QColor(SCr.toInt(), SCg.toInt(), SCb.toInt()); + QString PW = QAD_CONFIG->getSetting("SMESH:SettingsPreSelectWidth"); + if (PW.isEmpty()) PW = "5"; + + QString SP1 = QAD_CONFIG->getSetting("SMESH:SettingsNodeSelectTol"); + if (SP1.isEmpty()) SP1 = "0.025"; + QString SP2 = QAD_CONFIG->getSetting("SMESH:SettingsElementsSelectTol"); + if (SP2.isEmpty()) SP2 = "0.001"; + + for (QAD_StudyFrame* aStudyFrame = aFrameList.first(); aStudyFrame; aStudyFrame = aFrameList.next()) { + if (aStudyFrame->getTypeView() == VIEW_VTK) { + VTKViewer_ViewFrame* aVtkViewFrame = GetVtkViewFrame(aStudyFrame); + if (!aVtkViewFrame) continue; + // update VTK viewer properties + VTKViewer_RenderWindowInteractor* anInteractor = aVtkViewFrame->getRWInteractor(); + if (anInteractor) { + // mesh element selection + anInteractor->SetSelectionProp(aSelColor.red()/255., aSelColor.green()/255., + aSelColor.blue()/255., SW.toInt()); + + // tolerances + anInteractor->SetSelectionTolerance(SP1.toDouble(), SP2.toDouble()); + + // pre-selection + VTKViewer_InteractorStyleSALOME* aStyle = anInteractor->GetInteractorStyleSALOME(); + if (aStyle) { + aStyle->setPreselectionProp(aPreColor.red()/255., aPreColor.green()/255., + aPreColor.blue()/255., PW.toInt()); + } + } + // update actors + vtkRenderer* aRenderer = aVtkViewFrame->getRenderer(); + vtkActorCollection *aCollection = aRenderer->GetActors(); + aCollection->InitTraversal(); + while(vtkActor *anAct = aCollection->GetNextActor()){ + if(SMESH_Actor *anActor = dynamic_cast(anAct)){ + anActor->SetHighlightColor(aHiColor.red()/255., aHiColor.green()/255., + aHiColor.blue()/255.); + anActor->SetPreHighlightColor(aPreColor.red()/255., aPreColor.green()/255., + aPreColor.blue()/255.); + } + } + } + } + } + + + //---------------------------------------------------------------------------- + VTKViewer_InteractorStyleSALOME* GetInteractorStyle(QAD_StudyFrame *theStudyFrame){ + if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame(theStudyFrame)){ + if(VTKViewer_RenderWindowInteractor* anInteractor = aViewFrame->getRWInteractor()){ + return anInteractor->GetInteractorStyleSALOME(); + } + } + return NULL; + } + + void SetFilter(const Handle(VTKViewer_Filter)& theFilter, + VTKViewer_InteractorStyleSALOME* theStyle) + { + theStyle->SetFilter(theFilter); + } + + Handle(VTKViewer_Filter) GetFilter(int theId, VTKViewer_InteractorStyleSALOME* theStyle) + { + return theStyle->GetFilter(theId); + } + + bool IsFilterPresent(int theId, VTKViewer_InteractorStyleSALOME* theStyle) + { + return theStyle->IsFilterPresent(theId); + } + + void RemoveFilter(int theId, VTKViewer_InteractorStyleSALOME* theStyle){ + theStyle->RemoveFilter(theId); + } + + bool IsValid(SALOME_Actor* theActor, int theCellId, + VTKViewer_InteractorStyleSALOME* theStyle) + { + return theStyle->IsValid(theActor,theCellId); + } + + + //---------------------------------------------------------------------------- + void SetPointRepresentation(bool theIsVisible){ + if(VTKViewer_ViewFrame* aViewFrame = GetCurrentVtkView()){ + vtkRenderer *aRenderer = aViewFrame->getRenderer(); + vtkActorCollection *aCollection = aRenderer->GetActors(); + aCollection->InitTraversal(); + while(vtkActor *anAct = aCollection->GetNextActor()){ + if(SMESH_Actor *anActor = dynamic_cast(anAct)){ + if(anActor->GetVisibility()){ + anActor->SetPointRepresentation(theIsVisible); + } + } + } + RepaintCurrentView(); + } + } + + + void SetPickable(SMESH_Actor* theActor){ + if(VTKViewer_ViewFrame* aViewFrame = GetCurrentVtkView()){ + int anIsAllPickable = (theActor == NULL); + vtkRenderer *aRenderer = aViewFrame->getRenderer(); + vtkActorCollection *aCollection = aRenderer->GetActors(); + aCollection->InitTraversal(); + while(vtkActor *anAct = aCollection->GetNextActor()){ + if(SALOME_Actor *anActor = dynamic_cast(anAct)){ + if(anActor->GetVisibility()){ + anActor->SetPickable(anIsAllPickable); + } + } + } + if(theActor) + theActor->SetPickable(!anIsAllPickable); + RepaintCurrentView(); + } + } + + + int GetNameOfSelectedNodes(SALOME_Selection *theSel, + const Handle(SALOME_InteractiveObject)& theIO, + QString& theName) + { + theName = ""; + if(theIO->hasEntry()){ + if(SMESH_Actor *anActor = FindActorByEntry(theIO->getEntry())){ + TColStd_IndexedMapOfInteger aMapIndex; + theSel->GetIndex(theIO,aMapIndex); + for(int i = 1; i <= aMapIndex.Extent(); i++){ + theName += QString(" %1").arg(aMapIndex(i)); + } + return aMapIndex.Extent(); + } + } + return -1; + } + + + int GetNameOfSelectedNodes(SALOME_Selection *theSel, QString& theName){ + theName = ""; + if(theSel->IObjectCount() == 1){ + Handle(SALOME_InteractiveObject) anIO = theSel->firstIObject(); + return GetNameOfSelectedNodes(theSel,anIO,theName); + } + return -1; + } + + + int GetNameOfSelectedElements(SALOME_Selection *theSel, + const Handle(SALOME_InteractiveObject)& theIO, + QString& theName) + { + theName = ""; + if(theIO->hasEntry()){ + if(SMESH_Actor *anActor = FindActorByEntry(theIO->getEntry())){ + TColStd_IndexedMapOfInteger aMapIndex; + theSel->GetIndex(theIO,aMapIndex); + typedef std::set TIdContainer; + TIdContainer anIdContainer; + for( int i = 1; i <= aMapIndex.Extent(); i++) + anIdContainer.insert(aMapIndex(i)); + TIdContainer::const_iterator anIter = anIdContainer.begin(); + for(; anIter != anIdContainer.end(); anIter++){ + theName += QString(" %1").arg(*anIter); + } + return aMapIndex.Extent(); + } + } + return -1; + } + + + int GetNameOfSelectedElements(SALOME_Selection *theSel, QString& theName) + { + theName = ""; + if(theSel->IObjectCount() == 1){ + Handle(SALOME_InteractiveObject) anIO = theSel->firstIObject(); + return GetNameOfSelectedElements(theSel,anIO,theName); + } + return -1; + } + + + int GetSelected(SALOME_Selection* theSel, + TColStd_IndexedMapOfInteger& theMap, + const bool theIsElement) + { + theMap.Clear(); + + if ( theSel->IObjectCount() == 1 ) + { + Handle(SALOME_InteractiveObject) anIO = theSel->firstIObject(); + if ( anIO->hasEntry() ) { + theSel->GetIndex( anIO, theMap ); + } + } + return theMap.Extent(); + } + + + int GetEdgeNodes( SALOME_Selection* theSel, int& theId1, int& theId2 ) + { + if ( theSel->IObjectCount() != 1 ) + return -1; + + Handle(SALOME_InteractiveObject) anIO = theSel->firstIObject(); + if ( anIO.IsNull() || !anIO->hasEntry() ) + return -1; + + SMESH_Actor *anActor = SMESH::FindActorByEntry( anIO->getEntry() ); + if ( anActor == 0 ) + return -1; + + TColStd_IndexedMapOfInteger aMapIndex; + theSel->GetIndex( anIO, aMapIndex ); + if ( aMapIndex.Extent() != 2 ) + return -1; + + int anObjId = -1, anEdgeNum = -1; + for ( int i = 1; i <= aMapIndex.Extent(); i++ ) { + int aVal = aMapIndex( i ); + if ( aVal > 0 ) + anObjId = aVal; + else + anEdgeNum = abs( aVal ); + } + + if ( anObjId == -1 || anEdgeNum == -1 ) + return -1; + + return anActor->GetObject()->GetEdgeNodes( anObjId, anEdgeNum, theId1, theId2 ) ? 1 : -1; + } + + void SetControlsPrecision( const long theVal ) + { + if( VTKViewer_ViewFrame* aViewFrame = SMESH::GetCurrentVtkView() ) + { + vtkRenderer *aRenderer = aViewFrame->getRenderer(); + vtkActorCollection *aCollection = aRenderer->GetActors(); + aCollection->InitTraversal(); + + while ( vtkActor *anAct = aCollection->GetNextActor()) + { + if ( SMESH_Actor *anActor = dynamic_cast( anAct ) ) + { + anActor->SetControlsPrecision( theVal ); + anActor->SetControlMode( anActor->GetControlMode() ); + } + } + + } + } +} + + + + + + + + + + + + + + + + + diff --git a/src/SMESHGUI/SMESHGUI_VTKUtils.h b/src/SMESHGUI/SMESHGUI_VTKUtils.h new file mode 100644 index 000000000..9937073b6 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_VTKUtils.h @@ -0,0 +1,189 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +#ifndef SMESHGUI_VTKUtils_HeaderFile +#define SMESHGUI_VTKUtils_HeaderFile + +class QString; +class vtkRenderer; +class TColStd_IndexedMapOfInteger; + +#include "SALOME_InteractiveObject.hxx" +#include "VTKViewer_Filter.h" + +class QAD_Study; +class QAD_StudyFrame; +class SALOME_Selection; +class VTKViewer_ViewFrame; +class VTKViewer_InteractorStyleSALOME; + +#include + +#include "SALOMEconfig.h" +#include CORBA_CLIENT_HEADER(SALOMEDS) + +#include +#include "SMESH_Object.h" + +class SALOME_Actor; +class SMESH_Actor; + +namespace SMESH{ + + //---------------------------------------------------------------------------- + typedef pair TKeyOfVisualObj; + + TVisualObjPtr GetVisualObj(int theStudyId, + const char* theEntry); + + + //---------------------------------------------------------------------------- + QAD_StudyFrame* GetActiveStudyFrame(); + + VTKViewer_ViewFrame* FindVtkViewFrame(QAD_Study* theStudy, + QAD_StudyFrame* theStudyFrame); + + VTKViewer_ViewFrame* GetVtkViewFrame(QAD_StudyFrame* theStudyFrame); + + VTKViewer_ViewFrame* GetCurrentVtkView(); + + + //---------------------------------------------------------------------------- + SMESH_Actor* FindActorByEntry(QAD_StudyFrame *theStudyFrame, + const char* theEntry); + SMESH_Actor* FindActorByEntry(const char* theEntry); + + SMESH_Actor* FindActorByObject(CORBA::Object_ptr theObject); + + + //---------------------------------------------------------------------------- + SMESH_Actor* CreateActor(SALOMEDS::Study_ptr theStudy, + const char* theEntry, + int theIsClear = false); + + void DisplayActor(QAD_StudyFrame *theStudyFrame, + SMESH_Actor* theActor); + void RemoveActor(QAD_StudyFrame *theStudyFrame, + SMESH_Actor* theActor); + + + //---------------------------------------------------------------------------- + enum EDisplaing {eDisplayAll, eDisplay, eDisplayOnly, eErase, eEraseAll}; + void UpdateView(QAD_StudyFrame *theStudyFrame, + EDisplaing theAction, + const char* theEntry = ""); + void UpdateView(EDisplaing theAction, + const char* theEntry = ""); + + void UpdateView(); + + void Update(const Handle(SALOME_InteractiveObject)& theIO, + bool theDisplay); + + + //---------------------------------------------------------------------------- + void FitAll(); + + void RepaintCurrentView(); + + vtkRenderer* GetCurrentRenderer(); + + + //---------------------------------------------------------------------------- + void SetPointRepresentation(bool theIsVisible); + + void SetPickable(SMESH_Actor* theActor = NULL); + + void UpdateSelectionProp(); + + + //---------------------------------------------------------------------------- + VTKViewer_InteractorStyleSALOME* + GetInteractorStyle(QAD_StudyFrame *theStudyFrame = GetActiveStudyFrame()); + + void SetFilter(const Handle(VTKViewer_Filter)& theFilter, + VTKViewer_InteractorStyleSALOME* theStyle = GetInteractorStyle()); + + Handle(VTKViewer_Filter) + GetFilter(int theId, VTKViewer_InteractorStyleSALOME* theStyle = GetInteractorStyle()); + + bool IsFilterPresent(int theId, + VTKViewer_InteractorStyleSALOME* theStyle = GetInteractorStyle()); + + void RemoveFilter(int theId, + VTKViewer_InteractorStyleSALOME* theStyle = GetInteractorStyle()); + + bool IsValid(SALOME_Actor* theActor, int theCellId, + VTKViewer_InteractorStyleSALOME* theStyle = GetInteractorStyle()); + + //---------------------------------------------------------------------------- + int GetNameOfSelectedNodes(SALOME_Selection *theSel, + const Handle(SALOME_InteractiveObject)& theIO, + QString& theName); + + int GetNameOfSelectedNodes(SALOME_Selection *theSel, + QString& aName); + + int GetNameOfSelectedElements(SALOME_Selection *theSel, + const Handle(SALOME_InteractiveObject)& theIO, + QString& theName); + + int GetNameOfSelectedElements(SALOME_Selection *theSel, + QString& aName); + + int GetSelected(SALOME_Selection* theSel, + TColStd_IndexedMapOfInteger& theMap, + const bool theIsElement = true ); + + int GetEdgeNodes(SALOME_Selection* theSel, int& theId1, int& theId2); + + void SetControlsPrecision( const long theVal ); + +}; + + +#endif + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SMESHGUI/SMESHGUI_XmlHandler.cxx b/src/SMESHGUI/SMESHGUI_XmlHandler.cxx index ee42768b1..9939eb730 100644 --- a/src/SMESHGUI/SMESHGUI_XmlHandler.cxx +++ b/src/SMESHGUI/SMESHGUI_XmlHandler.cxx @@ -25,15 +25,21 @@ // Module : SMESH // $Header$ -using namespace std; #define INCLUDE_MENUITEM_DEF -#include "SMESHGUI_XmlHandler.h" - // QT Include -//#include #include +#include "QAD_ResourceMgr.h" +#include "QAD_Desktop.h" + +#include "SMESHGUI_XmlHandler.h" +#include "SMESHGUI_Hypotheses.h" + +#include "utilities.h" + +using namespace std; + /*! Constructor */ diff --git a/src/SMESHGUI/SMESHGUI_XmlHandler.h b/src/SMESHGUI/SMESHGUI_XmlHandler.h index 363d9830c..c64ff86c8 100644 --- a/src/SMESHGUI/SMESHGUI_XmlHandler.h +++ b/src/SMESHGUI/SMESHGUI_XmlHandler.h @@ -25,7 +25,10 @@ // Module : SMESH // $Header$ -#include "SMESHGUI.h" +#ifndef SMESHGUI_XmlHandler_HeaderFile +#define SMESHGUI_XmlHandler_HeaderFile + +#include "SMESHGUI_Hypotheses.h" #include #include @@ -47,8 +50,8 @@ class SMESHGUI_XmlHandler : public QXmlDefaultHandler bool fatalError (const QXmlParseException& exception); public: - map myHypothesesMap; - map myAlgorithmsMap; + std::map myHypothesesMap; + std::map myAlgorithmsMap; private: QString myErrorProt; @@ -56,3 +59,6 @@ class SMESHGUI_XmlHandler : public QXmlDefaultHandler QString myServerLib; QString myClientLib; }; + + +#endif diff --git a/src/SMESHGUI/SMESHGUI_aParameter.cxx b/src/SMESHGUI/SMESHGUI_aParameter.cxx new file mode 100644 index 000000000..7d40358d3 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_aParameter.cxx @@ -0,0 +1,119 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_aParameter.cxx +// Module : SMESH +// $Header$ + +#include "SMESHGUI_aParameter.h" + +#include +#include +#include "QAD_SpinBoxDbl.h" + +SMESHGUI_aParameter::~SMESHGUI_aParameter() {} + +//================================================================================= +// class : SMESHGUI_intParameter +// purpose : +//================================================================================= +SMESHGUI_intParameter::SMESHGUI_intParameter(const int theInitValue, + const QString& theLabel, + const int theBottom, + const int theTop) + :SMESHGUI_aParameter(theLabel), + _top(theTop), _bottom(theBottom), _initValue( theInitValue ) +{ +} +SMESHGUI_aParameter::Type SMESHGUI_intParameter::GetType() const +{ + return SMESHGUI_aParameter::INT; +} +bool SMESHGUI_intParameter::GetNewInt( int & theValue ) const +{ + theValue = _newValue; + return _newValue != _initValue; +} +bool SMESHGUI_intParameter::GetNewDouble( double & Value ) const +{ + return false; +} +void SMESHGUI_intParameter::InitializeWidget( QWidget* theQWidget) const +{ + QSpinBox * aSpin = dynamic_cast< QSpinBox *>( theQWidget ); + if ( aSpin ) { + aSpin->setMinValue( _bottom ); + aSpin->setMaxValue( _top ); + aSpin->setValue( _initValue ); + } +} +void SMESHGUI_intParameter::TakeValue( QWidget* theQWidget) +{ + QSpinBox * aSpin = dynamic_cast< QSpinBox *>( theQWidget ); + if ( aSpin ) + _newValue = aSpin->value(); +} +//================================================================================= +// class : SMESHGUI_doubleParameter +// purpose : +//================================================================================= +SMESHGUI_doubleParameter::SMESHGUI_doubleParameter(const double theInitValue, + const QString& theLabel, + const double theBottom, + const double theTop, + const double theStep, + const int theDecimals) + :SMESHGUI_aParameter( theLabel ), + _top( theTop ), _bottom( theBottom ), _step( theStep ), + _initValue( theInitValue ), _decimals( theDecimals ) +{ +} +SMESHGUI_aParameter::Type SMESHGUI_doubleParameter::GetType() const +{ + return SMESHGUI_aParameter::DOUBLE; +} +bool SMESHGUI_doubleParameter::GetNewInt( int & theValue ) const +{ + return false; +} +bool SMESHGUI_doubleParameter::GetNewDouble( double & Value ) const +{ + Value = _newValue; + return _newValue != _initValue; +} +void SMESHGUI_doubleParameter::InitializeWidget( QWidget* theQWidget) const +{ + QAD_SpinBoxDbl * aSpin = dynamic_cast< QAD_SpinBoxDbl *>( theQWidget ); + if ( aSpin ) { + aSpin->setRange( _bottom, _top ); + ((QDoubleValidator*)(aSpin->validator()))->setRange( _bottom, _top, _decimals ); + aSpin->setValue( _initValue ); + aSpin->setLineStep( _step ); + } +} +void SMESHGUI_doubleParameter::TakeValue( QWidget* theQWidget) +{ + QAD_SpinBoxDbl * aSpin = dynamic_cast< QAD_SpinBoxDbl *>( theQWidget ); + if ( aSpin ) + _newValue = aSpin->value(); +} diff --git a/src/SMESHGUI/SMESHGUI_aParameter.h b/src/SMESHGUI/SMESHGUI_aParameter.h new file mode 100644 index 000000000..dd392f684 --- /dev/null +++ b/src/SMESHGUI/SMESHGUI_aParameter.h @@ -0,0 +1,117 @@ +// SMESH SMESHGUI : GUI for SMESH component +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESHGUI_aParameter.h +// Module : SMESH +// $Header$ + +#ifndef SMESHGUI_aParameter_H +#define SMESHGUI_aParameter_H + +#include +#include + +class QWidget; +class SMESHGUI_aParameter; + +typedef boost::shared_ptr SMESHGUI_aParameterPtr; + +//================================================================================= +// class : SMESHGUI_aParameter +// purpose : +//================================================================================= +class SMESHGUI_aParameter +{ +public: + SMESHGUI_aParameter(const QString& label):_label(label) {} + virtual ~SMESHGUI_aParameter(); + + enum Type { INT, DOUBLE }; + virtual Type GetType() const = 0; + virtual bool GetNewInt( int & Value ) const = 0; + virtual bool GetNewDouble( double & Value ) const = 0; + virtual void InitializeWidget( QWidget* ) const = 0; + virtual void TakeValue( QWidget* ) = 0; + + QString & Label() { return _label; } + + private: + QString _label; +}; + +//================================================================================= +// class : SMESHGUI_intParameter +// purpose : +//================================================================================= +class SMESHGUI_intParameter: public SMESHGUI_aParameter +{ +public: + SMESHGUI_intParameter(const int initValue = 0, + const QString& label = QString::null, + const int bottom = 0, + const int top = 1000); + int & InitValue() { return _initValue; } + int & Top() { return _top; } + int & Bottom() { return _bottom; } + virtual Type GetType() const; + virtual bool GetNewInt( int & Value ) const; + virtual bool GetNewDouble( double & Value ) const; + virtual void InitializeWidget( QWidget* ) const; + virtual void TakeValue( QWidget* ); + + private: + int _top, _bottom; + int _initValue, _newValue; +}; + +//================================================================================= +// class : SMESHGUI_doubleParameter +// purpose : +//================================================================================= +class SMESHGUI_doubleParameter: public SMESHGUI_aParameter +{ +public: + SMESHGUI_doubleParameter(const double initValue = 0.0, + const QString& label = QString::null, + const double bottom = -1E6, + const double top = +1E6, + const double step = 1.0, + const int decimals = 3); + double & InitValue() { return _initValue; } + double & Top() { return _top; } + double & Bottom() { return _bottom; } + double & Step() { return _step; } + int & Decimals() { return _decimals; } + virtual Type GetType() const; + virtual bool GetNewInt( int & Value ) const; + virtual bool GetNewDouble( double & Value ) const; + virtual void InitializeWidget( QWidget* ) const; + virtual void TakeValue( QWidget* ); + + private: + double _top, _bottom, _step; + double _initValue, _newValue; + int _decimals; +}; + +#endif // SMESHGUI_aParameter.h diff --git a/src/SMESHGUI/SMESHGUI_aParameterDlg.cxx b/src/SMESHGUI/SMESHGUI_aParameterDlg.cxx index 75039e0b0..24560d0ef 100644 --- a/src/SMESHGUI/SMESHGUI_aParameterDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_aParameterDlg.cxx @@ -26,11 +26,14 @@ // Module : SMESH // $Header$ -using namespace std; +#include "QAD_Tools.h" +#include "QAD_Desktop.h" +#include "QAD_Application.h" + #include "SMESHGUI_aParameterDlg.h" +#include "SMESHGUI_aParameter.h" #include "SMESHGUI.h" -#include "QAD_SpinBoxDbl.h" -#include "QAD_Tools.h" +#include "SMESHGUI_SpinBox.h" // QT Includes #include @@ -40,79 +43,27 @@ using namespace std; #include #include -//====================================================================================== -// function : SMESHGUI_aParameterDlg() -// purpose : Constructs a SMESHGUI_aParametertDlg for double values -// -// parent : parent widget -// title : is the title for the user in dialog box -// label : text label for the value -// -// bottom : the minimal value to be entered -// top : the maximum value to be entered -// decimals : number of decimals to be entered -// -// The dialog will by default be modal, unless you set 'modal' to -// false when constructing dialog -// -//====================================================================================== -SMESHGUI_aParameterDlg::SMESHGUI_aParameterDlg( QWidget* parent, - QString title, - QString label, - const double bottom, - const double top, - const int decimals, - bool modal ) -: QDialog( parent, "MyParameterDialog", modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), - myIntSpin( 0 ), myDblSpin( 0 ) -{ - /* creating widgets */ - init( true ); - /* title */ - setCaption( title ); - /* caption */ - myTextLabel->setText( label ); - /* range */ - myDblSpin->setRange( bottom, top ); - ((QDoubleValidator*)(myDblSpin->validator()))->setRange( bottom, top, decimals ); - - /* Move widget on the botton right corner of main widget */ - QAD_Tools::centerWidget( this, parent ); -} +using namespace std; //====================================================================================== // function : SMESHGUI_aParameterDlg() -// purpose : Constructs a SMESHGUI_aParametertDlg for int values -// -// parent : parent widget -// title : is the title for the user in dialog box -// label : text label for the value -// -// bottom : the minimal value to be entered -// top : the maximum value to be entered // // The dialog will by default be modal, unless you set 'modal' to // false when constructing dialog // //====================================================================================== -SMESHGUI_aParameterDlg::SMESHGUI_aParameterDlg( QWidget* parent, - QString title, - QString label, - const int bottom, - const int top, - bool modal ) +SMESHGUI_aParameterDlg::SMESHGUI_aParameterDlg + (std::list params, + QWidget* parent, + QString title, + bool modal ) : QDialog( parent, "MyParameterDialog", modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ), - myIntSpin( 0 ), myDblSpin( 0 ) + myParamList( params ) { /* creating widgets */ - init( false ); + init(); /* title */ setCaption( title ); - /* caption */ - myTextLabel->setText( label ); - /* range */ - myIntSpin->setRange( bottom, top ); - ((QIntValidator*)(myIntSpin->validator()))->setRange( bottom, top ); /* Move widget on the botton right corner of main widget */ QAD_Tools::centerWidget( this, parent ); @@ -122,7 +73,7 @@ SMESHGUI_aParameterDlg::SMESHGUI_aParameterDlg( QWidget* parent, // function : SMESHGUI_aParameterDlg::init() // purpose : creates dialog's layout //====================================================================================== -void SMESHGUI_aParameterDlg::init( bool isDouble ) +void SMESHGUI_aParameterDlg::init() { setSizeGripEnabled( TRUE ); @@ -138,25 +89,34 @@ void SMESHGUI_aParameterDlg::init( bool isDouble ) GroupC1Layout->setAlignment( Qt::AlignTop ); GroupC1Layout->setSpacing( 6 ); GroupC1Layout->setMargin( 11 ); - /* Label */ - /* aTitle1 : text prompt on left of edit line */ - myTextLabel = new QLabel( GroupC1, "TextLabel" ); - GroupC1Layout->addWidget( myTextLabel, 0, 0 ); - /* Spin box */ - if ( isDouble ) { - myIntSpin = 0; - myDblSpin = new QAD_SpinBoxDbl( GroupC1 ); - myDblSpin->setPrecision( 12 ); - myDblSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); - myDblSpin->setMinimumSize( 150, 0 ); - GroupC1Layout->addWidget( myDblSpin, 0, 1 ); - } - else { - myDblSpin = 0; - myIntSpin = new QSpinBox( GroupC1 ); - myIntSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); - myIntSpin->setMinimumSize( 150, 0 ); - GroupC1Layout->addWidget( myIntSpin, 0, 1 ); + /* Spin boxes with labels */ + list::iterator paramIt = myParamList.begin(); + for ( int row = 0; paramIt != myParamList.end(); paramIt++ , row++ ) + { + SMESHGUI_aParameterPtr param = (*paramIt); + QLabel * label = new QLabel( GroupC1, "TextLabel" ); + GroupC1Layout->addWidget( label, row, 0 ); + label->setText( param->Label() ); + QWidget* aSpinWidget; + switch ( param->GetType() ) { + case SMESHGUI_aParameter::DOUBLE: { + SMESHGUI_SpinBox* spin = new SMESHGUI_SpinBox( GroupC1 ); + aSpinWidget = spin; + spin->setPrecision( 12 ); + break; + } + case SMESHGUI_aParameter::INT: { + QSpinBox* spin = new QSpinBox( GroupC1 ); + aSpinWidget = spin; + break; + } + default:; + } + GroupC1Layout->addWidget( aSpinWidget, row, 1 ); + aSpinWidget->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + aSpinWidget->setMinimumSize( 150, 0 ); + param->InitializeWidget( aSpinWidget ); + mySpinList.push_back( aSpinWidget ); } /***************************************************************/ @@ -187,7 +147,7 @@ void SMESHGUI_aParameterDlg::init( bool isDouble ) topLayout->addWidget( GroupButtons, 1, 0); /* signals and slots connections */ - connect( myButtonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); + connect( myButtonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) ); connect( myButtonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); /* Retrieve SMESHGUI */ @@ -203,51 +163,39 @@ SMESHGUI_aParameterDlg::~SMESHGUI_aParameterDlg() { } -//====================================================================================== -// function : SMESHGUI_aParameterDlg::setValue -// purpose : sets double value -//====================================================================================== -void SMESHGUI_aParameterDlg::setValue( const double val ) -{ - if ( myDblSpin ) - myDblSpin->setValue( val ); -} -//====================================================================================== -// function : SMESHGUI_aParameterDlg::setValue -// purpose : sets int value -//====================================================================================== -void SMESHGUI_aParameterDlg::setValue( const int val ) -{ - if ( myIntSpin ) - myIntSpin->setValue( val ); -} -//====================================================================================== -// function : SMESHGUI_aParameterDlg::getDblValue -// purpose : returns double value entered by user -//====================================================================================== -double SMESHGUI_aParameterDlg::getDblValue() -{ - if ( myDblSpin ) - return myDblSpin->value(); - return 0.0; -} +//======================================================================= +//function : ClickOnOk +//purpose : +//======================================================================= -//====================================================================================== -// function : SMESHGUI_aParameterDlg::getIntValu -// purpose : returns int value entered by user -//====================================================================================== -int SMESHGUI_aParameterDlg::getIntValue() +void SMESHGUI_aParameterDlg::ClickOnOk() { - if ( myIntSpin ) - return myIntSpin->value(); - return 0; + if ( !mySMESHGUI->ActiveStudyLocked() ) { + list::iterator paramIt = myParamList.begin(); + list::iterator widgetIt = mySpinList.begin(); + for ( ; + paramIt != myParamList.end() && widgetIt != mySpinList.end(); + paramIt++ , widgetIt++ ) + (*paramIt)->TakeValue( *widgetIt ); + + accept(); + } } - - - - - - - +//======================================================================= +// function : Parameters() +// purpose : return a list of parameters from a dialog box +//======================================================================= +bool SMESHGUI_aParameterDlg::Parameters( list params, const char *aTitle) +{ + if ( !params.empty() ) { + SMESHGUI_aParameterDlg *Dialog = + new SMESHGUI_aParameterDlg(params, + QAD_Application::getDesktop(), + aTitle, + TRUE); + return (Dialog->exec() == QDialog::Accepted); + } + return false; +} diff --git a/src/SMESHGUI/SMESHGUI_aParameterDlg.h b/src/SMESHGUI/SMESHGUI_aParameterDlg.h index c78aa9c1c..0d7dcc399 100644 --- a/src/SMESHGUI/SMESHGUI_aParameterDlg.h +++ b/src/SMESHGUI/SMESHGUI_aParameterDlg.h @@ -32,11 +32,14 @@ // QT Includes #include +#include +#include "SMESHGUI_aParameter.h" + class QLabel; class QPushButton; -class QSpinBox; class SMESHGUI; -class QAD_SpinBoxDbl; +class QWidget; + //================================================================================= // class : SMESHGUI_aParameterDlg @@ -47,38 +50,30 @@ class SMESHGUI_aParameterDlg : public QDialog Q_OBJECT public: - SMESHGUI_aParameterDlg( QWidget* parent = 0, - QString title = QString::null, - QString label = QString::null, - const double bottom = -1E6, - const double top = +1E6, - const int decimals = 3, - bool modal = TRUE ); - SMESHGUI_aParameterDlg( QWidget* parent = 0, - QString title = QString::null, - QString label = QString::null, - const int bottom = 0, - const int top = 1000, - bool modal = TRUE ); + SMESHGUI_aParameterDlg( std::list params, + QWidget* parent = 0, + QString title = QString::null, + bool modal = TRUE ); ~SMESHGUI_aParameterDlg(); - void setValue( const double val ); - void setValue( const int val ); - double getDblValue(); - int getIntValue(); + /* Parameter function */ + static bool Parameters( std::list params, const char *aTitle); protected: - void init( bool isDouble ); + void init(); + +private slots: + void ClickOnOk(); private: SMESHGUI* mySMESHGUI ; QPushButton* myButtonOk; QPushButton* myButtonCancel; - QLabel* myTextLabel; - QSpinBox* myIntSpin; - QAD_SpinBoxDbl* myDblSpin; + + std::list mySpinList; + std::list myParamList; }; #endif // SMESHGUI_aParameterDlg.h diff --git a/src/SMESHGUI/SMESH_icons.po b/src/SMESHGUI/SMESH_icons.po index 741477620..1cb8085b2 100644 --- a/src/SMESHGUI/SMESH_icons.po +++ b/src/SMESHGUI/SMESH_icons.po @@ -54,6 +54,61 @@ msgstr "mesh_diagonal.png" msgid "ICON_DLG_CONNECTIVITY" msgstr "mesh_connectivity.png" +#Smoothing +msgid "ICON_DLG_SMOOTHING" +msgstr "mesh_smoothing.png" + +#Renumbering nodes +msgid "ICON_DLG_RENUMBERING_NODES" +msgstr "mesh_renumbering_nodes.png" + +#Renumbering elements +msgid "ICON_DLG_RENUMBERING_ELEMENTS" +msgstr "mesh_renumbering_elements.png" + +#Rotation +msgid "ICON_DLG_ROTATION" +msgstr "mesh_rotation.png" + +#Translation by vector +msgid "ICON_SMESH_TRANSLATION_VECTOR" +msgstr "mesh_translation_vector.png" + +#Translation by two points +msgid "ICON_SMESH_TRANSLATION_POINTS" +msgstr "mesh_translation_points.png" + +#Symmetry by point +msgid "ICON_SMESH_SYMMETRY_POINT" +msgstr "mesh_symmetry_point.png" + +#Symmetry by axis +msgid "ICON_SMESH_SYMMETRY_AXIS" +msgstr "mesh_symmetry_axis.png" + +#Symmetry by plane +msgid "ICON_SMESH_SYMMETRY_PLANE" +msgstr "mesh_symmetry_plane.png" + +#Sew free borders +msgid "ICON_SMESH_SEWING_FREEBORDERS" +msgstr "mesh_sew_freeborders.png" + +#Sew conform free borders +msgid "ICON_SMESH_SEWING_CONFORM_FREEBORDERS" +msgstr "mesh_sew_conform_freeborders.png" + +#Sew border to side +msgid "ICON_SMESH_SEWING_BORDERTOSIDE" +msgstr "mesh_sew_bordertoside.png" + +#Sew side elements +msgid "ICON_SMESH_SEWING_SIDEELEMENTS" +msgstr "mesh_sew_sideelements.png" + +#Merge nodes +msgid "ICON_SMESH_MERGE_NODES" +msgstr "mesh_merge_nodes.png" #----------------------------------------------------------- # Hypothesis @@ -81,7 +136,7 @@ msgid "ICON_DLG_NODE" msgstr "mesh_vertex.png" #Line -msgid "ICON_DLG_LINE" +msgid "ICON_DLG_EDGE" msgstr "mesh_line.png" #triangle @@ -139,3 +194,44 @@ msgstr "mesh_edit_group.png" msgid "ICON_CONSTRUCT_GROUP" msgstr "mesh_make_group.png" + +#----------------------------------------------------------- +# Mesh pattern +#----------------------------------------------------------- + +msgid "ICON_PATTERN_2d" +msgstr "mesh_algo_mefisto.png" + +msgid "ICON_PATTERN_3d" +msgstr "mesh_algo_hexa.png" + +msgid "ICON_PATTERN_SAMPLE_2D" +msgstr "pattern_sample_2d.png" + +msgid "ICON_PATTERN_SAMPLE_3D" +msgstr "pattern_sample_3D.png" + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SMESHGUI/SMESH_msg_en.po b/src/SMESHGUI/SMESH_msg_en.po index 38d6f37ed..c1187f34d 100644 --- a/src/SMESHGUI/SMESH_msg_en.po +++ b/src/SMESHGUI/SMESH_msg_en.po @@ -1,11 +1,11 @@ -# This is a Qt message file in .po format. Each msgid starts with +OA# This is a Qt message file in .po format. Each msgid starts with # a scope. This scope should *NOT* be translated - eg. "Foo::Bar" # would be translated to "Pub", not "Foo::Pub". msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "POT-Creation-Date: 2002-05-28 10:46:48 AM CEST\n" -"PO-Revision-Date: YYYY-MM-DD\n" +"PO-Revision-Date: 2004-10-20 17:25+0400\n" "Last-Translator: FULLNAME \n" "Content-Type: text/plain; charset=iso-8859-1\n" @@ -58,6 +58,15 @@ msgstr "&Sort List" msgid "SMESH_BUT_CREATE" msgstr "Create" +#New +msgid "SMESH_BUT_NEW" +msgstr "New" + +#Delete +msgid "SMESH_BUT_DELETE" +msgstr "Delete" + + #------------------------------------------------------------------------- # WARNING #------------------------------------------------------------------------- @@ -70,6 +79,13 @@ msgstr "Error" msgid "SMESH_WRN_WARNING" msgstr "Warning" +msgid "SMESH_WARNING" +msgstr "Warning" + +#Error +msgid "SMESH_OPERATION_FAILED" +msgstr "Operation failed" + #: SMESHGUI.cxx:465 msgid "SMESH_REALLY_DELETE" msgstr "Do you really want to delete object(s) ?" @@ -90,6 +106,10 @@ msgstr "Algorithm already exists" msgid "SMESH_WRN_MISSING_PARAMETERS" msgstr "Missing parameters" +#Compute failed +msgid "SMESH_WRN_COMPUTE_FAILED" +msgstr "Mesh computation failed" + #Study frame with VTK Viewer must be activated msgid "SMESH_WRN_VIEWER_VTK" msgstr "Study frame with VTK Viewer must be activated" @@ -199,6 +219,50 @@ msgstr "Y" msgid "SMESH_Z" msgstr "Z" +#dX +msgid "SMESH_DX" +msgstr "dX" + +#dY +msgid "SMESH_DY" +msgstr "dY" + +#dZ +msgid "SMESH_DZ" +msgstr "dZ" + +msgid "SMESH_POINT" +msgstr "Point" + +msgid "SMESH_POINT_1" +msgstr "Point 1" + +msgid "SMESH_POINT_2" +msgstr "Point 2" + +msgid "SMESH_VECTOR" +msgstr "Vector" + +#Axis +msgid "SMESH_AXIS" +msgstr "Axis" + +#Plane +msgid "SMESH_PLANE" +msgstr "Plane" + +#Normal +msgid "SMESH_NORMAL" +msgstr "Normal" + +#Parameters +msgid "SMESH_PARAMETERS" +msgstr "Parameters" + +#Distance +msgid "SMESH_DISTANCE" +msgstr "Distance" + #------------------------------------------------------------------------- # DLG @@ -278,7 +342,7 @@ msgstr "Node" #Node Construction msgid "MESH_NODE_TITLE" -msgstr "Node Construction" +msgstr "Add Node" #Segments msgid "SMESH_SEGMENTS" @@ -385,6 +449,14 @@ msgid "SMESH_ADD_HEXAS" msgstr "Add Hexahedron" +#Angle +msgid "SMESH_ANGLE" +msgstr "Angle" + +#Tolerance +msgid "SMESH_TOLERANCE" +msgstr "Tolerance" + # -------------- Transparency -------------- #Opacity @@ -400,6 +472,21 @@ msgid "SMESH_TRANSPARENCY_TRANSPARENT" msgstr "Transparent <---" +# -------------- Clipping -------------- + +#Transparency +msgid "SMESH_CLIPPING_TITLE" +msgstr "Change Clipping" + +#Front +msgid "SMESH_CLIPPING_FROM" +msgstr "From <---" + +#Back +msgid "SMESH_CLIPPING_INTO" +msgstr "---> Into" + + # -------------- Preferences ----------- #Scalar Bar Preferences @@ -470,6 +557,10 @@ msgstr "Nb of colors:" msgid "SMESH_NUMBEROFLABELS" msgstr "Nb of labels:" +#Number Of Steps +msgid "SMESH_NUMBEROFSTEPS" +msgstr "Number of steps:" + #Orientation msgid "SMESH_ORIENTATION" msgstr "Orientation" @@ -569,6 +660,61 @@ msgstr "Diagonal Inversion" msgid "SMESH_DIAGONAL_INVERSION_TITLE" msgstr "Diagonal Inversion" +#Select whole mesh or submesh +msgid "SMESH_SELECT_WHOLE_MESH" +msgstr "Select whole mesh, submesh or group" + +#Smoothing +msgid "SMESH_SMOOTHING" +msgstr "Smoothing" + +#Renumberig +msgid "SMESH_RENUMBERING" +msgstr "Renumbering" + +#Renumberig nodes +msgid "SMESH_RENUMBERING_NODES_TITLE" +msgstr "Renumbering nodes" + +#Renumberig elements +msgid "SMESH_RENUMBERING_ELEMENTS_TITLE" +msgstr "Renumbering elements" + +#Rotation about an axis +msgid "SMESH_ROTATION_TITLE" +msgstr "Rotation about an axis" + +#Translation +msgid "SMESH_TRANSLATION" +msgstr "Translation" + +#Symmetry +msgid "SMESH_SYMMETRY" +msgstr "Symmetry" + +#Sewing +msgid "SMESH_SEWING" +msgstr "Sewing" + +#Merge nodes +msgid "SMESH_MERGE_NODES" +msgstr "Merge nodes" + +#Extrusion +msgid "SMESH_EXTRUSION" +msgstr "Extrusion" + +#Revolution +msgid "SMESH_REVOLUTION" +msgstr "Revolution" + +#Create a copy +msgid "SMESH_CREATE_COPY" +msgstr "Create a copy" + +#Rotation +msgid "SMESH_ROTATION" +msgstr "Rotation" # -------------- Mesh Infos -------------- @@ -702,7 +848,7 @@ msgstr "Volume" msgid "SMESH_CONTENT" msgstr "Content" -#Select rom +#Select from msgid "SMESH_SELECT_FROM" msgstr "Select From" @@ -710,6 +856,22 @@ msgstr "Select From" msgid "SMESH_GROUP" msgstr "Group" +#Group type +msgid "SMESH_GROUP_TYPE" +msgstr "Group type" + +#Group type: standalone +msgid "SMESH_GROUP_STANDALONE" +msgstr "Standalone group" + +#Group type: geometry +msgid "SMESH_GROUP_GEOMETRY" +msgstr "Group on geometry" + +#Geometry group +msgid "SMESH_GEOM_GROUP" +msgstr "Geometry group" + #%1 SubMeshes msgid "SMESH_SUBMESH_SELECTED" msgstr "%1 SubMeshes" @@ -741,86 +903,150 @@ msgstr "Precision" msgid "SMESH_OUTLINE_COLOR" msgstr "Mesh Object Color" +# -------------- SMESHGUI_FilterTable -------------- -# -------------- SMESHGUI_FilterDlg -------------- -msgid "SMESHGUI_FilterDlg::FACES_TLT" -msgstr "Filter for Faces" +msgid "SMESHGUI_FilterTable::FILTER" +msgstr "Filter" -msgid "SMESHGUI_FilterDlg::EDGES_TLT" -msgstr "Filter for Edges" - -msgid "SMESHGUI_FilterDlg::ADD" +msgid "SMESHGUI_FilterTable::ADD" msgstr "Add" -msgid "SMESHGUI_FilterDlg::REMOVE" +msgid "SMESHGUI_FilterTable::CLEAR" +msgstr "Clear" + +msgid "SMESHGUI_FilterTable::REMOVE" msgstr "Remove" -msgid "SMESHGUI_FilterDlg::CRITERION" +msgid "SMESHGUI_FilterTable::INSERT" +msgstr "Insert" + +msgid "SMESHGUI_FilterTable::ADD_TO" +msgstr "Add to..." + +msgid "SMESHGUI_FilterTable::COPY_FROM" +msgstr "Copy from..." + +msgid "SMESHGUI_FilterTable::ADDITIONAL_PARAMETERS" +msgstr "Additional parameters" + +msgid "SMESHGUI_FilterTable::CRITERION" msgstr "Criterion" -msgid "SMESHGUI_FilterDlg::COMPARE" +msgid "SMESHGUI_FilterTable::COMPARE" msgstr "Compare" -msgid "SMESHGUI_FilterDlg::THRESHOLD_VALUE" +msgid "SMESHGUI_FilterTable::THRESHOLD_VALUE" msgstr "Threshold value" -msgid "SMESHGUI_FilterDlg::UNARY" +msgid "SMESHGUI_FilterTable::UNARY" msgstr "Unary" -msgid "SMESHGUI_FilterDlg::BINARY" +msgid "SMESHGUI_FilterTable::BINARY" msgstr "Binary" -msgid "SMESHGUI_FilterDlg::FREE_BORDERS" +msgid "SMESHGUI_FilterTable::FREE_EDGES" +msgstr "Free edges" + +msgid "SMESHGUI_FilterTable::FREE_BORDERS" msgstr "Free borders" -msgid "SMESHGUI_FilterDlg::MULTI_BORDERS" +msgid "SMESHGUI_FilterTable::MULTI_BORDERS" msgstr "Borders at multi-connections" -msgid "SMESHGUI_FilterDlg::LENGTH" +msgid "SMESHGUI_FilterTable::LENGTH" msgstr "Length" -msgid "SMESHGUI_FilterDlg::ASPECT_RATIO" +msgid "SMESHGUI_FilterTable::ASPECT_RATIO" msgstr "Aspect ratio" -msgid "SMESHGUI_FilterDlg::WARPING" +msgid "SMESHGUI_FilterTable::WARPING" msgstr "Warping" -msgid "SMESHGUI_FilterDlg::MINIMUM_ANGLE" +msgid "SMESHGUI_FilterTable::MINIMUM_ANGLE" msgstr "Minimum angle" -msgid "SMESHGUI_FilterDlg::TAPER" +msgid "SMESHGUI_FilterTable::TAPER" msgstr "Taper" -msgid "SMESHGUI_FilterDlg::SKEW" +msgid "SMESHGUI_FilterTable::SKEW" msgstr "Skew" -msgid "SMESHGUI_FilterDlg::AREA" +msgid "SMESHGUI_FilterTable::AREA" msgstr "Area" -msgid "SMESHGUI_FilterDlg::LESS_THAN" +msgid "SMESHGUI_FilterTable::LESS_THAN" msgstr "Less than" -msgid "SMESHGUI_FilterDlg::MORE_THAN" +msgid "SMESHGUI_FilterTable::MORE_THAN" msgstr "More than" -msgid "SMESHGUI_FilterDlg::EQUAL_TO" +msgid "SMESHGUI_FilterTable::EQUAL_TO" msgstr "Equal to" -msgid "SMESHGUI_FilterDlg::NOT" +msgid "SMESHGUI_FilterTable::NOT" msgstr "Not" -msgid "SMESHGUI_FilterDlg::AND" +msgid "SMESHGUI_FilterTable::AND" msgstr "And" -msgid "SMESHGUI_FilterDlg::OR" +msgid "SMESHGUI_FilterTable::OR" msgstr "Or" -msgid "SMESHGUI_FilterDlg::ERROR" +msgid "SMESHGUI_FilterTable::ERROR" msgstr "Threshold value is not correctly specified\nPlease enter correct value and try again" -msgid "SMESHGUI_FilterDlg::MULTIEDGES_ERROR" +msgid "SMESHGUI_INVALID_PARAMETERS" +msgstr "Parameters are not correctly specified\nPlease enter correct values and try again" + +msgid "SMESHGUI_FilterTable::MULTIEDGES_ERROR" msgstr "Threshold value of borders at multi-connections can not be equal 1\nPlease enter correct value and try again" +msgid "SMESHGUI_FilterTable::ENTITY_TYPE" +msgstr "Entity type" + +msgid "SMESHGUI_FilterTable::FACES" +msgstr "Faces" + +msgid "SMESHGUI_FilterTable::EDGES" +msgstr "Edges" + +msgid "SMESHGUI_FilterTable::NODES" +msgstr "Nodes" + +msgid "SMESHGUI_FilterTable::VOLUMES" +msgstr "Volumes" + +msgid "SMESHGUI_FilterTable::ID" +msgstr "ID" + +msgid "SMESHGUI_FilterTable::RANGE_OF_IDS" +msgstr "Range of IDs" + +msgid "SMESHGUI_FilterTable::BELONG_TO_GEOM" +msgstr "Belong to Geom" + +msgid "SMESHGUI_FilterTable::BELONG_TO_PLANE" +msgstr "Belong to Plane" + +msgid "SMESHGUI_FilterTable::BELONG_TO_CYLINDER" +msgstr "Belong to Cylinder" + +# -------------- SMESHGUI_FilterDlg -------------- +msgid "SMESHGUI_FilterDlg::TLT" +msgstr "Selection filter" + +msgid "SMESHGUI_FilterDlg::FACES_TLT" +msgstr "Filter for Faces" + +msgid "SMESHGUI_FilterDlg::EDGES_TLT" +msgstr "Filter for Edges" + +msgid "SMESHGUI_FilterDlg::NODES_TLT" +msgstr "Filter for Nodes" + +msgid "SMESHGUI_FilterDlg::VOLUMES_TLT" +msgstr "Filter for Volumes" + msgid "SMESHGUI_FilterDlg::SOURCE" msgstr "Source" @@ -828,68 +1054,86 @@ msgid "SMESHGUI_FilterDlg::MESH" msgstr "Mesh" msgid "SMESHGUI_FilterDlg::SELECTION" -msgstr "Current Selection" +msgstr "Initial Selection" msgid "SMESHGUI_FilterDlg::CURRENT_GROUP" msgstr "Current Group" -msgid "SMESHGUI_FilterDlg::NONE" -msgstr "None" - msgid "SMESHGUI_FilterDlg::SET_IN_VIEWER" msgstr "Insert filter in viewer" -msgid "SMESHGUI_FilterDlg::CLEAR" -msgstr "Clear" +msgid "SMESHGUI_FilterDlg::BAD_SHAPE_NAME" +msgstr "There is no \"%1\" geometrical object in the current study\nPlease select valid object and try again" + +msgid "SMESHGUI_FilterDlg::SHAPE_IS_NOT_A_FACE" +msgstr "\"%1\" is not a face\nPlease select a face and try again" + +msgid "SMESHGUI_FilterDlg::SHAPE_IS_NOT_A_PLANE" +msgstr "\"%1\" is not a plane\nPlease select a plane and try again" + +msgid "SMESHGUI_FilterDlg::SHAPE_IS_NOT_A_CYLINDER" +msgstr "\"%1\" is not a cylinderical face\nPlease select a cylindrical face and try again" # -------------- SMESHGUI -------------- -msgid "SMESHGUI::MESH_IS_NOT_SELECTED" +msgid "MESH_IS_NOT_SELECTED" msgstr "There is no selected mesh\nPlease, select a mesh and try again" msgid "SMESHGUI::NOT_A_VTK_VIEWER" msgstr "This command is available in VTK viewer only\nPlease, create VTK viewer and try again" -msgid "SMESHGUI::LENGTH_EDGES" +msgid "LENGTH_EDGES" msgstr "Length" -msgid "SMESHGUI::FREE_BORDERS" +msgid "FREE_BORDERS" msgstr "Free borders" -msgid "SMESHGUI::MULTI_BORDERS" +msgid "MULTI_BORDERS" msgstr "Borders at multi-connections" -msgid "SMESHGUI::AREA_ELEMENTS" +msgid "AREA_ELEMENTS" msgstr "Area" -msgid "SMESHGUI::TAPER_ELEMENTS" +msgid "TAPER_ELEMENTS" msgstr "Taper" -msgid "SMESHGUI::ASPECTRATIO_ELEMENTS" +msgid "ASPECTRATIO_ELEMENTS" msgstr "Aspect Ratio" -msgid "SMESHGUI::MINIMUMANGLE_ELEMENTS" +msgid "MINIMUMANGLE_ELEMENTS" msgstr "Minimum Angle" -msgid "SMESHGUI::WARP_ELEMENTS" -msgstr "Warp" +msgid "WARP_ELEMENTS" +msgstr "Warping" -msgid "SMESHGUI::SKEW_ELEMENTS" +msgid "SKEW_ELEMENTS" msgstr "Skew" msgid "SMESH_INSUFFICIENT_DATA" msgstr "Insufficient input value" +msgid "SMESH_CANT_ADD_HYP" +msgstr "Can not assign \"%1\":\n" + +msgid "SMESH_ADD_HYP_WRN" +msgstr "\"%1\" assigned but:\n" + +msgid "SMESH_CANT_RM_HYP" +msgstr "Can not unassign \"%1\":\n" + +msgid "SMESH_RM_HYP_WRN" +msgstr "\"%1\" unassigned but:\n" + msgid "SMESH_HYP_1" msgstr "Algorithm misses a hypothesis" msgid "SMESH_HYP_2" -msgstr "Concurrent hypotheses on a shape" +msgstr "There are concurrent hypotheses on a shape" msgid "SMESH_HYP_3" msgstr "Hypothesis has a bad parameter value" msgid "SMESH_HYP_4" -msgstr "Unknown fatal error while assigning hypothesis" +msgstr "Unknown fatal error at hypothesis definition" msgid "SMESH_HYP_5" msgstr "Hypothesis is not suitable in the current context" @@ -898,7 +1142,7 @@ msgid "SMESH_HYP_6" msgstr "Non-conform mesh is produced using applied hypotheses" msgid "SMESH_HYP_7" -msgstr "Such hypothesis is already assigned to the shape" +msgstr "Such dimention hypothesis is already assigned to the shape" msgid "SMESH_HYP_8" msgstr "Hypothesis and submesh dimensions mismatch" @@ -918,5 +1162,527 @@ msgid "SMESH_DRS_4" msgstr " The file is incorrect,\n" "some information will be missed" +msgid "SMESH_DRS_EMPTY" +msgstr " The file is empty,\n" + "there is nothing to be published" + +msgid "SMESH_EXPORT_UNV" +msgstr "During export mesh with name - \"%1\" to UNV\n" + " pyramid's elements will be missed" + msgid "INF_SELECT_OBJECT" -msgstr "Select an object" \ No newline at end of file +msgstr "Select an object" + +#---------------------------------------------------- + +msgid "SMESHGUI_FilterLibraryDlg::ADD_TO_TLT" +msgstr "Add selection filter to library" + +msgid "SMESHGUI_FilterLibraryDlg::COPY_FROM_TLT" +msgstr "Copy selection filter from library" + +msgid "SMESHGUI_FilterLibraryDlg::EDIT_LIB_TLT" +msgstr "Selection filter library" + +msgid "SMESHGUI_FilterLibraryDlg::LIBRARY_FILE" +msgstr "Library file name" + +msgid "SMESHGUI_FilterLibraryDlg::ADD" +msgstr "Add" + +msgid "SMESHGUI_FilterLibraryDlg::DELETE" +msgstr "Delete" + +msgid "SMESHGUI_FilterLibraryDlg::FILTER_NAME" +msgstr "Filter name" + +msgid "SMESHGUI_FilterLibraryDlg::OPEN_LIBRARY" +msgstr "Open library" + +msgid "SMESHGUI_FilterLibraryDlg::XML_FILT" +msgstr "XML files(*.xml)" + +msgid "SMESHGUI_FilterLibraryDlg::ALL_FILES_FILTER" +msgstr "All Files (*.*)" + +msgid "SMESHGUI_FilterLibraryDlg::ERROR_LOAD" +msgstr "It is impossible to load library\nPlease check library file name and attributes" + +msgid "SMESHGUI_FilterLibraryDlg::ERROR_FILTER_NAME" +msgstr "Name of the filter is not unique\nPlease enter other name" + +msgid "SMESHGUI_FilterLibraryDlg::EMPTY_FILTER_NAME" +msgstr "Name of the filter is empty\nPlease enter a non-empty name" + +msgid "SMESHGUI_FilterLibraryDlg::FACE" +msgstr "Face" + +msgid "SMESHGUI_FilterLibraryDlg::EDGE" +msgstr "Edge" + +msgid "SMESHGUI_FilterLibraryDlg::NODE" +msgstr "Node" + +msgid "SMESHGUI_FilterLibraryDlg::VOLUME" +msgstr "Volume" + +msgid "SMESHGUI_FilterLibraryDlg::ELEMENT" +msgstr "Element" + +msgid "SMESHGUI_FilterLibraryDlg::LIB_NAME" +msgstr "FilterLib.xml" + +msgid "SMESHGUI_FilterLibraryDlg::SELECTION" +msgstr "Selection" + +msgid "SMESHGUI_FilterLibraryDlg::FILTER" +msgstr "Filter" + +msgid "SMESHGUI_FilterLibraryDlg::LIBRARY_IS_NOT_LOADED" +msgstr "Library is not loaded. Please load library and try again" + +msgid "SMESHGUI_FilterLibraryDlg::ERROR_OF_ADDING" +msgstr "Internal error occurs during adiing new filter in library.\nPlease verify validity of entered information" + +msgid "SMESHGUI_FilterLibraryDlg::ERROR_OF_DELETING" +msgstr "Internal error occurs during deleting filter from library.\nPlease verify validity of entered information" + +msgid "SMESHGUI_FilterLibraryDlg::ERROR_OF_COPYING" +msgstr "Internal error occurs during copying filter from library.\nPlease verify validity of entered information" + +msgid "SMESHGUI_FilterLibraryDlg::ERROR_OF_EDITING" +msgstr "Internal error occurs during editing filter library.\nPlease verify validity of entered information" + +msgid "SMESHGUI_FilterLibraryDlg::ASSIGN_NEW_NAME" +msgstr "Library already contains filter with name \"%1\"\nNew name \"%2\" is assigned to added filter" + +msgid "SMESHGUI_FilterLibraryDlg::FILTER_NAMES" +msgstr "Names of filters" + +msgid "SMESHGUI_FilterLibraryDlg::NO_PERMISSION" +msgstr "You do not have write permission to this file" + +msgid "SMESHGUI_FilterLibraryDlg::ERROR_OF_SAVING" +msgstr "Internal error occurs during saving filter library\nPlease check input data and try again" + +#---------------------------------------------------- + +msgid "SMESHGUI_SingleEditDlg::EDGE_BETWEEN" +msgstr "Edge between neighboring triangles" + +msgid "SMESHGUI_TrianglesInversionDlg::CAPTION" +msgstr "Diagonal inversion" + +msgid "SMESHGUI_UnionOfTwoTrianglesDlg::CAPTION" +msgstr "Union of two triangles" + +#---------------------------------------------------- + +msgid "SMESHGUI_MultiEditDlg::FILTER" +msgstr "Filter" + +msgid "SMESHGUI_MultiEditDlg::ADD" +msgstr "Add" + +msgid "SMESHGUI_MultiEditDlg::REMOVE" +msgstr "Remove" + +msgid "SMESHGUI_MultiEditDlg::SORT_LIST" +msgstr "Sort list" + +msgid "SMESHGUI_MultiEditDlg::TO_ALL" +msgstr "Apply to all" + +msgid "SMESHGUI_MultiEditDlg::SELECT_FROM" +msgstr "Select from" + +msgid "SMESHGUI_MultiEditDlg::GROUP" +msgstr "Group" + +msgid "SMESHGUI_ChangeOrientationDlg::CAPTION" +msgstr "Modification of orientation" + +msgid "SMESHGUI_UnionOfTrianglesDlg::CAPTION" +msgstr "Union of triangles" + +msgid "SMESHGUI_CuttingOfQuadsDlg::CAPTION" +msgstr "Cutting of quadrangles" + +msgid "SMESHGUI_CuttingOfQuadsDlg::USE_DIAGONAL_2_4" +msgstr "Use diagonal 2-4" + +msgid "SMESHGUI_CuttingOfQuadsDlg::PREVIEW" +msgstr "Preview" + +#---------------------------------------------------- + +msgid "SMESHGUI_MoveNodesDlg::CAPTION" +msgstr "Move node" + +msgid "SMESHGUI_MoveNodesDlg::NODE_ID" +msgstr "Node ID" + +msgid "SMESHGUI_MoveNodesDlg::NODE_ID_IS_NOT_DEFINED" +msgstr "Node ID is not defined" + +#---------------------------------------------------- + +msgid "SMESHGUI_DeleteGroupDlg::CAPTION" +msgstr "Delete groups with contents" + +msgid "SMESHGUI_DeleteGroupDlg::SELECTED_GROUPS" +msgstr "Selected groups" + +msgid "SMESHGUI_DeleteGroupDlg::NO_SELECTED_GROUPS" +msgstr "There are no selected groups\nPlease select a groups and try again" + +#---------------------------------------------------- + +msgid "SMESHGUI_GroupOpDlg::NAME" +msgstr "Name" + +msgid "SMESHGUI_GroupOpDlg::RESULT_NAME" +msgstr "Result name" + +msgid "SMESHGUI_GroupOpDlg::ARGUMENTS" +msgstr "Arguments" + +msgid "SMESHGUI_GroupOpDlg::OBJECT_1" +msgstr "Object 1" + +msgid "SMESHGUI_GroupOpDlg::OBJECT_2" +msgstr "Object 2" + +msgid "SMESHGUI_GroupOpDlg::MAIN_OBJECT" +msgstr "Main object" + +msgid "SMESHGUI_GroupOpDlg::TOOL_OBJECT" +msgstr "Tool object" + +msgid "SMESHGUI_GroupOpDlg::UNION_OF_TWO_GROUPS" +msgstr "Union of two groups" + +msgid "SMESHGUI_GroupOpDlg::INTERSECTION_OF_TWO_GROUPS" +msgstr "Intersection of two groups" + +msgid "SMESHGUI_GroupOpDlg::CUT_OF_TWO_GROUPS" +msgstr "Cut of two groups" + +msgid "SMESHGUI_GroupOpDlg::INCORRECT_ARGUMENTS" +msgstr "Arguments of operation are not specified\nPlease specify them and try again" + +msgid "SMESHGUI_GroupOpDlg::DIFF_MESHES" +msgstr "Arguments of operation are not correctly specified\nGroups correspond to a different meshes\nPlease specify valid arguments and try again" + +msgid "SMESHGUI_GroupOpDlg::DIFF_TYPES" +msgstr "Arguments of operation are not correctly specified\nGroups contain elements of different types\nPlease specify valid arguments and try again" + +msgid "SMESHGUI_GroupOpDlg::EMPTY_NAME" +msgstr "Name of group to be created is not valid\nPlease specify non-empty name and try again" + +#---------------------------------------------------- + + +msgid "SMESHGUI_SmoothingDlg::FIXED_NODES_IDS" +msgstr "Fixed nodes ids" + +msgid "SMESHGUI_SmoothingDlg::METHOD" +msgstr "Method" + +msgid "SMESHGUI_SmoothingDlg::ITERATION_LIMIT" +msgstr "Iteration limit" + +msgid "SMESHGUI_SmoothingDlg::MAX_ASPECT_RATIO" +msgstr "Max. aspect ratio" + +msgid "SMESHGUI_SmoothingDlg::LAPLACIAN" +msgstr "Laplacian" + +msgid "SMESHGUI_SmoothingDlg::CENTROIDAL" +msgstr "Centroidal" + +#---------------------------------------------------- + +msgid "SMESHGUI_ExtrusionDlg::EXTRUSION_ALONG_LINE" +msgstr "Extrusion along a line" + + +msgid "SMESHGUI_ExtrusionDlg::EXTRUSION_1D" +msgstr "Extrusion of 1D elements" + +msgid "SMESHGUI_ExtrusionDlg::EXTRUSION_2D" +msgstr "Extrusion of 2D elements" + +#---------------------------------------------------- + +msgid "SMESHGUI_RevolutionDlg::REVOLUTION_AROUND_AXIS" +msgstr "Revolution around an axis" + +msgid "SMESHGUI_RevolutionDlg::REVOLUTION_1D" +msgstr "Revolution of 1D elements" + +msgid "SMESHGUI_RevolutionDlg::REVOLUTION_2D" +msgstr "Revolution of 2D elements" + +#---------------------------------------------------- + +msgid "SMESHGUI_SewingDlg::MERGE_EQUAL_ELEMENTS" +msgstr "Merge equal elements" + +msgid "SMESHGUI_SewingDlg::SEW_FREE_BORDERS" +msgstr "Sew Free Borders" + +msgid "SMESHGUI_SewingDlg::BORDER" +msgstr "Border" + +msgid "SMESHGUI_SewingDlg::BORDER_1" +msgstr "Border 1" + +msgid "SMESHGUI_SewingDlg::BORDER_2" +msgstr "Border 2" + +msgid "SMESHGUI_SewingDlg::SEW_CONFORM_FREE_BORDERS" +msgstr "Sew Conform Free Borders" + +msgid "SMESHGUI_SewingDlg::SEW_BORDER_TO_SIDE" +msgstr "Sew Border To Side" + +msgid "SMESHGUI_SewingDlg::SIDE" +msgstr "Side" + +msgid "SMESHGUI_SewingDlg::SEW_SIDE_ELEMENTS" +msgstr "Sew Side Elements" + +msgid "SMESHGUI_SewingDlg::SIDE_1" +msgstr "Side 1" + +msgid "SMESHGUI_SewingDlg::SIDE_2" +msgstr "Side 2" + +msgid "SMESHGUI_SewingDlg::NODE1_TO_MERGE" +msgstr "Node 1 To Merge" + +msgid "SMESHGUI_SewingDlg::NODE2_TO_MERGE" +msgstr "Node 2 To Merge" + +msgid "SMESHGUI_SewingDlg::FIRST_NODE_ID" +msgstr "First Node ID" + +msgid "SMESHGUI_SewingDlg::SECOND_NODE_ID" +msgstr "Second Node ID" + +msgid "SMESHGUI_SewingDlg::LAST_NODE_ID" +msgstr "Last Node ID" + +msgid "SMESHGUI_SewingDlg::ERROR_1" +msgstr "Free Border1 not found by the selected nodes" + +msgid "SMESHGUI_SewingDlg::ERROR_2" +msgstr "Free Border2 not found by the selected nodes" + +msgid "SMESHGUI_SewingDlg::ERROR_3" +msgstr "Free Border1 and Border2 not found by the selected nodes" + +msgid "SMESHGUI_SewingDlg::ERROR_4" +msgstr "No path from the first side node to the last side node have been found" + +msgid "SMESHGUI_SewingDlg::ERROR_5" +msgstr "Not allowed to splite volumes on the side!" + +msgid "SMESHGUI_SewingDlg::ERROR_6" +msgstr "Different number of elements selected on the sides" + +msgid "SMESHGUI_SewingDlg::ERROR_7" +msgstr "Element sets are topologically different or given nodes are inconvenient" + +msgid "SMESHGUI_SewingDlg::ERROR_8" +msgstr "Nodes on the side 1 are either not linked or not laying on the element set boundary" + +msgid "SMESHGUI_SewingDlg::ERROR_9" +msgstr "Nodes on the side 2 are either not linked or not laying on the element set boundary" + + +#---------------------------------------------------- + +#Coincident nodes +msgid "SMESHGUI_MergeNodesDlg::COINCIDENT_NODES" +msgstr "Coincident nodes" + +#Detect +msgid "SMESHGUI_MergeNodesDlg::DETECT" +msgstr "Detect" + +#Select all +msgid "SMESHGUI_MergeNodesDlg::SELECT_ALL" +msgstr "Select all" + +# Edit group of nodes +msgid "SMESHGUI_MergeNodesDlg::EDIT_GROUP_OF_NODES" +msgstr "Edit group of nodes" + +#---------------------------------------------------- + +msgid "SMESHGUI_MeshPatternDlg::CAPTION" +msgstr "Pattern Mapping" + +msgid "SMESHGUI_MeshPatternDlg::PATTERN_TYPE" +msgstr "Pattern type" + +msgid "SMESHGUI_MeshPatternDlg::PATTERN" +msgstr "Pattern" + +msgid "SMESHGUI_MeshPatternDlg::NEW" +msgstr "New..." + +msgid "SMESHGUI_MeshPatternDlg::FACE" +msgstr "Face" + +msgid "SMESHGUI_MeshPatternDlg::VERTEX" +msgstr "Vertex " + +msgid "SMESHGUI_MeshPatternDlg::VERTEX1" +msgstr "Vertex 1" + +msgid "SMESHGUI_MeshPatternDlg::VERTEX2" +msgstr "Vertex 2" + +msgid "SMESHGUI_MeshPatternDlg::REVERSE" +msgstr "Reverse order of key-points" + +msgid "SMESHGUI_MeshPatternDlg::PREVIEW" +msgstr "Preview" + +msgid "SMESHGUI_MeshPatternDlg::3D_BLOCK" +msgstr "3D block" + +msgid "SMESHGUI_MeshPatternDlg::LOAD_PATTERN" +msgstr "Load pattern" + +msgid "SMESHGUI_MeshPatternDlg::PATTERN_FILT" +msgstr "Pattern files(*.smp)" + +msgid "SMESHGUI_MeshPatternDlg::ERROR_OF_LOADING" +msgstr "Loading of pattern from file failed. Probably file\nis corrupted or contains pattern of the other type" + +msgid "SMESHGUI_MeshPatternDlg::ERROR_OF_OPENING" +msgstr "It is impossible to open file. Please verify whether\nfile exists and your permission to this file" + +msgid "SMESHGUI_MeshPatternDlg::ERROR_OF_READING" +msgstr "It is impossible to load pattern\nPlease verify file's contents" + +msgid "SMESHGUI_MeshPatternDlg::ERR_READ_NB_POINTS" +msgstr "It is impossible to load pattern\nIt is impossible to read number of points from file" + +msgid "SMESHGUI_MeshPatternDlg::ERR_READ_POINT_COORDS" +msgstr "It is impossible to load pattern\nIt is impossible to read point coordinates from file" + +msgid "SMESHGUI_MeshPatternDlg::ERR_READ_TOO_FEW_POINTS" +msgstr "It is impossible to load pattern. There are\n too few points in the file for pattern loading" + +msgid "SMESHGUI_MeshPatternDlg::ERR_READ_3D_COORD" +msgstr "It is impossible to load pattern\nCoordinates of 3D points out of [0,1] range" + +msgid "SMESHGUI_MeshPatternDlg::ERR_READ_NO_KEYPOINT" +msgstr "It is impossible to load pattern\nThere are no key-points in 2D one" + +msgid "SMESHGUI_MeshPatternDlg::ERR_READ_BAD_INDEX" +msgstr "It is impossible to load pattern\nInvalid index of point detected" + +msgid "SMESHGUI_MeshPatternDlg::ERR_READ_ELEM_POINTS" +msgstr "It is impossible to load pattern\ninvalid number of points in element" + +msgid "SMESHGUI_MeshPatternDlg::ERR_READ_NO_ELEMS" +msgstr "It is impossible to load pattern\nThere are no elements in it" + +msgid "SMESHGUI_MeshPatternDlg::ERR_READ_BAD_KEY_POINT" +msgstr "It is impossible to load pattern\nKey-point not on a boundary" + + +#---------------------------------------------------- + +msgid "SMESHGUI_CreatePatternDlg::CAPTION" +msgstr "Pattern Creation" + +msgid "SMESHGUI_CreatePatternDlg::MESH_OR_SUBMESH" +msgstr "Mesh or SubMesh" + +msgid "SMESHGUI_CreatePatternDlg::PROJECT" +msgstr "Project nodes on the face" + +msgid "SMESHGUI_CreatePatternDlg::PATTERN" +msgstr "Pattern" + +msgid "SMESHGUI_CreatePatternDlg::PATTERN_NAME" +msgstr "Pattern name" + +msgid "SMESHGUI_CreatePatternDlg::SAVE" +msgstr "Save..." + +msgid "SMESHGUI_CreatePatternDlg::ERROR_OF_CREATION" +msgstr "Internal error occurs during pattern creation\nPlease verify validity of entered information" + +msgid "SMESHGUI_CreatePatternDlg::DEFAULT_2D" +msgstr "Pattern_2d" + +msgid "SMESHGUI_CreatePatternDlg::DEFAULT_3D" +msgstr "Pattern_3d" + +msgid "SMESHGUI_CreatePatternDlg::SAVE_PATTERN" +msgstr "Save Pattern" + +msgid "SMESHGUI_CreatePatternDlg::ERROR_OF_SAVING" +msgstr "Internal error occurs during pattern saving. Please verify\n\free disk space and your write permission to this file" + +msgid "SMESHGUI_CreatePatternDlg::PATTERN_TYPE" +msgstr "Pattern type" + +msgid "SMESHGUI_CreatePatternDlg::PATTERN_FILT" +msgstr "Pattern files(*.smp)" + +msgid "SMESHGUI_CreatePatternDlg::ERR_LOAD_EMPTY_SUBMESH" +msgstr "There are no elements to create pattern" + +msgid "SMESHGUI_CreatePatternDlg::ERR_LOADF_NARROW_FACE" +msgstr "It is impossible to create pattern from narrow face" + +msgid "SMESHGUI_CreatePatternDlg::ERR_LOADF_CLOSED_FACE" +msgstr "It is impossible to create pattern from face having seam edge" + +msgid "SMESHGUI_CreatePatternDlg::ERR_LOADV_BAD_SHAPE" +msgstr "Pattern can be created from closed shell or solid with 6 faces only" + +msgid "SMESHGUI_CreatePatternDlg::ERR_LOADV_COMPUTE_PARAMS" +msgstr "It is impossible to compute point parameters" + +#------------------------------------------------------------------------- + +msgid "SMESHGUI_PrecisionDlg::CAPTION" +msgstr "Precision for mesh quality controls" + +msgid "SMESHGUI_PrecisionDlg::PRECISION" +msgstr "Number of digits after point" + +msgid "SMESHGUI_PrecisionDlg::NOT_USE" +msgstr "Do not use" + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/SMESH_I/Makefile.in b/src/SMESH_I/Makefile.in index 2f38fc04e..a2b64c5da 100644 --- a/src/SMESH_I/Makefile.in +++ b/src/SMESH_I/Makefile.in @@ -43,7 +43,6 @@ EXPORT_HEADERS= \ SMESH_2D_Algo_i.hxx \ SMESH_3D_Algo_i.hxx \ SMESH_subMesh_i.hxx \ - SMESH_topo.hxx \ SMESH_Mesh_i.hxx \ SMESH_Hypothesis_i.hxx @@ -55,6 +54,7 @@ LIB= libSMESHEngine.la LIB_SRC = \ SMESH_Gen_i.cxx \ + SMESH_Gen_i_1.cxx \ SMESH_Mesh_i.cxx \ SMESH_MEDMesh_i.cxx \ SMESH_MEDFamily_i.cxx \ @@ -62,22 +62,22 @@ LIB_SRC = \ SMESH_subMesh_i.cxx \ SMESH_MeshEditor_i.cxx \ SMESH_Hypothesis_i.cxx \ - SMESH_topo.cxx \ SMESH_Algo_i.cxx \ SMESH_1D_Algo_i.cxx \ SMESH_2D_Algo_i.cxx \ SMESH_3D_Algo_i.cxx \ SMESH_Filter_i.cxx \ - SMESH_Group_i.cxx + SMESH_Group_i.cxx \ + SMESH_Pattern_i.cxx LIB_SERVER_IDL = SMESH_Gen.idl SMESH_Hypothesis.idl SMESH_Mesh.idl \ SALOME_Component.idl SALOME_Exception.idl \ - SMESH_Filter.idl SMESH_Group.idl + SMESH_Filter.idl SMESH_Group.idl SMESH_Pattern.idl -LIB_CLIENT_IDL = SALOMEDS.idl GEOM_Gen.idl GEOM_Shape.idl MED.idl SALOMEDS_Attributes.idl SALOME_GenericObj.idl +LIB_CLIENT_IDL = SALOMEDS.idl GEOM_Gen.idl MED.idl SALOMEDS_Attributes.idl SALOME_GenericObj.idl SALOME_Comm.idl # Executables targets -BIN = +BIN = SMESHEngine BIN_SRC = # additionnal information to compil and link file @@ -86,8 +86,16 @@ CPPFLAGS+= $(OCC_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR CXXFLAGS+= $(OCC_CXXFLAGS) $(MED2_INCLUDES) $(HDF5_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome \ -I${GEOM_ROOT_DIR}/include/salome -#IDLCXXFLAGS+= -Wbtp +LDFLAGS+= -L${KERNEL_ROOT_DIR}/lib/salome -lSalomeContainer -lSalomeNS -lRegistry -lSalomeHDFPersist -lSalomeLifeCycleCORBA -lTOOLSDS -lSalomeGenericObj \ + -L${GEOM_ROOT_DIR}/lib/salome -lGEOMClient -lSMESHimpl -lSMESHControls \ + -L${CASROOT}/lin/lib -lTKCDF -lTKBO -LDFLAGS+= $(HDF5_LIBS) $(MED2_LIBS) -lSMESHimpl -lSalomeContainer -lSalomeNS -lSalomeDS -lRegistry -lSalomeHDFPersist -lOpUtil -lGEOMClient -lSMESHDS -lSMDS -lMeshDriverMED -lSalomeLifeCycleCORBA -L${KERNEL_ROOT_DIR}/lib/salome -L${GEOM_ROOT_DIR}/lib/salome -lSalomeGenericObj + +LDFLAGSFORBIN += -lSMDS -lSMESHDS -lMEDWrapper -lMeshDriver -lMeshDriverMED -lMeshDriverUNV -lMeshDriverDAT -lMeshDriverSTL \ + -L${KERNEL_ROOT_DIR}/lib/salome -lSalomeContainer -lSalomeNS -lRegistry \ + -lOpUtil -lSALOMELocalTrace -lSalomeNotification \ + -lSalomeHDFPersist -lSalomeLifeCycleCORBA -lTOOLSDS -lSalomeGenericObj \ + -L${GEOM_ROOT_DIR}/lib/salome -lGEOMClient -lSMESHimpl -lSMESHControls \ + -L${CASROOT}/lin/lib -lTKCDF -lTKBO @CONCLUDE@ diff --git a/src/SMESH_I/SMESHEngine.cxx b/src/SMESH_I/SMESHEngine.cxx new file mode 100644 index 000000000..fc1bd440b --- /dev/null +++ b/src/SMESH_I/SMESHEngine.cxx @@ -0,0 +1,23 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org + +int main(int argc, char** argv) +{ + return 1; +} diff --git a/src/SMESH_I/SMESH_Algo_i.cxx b/src/SMESH_I/SMESH_Algo_i.cxx index 17995f4b7..a57df7bef 100644 --- a/src/SMESH_I/SMESH_Algo_i.cxx +++ b/src/SMESH_I/SMESH_Algo_i.cxx @@ -79,7 +79,7 @@ SMESH::ListOfHypothesisName* SMESH_Algo_i::GetCompatibleHypothesis() int nbHyp = hypList.size(); listOfHypothesis->length( nbHyp ); for ( int i = 0; i < nbHyp; i++ ) { - listOfHypothesis[ i ] = strdup( hypList[ i ].c_str() ); + listOfHypothesis[ i ] = CORBA::string_dup( hypList[ i ].c_str() ); } return listOfHypothesis._retn(); } diff --git a/src/SMESH_I/SMESH_Filter_i.cxx b/src/SMESH_I/SMESH_Filter_i.cxx index 724d602dd..052053500 100644 --- a/src/SMESH_I/SMESH_Filter_i.cxx +++ b/src/SMESH_I/SMESH_Filter_i.cxx @@ -28,757 +28,926 @@ #include "SMESH_Filter_i.hxx" -#include "SMDS_Iterator.hxx" -#include "SMDS_MeshElement.hxx" -#include "SMDS_MeshNode.hxx" -#include "SMDSAbs_ElementType.hxx" #include "SMESH_Gen_i.hxx" + +#include "SMDS_Mesh.hxx" +#include "SMDS_MeshNode.hxx" +#include "SMDS_MeshElement.hxx" + #include "SMESHDS_Mesh.hxx" -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include #include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace SMESH; +using namespace SMESH::Controls; /* - AUXILIARY METHODS + Class : BelongToGeom + Description : Predicate for verifying whether entiy belong to + specified geometrical support */ -static inline double getAngle( const gp_XYZ& P1, const gp_XYZ& P2, const gp_XYZ& P3 ) -{ - return gp_Vec( P1 - P2 ).Angle( gp_Vec( P3 - P2 ) ); -} +Controls::BelongToGeom::BelongToGeom() +: myMeshDS(NULL), + myType(SMDSAbs_All) +{} -static inline double getArea( const gp_XYZ& P1, const gp_XYZ& P2, const gp_XYZ& P3 ) +void Controls::BelongToGeom::SetMesh( SMDS_Mesh* theMesh ) { - gp_Vec aVec1( P2 - P1 ); - gp_Vec aVec2( P3 - P1 ); - return ( aVec1 ^ aVec2 ).Magnitude() * 0.5; + myMeshDS = dynamic_cast(theMesh); } -static inline double getArea( const gp_Pnt& P1, const gp_Pnt& P2, const gp_Pnt& P3 ) +void Controls::BelongToGeom::SetGeom( const TopoDS_Shape& theShape ) { - return getArea( P1.XYZ(), P2.XYZ(), P3.XYZ() ); + myShape = theShape; } -static inline double getDistance( const gp_XYZ& P1, const gp_XYZ& P2 ) +static bool IsContains( SMESHDS_Mesh* theMeshDS, + const TopoDS_Shape& theShape, + const SMDS_MeshElement* theElem, + TopAbs_ShapeEnum theFindShapeEnum, + TopAbs_ShapeEnum theAvoidShapeEnum = TopAbs_SHAPE ) { - double aDist = gp_Pnt( P1 ).Distance( gp_Pnt( P2 ) ); - return aDist; + TopExp_Explorer anExp( theShape,theFindShapeEnum,theAvoidShapeEnum ); + + while( anExp.More() ) + { + const TopoDS_Shape& aShape = anExp.Current(); + if( SMESHDS_SubMesh* aSubMesh = theMeshDS->MeshElements( aShape ) ){ + if( aSubMesh->Contains( theElem ) ) + return true; + } + anExp.Next(); + } + return false; } -static int getNbMultiConnection( SMESHDS_Mesh* theMesh, const int theId ) +bool Controls::BelongToGeom::IsSatisfy( long theId ) { - if ( theMesh == 0 ) - return 0; - - const SMDS_MeshElement* anEdge = theMesh->FindElement( theId ); - if ( anEdge == 0 || anEdge->GetType() != SMDSAbs_Edge || anEdge->NbNodes() != 2 ) - return 0; - - TColStd_MapOfInteger aMap; + if ( myMeshDS == 0 || myShape.IsNull() ) + return false; - int aResult = 0; - SMDS_ElemIteratorPtr anIter = anEdge->nodesIterator(); - if ( anIter != 0 ) + if( myType == SMDSAbs_Node ) + { + if( const SMDS_MeshNode* aNode = myMeshDS->FindNode( theId ) ) + { + const SMDS_PositionPtr& aPosition = aNode->GetPosition(); + SMDS_TypeOfPosition aTypeOfPosition = aPosition->GetTypeOfPosition(); + switch( aTypeOfPosition ) + { + case SMDS_TOP_VERTEX : return IsContains( myMeshDS,myShape,aNode,TopAbs_VERTEX ); + case SMDS_TOP_EDGE : return IsContains( myMeshDS,myShape,aNode,TopAbs_EDGE ); + case SMDS_TOP_FACE : return IsContains( myMeshDS,myShape,aNode,TopAbs_FACE ); + case SMDS_TOP_3DSPACE: return IsContains( myMeshDS,myShape,aNode,TopAbs_SHELL ); + } + } + } + else { - while( anIter->more() ) + if( const SMDS_MeshElement* anElem = myMeshDS->FindElement( theId ) ) { - const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next(); - if ( aNode == 0 ) - return 0; - SMDS_ElemIteratorPtr anElemIter = aNode->GetInverseElementIterator(); - while( anElemIter->more() ) + if( myType == SMDSAbs_All ) { - const SMDS_MeshElement* anElem = anElemIter->next(); - if ( anElem != 0 && anElem->GetType() != SMDSAbs_Edge ) + return IsContains( myMeshDS,myShape,anElem,TopAbs_EDGE ) || + IsContains( myMeshDS,myShape,anElem,TopAbs_FACE ) || + IsContains( myMeshDS,myShape,anElem,TopAbs_SHELL )|| + IsContains( myMeshDS,myShape,anElem,TopAbs_SOLID ); + } + else if( myType == anElem->GetType() ) + { + switch( myType ) { - int anId = anElem->GetID(); - - if ( anIter->more() ) // i.e. first node - aMap.Add( anId ); - else if ( aMap.Contains( anId ) ) - aResult++; + case SMDSAbs_Edge : return IsContains( myMeshDS,myShape,anElem,TopAbs_EDGE ); + case SMDSAbs_Face : return IsContains( myMeshDS,myShape,anElem,TopAbs_FACE ); + case SMDSAbs_Volume: return IsContains( myMeshDS,myShape,anElem,TopAbs_SHELL )|| + IsContains( myMeshDS,myShape,anElem,TopAbs_SOLID ); } } -// delete anElemIter; } -// delete anIter; } + + return false; +} - return aResult; +void Controls::BelongToGeom::SetType( SMDSAbs_ElementType theType ) +{ + myType = theType; } -using namespace std; -using namespace SMESH; +SMDSAbs_ElementType Controls::BelongToGeom::GetType() const +{ + return myType; +} + +TopoDS_Shape Controls::BelongToGeom::GetShape() +{ + return myShape; +} + +SMESHDS_Mesh* Controls::BelongToGeom::GetMeshDS() +{ + return myMeshDS; +} -/* - FUNCTORS -*/ /* - Class : NumericalFunctor_i - Description : Base class for numerical functors + AUXILIARY METHODS */ -NumericalFunctor_i::NumericalFunctor_i() -: SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() ) +static inline SMDS_Mesh* MeshPtr2SMDSMesh( SMESH_Mesh_ptr theMesh ) { - myMesh = 0; - SMESH_Gen_i::GetPOA()->activate_object( this ); + SMESH_Mesh_i* anImplPtr = + dynamic_cast( SMESH_Gen_i::GetServant( theMesh ).in() ); + return anImplPtr ? anImplPtr->GetImpl().GetMeshDS() : 0; } -void NumericalFunctor_i::SetMesh( SMESH_Mesh_ptr theMesh ) +static inline SMESH::long_array* toArray( const TColStd_ListOfInteger& aList ) { - SMESH_Mesh_i* anImplPtr = - dynamic_cast( SMESH_Gen_i::GetServant( theMesh ).in() ); - myMesh = anImplPtr ? anImplPtr->GetImpl().GetMeshDS() : 0; + SMESH::long_array_var anArray = new SMESH::long_array; + anArray->length( aList.Extent() ); + TColStd_ListIteratorOfListOfInteger anIter( aList ); + int i = 0; + for( ; anIter.More(); anIter.Next() ) + anArray[ i++ ] = anIter.Value(); + + return anArray._retn(); } -bool NumericalFunctor_i::getPoints( const int theId, - TColgp_SequenceOfXYZ& theRes ) const +static inline SMESH::double_array* toArray( const TColStd_ListOfReal& aList ) { - theRes.Clear(); + SMESH::double_array_var anArray = new SMESH::double_array; + anArray->length( aList.Extent() ); + TColStd_ListIteratorOfListOfReal anIter( aList ); + int i = 0; + for( ; anIter.More(); anIter.Next() ) + anArray[ i++ ] = anIter.Value(); - if ( myMesh == 0 ) - return false; + return anArray._retn(); +} - // Get nodes of the face - const SMDS_MeshElement* anElem = myMesh->FindElement( theId ); - if ( anElem == 0 || anElem->GetType() != GetType() ) - return false; +static SMESH::Filter::Criterion createCriterion() +{ + SMESH::Filter::Criterion aCriterion; + + aCriterion.Type = FT_Undefined; + aCriterion.Compare = FT_Undefined; + aCriterion.Threshold = 0; + aCriterion.UnaryOp = FT_Undefined; + aCriterion.BinaryOp = FT_Undefined; + aCriterion.ThresholdStr = ""; + aCriterion.Tolerance = Precision::Confusion(); + aCriterion.TypeOfElement = SMESH::ALL; + aCriterion.Precision = -1; - int nbNodes = anElem->NbNodes(); + return aCriterion; +} - SMDS_ElemIteratorPtr anIter = anElem->nodesIterator(); - if ( anIter != 0 ) +static TopoDS_Shape getShapeByName( const char* theName ) +{ + if ( theName != 0 ) { - while( anIter->more() ) + SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); + SALOMEDS::Study_ptr aStudy = aSMESHGen->GetCurrentStudy(); + if ( aStudy != 0 ) { - const SMDS_MeshNode* aNode = (SMDS_MeshNode*)anIter->next(); - if ( aNode != 0 ) - theRes.Append( gp_XYZ( aNode->X(), aNode->Y(), aNode->Z() ) ); + SALOMEDS::Study::ListOfSObject_var aList = + aStudy->FindObjectByName( theName, "GEOM" ); + if ( aList->length() > 0 ) + { + GEOM::GEOM_Object_var aGeomObj = GEOM::GEOM_Object::_narrow( aList[ 0 ]->GetObject() ); + if ( !aGeomObj->_is_nil() ) + { + GEOM::GEOM_Gen_var aGEOMGen = SMESH_Gen_i::GetGeomEngine(); + TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, aGeomObj ); + return aLocShape; + } + } } - -// delete anIter; } - - return true; + return TopoDS_Shape(); } + /* - Class : SMESH_MinimumAngleFunct - Description : Functor for calculation of minimum angle + FUNCTORS */ -CORBA::Double MinimumAngle_i::GetValue( CORBA::Long theId ) +/* + Class : Functor_i + Description : An abstact class for all functors +*/ +Functor_i::Functor_i(): + SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() ) { - TColgp_SequenceOfXYZ P; - if ( !getPoints( theId, P ) || P.Length() != 3 && P.Length() != 4 ) - return 0; - - double aMin; - - if ( P.Length() == 3 ) - { - double A0 = getAngle( P( 3 ), P( 1 ), P( 2 ) ); - double A1 = getAngle( P( 1 ), P( 2 ), P( 3 ) ); - double A2 = getAngle( P( 2 ), P( 3 ), P( 1 ) ); + SMESH_Gen_i::GetPOA()->activate_object( this ); +} - aMin = Min( A0, Min( A1, A2 ) ); - } - else - { - double A0 = getAngle( P( 4 ), P( 1 ), P( 2 ) ); - double A1 = getAngle( P( 1 ), P( 2 ), P( 3 ) ); - double A2 = getAngle( P( 2 ), P( 3 ), P( 4 ) ); - double A3 = getAngle( P( 3 ), P( 4 ), P( 1 ) ); - - aMin = Min( Min( A0, A1 ), Min( A2, A3 ) ); - } - - return aMin * 180 / PI; +void Functor_i::SetMesh( SMESH_Mesh_ptr theMesh ) +{ + myFunctorPtr->SetMesh( MeshPtr2SMDSMesh( theMesh ) ); + INFOS("Functor_i::SetMesh~"); } -int MinimumAngle_i::GetType() const +ElementType Functor_i::GetElementType() { - return SMDSAbs_Face; + return ( ElementType )myFunctorPtr->GetType(); } + /* - Class : AspectRatio_i - Description : Functor for calculating aspect ratio + Class : NumericalFunctor_i + Description : Base class for numerical functors */ - -CORBA::Double AspectRatio_i::GetValue( CORBA::Long theId ) +CORBA::Double NumericalFunctor_i::GetValue( CORBA::Long theId ) { - TColgp_SequenceOfXYZ P; - if ( !getPoints( theId, P ) || P.Length() != 3 && P.Length() != 4 ) - return 0; - - int nbNodes = P.Length(); - - // Compute lengths of the sides - - double aLen[ nbNodes ]; - for ( int i = 0; i < nbNodes - 1; i++ ) - aLen[ i ] = getDistance( P( i + 1 ), P( i + 2 ) ); - aLen[ nbNodes - 1 ] = getDistance( P( 1 ), P( nbNodes ) ); - - // Compute aspect ratio + return myNumericalFunctorPtr->GetValue( theId ); +} - if ( nbNodes == 3 ) - { - double aMaxLen = Max( aLen[ 0 ], Max( aLen[ 1 ], aLen[ 2 ] ) ); - double anArea = getArea( P( 1 ), P( 2 ), P( 3 ) ); - static double aCoef = sqrt( 3. ) / 4; +void NumericalFunctor_i::SetPrecision( CORBA::Long thePrecision ) +{ + myNumericalFunctorPtr->SetPrecision( thePrecision ); +} - return anArea != 0 ? aCoef * aMaxLen * aMaxLen / anArea : 0; - } - else - { - double aMaxLen = Max( Max( aLen[ 0 ], aLen[ 1 ] ), Max( aLen[ 2 ], aLen[ 3 ] ) ); - double aMinLen = Min( Min( aLen[ 0 ], aLen[ 1 ] ), Min( aLen[ 2 ], aLen[ 3 ] ) ); - - return aMinLen != 0 ? aMaxLen / aMinLen : 0; - } +CORBA::Long NumericalFunctor_i::GetPrecision() +{ + return myNumericalFunctorPtr->GetPrecision(); } -int AspectRatio_i::GetType() const +Controls::NumericalFunctorPtr NumericalFunctor_i::GetNumericalFunctor() { - return SMDSAbs_Face; + return myNumericalFunctorPtr; } + /* - Class : Warping_i - Description : Functor for calculating warping + Class : SMESH_MinimumAngle + Description : Functor for calculation of minimum angle */ - -CORBA::Double Warping_i::GetValue( CORBA::Long theId ) +MinimumAngle_i::MinimumAngle_i() { - TColgp_SequenceOfXYZ P; - if ( !getPoints( theId, P ) || P.Length() != 4 ) - return 0; + myNumericalFunctorPtr.reset( new Controls::MinimumAngle() ); + myFunctorPtr = myNumericalFunctorPtr; +} - gp_XYZ G = ( P( 1 ) + P( 2 ) + P( 3 ) + P( 4 ) ) / 4; +FunctorType MinimumAngle_i::GetFunctorType() +{ + return SMESH::FT_MinimumAngle; +} - double A1 = ComputeA( P( 1 ), P( 2 ), P( 3 ), G ); - double A2 = ComputeA( P( 2 ), P( 3 ), P( 4 ), G ); - double A3 = ComputeA( P( 3 ), P( 4 ), P( 1 ), G ); - double A4 = ComputeA( P( 4 ), P( 1 ), P( 2 ), G ); - return Max( Max( A1, A2 ), Max( A3, A4 ) ); +/* + Class : AspectRatio + Description : Functor for calculating aspect ratio +*/ +AspectRatio_i::AspectRatio_i() +{ + myNumericalFunctorPtr.reset( new Controls::AspectRatio() ); + myFunctorPtr = myNumericalFunctorPtr; } -double Warping_i::ComputeA( const gp_XYZ& thePnt1, - const gp_XYZ& thePnt2, - const gp_XYZ& thePnt3, - const gp_XYZ& theG ) const +FunctorType AspectRatio_i::GetFunctorType() { - double aLen1 = gp_Pnt( thePnt1 ).Distance( gp_Pnt( thePnt2 ) ); - double aLen2 = gp_Pnt( thePnt2 ).Distance( gp_Pnt( thePnt3 ) ); - double L = Min( aLen1, aLen2 ) * 0.5; + return SMESH::FT_AspectRatio; +} - gp_XYZ GI = ( thePnt2 - thePnt1 ) / 2. - theG; - gp_XYZ GJ = ( thePnt3 - thePnt2 ) / 2. - theG; - gp_XYZ N = GI.Crossed( GJ ); - N.Normalize(); - double H = gp_Vec( thePnt2 - theG ).Dot( gp_Vec( N ) ); - return asin( fabs( H / L ) ) * 180 / PI; +/* + Class : Warping_i + Description : Functor for calculating warping +*/ +Warping_i::Warping_i() +{ + myNumericalFunctorPtr.reset( new Controls::Warping() ); + myFunctorPtr = myNumericalFunctorPtr; } -int Warping_i::GetType() const +FunctorType Warping_i::GetFunctorType() { - return SMDSAbs_Face; + return SMESH::FT_Warping; } + /* Class : Taper_i Description : Functor for calculating taper */ - -CORBA::Double Taper_i::GetValue( CORBA::Long theId ) +Taper_i::Taper_i() { - TColgp_SequenceOfXYZ P; - if ( !getPoints( theId, P ) || P.Length() != 4 ) - return 0; - - // Compute taper - double J1 = getArea( P( 4 ), P( 1 ), P( 2 ) ) / 2; - double J2 = getArea( P( 3 ), P( 1 ), P( 2 ) ) / 2; - double J3 = getArea( P( 2 ), P( 3 ), P( 4 ) ) / 2; - double J4 = getArea( P( 3 ), P( 4 ), P( 1 ) ) / 2; - - double JA = 0.25 * ( J1 + J2 + J3 + J4 ); - - double T1 = fabs( ( J1 - JA ) / JA ); - double T2 = fabs( ( J2 - JA ) / JA ); - double T3 = fabs( ( J3 - JA ) / JA ); - double T4 = fabs( ( J4 - JA ) / JA ); - - return Max( Max( T1, T2 ), Max( T3, T4 ) ); + myNumericalFunctorPtr.reset( new Controls::Taper() ); + myFunctorPtr = myNumericalFunctorPtr; } -int Taper_i::GetType() const +FunctorType Taper_i::GetFunctorType() { - return SMDSAbs_Face; + return SMESH::FT_Taper; } + /* Class : Skew_i Description : Functor for calculating skew in degrees */ - -static inline double skewAngle( const gp_XYZ& p1, const gp_XYZ& p2, const gp_XYZ& p3 ) -{ - gp_XYZ p12 = ( p2 + p1 ) / 2; - gp_XYZ p23 = ( p3 + p2 ) / 2; - gp_XYZ p31 = ( p3 + p1 ) / 2; - - return gp_Vec( p31 - p2 ).Angle( p12 - p23 ); -} - -CORBA::Double Skew_i::GetValue( CORBA::Long theId ) +Skew_i::Skew_i() { - TColgp_SequenceOfXYZ P; - if ( !getPoints( theId, P ) || P.Length() != 3 && P.Length() != 4 ) - return 0; - - // Compute skew - static double PI2 = PI / 2; - if ( P.Length() == 3 ) - { - double A0 = fabs( PI2 - skewAngle( P( 3 ), P( 1 ), P( 2 ) ) ); - double A1 = fabs( PI2 - skewAngle( P( 1 ), P( 2 ), P( 3 ) ) ); - double A2 = fabs( PI2 - skewAngle( P( 2 ), P( 3 ), P( 1 ) ) ); - - return Max( A0, Max( A1, A2 ) ) * 180 / PI; - } - else - { - gp_XYZ p12 = ( P( 1 ) + P( 2 ) ) / 2; - gp_XYZ p23 = ( P( 2 ) + P( 3 ) ) / 2; - gp_XYZ p34 = ( P( 3 ) + P( 4 ) ) / 2; - gp_XYZ p41 = ( P( 4 ) + P( 1 ) ) / 2; - - double A = fabs( PI2 - gp_Vec( p34 - p12 ).Angle( p23 - p41 ) ); - - return A * 180 / PI; - } + myNumericalFunctorPtr.reset( new Controls::Skew() ); + myFunctorPtr = myNumericalFunctorPtr; } -int Skew_i::GetType() const +FunctorType Skew_i::GetFunctorType() { - return SMDSAbs_Face; + return SMESH::FT_Skew; } /* Class : Area_i Description : Functor for calculating area */ - -CORBA::Double Area_i::GetValue( CORBA::Long theId ) +Area_i::Area_i() { - TColgp_SequenceOfXYZ P; - if ( !getPoints( theId, P ) || P.Length() != 3 && P.Length() != 4 ) - return 0; - - if ( P.Length() == 3 ) - return getArea( P( 1 ), P( 2 ), P( 3 ) ); - else - return getArea( P( 1 ), P( 2 ), P( 3 ) ) + getArea( P( 1 ), P( 3 ), P( 4 ) ); + myNumericalFunctorPtr.reset( new Controls::Area() ); + myFunctorPtr = myNumericalFunctorPtr; } -int Area_i::GetType() const +FunctorType Area_i::GetFunctorType() { - return SMDSAbs_Face; + return SMESH::FT_Area; } /* Class : Length_i Description : Functor for calculating length off edge */ - -CORBA::Double Length_i::GetValue( CORBA::Long theId ) +Length_i::Length_i() { - TColgp_SequenceOfXYZ P; - return getPoints( theId, P ) && P.Length() == 2 ? getDistance( P( 1 ), P( 2 ) ) : 0; + myNumericalFunctorPtr.reset( new Controls::Length() ); + myFunctorPtr = myNumericalFunctorPtr; } -int Length_i::GetType() const +FunctorType Length_i::GetFunctorType() { - return SMDSAbs_Edge; + return SMESH::FT_Length; } /* Class : MultiConnection_i Description : Functor for calculating number of faces conneted to the edge */ - -CORBA::Double MultiConnection_i::GetValue( CORBA::Long theId ) +MultiConnection_i::MultiConnection_i() { - return getNbMultiConnection( myMesh, theId ); + myNumericalFunctorPtr.reset( new Controls::MultiConnection() ); + myFunctorPtr = myNumericalFunctorPtr; } -int MultiConnection_i::GetType() const +FunctorType MultiConnection_i::GetFunctorType() { - return SMDSAbs_Edge; + return SMESH::FT_MultiConnection; } + /* PREDICATES */ + /* Class : Predicate_i Description : Base class for all predicates */ -Predicate_i::Predicate_i() -: SALOME::GenericObj_i( SMESH_Gen_i::GetPOA() ) +CORBA::Boolean Predicate_i::IsSatisfy( CORBA::Long theId ) { - SMESH_Gen_i::GetPOA()->activate_object( this ); + return myPredicatePtr->IsSatisfy( theId ); +} + +Controls::PredicatePtr Predicate_i::GetPredicate() +{ + return myPredicatePtr; } /* - Class : FreeBorders_i - Description : Predicate for free borders + Class : BelongToGeom_i + Description : Predicate for selection on geometrical support */ +BelongToGeom_i::BelongToGeom_i() +{ + myBelongToGeomPtr.reset( new Controls::BelongToGeom() ); + myFunctorPtr = myPredicatePtr = myBelongToGeomPtr; + myShapeName = 0; +} -FreeBorders_i::FreeBorders_i() +BelongToGeom_i::~BelongToGeom_i() { - myMesh = 0; + delete myShapeName; } -void FreeBorders_i::SetMesh( SMESH_Mesh_ptr theMesh ) +void BelongToGeom_i::SetGeom( GEOM::GEOM_Object_ptr theGeom ) { - SMESH_Mesh_i* anImplPtr = - dynamic_cast( SMESH_Gen_i::GetServant( theMesh ).in() ); - myMesh = anImplPtr ? anImplPtr->GetImpl().GetMeshDS() : 0; + if ( theGeom->_is_nil() ) + return; + SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); + GEOM::GEOM_Gen_var aGEOMGen = SMESH_Gen_i::GetGeomEngine(); + TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom ); + myBelongToGeomPtr->SetGeom( aLocShape ); } -CORBA::Boolean FreeBorders_i::IsSatisfy( CORBA::Long theId ) +void BelongToGeom_i::SetGeom( const TopoDS_Shape& theShape ) { - return getNbMultiConnection( myMesh, theId ) == 1; + myBelongToGeomPtr->SetGeom( theShape ); +} + +void BelongToGeom_i::SetElementType(ElementType theType){ + myBelongToGeomPtr->SetType(SMDSAbs_ElementType(theType)); } -int FreeBorders_i::GetType() const +FunctorType BelongToGeom_i::GetFunctorType() { - return SMDSAbs_Edge; + return SMESH::FT_BelongToGeom; } -/* - Class : Comparator_i - Description : Base class for comparators -*/ +void BelongToGeom_i::SetShapeName( const char* theName ) +{ + delete myShapeName; + myShapeName = strdup( theName ); + myBelongToGeomPtr->SetGeom( getShapeByName( myShapeName ) ); +} -Comparator_i::Comparator_i() +char* BelongToGeom_i::GetShapeName() { - myMargin = 0; - myFunctor = 0; + return CORBA::string_dup( myShapeName ); } -Comparator_i::~Comparator_i() +/* + Class : BelongToSurface_i + Description : Predicate for selection on geometrical support +*/ +BelongToSurface_i::BelongToSurface_i( const Handle(Standard_Type)& theSurfaceType ) { - if ( myFunctor != 0 ) - myFunctor->Destroy(); + myElementsOnSurfacePtr.reset( new Controls::ElementsOnSurface() ); + myFunctorPtr = myPredicatePtr = myElementsOnSurfacePtr; + myShapeName = 0; + mySurfaceType = theSurfaceType; } -void Comparator_i::SetMesh( SMESH_Mesh_ptr theMesh ) +BelongToSurface_i::~BelongToSurface_i() { - if ( myFunctor != 0 ) - myFunctor->SetMesh( theMesh ); + delete myShapeName; } -void Comparator_i::SetMargin( CORBA::Double theValue ) +void BelongToSurface_i::SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType ) { - myMargin = theValue; + if ( theGeom->_is_nil() ) + return; + SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); + GEOM::GEOM_Gen_var aGEOMGen = SMESH_Gen_i::GetGeomEngine(); + TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom ); + + if ( aLocShape.ShapeType() == TopAbs_FACE ) + { + Handle(Geom_Surface) aSurf = BRep_Tool::Surface( TopoDS::Face( aLocShape ) ); + if ( !aSurf.IsNull() && aSurf->DynamicType() == mySurfaceType ) + { + myElementsOnSurfacePtr->SetSurface( aLocShape, (SMDSAbs_ElementType)theType ); + return; + } + } + + myElementsOnSurfacePtr->SetSurface( TopoDS_Shape(), (SMDSAbs_ElementType)theType ); } -void Comparator_i::SetNumFunctor( NumericalFunctor_ptr theFunct ) +void BelongToSurface_i::SetShapeName( const char* theName, ElementType theType ) { - if ( myFunctor != 0 ) - myFunctor->Destroy(); + delete myShapeName; + myShapeName = strdup( theName ); + myElementsOnSurfacePtr->SetSurface( getShapeByName( myShapeName ), (SMDSAbs_ElementType)theType ); +} - myFunctor = dynamic_cast( SMESH_Gen_i::GetServant( theFunct ).in() ); +char* BelongToSurface_i::GetShapeName() +{ + return CORBA::string_dup( myShapeName ); +} - if ( myFunctor != 0 ) - myFunctor->Register(); +void BelongToSurface_i::SetTolerance( CORBA::Double theToler ) +{ + myElementsOnSurfacePtr->SetTolerance( theToler ); } -int Comparator_i::GetType() const +CORBA::Double BelongToSurface_i::GetTolerance() { - return myFunctor != 0 ? myFunctor->GetType() : SMDSAbs_All; + return myElementsOnSurfacePtr->GetTolerance(); } /* - Class : LessThan_i - Description : Comparator "<" + Class : BelongToPlane_i + Description : Verify whether mesh element lie in pointed Geom planar object */ -CORBA::Boolean LessThan_i::IsSatisfy( CORBA::Long theId ) +BelongToPlane_i::BelongToPlane_i() +: BelongToSurface_i( STANDARD_TYPE( Geom_Plane ) ) { - return myFunctor != 0 && myFunctor->GetValue( theId ) < myMargin; } -/* - Class : MoreThan_i - Description : Comparator ">" -*/ +void BelongToPlane_i::SetPlane( GEOM::GEOM_Object_ptr theGeom, ElementType theType ) +{ + BelongToSurface_i::SetSurface( theGeom, theType ); +} -CORBA::Boolean MoreThan_i::IsSatisfy( CORBA::Long theId ) +FunctorType BelongToPlane_i::GetFunctorType() { - return myFunctor != 0 && myFunctor->GetValue( theId ) > myMargin; + return FT_BelongToPlane; } /* - Class : EqualTo_i - Description : Comparator "=" + Class : BelongToCylinder_i + Description : Verify whether mesh element lie in pointed Geom planar object */ -EqualTo_i::EqualTo_i() + +BelongToCylinder_i::BelongToCylinder_i() +: BelongToSurface_i( STANDARD_TYPE( Geom_CylindricalSurface ) ) { - myToler = Precision::Confusion(); } -CORBA::Boolean EqualTo_i::IsSatisfy( CORBA::Long theId ) +void BelongToCylinder_i::SetCylinder( GEOM::GEOM_Object_ptr theGeom, ElementType theType ) { - return myFunctor != 0 && fabs( myFunctor->GetValue( theId ) - myMargin ) < myToler; + BelongToSurface_i::SetSurface( theGeom, theType ); } -void EqualTo_i::SetTolerance( CORBA::Double theToler ) +FunctorType BelongToCylinder_i::GetFunctorType() { - myToler = theToler; + return FT_BelongToCylinder; } + /* - Class : LogicalNOT_i - Description : Logical NOT predicate + Class : FreeBorders_i + Description : Predicate for free borders */ - -LogicalNOT_i::LogicalNOT_i() +FreeBorders_i::FreeBorders_i() { - myPredicate = 0; + myPredicatePtr.reset(new Controls::FreeBorders()); + myFunctorPtr = myPredicatePtr; } -LogicalNOT_i::~LogicalNOT_i() +FunctorType FreeBorders_i::GetFunctorType() { - if ( myPredicate ) - myPredicate->Destroy(); + return SMESH::FT_FreeBorders; } -CORBA::Boolean LogicalNOT_i::IsSatisfy( CORBA::Long theId ) +/* + Class : FreeEdges_i + Description : Predicate for free borders +*/ +FreeEdges_i::FreeEdges_i() +: myFreeEdgesPtr( new Controls::FreeEdges() ) { - return myPredicate !=0 && !myPredicate->IsSatisfy( theId ); + myFunctorPtr = myPredicatePtr = myFreeEdgesPtr; } -void LogicalNOT_i::SetMesh( SMESH_Mesh_ptr theMesh ) +SMESH::FreeEdges::Borders* FreeEdges_i::GetBorders() { - if ( myPredicate != 0 ) - myPredicate->SetMesh( theMesh ); -} + INFOS("FreeEdges_i::GetBorders"); + SMESH::Controls::FreeEdges::TBorders aBorders; + myFreeEdgesPtr->GetBoreders( aBorders ); + + long i = 0, iEnd = aBorders.size(); -void LogicalNOT_i::SetPredicate( Predicate_ptr thePred ) -{ - if ( myPredicate != 0 ) - myPredicate->Destroy(); + SMESH::FreeEdges::Borders_var aResult = new SMESH::FreeEdges::Borders(iEnd); - myPredicate = dynamic_cast( SMESH_Gen_i::GetServant( thePred ).in() ); + SMESH::Controls::FreeEdges::TBorders::const_iterator anIter; + for ( anIter = aBorders.begin() ; anIter != aBorders.end(); anIter++, i++ ) + { + const SMESH::Controls::FreeEdges::Border& aBord = *anIter; + SMESH::FreeEdges::Border &aBorder = aResult[ i ]; + + aBorder.myElemId = aBord.myElemId; + aBorder.myPnt1 = aBord.myPntId[ 0 ]; + aBorder.myPnt2 = aBord.myPntId[ 1 ]; + } - if ( myPredicate != 0 ) - myPredicate->Register(); + INFOS("FreeEdges_i::GetBorders~"); + return aResult._retn(); } -int LogicalNOT_i::GetType() const +FunctorType FreeEdges_i::GetFunctorType() { - return myPredicate != 0 ? myPredicate->GetType() : SMDSAbs_All; + return SMESH::FT_FreeEdges; } - /* - Class : LogicalBinary_i - Description : Base class for binary logical predicate + Class : RangeOfIds_i + Description : Predicate for Range of Ids. + Range may be specified with two ways. + 1. Using AddToRange method + 2. With SetRangeStr method. Parameter of this method is a string + like as "1,2,3,50-60,63,67,70-" */ -LogicalBinary_i::LogicalBinary_i() +RangeOfIds_i::RangeOfIds_i() { - myPredicate1 = 0; - myPredicate2 = 0; + myRangeOfIdsPtr.reset( new Controls::RangeOfIds() ); + myFunctorPtr = myPredicatePtr = myRangeOfIdsPtr; } -LogicalBinary_i::~LogicalBinary_i() + +void RangeOfIds_i::SetRange( const SMESH::long_array& theIds ) { - if ( myPredicate1 != 0 ) - myPredicate1->Destroy(); + CORBA::Long iEnd = theIds.length(); + for ( CORBA::Long i = 0; i < iEnd; i++ ) + myRangeOfIdsPtr->AddToRange( theIds[ i ] ); +} - if ( myPredicate2 != 0 ) - myPredicate2->Destroy(); +CORBA::Boolean RangeOfIds_i::SetRangeStr( const char* theRange ) +{ + return myRangeOfIdsPtr->SetRangeStr( + TCollection_AsciiString( (Standard_CString)theRange ) ); } -void LogicalBinary_i::SetMesh( SMESH_Mesh_ptr theMesh ) +char* RangeOfIds_i::GetRangeStr() { - if ( myPredicate1 != 0 ) - myPredicate1->SetMesh( theMesh ); + TCollection_AsciiString aStr; + myRangeOfIdsPtr->GetRangeStr( aStr ); + return CORBA::string_dup( aStr.ToCString() ); +} - if ( myPredicate2 != 0 ) - myPredicate2->SetMesh( theMesh ); +void RangeOfIds_i::SetElementType( ElementType theType ) +{ + myRangeOfIdsPtr->SetType( SMDSAbs_ElementType( theType ) ); } -void LogicalBinary_i::SetPredicate1( Predicate_ptr thePredicate ) +FunctorType RangeOfIds_i::GetFunctorType() { - if ( myPredicate1 != 0 ) - myPredicate1->Destroy(); + return SMESH::FT_RangeOfIds; +} - myPredicate1 = dynamic_cast( SMESH_Gen_i::GetServant( thePredicate ).in() ); +/* + Class : Comparator_i + Description : Base class for comparators +*/ +Comparator_i::Comparator_i(): + myNumericalFunctor( NULL ) +{} - if ( myPredicate1 != 0 ) - myPredicate1->Register(); +Comparator_i::~Comparator_i() +{ + if ( myNumericalFunctor ) + myNumericalFunctor->Destroy(); } -void LogicalBinary_i::SetPredicate2( Predicate_ptr thePredicate ) +void Comparator_i::SetMargin( CORBA::Double theValue ) { - if ( myPredicate2 != 0 ) - myPredicate2->Destroy(); - - myPredicate2 = dynamic_cast( SMESH_Gen_i::GetServant( thePredicate ).in() ); + myComparatorPtr->SetMargin( theValue ); +} - if ( myPredicate2 != 0 ) - myPredicate2->Register(); +CORBA::Double Comparator_i::GetMargin() +{ + return myComparatorPtr->GetMargin(); } -int LogicalBinary_i::GetType() const +void Comparator_i::SetNumFunctor( NumericalFunctor_ptr theFunct ) { - if ( myPredicate1 == 0 || myPredicate2 == 0 ) - return SMDSAbs_All; + if ( myNumericalFunctor ) + myNumericalFunctor->Destroy(); - int aType1 = myPredicate1->GetType(); - int aType2 = myPredicate2->GetType(); + myNumericalFunctor = dynamic_cast( SMESH_Gen_i::GetServant( theFunct ).in() ); - return aType1 == aType2 ? aType1 : SMDSAbs_All; + if ( myNumericalFunctor ) + { + myComparatorPtr->SetNumFunctor( myNumericalFunctor->GetNumericalFunctor() ); + myNumericalFunctor->Register(); + } +} + +Controls::ComparatorPtr Comparator_i::GetComparator() +{ + return myComparatorPtr; +} + +NumericalFunctor_i* Comparator_i::GetNumFunctor_i() +{ + return myNumericalFunctor; } + /* - Class : LogicalAND_i - Description : Logical AND + Class : LessThan_i + Description : Comparator "<" */ +LessThan_i::LessThan_i() +{ + myComparatorPtr.reset( new Controls::LessThan() ); + myFunctorPtr = myPredicatePtr = myComparatorPtr; +} -CORBA::Boolean LogicalAND_i::IsSatisfy( CORBA::Long theId ) +FunctorType LessThan_i::GetFunctorType() { - return myPredicate1 != 0 && - myPredicate2 != 0 && - myPredicate1->IsSatisfy( theId ) && myPredicate2->IsSatisfy( theId );; + return SMESH::FT_LessThan; } + /* - Class : LogicalOR_i - Description : Logical OR + Class : MoreThan_i + Description : Comparator ">" */ +MoreThan_i::MoreThan_i() +{ + myComparatorPtr.reset( new Controls::MoreThan() ); + myFunctorPtr = myPredicatePtr = myComparatorPtr; +} -CORBA::Boolean LogicalOR_i::IsSatisfy( CORBA::Long theId ) +FunctorType MoreThan_i::GetFunctorType() { - return myPredicate1 != 0 && - myPredicate2 != 0 && - myPredicate1->IsSatisfy( theId ) || myPredicate2->IsSatisfy( theId ); + return SMESH::FT_MoreThan; } /* - FILTER + Class : EqualTo_i + Description : Comparator "=" */ +EqualTo_i::EqualTo_i() +: myEqualToPtr( new Controls::EqualTo() ) +{ + myFunctorPtr = myPredicatePtr = myComparatorPtr = myEqualToPtr; +} -Filter_i::Filter_i() +void EqualTo_i::SetTolerance( CORBA::Double theToler ) { - myPredicate = 0; + myEqualToPtr->SetTolerance( theToler ); } -Filter_i::~Filter_i() +CORBA::Double EqualTo_i::GetTolerance() { - if ( myPredicate != 0 ) + return myEqualToPtr->GetTolerance(); +} + +FunctorType EqualTo_i::GetFunctorType() +{ + return SMESH::FT_EqualTo; +} + +/* + Class : LogicalNOT_i + Description : Logical NOT predicate +*/ +LogicalNOT_i::LogicalNOT_i() +: myPredicate( NULL ), + myLogicalNOTPtr( new Controls::LogicalNOT() ) +{ + myFunctorPtr = myPredicatePtr = myLogicalNOTPtr; +} + +LogicalNOT_i::~LogicalNOT_i() +{ + if ( myPredicate ) myPredicate->Destroy(); } -void Filter_i::SetPredicate( Predicate_ptr thePredicate ) +void LogicalNOT_i::SetPredicate( Predicate_ptr thePred ) { - if ( myPredicate != 0 ) + if ( myPredicate ) myPredicate->Destroy(); - myPredicate = dynamic_cast( SMESH_Gen_i::GetServant( thePredicate ).in() ); + myPredicate = dynamic_cast( SMESH_Gen_i::GetServant( thePred ).in() ); - if ( myPredicate != 0 ) + if ( myPredicate ){ + myLogicalNOTPtr->SetPredicate(myPredicate->GetPredicate()); myPredicate->Register(); + } } -void Filter_i::SetMesh( SMESH_Mesh_ptr theMesh ) +FunctorType LogicalNOT_i::GetFunctorType() { - if ( myPredicate != 0 ) - myPredicate->SetMesh( theMesh ); + return SMESH::FT_LogicalNOT; } -SMESH::long_array* Filter_i::GetElementsId( SMESH_Mesh_ptr theMesh ) +Predicate_i* LogicalNOT_i::GetPredicate_i() { + return myPredicate; +} - SetMesh( theMesh ); - SMESH_Mesh_i* anImplPtr = - dynamic_cast( SMESH_Gen_i::GetServant( theMesh ).in() ); +/* + Class : LogicalBinary_i + Description : Base class for binary logical predicate +*/ +LogicalBinary_i::LogicalBinary_i() +: myPredicate1( NULL ), + myPredicate2( NULL ) +{} - TColStd_ListOfInteger aList; +LogicalBinary_i::~LogicalBinary_i() +{ + if ( myPredicate1 ) + myPredicate1->Destroy(); - if ( anImplPtr != 0 ) - { - SMESHDS_Mesh* aMesh = anImplPtr->GetImpl().GetMeshDS(); + if ( myPredicate2 ) + myPredicate2->Destroy(); +} - if ( myPredicate != 0 ) - { - int aType = myPredicate->GetType(); - - if ( aType == SMDSAbs_Edge ) - { - SMDS_EdgeIteratorPtr anIter = aMesh->edgesIterator(); - if ( anIter != 0 ) - { - while( anIter->more() ) - { - const SMDS_MeshElement* anElem = anIter->next(); - if ( myPredicate->IsSatisfy( anElem->GetID() ) ) - aList.Append( anElem->GetID() ); - } - } -// delete anIter; - } - else if ( aType == SMDSAbs_Face ) - { - SMDS_FaceIteratorPtr anIter = aMesh->facesIterator(); - if ( anIter != 0 ) - { - while( anIter->more() ) - { - const SMDS_MeshElement* anElem = anIter->next(); - if ( myPredicate->IsSatisfy( anElem->GetID() ) ) - aList.Append( anElem->GetID() ); - } - } -// delete anIter; - } - } +void LogicalBinary_i::SetMesh( SMESH_Mesh_ptr theMesh ) +{ + if ( myPredicate1 ) + myPredicate1->SetMesh( theMesh ); + + if ( myPredicate2 ) + myPredicate2->SetMesh( theMesh ); +} + +void LogicalBinary_i::SetPredicate1( Predicate_ptr thePredicate ) +{ + if ( myPredicate1 ) + myPredicate1->Destroy(); + + myPredicate1 = dynamic_cast( SMESH_Gen_i::GetServant( thePredicate ).in() ); + + if ( myPredicate1 ){ + myLogicalBinaryPtr->SetPredicate1(myPredicate1->GetPredicate()); + myPredicate1->Register(); } - - SMESH::long_array_var anArray = new SMESH::long_array; - - anArray->length( aList.Extent() ); - TColStd_ListIteratorOfListOfInteger anIter( aList ); - int i = 0; - for( ; anIter.More(); anIter.Next() ) - anArray[ i++ ] = anIter.Value(); +} - return anArray._retn(); +void LogicalBinary_i::SetPredicate2( Predicate_ptr thePredicate ) +{ + if ( myPredicate2 ) + myPredicate2->Destroy(); + + myPredicate2 = dynamic_cast( SMESH_Gen_i::GetServant( thePredicate ).in() ); + + if ( myPredicate2 ){ + myLogicalBinaryPtr->SetPredicate2(myPredicate2->GetPredicate()); + myPredicate2->Register(); + } +} + +Controls::LogicalBinaryPtr LogicalBinary_i::GetLogicalBinary() +{ + return myLogicalBinaryPtr; +} + +Predicate_i* LogicalBinary_i::GetPredicate1_i() +{ + return myPredicate1; +} +Predicate_i* LogicalBinary_i::GetPredicate2_i() +{ + return myPredicate2; +} + + +/* + Class : LogicalAND_i + Description : Logical AND +*/ +LogicalAND_i::LogicalAND_i() +{ + myLogicalBinaryPtr.reset( new Controls::LogicalAND() ); + myFunctorPtr = myPredicatePtr = myLogicalBinaryPtr; +} + +FunctorType LogicalAND_i::GetFunctorType() +{ + return SMESH::FT_LogicalAND; +} + + +/* + Class : LogicalOR_i + Description : Logical OR +*/ +LogicalOR_i::LogicalOR_i() +{ + myLogicalBinaryPtr.reset( new Controls::LogicalOR() ); + myFunctorPtr = myPredicatePtr = myLogicalBinaryPtr; } +FunctorType LogicalOR_i::GetFunctorType() +{ + return SMESH::FT_LogicalOR; +} + + /* FILTER MANAGER */ @@ -853,6 +1022,27 @@ MultiConnection_ptr FilterManager_i::CreateMultiConnection() } +BelongToGeom_ptr FilterManager_i::CreateBelongToGeom() +{ + SMESH::BelongToGeom_i* aServant = new SMESH::BelongToGeom_i(); + SMESH::BelongToGeom_var anObj = aServant->_this(); + return anObj._retn(); +} + +BelongToPlane_ptr FilterManager_i::CreateBelongToPlane() +{ + SMESH::BelongToPlane_i* aServant = new SMESH::BelongToPlane_i(); + SMESH::BelongToPlane_var anObj = aServant->_this(); + return anObj._retn(); +} + +BelongToCylinder_ptr FilterManager_i::CreateBelongToCylinder() +{ + SMESH::BelongToCylinder_i* aServant = new SMESH::BelongToCylinder_i(); + SMESH::BelongToCylinder_var anObj = aServant->_this(); + return anObj._retn(); +} + FreeBorders_ptr FilterManager_i::CreateFreeBorders() { SMESH::FreeBorders_i* aServant = new SMESH::FreeBorders_i(); @@ -860,6 +1050,20 @@ FreeBorders_ptr FilterManager_i::CreateFreeBorders() return anObj._retn(); } +FreeEdges_ptr FilterManager_i::CreateFreeEdges() +{ + SMESH::FreeEdges_i* aServant = new SMESH::FreeEdges_i(); + SMESH::FreeEdges_var anObj = aServant->_this(); + return anObj._retn(); +} + +RangeOfIds_ptr FilterManager_i::CreateRangeOfIds() +{ + SMESH::RangeOfIds_i* aServant = new SMESH::RangeOfIds_i(); + SMESH::RangeOfIds_var anObj = aServant->_this(); + return anObj._retn(); +} + LessThan_ptr FilterManager_i::CreateLessThan() { SMESH::LessThan_i* aServant = new SMESH::LessThan_i(); @@ -912,3 +1116,1111 @@ Filter_ptr FilterManager_i::CreateFilter() SMESH::Filter_var anObj = aServant->_this(); return anObj._retn(); } + +FilterLibrary_ptr FilterManager_i::LoadLibrary( const char* aFileName ) +{ + SMESH::FilterLibrary_i* aServant = new SMESH::FilterLibrary_i( aFileName ); + SMESH::FilterLibrary_var anObj = aServant->_this(); + return anObj._retn(); +} + +FilterLibrary_ptr FilterManager_i::CreateLibrary() +{ + SMESH::FilterLibrary_i* aServant = new SMESH::FilterLibrary_i(); + SMESH::FilterLibrary_var anObj = aServant->_this(); + return anObj._retn(); +} + +CORBA::Boolean FilterManager_i::DeleteLibrary( const char* aFileName ) +{ + return remove( aFileName ) ? false : true; +} + +//============================================================================= +/*! + * SMESH_Gen_i::CreateFilterManager + * + * Create filter manager + */ +//============================================================================= + +SMESH::FilterManager_ptr SMESH_Gen_i::CreateFilterManager() +{ + SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i(); + SMESH::FilterManager_var anObj = aFilter->_this(); + return anObj._retn(); +} + + +/* + FILTER +*/ + +//======================================================================= +// name : Filter_i::Filter_i +// Purpose : Constructor +//======================================================================= +Filter_i::Filter_i() +: myPredicate( NULL ) +{} + +//======================================================================= +// name : Filter_i::~Filter_i +// Purpose : Destructor +//======================================================================= +Filter_i::~Filter_i() +{ + if ( myPredicate ) + myPredicate->Destroy(); +} + +//======================================================================= +// name : Filter_i::SetPredicate +// Purpose : Set predicate +//======================================================================= +void Filter_i::SetPredicate( Predicate_ptr thePredicate ) +{ + if ( myPredicate ) + myPredicate->Destroy(); + + myPredicate = dynamic_cast( SMESH_Gen_i::GetServant( thePredicate ).in() ); + + if ( myPredicate ) + { + myFilter.SetPredicate( myPredicate->GetPredicate() ); + myPredicate->Register(); + } +} + +//======================================================================= +// name : Filter_i::GetElementType +// Purpose : Get entity type +//======================================================================= +SMESH::ElementType Filter_i::GetElementType() +{ + return myPredicate != 0 ? myPredicate->GetElementType() : SMESH::ALL; +} + +//======================================================================= +// name : Filter_i::SetMesh +// Purpose : Set mesh +//======================================================================= +void Filter_i::SetMesh( SMESH_Mesh_ptr theMesh ) +{ + if ( myPredicate ) + myPredicate->SetMesh( theMesh ); +} + +//======================================================================= +// name : Filter_i::GetElementsId +// Purpose : Get ids of entities +//======================================================================= +SMESH::long_array* Filter_i::GetElementsId( SMESH_Mesh_ptr theMesh ) +{ + SMDS_Mesh* aMesh = MeshPtr2SMDSMesh(theMesh); + Controls::Filter::TIdSequence aSequence = myFilter.GetElementsId(aMesh); + + SMESH::long_array_var anArray = new SMESH::long_array; + long i = 0, iEnd = aSequence.size(); + + anArray->length( iEnd ); + for ( ; i < iEnd; i++ ) + anArray[ i ] = aSequence[i]; + + return anArray._retn(); +} + +//======================================================================= +// name : getCriteria +// Purpose : Retrieve criterions from predicate +//======================================================================= +static inline bool getCriteria( Predicate_i* thePred, + SMESH::Filter::Criteria_out theCriteria ) +{ + int aFType = thePred->GetFunctorType(); + + switch ( aFType ) + { + case FT_FreeBorders: + case FT_FreeEdges: + { + CORBA::ULong i = theCriteria->length(); + theCriteria->length( i + 1 ); + + theCriteria[ i ] = createCriterion(); + + theCriteria[ i ].Type = aFType; + theCriteria[ i ].TypeOfElement = thePred->GetElementType(); + return true; + } + case FT_BelongToGeom: + { + BelongToGeom_i* aPred = dynamic_cast( thePred ); + + CORBA::ULong i = theCriteria->length(); + theCriteria->length( i + 1 ); + + theCriteria[ i ] = createCriterion(); + + theCriteria[ i ].Type = FT_BelongToGeom; + theCriteria[ i ].ThresholdStr = aPred->GetShapeName(); + theCriteria[ i ].TypeOfElement = aPred->GetElementType(); + + return true; + } + case FT_BelongToPlane: + case FT_BelongToCylinder: + { + BelongToSurface_i* aPred = dynamic_cast( thePred ); + + CORBA::ULong i = theCriteria->length(); + theCriteria->length( i + 1 ); + + theCriteria[ i ] = createCriterion(); + + theCriteria[ i ].Type = aFType; + theCriteria[ i ].ThresholdStr = aPred->GetShapeName(); + theCriteria[ i ].TypeOfElement = aPred->GetElementType(); + theCriteria[ i ].Tolerance = aPred->GetTolerance(); + + return true; + } + case FT_RangeOfIds: + { + RangeOfIds_i* aPred = dynamic_cast( thePred ); + + CORBA::ULong i = theCriteria->length(); + theCriteria->length( i + 1 ); + + theCriteria[ i ] = createCriterion(); + + theCriteria[ i ].Type = FT_RangeOfIds; + theCriteria[ i ].ThresholdStr = aPred->GetRangeStr(); + theCriteria[ i ].TypeOfElement = aPred->GetElementType(); + + return true; + } + case FT_LessThan: + case FT_MoreThan: + case FT_EqualTo: + { + Comparator_i* aCompar = dynamic_cast( thePred ); + + CORBA::ULong i = theCriteria->length(); + theCriteria->length( i + 1 ); + + theCriteria[ i ] = createCriterion(); + + theCriteria[ i ].Type = aCompar->GetNumFunctor_i()->GetFunctorType(); + theCriteria[ i ].Compare = aFType; + theCriteria[ i ].Threshold = aCompar->GetMargin(); + theCriteria[ i ].TypeOfElement = aCompar->GetElementType(); + + if ( aFType == FT_EqualTo ) + { + EqualTo_i* aCompar = dynamic_cast( thePred ); + theCriteria[ i ].Tolerance = aCompar->GetTolerance(); + } + } + return true; + + case FT_LogicalNOT: + { + Predicate_i* aPred = ( dynamic_cast( thePred ) )->GetPredicate_i(); + getCriteria( aPred, theCriteria ); + theCriteria[ theCriteria->length() - 1 ].UnaryOp = FT_LogicalNOT; + } + return true; + + case FT_LogicalAND: + case FT_LogicalOR: + { + Predicate_i* aPred1 = ( dynamic_cast( thePred ) )->GetPredicate1_i(); + Predicate_i* aPred2 = ( dynamic_cast( thePred ) )->GetPredicate2_i(); + if ( !getCriteria( aPred1, theCriteria ) ) + return false; + theCriteria[ theCriteria->length() - 1 ].BinaryOp = aFType; + return getCriteria( aPred2, theCriteria ); + } + + case FT_Undefined: + return false; + default: + return false; + } +} + +//======================================================================= +// name : Filter_i::GetCriteria +// Purpose : Retrieve criterions from predicate +//======================================================================= +CORBA::Boolean Filter_i::GetCriteria( SMESH::Filter::Criteria_out theCriteria ) +{ + theCriteria = new SMESH::Filter::Criteria; + return myPredicate != 0 ? getCriteria( myPredicate, theCriteria ) : true; +} + +//======================================================================= +// name : Filter_i::SetCriteria +// Purpose : Create new predicate and set criterions in it +//======================================================================= +CORBA::Boolean Filter_i::SetCriteria( const SMESH::Filter::Criteria& theCriteria ) +{ + if ( myPredicate != 0 ) + myPredicate->Destroy(); + + SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i(); + FilterManager_ptr aFilterMgr = aFilter->_this(); + + // CREATE two lists ( PREDICATES and LOG OP ) + + // Criterion + std::list aPredicates; + std::list aBinaries; + for ( int i = 0, n = theCriteria.length(); i < n; i++ ) + { + int aCriterion = theCriteria[ i ].Type; + int aCompare = theCriteria[ i ].Compare; + double aThreshold = theCriteria[ i ].Threshold; + int aUnary = theCriteria[ i ].UnaryOp; + int aBinary = theCriteria[ i ].BinaryOp; + double aTolerance = theCriteria[ i ].Tolerance; + const char* aThresholdStr = theCriteria[ i ].ThresholdStr; + ElementType aTypeOfElem = theCriteria[ i ].TypeOfElement; + long aPrecision = theCriteria[ i ].Precision; + + SMESH::Predicate_ptr aPredicate = SMESH::Predicate::_nil(); + SMESH::NumericalFunctor_ptr aFunctor = SMESH::NumericalFunctor::_nil(); + + switch ( aCriterion ) + { + // Functors + + case SMESH::FT_MultiConnection: + aFunctor = aFilterMgr->CreateMultiConnection(); + break; + case SMESH::FT_Length: + aFunctor = aFilterMgr->CreateLength(); + break; + case SMESH::FT_AspectRatio: + aFunctor = aFilterMgr->CreateAspectRatio(); + break; + case SMESH::FT_Warping: + aFunctor = aFilterMgr->CreateWarping(); + break; + case SMESH::FT_MinimumAngle: + aFunctor = aFilterMgr->CreateMinimumAngle(); + break; + case SMESH::FT_Taper: + aFunctor = aFilterMgr->CreateTaper(); + break; + case SMESH::FT_Skew: + aFunctor = aFilterMgr->CreateSkew(); + break; + case SMESH::FT_Area: + aFunctor = aFilterMgr->CreateArea(); + break; + + // Predicates + + case SMESH::FT_FreeBorders: + aPredicate = aFilterMgr->CreateFreeBorders(); + break; + case SMESH::FT_FreeEdges: + aPredicate = aFilterMgr->CreateFreeEdges(); + break; + case SMESH::FT_BelongToGeom: + { + SMESH::BelongToGeom_ptr tmpPred = aFilterMgr->CreateBelongToGeom(); + tmpPred->SetElementType( aTypeOfElem ); + tmpPred->SetShapeName( aThresholdStr ); + aPredicate = tmpPred; + } + break; + case SMESH::FT_BelongToPlane: + case SMESH::FT_BelongToCylinder: + { + SMESH::BelongToSurface_ptr tmpPred; + if ( aCriterion == SMESH::FT_BelongToPlane ) + tmpPred = aFilterMgr->CreateBelongToPlane(); + else + tmpPred = aFilterMgr->CreateBelongToCylinder(); + tmpPred->SetShapeName( aThresholdStr, aTypeOfElem ); + tmpPred->SetTolerance( aTolerance ); + aPredicate = tmpPred; + } + break; + case SMESH::FT_RangeOfIds: + { + SMESH::RangeOfIds_ptr tmpPred = aFilterMgr->CreateRangeOfIds(); + tmpPred->SetRangeStr( aThresholdStr ); + tmpPred->SetElementType( aTypeOfElem ); + aPredicate = tmpPred; + } + break; + + default: + continue; + } + + // Comparator + if ( !aFunctor->_is_nil() && aPredicate->_is_nil() ) + { + SMESH::Comparator_ptr aComparator = SMESH::Comparator::_nil(); + + if ( aCompare == SMESH::FT_LessThan ) + aComparator = aFilterMgr->CreateLessThan(); + else if ( aCompare == SMESH::FT_MoreThan ) + aComparator = aFilterMgr->CreateMoreThan(); + else if ( aCompare == SMESH::FT_EqualTo ) + aComparator = aFilterMgr->CreateEqualTo(); + else + continue; + + aComparator->SetNumFunctor( aFunctor ); + aComparator->SetMargin( aThreshold ); + + if ( aCompare == FT_EqualTo ) + { + SMESH::EqualTo_var anEqualTo = SMESH::EqualTo::_narrow( aComparator ); + anEqualTo->SetTolerance( aTolerance ); + } + + aPredicate = aComparator; + + aFunctor->SetPrecision( aPrecision ); + } + + // Logical not + if ( aUnary == FT_LogicalNOT ) + { + SMESH::LogicalNOT_ptr aNotPred = aFilterMgr->CreateLogicalNOT(); + aNotPred->SetPredicate( aPredicate ); + aPredicate = aNotPred; + } + + // logical op + aPredicates.push_back( aPredicate ); + aBinaries.push_back( aBinary ); + + } // end of for + + // CREATE ONE PREDICATE FROM PREVIOUSLY CREATED MAP + + // combine all "AND" operations + + std::list aResList; + + std::list::iterator aPredIter; + std::list::iterator aBinaryIter; + + SMESH::Predicate_ptr aPrevPredicate = SMESH::Predicate::_nil(); + int aPrevBinary = SMESH::FT_Undefined; + + for ( aPredIter = aPredicates.begin(), aBinaryIter = aBinaries.begin(); + aPredIter != aPredicates.end() && aBinaryIter != aBinaries.end(); + ++aPredIter, ++aBinaryIter ) + { + int aCurrBinary = *aBinaryIter; + + SMESH::Predicate_ptr aCurrPred = SMESH::Predicate::_nil(); + + if ( aPrevBinary == SMESH::FT_LogicalAND ) + { + + SMESH::LogicalBinary_ptr aBinaryPred = aFilterMgr->CreateLogicalAND(); + aBinaryPred->SetPredicate1( aPrevPredicate ); + aBinaryPred->SetPredicate2( *aPredIter ); + aCurrPred = aBinaryPred; + } + else + aCurrPred = *aPredIter; + + if ( aCurrBinary != SMESH::FT_LogicalAND ) + aResList.push_back( aCurrPred ); + + aPrevPredicate = aCurrPred; + aPrevBinary = aCurrBinary; + } + + // combine all "OR" operations + + SMESH::Predicate_ptr aResPredicate = SMESH::Predicate::_nil(); + + if ( aResList.size() == 1 ) + aResPredicate = *aResList.begin(); + else if ( aResList.size() > 1 ) + { + std::list::iterator anIter = aResList.begin(); + aResPredicate = *anIter; + anIter++; + for ( ; anIter != aResList.end(); ++anIter ) + { + SMESH::LogicalBinary_ptr aBinaryPred = aFilterMgr->CreateLogicalOR(); + aBinaryPred->SetPredicate1( aResPredicate ); + aBinaryPred->SetPredicate2( *anIter ); + aResPredicate = aBinaryPred; + } + } + + SetPredicate( aResPredicate ); + + return !aResPredicate->_is_nil(); +} + +//======================================================================= +// name : Filter_i::GetPredicate_i +// Purpose : Get implementation of predicate +//======================================================================= +Predicate_i* Filter_i::GetPredicate_i() +{ + return myPredicate; +} + +//======================================================================= +// name : Filter_i::GetPredicate +// Purpose : Get predicate +//======================================================================= +Predicate_ptr Filter_i::GetPredicate() +{ + if ( myPredicate == 0 ) + return SMESH::Predicate::_nil(); + else + { + SMESH::Predicate_var anObj = myPredicate->_this(); + return anObj._retn(); + } +} + +/* + FILTER LIBRARY +*/ + +#define ATTR_TYPE "type" +#define ATTR_COMPARE "compare" +#define ATTR_THRESHOLD "threshold" +#define ATTR_UNARY "unary" +#define ATTR_BINARY "binary" +#define ATTR_THRESHOLD_STR "threshold_str" +#define ATTR_TOLERANCE "tolerance" +#define ATTR_ELEMENT_TYPE "ElementType" + +//======================================================================= +// name : toString +// Purpose : Convert bool to LDOMString +//======================================================================= +static inline LDOMString toString( const bool val ) +{ + return val ? "logical not" : ""; +} + +//======================================================================= +// name : toBool +// Purpose : Convert LDOMString to bool +//======================================================================= +static inline bool toBool( const LDOMString& theStr ) +{ + return theStr.equals( "logical not" ); +} + +//======================================================================= +// name : toString +// Purpose : Convert double to LDOMString +//======================================================================= +static inline LDOMString toString( const double val ) +{ + char a[ 255 ]; + sprintf( a, "%e", val ); + return LDOMString( a ); +} + +//======================================================================= +// name : toDouble +// Purpose : Convert LDOMString to double +//======================================================================= +static inline double toDouble( const LDOMString& theStr ) +{ + return atof( theStr.GetString() ); +} + +//======================================================================= +// name : toString +// Purpose : Convert functor type to LDOMString +//======================================================================= +static inline LDOMString toString( const long theType ) +{ + switch ( theType ) + { + case FT_AspectRatio : return "Aspect ratio"; + case FT_Warping : return "Warping"; + case FT_MinimumAngle : return "Minimum angle"; + case FT_Taper : return "Taper"; + case FT_Skew : return "Skew"; + case FT_Area : return "Area"; + case FT_BelongToGeom : return "Belong to Geom"; + case FT_BelongToPlane : return "Belong to Plane"; + case FT_BelongToCylinder: return "Belong to Cylinder"; + case FT_RangeOfIds : return "Range of IDs"; + case FT_FreeBorders : return "Free borders"; + case FT_FreeEdges : return "Free edges"; + case FT_MultiConnection : return "Borders at multi-connections"; + case FT_Length : return "Length"; + 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_Undefined : return ""; + default : return ""; + } +} + +//======================================================================= +// name : toFunctorType +// Purpose : Convert LDOMString to functor type +//======================================================================= +static inline SMESH::FunctorType toFunctorType( const LDOMString& theStr ) +{ + if ( theStr.equals( "Aspect ratio" ) ) return FT_AspectRatio; + else if ( theStr.equals( "Warping" ) ) return FT_Warping; + else if ( theStr.equals( "Minimum angle" ) ) return FT_MinimumAngle; + else if ( theStr.equals( "Taper" ) ) return FT_Taper; + else if ( theStr.equals( "Skew" ) ) return FT_Skew; + else if ( theStr.equals( "Area" ) ) return FT_Area; + else if ( theStr.equals( "Belong to Geom" ) ) return FT_BelongToGeom; + else if ( theStr.equals( "Belong to Plane" ) ) return FT_BelongToPlane; + else if ( theStr.equals( "Belong to Cylinder" ) ) return FT_BelongToCylinder; + else if ( theStr.equals( "Free borders" ) ) return FT_FreeBorders; + else if ( theStr.equals( "Free edges" ) ) return FT_FreeEdges; + else if ( theStr.equals( "Borders at multi-connections" ) ) return FT_MultiConnection; + else if ( theStr.equals( "Length" ) ) return FT_Length; + else if ( theStr.equals( "Range of IDs" ) ) return FT_RangeOfIds; + else if ( theStr.equals( "Less than" ) ) return FT_LessThan; + else if ( theStr.equals( "More than" ) ) return FT_MoreThan; + else if ( theStr.equals( "Equal to" ) ) return FT_EqualTo; + 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( "" ) ) return FT_Undefined; + else return FT_Undefined; +} + +//======================================================================= +// name : toFunctorType +// Purpose : Convert LDOMString to value of ElementType enumeration +//======================================================================= +static inline SMESH::ElementType toElementType( const LDOMString& theStr ) +{ + if ( theStr.equals( "NODE" ) ) return SMESH::NODE; + else if ( theStr.equals( "EDGE" ) ) return SMESH::EDGE; + else if ( theStr.equals( "FACE" ) ) return SMESH::FACE; + else if ( theStr.equals( "VOLUME" ) ) return SMESH::VOLUME; + else return SMESH::ALL; +} + +//======================================================================= +// name : toString +// Purpose : Convert ElementType to string +//======================================================================= +static inline LDOMString toString( const SMESH::ElementType theType ) +{ + switch ( theType ) + { + case SMESH::NODE : return "NODE"; + case SMESH::EDGE : return "EDGE"; + case SMESH::FACE : return "FACE"; + case SMESH::VOLUME : return "VOLUME"; + case SMESH::ALL : return "ALL"; + default : return ""; + } +} + +//======================================================================= +// name : findFilter +// Purpose : Find filter in document +//======================================================================= +static LDOM_Element findFilter( const char* theFilterName, + const LDOM_Document& theDoc, + LDOM_Node* theParent = 0 ) +{ + LDOM_Element aRootElement = theDoc.getDocumentElement(); + if ( aRootElement.isNull() || !aRootElement.hasChildNodes() ) + return LDOM_Element(); + + for ( LDOM_Node aTypeNode = aRootElement.getFirstChild(); + !aTypeNode.isNull(); aTypeNode = aTypeNode.getNextSibling() ) + { + for ( LDOM_Node aFilter = aTypeNode.getFirstChild(); + !aFilter.isNull(); aFilter = aFilter.getNextSibling() ) + { + LDOM_Element* anElem = ( LDOM_Element* )&aFilter; + if ( anElem->getTagName().equals( LDOMString( "filter" ) ) && + anElem->getAttribute( "name" ).equals( LDOMString( theFilterName ) ) ) + { + if ( theParent != 0 ) + *theParent = aTypeNode; + return (LDOM_Element&)aFilter; + } + } + } + return LDOM_Element(); +} + +//======================================================================= +// name : getSectionName +// Purpose : Get name of section of filters +//======================================================================= +static const char* getSectionName( const ElementType theType ) +{ + switch ( theType ) + { + case SMESH::NODE : return "Filters for nodes"; + case SMESH::EDGE : return "Filters for edges"; + case SMESH::FACE : return "Filters for faces"; + case SMESH::VOLUME : return "Filters for volumes"; + case SMESH::ALL : return "Filters for elements"; + default : return ""; + } +} + +//======================================================================= +// name : getSection +// Purpose : Create section for filters corresponding to the entity type +//======================================================================= +static LDOM_Node getSection( const ElementType theType, + LDOM_Document& theDoc, + const bool toCreate = false ) +{ + LDOM_Element aRootElement = theDoc.getDocumentElement(); + if ( aRootElement.isNull() ) + return LDOM_Node(); + + // Find section + bool anExist = false; + const char* aSectionName = getSectionName( theType ); + if ( strcmp( aSectionName, "" ) == 0 ) + return LDOM_Node(); + + LDOM_NodeList aSections = theDoc.getElementsByTagName( "section" ); + LDOM_Node aNode; + for ( int i = 0, n = aSections.getLength(); i < n; i++ ) + { + aNode = aSections.item( i ); + LDOM_Element& anItem = ( LDOM_Element& )aNode; + if ( anItem.getAttribute( "name" ).equals( LDOMString( aSectionName ) ) ) + { + anExist = true; + break; + } + } + + // Create new section if necessary + if ( !anExist ) + { + if ( toCreate ) + { + LDOM_Element aNewItem = theDoc.createElement( "section" ); + aNewItem.setAttribute( "name", aSectionName ); + aRootElement.appendChild( aNewItem ); + return aNewItem; + } + else + return LDOM_Node(); + } + return + aNode; +} + +//======================================================================= +// name : createFilterItem +// Purpose : Create filter item or LDOM document +//======================================================================= +static LDOM_Element createFilterItem( const char* theName, + SMESH::Filter_ptr theFilter, + LDOM_Document& theDoc ) +{ + // create new filter in document + LDOM_Element aFilterItem = theDoc.createElement( "filter" ); + aFilterItem.setAttribute( "name", theName ); + + // save filter criterions + SMESH::Filter::Criteria_var aCriteria = new SMESH::Filter::Criteria; + + if ( !theFilter->GetCriteria( aCriteria ) ) + return LDOM_Element(); + + for ( CORBA::ULong i = 0, n = aCriteria->length(); i < n; i++ ) + { + LDOM_Element aCriterionItem = theDoc.createElement( "criterion" ); + + aCriterionItem.setAttribute( ATTR_TYPE , toString( aCriteria[ i ].Type ) ); + aCriterionItem.setAttribute( ATTR_COMPARE , toString( aCriteria[ i ].Compare ) ); + aCriterionItem.setAttribute( ATTR_THRESHOLD , toString( aCriteria[ i ].Threshold ) ); + aCriterionItem.setAttribute( ATTR_UNARY , toString( aCriteria[ i ].UnaryOp ) ); + aCriterionItem.setAttribute( ATTR_BINARY , toString( aCriteria[ i ].BinaryOp ) ); + + aCriterionItem.setAttribute( ATTR_THRESHOLD_STR, (const char*)aCriteria[ i ].ThresholdStr ); + aCriterionItem.setAttribute( ATTR_TOLERANCE , toString( aCriteria[ i ].Tolerance ) ); + aCriterionItem.setAttribute( ATTR_ELEMENT_TYPE , + toString( (SMESH::ElementType)aCriteria[ i ].TypeOfElement ) ); + + aFilterItem.appendChild( aCriterionItem ); + } + + return aFilterItem; +} + +//======================================================================= +// name : FilterLibrary_i::FilterLibrary_i +// Purpose : Constructor +//======================================================================= +FilterLibrary_i::FilterLibrary_i( const char* theFileName ) +{ + myFileName = strdup( theFileName ); + SMESH::FilterManager_i* aFilterMgr = new SMESH::FilterManager_i(); + myFilterMgr = aFilterMgr->_this(); + + LDOMParser aParser; + + // Try to use existing library file + bool anExists = false; + if ( !aParser.parse( myFileName ) ) + { + myDoc = aParser.getDocument(); + anExists = true; + } + // Create a new XML document if it doesn't exist + else + myDoc = LDOM_Document::createDocument( LDOMString() ); + + LDOM_Element aRootElement = myDoc.getDocumentElement(); + if ( aRootElement.isNull() ) + { + // If the existing document is empty --> try to create a new one + if ( anExists ) + myDoc = LDOM_Document::createDocument( LDOMString() ); + } +} + +//======================================================================= +// name : FilterLibrary_i::FilterLibrary_i +// Purpose : Constructor +//======================================================================= +FilterLibrary_i::FilterLibrary_i() +{ + myFileName = 0; + SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i(); + myFilterMgr = aFilter->_this(); + + myDoc = LDOM_Document::createDocument( LDOMString() ); +} + +FilterLibrary_i::~FilterLibrary_i() +{ + delete myFileName; +} + +//======================================================================= +// name : FilterLibrary_i::Copy +// Purpose : Create filter and initialize it with values from library +//======================================================================= +Filter_ptr FilterLibrary_i::Copy( const char* theFilterName ) +{ + Filter_ptr aRes; + LDOM_Node aFilter = findFilter( theFilterName, myDoc ); + + if ( aFilter.isNull() ) + return aRes; + + std::list aCriteria; + + for ( LDOM_Node aCritNode = aFilter.getFirstChild(); + !aCritNode.isNull() ; aCritNode = aCritNode.getNextSibling() ) + { + LDOM_Element* aCrit = (LDOM_Element*)&aCritNode; + + const char* aTypeStr = aCrit->getAttribute( ATTR_TYPE ).GetString(); + const char* aCompareStr = aCrit->getAttribute( ATTR_COMPARE ).GetString(); + const char* aUnaryStr = aCrit->getAttribute( ATTR_UNARY ).GetString(); + const char* aBinaryStr = aCrit->getAttribute( ATTR_BINARY ).GetString(); + const char* anElemTypeStr = aCrit->getAttribute( ATTR_ELEMENT_TYPE ).GetString(); + + SMESH::Filter::Criterion aCriterion = createCriterion(); + + aCriterion.Type = toFunctorType( aTypeStr ); + aCriterion.Compare = toFunctorType( aCompareStr ); + aCriterion.UnaryOp = toFunctorType( aUnaryStr ); + aCriterion.BinaryOp = toFunctorType( aBinaryStr ); + + aCriterion.TypeOfElement = toElementType( anElemTypeStr ); + + LDOMString str = aCrit->getAttribute( ATTR_THRESHOLD ); + int val = 0; + aCriterion.Threshold = str.Type() == LDOMBasicString::LDOM_Integer && str.GetInteger( val ) + ? val : atof( str.GetString() ); + + str = aCrit->getAttribute( ATTR_TOLERANCE ); + aCriterion.Tolerance = str.Type() == LDOMBasicString::LDOM_Integer && str.GetInteger( val ) + ? val : atof( str.GetString() ); + + str = aCrit->getAttribute( ATTR_THRESHOLD_STR ); + if ( str.Type() == LDOMBasicString::LDOM_Integer && str.GetInteger( val ) ) + { + char a[ 255 ]; + sprintf( a, "%d", val ); + aCriterion.ThresholdStr = strdup( a ); + } + else + aCriterion.ThresholdStr = str.GetString(); + + aCriteria.push_back( aCriterion ); + } + + SMESH::Filter::Criteria_var aCriteriaVar = new SMESH::Filter::Criteria; + aCriteriaVar->length( aCriteria.size() ); + + CORBA::ULong i = 0; + std::list::iterator anIter = aCriteria.begin(); + + for( ; anIter != aCriteria.end(); ++anIter ) + aCriteriaVar[ i++ ] = *anIter; + + aRes = myFilterMgr->CreateFilter(); + aRes->SetCriteria( aCriteriaVar.inout() ); + + return aRes; +} + +//======================================================================= +// name : FilterLibrary_i::SetFileName +// Purpose : Set file name for library +//======================================================================= +void FilterLibrary_i::SetFileName( const char* theFileName ) +{ + delete myFileName; + myFileName = strdup( theFileName ); +} + +//======================================================================= +// name : FilterLibrary_i::GetFileName +// Purpose : Get file name of library +//======================================================================= +char* FilterLibrary_i::GetFileName() +{ + return CORBA::string_dup( myFileName ); +} + +//======================================================================= +// name : FilterLibrary_i::Add +// Purpose : Add new filter to library +//======================================================================= +CORBA::Boolean FilterLibrary_i::Add( const char* theFilterName, Filter_ptr theFilter ) +{ + // if filter already in library or entry filter is null do nothing + LDOM_Node aFilterNode = findFilter( theFilterName, myDoc ); + if ( !aFilterNode.isNull() || theFilter->_is_nil() ) + return false; + + // get section corresponding to the filter type + ElementType anEntType = theFilter->GetElementType(); + + LDOM_Node aSection = getSection( anEntType, myDoc, true ); + if ( aSection.isNull() ) + return false; + + // create filter item + LDOM_Element aFilterItem = createFilterItem( theFilterName, theFilter, myDoc ); + if ( aFilterItem.isNull() ) + return false; + else + { + aSection.appendChild( aFilterItem ); + return true; + } +} + +//======================================================================= +// name : FilterLibrary_i::Add +// Purpose : Add new filter to library +//======================================================================= +CORBA::Boolean FilterLibrary_i::AddEmpty( const char* theFilterName, ElementType theType ) +{ + // if filter already in library or entry filter is null do nothing + LDOM_Node aFilterNode = findFilter( theFilterName, myDoc ); + if ( !aFilterNode.isNull() ) + return false; + + LDOM_Node aSection = getSection( theType, myDoc, true ); + if ( aSection.isNull() ) + return false; + + // create filter item + Filter_var aFilter = myFilterMgr->CreateFilter(); + + LDOM_Element aFilterItem = createFilterItem( theFilterName, aFilter, myDoc ); + if ( aFilterItem.isNull() ) + return false; + else + { + aSection.appendChild( aFilterItem ); + return true; + } +} + +//======================================================================= +// name : FilterLibrary_i::Delete +// Purpose : Delete filter from library +//======================================================================= +CORBA::Boolean FilterLibrary_i::Delete ( const char* theFilterName ) +{ + LDOM_Node aParentNode; + LDOM_Node aFilterNode = findFilter( theFilterName, myDoc, &aParentNode ); + if ( aFilterNode.isNull() || aParentNode.isNull() ) + return false; + + aParentNode.removeChild( aFilterNode ); + return true; +} + +//======================================================================= +// name : FilterLibrary_i::Replace +// Purpose : Replace existing filter with entry filter. +// IMPORTANT : If filter does not exist it is not created +//======================================================================= +CORBA::Boolean FilterLibrary_i::Replace( const char* theFilterName, + const char* theNewName, + Filter_ptr theFilter ) +{ + LDOM_Element aFilterItem = findFilter( theFilterName, myDoc ); + if ( aFilterItem.isNull() || theFilter->_is_nil() ) + return false; + + LDOM_Element aNewItem = createFilterItem( theNewName, theFilter, myDoc ); + if ( aNewItem.isNull() ) + return false; + else + { + aFilterItem.ReplaceElement( aNewItem ); + return true; + } +} + +//======================================================================= +// name : FilterLibrary_i::Save +// Purpose : Save library on disk +//======================================================================= +CORBA::Boolean FilterLibrary_i::Save() +{ + if ( myFileName == 0 || strlen( myFileName ) == 0 ) + return false; + + FILE* aOutFile = fopen( myFileName, "wt" ); + if ( !aOutFile ) + return false; + + LDOM_XmlWriter aWriter( aOutFile ); + aWriter.SetIndentation( 2 ); + aWriter << myDoc; + fclose( aOutFile ); + + return true; +} + +//======================================================================= +// name : FilterLibrary_i::SaveAs +// Purpose : Save library on disk +//======================================================================= +CORBA::Boolean FilterLibrary_i::SaveAs( const char* aFileName ) +{ + myFileName = strdup ( aFileName ); + return Save(); +} + +//======================================================================= +// name : FilterLibrary_i::IsPresent +// Purpose : Verify whether filter is in library +//======================================================================= +CORBA::Boolean FilterLibrary_i::IsPresent( const char* theFilterName ) +{ + return !findFilter( theFilterName, myDoc ).isNull(); +} + +//======================================================================= +// name : FilterLibrary_i::NbFilters +// Purpose : Return amount of filters in library +//======================================================================= +CORBA::Long FilterLibrary_i::NbFilters( ElementType theType ) +{ + string_array_var aNames = GetNames( theType ); + return aNames->length(); +} + +//======================================================================= +// name : FilterLibrary_i::GetNames +// Purpose : Get names of filters from library +//======================================================================= +string_array* FilterLibrary_i::GetNames( ElementType theType ) +{ + string_array_var anArray = new string_array; + TColStd_SequenceOfHAsciiString aSeq; + + LDOM_Node aSection = getSection( theType, myDoc, false ); + + if ( !aSection.isNull() ) + { + for ( LDOM_Node aFilter = aSection.getFirstChild(); + !aFilter.isNull(); aFilter = aFilter.getNextSibling() ) + { + LDOM_Element& anElem = ( LDOM_Element& )aFilter; + aSeq.Append( new TCollection_HAsciiString( + (Standard_CString)anElem.getAttribute( "name" ).GetString() ) ); + } + } + + anArray->length( aSeq.Length() ); + for ( int i = 1, n = aSeq.Length(); i <= n; i++ ) + anArray[ i - 1 ] = CORBA::string_dup( aSeq( i )->ToCString() ); + + return anArray._retn(); +} + +//======================================================================= +// name : FilterLibrary_i::GetAllNames +// Purpose : Get names of filters from library +//======================================================================= +string_array* FilterLibrary_i::GetAllNames() +{ + string_array_var aResArray = new string_array; + for ( int type = SMESH::ALL; type <= SMESH::VOLUME; type++ ) + { + SMESH::string_array_var aNames = GetNames( (SMESH::ElementType)type ); + + int aPrevLength = aResArray->length(); + aResArray->length( aPrevLength + aNames->length() ); + for ( int i = 0, n = aNames->length(); i < n; i++ ) + aResArray[ aPrevLength + i ] = aNames[ i ]; + } + + return aResArray._retn(); +} + + + + + + + + + + + + + + + + + + + + diff --git a/src/SMESH_I/SMESH_Filter_i.hxx b/src/SMESH_I/SMESH_Filter_i.hxx index 26edd5b72..2c3efb20e 100644 --- a/src/SMESH_I/SMESH_Filter_i.hxx +++ b/src/SMESH_I/SMESH_Filter_i.hxx @@ -1,417 +1,622 @@ -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : SMESH_Filter_i.hxx -// Author : Alexey Petrov, OCC -// Module : SMESH - -#ifndef _SMESH_FILTER_I_HXX_ -#define _SMESH_FILTER_I_HXX_ - -#include -#include CORBA_SERVER_HEADER(SMESH_Filter) -#include "SALOME_GenericObj_i.hh" - -class SMESHDS_Mesh; -class gp_Pnt; -class gp_XYZ; -class TColgp_SequenceOfXYZ; - -namespace SMESH{ - -/* - FUNCTORS -*/ - -/* - Class : NumericalFunctor_i - Description : Base class for numerical functors - - PortableServer::POA_ptr thePOA - -*/ - -class NumericalFunctor_i: public virtual POA_SMESH::NumericalFunctor, - public virtual SALOME::GenericObj_i -{ -public: - NumericalFunctor_i(); - void SetMesh( SMESH_Mesh_ptr theMesh ); - virtual int GetType() const = 0; - -protected: - bool getPoints( const int theId, - TColgp_SequenceOfXYZ& theRes ) const; -protected: - SMESHDS_Mesh* myMesh; -}; - -/* - Class : SMESH_MinimumAngleFunct - Description : Functor for calculation of minimum angle -*/ - -class MinimumAngle_i: public virtual POA_SMESH::MinimumAngle, - public virtual NumericalFunctor_i -{ -public: - CORBA::Double GetValue( CORBA::Long theElementId ); - virtual int GetType() const; -}; - -/* - Class : AspectRatio_i - Description : Functor for calculating aspect ratio -*/ - -class AspectRatio_i: public virtual POA_SMESH::AspectRatio, - public virtual NumericalFunctor_i -{ -public: - CORBA::Double GetValue(CORBA::Long theElementId); - virtual int GetType() const; -}; - -/* - Class : Warping_i - Description : Functor for calculating warping -*/ - -class Warping_i: public virtual POA_SMESH::Warping, - public virtual NumericalFunctor_i -{ -public: - CORBA::Double GetValue(CORBA::Long theElementId); - virtual int GetType() const; - -private: - double ComputeA( const gp_XYZ&, const gp_XYZ&, - const gp_XYZ&, const gp_XYZ& ) const; -}; - -/* - Class : Taper_i - Description : Functor for calculating taper -*/ - -class Taper_i: public virtual POA_SMESH::Taper, - public virtual NumericalFunctor_i -{ -public: - CORBA::Double GetValue( CORBA::Long theElementId ); - virtual int GetType() const; -}; - -/* - Class : Skew_i - Description : Functor for calculating skew in degrees -*/ - -class Skew_i: public virtual POA_SMESH::Skew, - public virtual NumericalFunctor_i -{ -public: - CORBA::Double GetValue( CORBA::Long theElementId ); - virtual int GetType() const; -}; - -/* - Class : Area_i - Description : Functor for calculating area -*/ - -class Area_i: public virtual POA_SMESH::Area, - public virtual NumericalFunctor_i -{ -public: - CORBA::Double GetValue( CORBA::Long theElementId ); - virtual int GetType() const; -}; - -/* - Class : Length_i - Description : Functor for calculating length of edge -*/ - -class Length_i: public virtual POA_SMESH::Length, - public virtual NumericalFunctor_i -{ -public: - CORBA::Double GetValue( CORBA::Long theElementId ); - virtual int GetType() const; -}; - -/* - Class : MultiConnection_i - Description : Functor for calculating number of faces conneted to the edge -*/ - -class MultiConnection_i: public virtual POA_SMESH::MultiConnection, - public virtual NumericalFunctor_i -{ -public: - CORBA::Double GetValue( CORBA::Long theElementId ); - virtual int GetType() const; -}; - - -/* - PREDICATES -*/ - -/* - Class : Predicate_i - Description : Base class for all predicates -*/ - -class Predicate_i: public virtual POA_SMESH::Predicate, - public virtual SALOME::GenericObj_i -{ -public: - Predicate_i(); - virtual int GetType() const = 0; -}; - - -/* - Class : FreeBorders_i - Description : Predicate for free borders -*/ - -class FreeBorders_i: public virtual POA_SMESH::FreeBorders, - public virtual Predicate_i -{ -public: - FreeBorders_i(); - void SetMesh( SMESH_Mesh_ptr theMesh ); - CORBA::Boolean IsSatisfy( CORBA::Long theElementId ); - virtual int GetType() const; - -protected: - SMESHDS_Mesh* myMesh; -}; - -/* - Class : Comparator_i - Description : Base class for comparators -*/ - -class Comparator_i: public virtual POA_SMESH::Comparator, - public virtual Predicate_i -{ -public: - Comparator_i(); - virtual ~Comparator_i(); - - void SetMesh( SMESH_Mesh_ptr theMesh ); - void SetMargin( CORBA::Double ); - void SetNumFunctor( NumericalFunctor_ptr ); - - virtual int GetType() const; - -protected: - CORBA::Double myMargin; - NumericalFunctor_i* myFunctor; -}; - -/* - Class : LessThan_i - Description : Comparator "<" -*/ - -class LessThan_i: public virtual POA_SMESH::LessThan, - public virtual Comparator_i -{ -public: - CORBA::Boolean IsSatisfy( CORBA::Long theElementId ); -}; - -/* - Class : MoreThan_i - Description : Comparator ">" -*/ -class MoreThan_i: public virtual POA_SMESH::MoreThan, - public virtual Comparator_i -{ -public: - CORBA::Boolean IsSatisfy( CORBA::Long theElementId ); -}; - -/* - Class : EqualTo_i - Description : Comparator "=" -*/ -class EqualTo_i: public virtual POA_SMESH::EqualTo, - public virtual Comparator_i -{ -public: - EqualTo_i(); - - CORBA::Boolean IsSatisfy( CORBA::Long theElementId ); - - void SetTolerance( CORBA::Double ); - -private: - CORBA::Double myToler; -}; - -/* - Class : Logical_i - Description : Base class for logical predicate -*/ - -class Logical_i: public virtual POA_SMESH::Logical, - public virtual Predicate_i - -{ -}; - -/* - Class : LogicalNOT_i - Description : Logical NOT predicate -*/ - -class LogicalNOT_i: public virtual POA_SMESH::LogicalNOT, - public virtual Logical_i -{ -public: - LogicalNOT_i(); - virtual ~LogicalNOT_i(); - - CORBA::Boolean IsSatisfy( CORBA::Long ); - - void SetMesh( SMESH_Mesh_ptr ); - void SetPredicate( Predicate_ptr ); - - virtual int GetType() const; - -private: - Predicate_i* myPredicate; -}; - - -/* - Class : LogicalBinary_i - Description : Base class for binary logical predicate -*/ - -class LogicalBinary_i: public virtual POA_SMESH::LogicalBinary, - public virtual Logical_i -{ -public: - LogicalBinary_i(); - virtual ~LogicalBinary_i(); - - void SetMesh( SMESH_Mesh_ptr ); - - void SetPredicate1( Predicate_ptr ); - void SetPredicate2( Predicate_ptr ); - - virtual int GetType() const; - -protected: - Predicate_i* myPredicate1; - Predicate_i* myPredicate2; -}; - -/* - Class : LogicalAND_i - Description : Logical AND -*/ - -class LogicalAND_i: public virtual POA_SMESH::LogicalAND, - public virtual LogicalBinary_i -{ -public: - CORBA::Boolean IsSatisfy( CORBA::Long theElementId ); -}; - -/* - Class : LogicalOR_i - Description : Logical OR -*/ - -class LogicalOR_i: public virtual POA_SMESH::LogicalOR, - public virtual LogicalBinary_i -{ -public: - CORBA::Boolean IsSatisfy( CORBA::Long theElementId ); -}; - - -/* - FILTER -*/ - -class Filter_i: public virtual POA_SMESH::Filter, - public virtual SALOME::GenericObj_i -{ -public: - Filter_i(); - virtual ~Filter_i(); - void SetPredicate(Predicate_ptr ); - long_array* GetElementsId(SMESH_Mesh_ptr ); - void SetMesh( SMESH_Mesh_ptr ); - -protected: - Predicate_i* myPredicate; -}; - - -/* - FILTER MANAGER -*/ - -class FilterManager_i: public virtual POA_SMESH::FilterManager, - public virtual SALOME::GenericObj_i -{ -public: - FilterManager_i(); - MinimumAngle_ptr CreateMinimumAngle(); - AspectRatio_ptr CreateAspectRatio(); - Warping_ptr CreateWarping(); - Taper_ptr CreateTaper(); - Skew_ptr CreateSkew(); - Area_ptr CreateArea(); - Length_ptr CreateLength(); - MultiConnection_ptr CreateMultiConnection(); - - FreeBorders_ptr CreateFreeBorders(); - - LessThan_ptr CreateLessThan(); - MoreThan_ptr CreateMoreThan(); - EqualTo_ptr CreateEqualTo(); - - LogicalNOT_ptr CreateLogicalNOT(); - LogicalAND_ptr CreateLogicalAND(); - LogicalOR_ptr CreateLogicalOR(); - - Filter_ptr CreateFilter(); -}; - - - -}; - - -#endif +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESH_Filter_i.hxx +// Author : Alexey Petrov, OCC +// Module : SMESH + +#ifndef _SMESH_FILTER_I_HXX_ +#define _SMESH_FILTER_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_Filter) + +#include +#include + +#include "SALOME_GenericObj_i.hh" +#include "SMESH_Controls.hxx" + +class SMESHDS_Mesh; + +namespace SMESH +{ + +namespace Controls +{ + +/* + Class : BelongToGeom + Description : Predicate for verifying whether entiy belong to + specified geometrical support +*/ +class BelongToGeom: public virtual Predicate +{ +public: + BelongToGeom(); + + virtual void SetMesh( SMDS_Mesh* theMesh ); + virtual void SetGeom( const TopoDS_Shape& theShape ); + + virtual bool IsSatisfy( long theElementId ); + + virtual void SetType( SMDSAbs_ElementType theType ); + virtual SMDSAbs_ElementType GetType() const; + + TopoDS_Shape GetShape(); + SMESHDS_Mesh* GetMeshDS(); + +private: + TopoDS_Shape myShape; + SMESHDS_Mesh* myMeshDS; + SMDSAbs_ElementType myType; +}; +typedef boost::shared_ptr BelongToGeomPtr; +} + +/* + FUNCTORS +*/ + +/* + Class : Functor_i + Description : An abstact class for all functors +*/ +class Functor_i: public virtual POA_SMESH::Functor, + public virtual SALOME::GenericObj_i +{ +public: + void SetMesh( SMESH_Mesh_ptr theMesh ); + Controls::FunctorPtr GetFunctor(){ return myFunctorPtr;} + ElementType GetElementType(); + +protected: + Functor_i(); +protected: + Controls::FunctorPtr myFunctorPtr; +}; + + +/* + Class : NumericalFunctor_i + Description : Base class for numerical functors +*/ +class NumericalFunctor_i: public virtual POA_SMESH::NumericalFunctor, + public virtual Functor_i +{ +public: + CORBA::Double GetValue( CORBA::Long theElementId ); + void SetPrecision( CORBA::Long thePrecision ); + CORBA::Long GetPrecision(); + Controls::NumericalFunctorPtr GetNumericalFunctor(); + +protected: + Controls::NumericalFunctorPtr myNumericalFunctorPtr; +}; + + +/* + Class : SMESH_MinimumAngleFunct + Description : Functor for calculation of minimum angle +*/ +class MinimumAngle_i: public virtual POA_SMESH::MinimumAngle, + public virtual NumericalFunctor_i +{ +public: + MinimumAngle_i(); + FunctorType GetFunctorType(); +}; + + +/* + Class : AspectRatio_i + Description : Functor for calculating aspect ratio +*/ +class AspectRatio_i: public virtual POA_SMESH::AspectRatio, + public virtual NumericalFunctor_i +{ +public: + AspectRatio_i(); + FunctorType GetFunctorType(); +}; + + +/* + Class : Warping_i + Description : Functor for calculating warping +*/ +class Warping_i: public virtual POA_SMESH::Warping, + public virtual NumericalFunctor_i +{ +public: + Warping_i(); + FunctorType GetFunctorType(); +}; + + +/* + Class : Taper_i + Description : Functor for calculating taper +*/ +class Taper_i: public virtual POA_SMESH::Taper, + public virtual NumericalFunctor_i +{ +public: + Taper_i(); + FunctorType GetFunctorType(); +}; + + +/* + Class : Skew_i + Description : Functor for calculating skew in degrees +*/ +class Skew_i: public virtual POA_SMESH::Skew, + public virtual NumericalFunctor_i +{ +public: + Skew_i(); + FunctorType GetFunctorType(); +}; + + +/* + Class : Area_i + Description : Functor for calculating area +*/ +class Area_i: public virtual POA_SMESH::Area, + public virtual NumericalFunctor_i +{ +public: + Area_i(); + FunctorType GetFunctorType(); +}; + + +/* + Class : Length_i + Description : Functor for calculating length of edge +*/ +class Length_i: public virtual POA_SMESH::Length, + public virtual NumericalFunctor_i +{ +public: + Length_i(); + FunctorType GetFunctorType(); +}; + + +/* + Class : MultiConnection_i + Description : Functor for calculating number of faces conneted to the edge +*/ +class MultiConnection_i: public virtual POA_SMESH::MultiConnection, + public virtual NumericalFunctor_i +{ +public: + MultiConnection_i(); + FunctorType GetFunctorType(); +}; + + +/* + PREDICATES +*/ +/* + Class : Predicate_i + Description : Base class for all predicates +*/ +class Predicate_i: public virtual POA_SMESH::Predicate, + public virtual Functor_i +{ +public: + CORBA::Boolean IsSatisfy( CORBA::Long theElementId ); + Controls::PredicatePtr GetPredicate(); + +protected: + Controls::PredicatePtr myPredicatePtr; +}; + + +/* + Class : BelongToGeom_i + Description : Predicate for selection on geometrical support +*/ +class BelongToGeom_i: public virtual POA_SMESH::BelongToGeom, + public virtual Predicate_i +{ +public: + BelongToGeom_i(); + virtual ~BelongToGeom_i(); + + void SetGeom( GEOM::GEOM_Object_ptr theGeom ); + void SetElementType( ElementType theType ); + FunctorType GetFunctorType(); + + void SetGeom( const TopoDS_Shape& theShape ); + + void SetShapeName( const char* theName ); + char* GetShapeName(); + +protected: + Controls::BelongToGeomPtr myBelongToGeomPtr; + char* myShapeName; +}; + +/* + Class : BelongToSurface_i + Description : Verify whether mesh element lie in pointed Geom planar object +*/ +class BelongToSurface_i: public virtual POA_SMESH::BelongToSurface, + public virtual Predicate_i +{ +public: + BelongToSurface_i( const Handle(Standard_Type)& ); + virtual ~BelongToSurface_i(); + + void SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType theType ); + + void SetShapeName( const char* theName, ElementType theType ); + char* GetShapeName(); + + void SetTolerance( CORBA::Double ); + CORBA::Double GetTolerance(); + +protected: + Controls::ElementsOnSurfacePtr myElementsOnSurfacePtr; + char* myShapeName; + Handle(Standard_Type) mySurfaceType; +}; + +/* + Class : BelongToPlane_i + Description : Verify whether mesh element lie in pointed Geom planar object +*/ +class BelongToPlane_i: public virtual POA_SMESH::BelongToPlane, + public virtual BelongToSurface_i +{ +public: + BelongToPlane_i(); + void SetPlane( GEOM::GEOM_Object_ptr theGeom, ElementType theType ); + FunctorType GetFunctorType(); +}; + +/* + Class : BelongToCylinder_i + Description : Verify whether mesh element lie in pointed Geom cylindrical object +*/ +class BelongToCylinder_i: public virtual POA_SMESH::BelongToCylinder, + public virtual BelongToSurface_i +{ +public: + BelongToCylinder_i(); + void SetCylinder( GEOM::GEOM_Object_ptr theGeom, ElementType theType ); + FunctorType GetFunctorType(); +}; + + +/* + Class : FreeBorders_i + Description : Predicate for free borders +*/ +class FreeBorders_i: public virtual POA_SMESH::FreeBorders, + public virtual Predicate_i +{ +public: + FreeBorders_i(); + FunctorType GetFunctorType(); +}; + + +/* + Class : FreeEdges_i + Description : Predicate for free edges +*/ +class FreeEdges_i: public virtual POA_SMESH::FreeEdges, + public virtual Predicate_i +{ +public: + FreeEdges_i(); + SMESH::FreeEdges::Borders* GetBorders(); + FunctorType GetFunctorType(); + +protected: + Controls::FreeEdgesPtr myFreeEdgesPtr; +}; + + +/* + Class : RangeOfIds_i + Description : Predicate for Range of Ids +*/ +class RangeOfIds_i: public virtual POA_SMESH::RangeOfIds, + public virtual Predicate_i +{ +public: + RangeOfIds_i(); + void SetRange( const SMESH::long_array& theIds ); + CORBA::Boolean SetRangeStr( const char* theRange ); + char* GetRangeStr(); + + void SetElementType( ElementType theType ); + FunctorType GetFunctorType(); + +protected: + Controls::RangeOfIdsPtr myRangeOfIdsPtr; +}; + +/* + Class : Comparator_i + Description : Base class for comparators +*/ +class Comparator_i: public virtual POA_SMESH::Comparator, + public virtual Predicate_i +{ +public: + virtual ~Comparator_i(); + + virtual void SetMargin( CORBA::Double ); + virtual void SetNumFunctor( NumericalFunctor_ptr ); + + Controls::ComparatorPtr GetComparator(); + NumericalFunctor_i* GetNumFunctor_i(); + CORBA::Double GetMargin(); + +protected: + Comparator_i(); +protected: + Controls::ComparatorPtr myComparatorPtr; + NumericalFunctor_i* myNumericalFunctor; +}; + + +/* + Class : LessThan_i + Description : Comparator "<" +*/ +class LessThan_i: public virtual POA_SMESH::LessThan, + public virtual Comparator_i +{ +public: + LessThan_i(); + FunctorType GetFunctorType(); +}; + + +/* + Class : MoreThan_i + Description : Comparator ">" +*/ +class MoreThan_i: public virtual POA_SMESH::MoreThan, + public virtual Comparator_i +{ +public: + MoreThan_i(); + FunctorType GetFunctorType(); +}; + + +/* + Class : EqualTo_i + Description : Comparator "=" +*/ +class EqualTo_i: public virtual POA_SMESH::EqualTo, + public virtual Comparator_i +{ +public: + EqualTo_i(); + virtual void SetTolerance( CORBA::Double ); + CORBA::Double GetTolerance(); + FunctorType GetFunctorType(); + +protected: + Controls::EqualToPtr myEqualToPtr; +}; + + +/* + Class : LogicalNOT_i + Description : Logical NOT predicate +*/ +class LogicalNOT_i: public virtual POA_SMESH::LogicalNOT, + public virtual Predicate_i +{ +public: + LogicalNOT_i(); + virtual ~LogicalNOT_i(); + + virtual void SetPredicate( Predicate_ptr ); + Predicate_i* GetPredicate_i(); + FunctorType GetFunctorType(); + +protected: + Controls::LogicalNOTPtr myLogicalNOTPtr; + Predicate_i* myPredicate; +}; + + +/* + Class : LogicalBinary_i + Description : Base class for binary logical predicate +*/ +class LogicalBinary_i: public virtual POA_SMESH::LogicalBinary, + public virtual Predicate_i +{ +public: + virtual ~LogicalBinary_i(); + virtual void SetMesh( SMESH_Mesh_ptr theMesh ); + virtual void SetPredicate1( Predicate_ptr ); + virtual void SetPredicate2( Predicate_ptr ); + + Controls::LogicalBinaryPtr GetLogicalBinary(); + Predicate_i* GetPredicate1_i(); + Predicate_i* GetPredicate2_i(); + +protected: + LogicalBinary_i(); +protected: + Controls::LogicalBinaryPtr myLogicalBinaryPtr; + Predicate_i* myPredicate1; + Predicate_i* myPredicate2; +}; + + +/* + Class : LogicalAND_i + Description : Logical AND +*/ +class LogicalAND_i: public virtual POA_SMESH::LogicalAND, + public virtual LogicalBinary_i +{ +public: + LogicalAND_i(); + FunctorType GetFunctorType(); +}; + + +/* + Class : LogicalOR_i + Description : Logical OR +*/ +class LogicalOR_i: public virtual POA_SMESH::LogicalOR, + public virtual LogicalBinary_i +{ +public: + LogicalOR_i(); + FunctorType GetFunctorType(); +}; + + +/* + FILTER +*/ +class Filter_i: public virtual POA_SMESH::Filter, + public virtual SALOME::GenericObj_i +{ +public: + Filter_i(); + virtual ~Filter_i(); + + void SetPredicate( Predicate_ptr ); + void SetMesh( SMESH_Mesh_ptr ); + + long_array* GetElementsId( SMESH_Mesh_ptr ); + ElementType GetElementType(); + + CORBA::Boolean GetCriteria( SMESH::Filter::Criteria_out theCriteria ); + CORBA::Boolean SetCriteria( const SMESH::Filter::Criteria& theCriteria ); + + Predicate_ptr GetPredicate(); + Predicate_i* GetPredicate_i(); + +private: + Controls::Filter myFilter; + Predicate_i* myPredicate; +}; + + +/* + FILTER LIBRARY +*/ +class FilterLibrary_i: public virtual POA_SMESH::FilterLibrary, + public virtual SALOME::GenericObj_i +{ +public: + FilterLibrary_i( const char* theFileName ); + FilterLibrary_i(); + ~FilterLibrary_i(); + + Filter_ptr Copy( const char* theFilterName ); + + CORBA::Boolean Add ( const char* theFilterName, Filter_ptr theFilter ); + CORBA::Boolean AddEmpty( const char* theFilterName, ElementType theType ); + CORBA::Boolean Delete ( const char* theFilterName ); + CORBA::Boolean Replace ( const char* theFilterName, + const char* theNewName, + Filter_ptr theFilter ); + + CORBA::Boolean Save(); + CORBA::Boolean SaveAs( const char* aFileName ); + + CORBA::Boolean IsPresent( const char* aFilterName ); + CORBA::Long NbFilters( ElementType ); + string_array* GetNames( ElementType ); + string_array* GetAllNames(); + void SetFileName( const char* theFileName ); + char* GetFileName(); + +private: + char* myFileName; + LDOM_Document myDoc; + FilterManager_var myFilterMgr; +}; + + +/* + FILTER MANAGER +*/ + +class FilterManager_i: public virtual POA_SMESH::FilterManager, + public virtual SALOME::GenericObj_i +{ +public: + FilterManager_i(); + MinimumAngle_ptr CreateMinimumAngle(); + AspectRatio_ptr CreateAspectRatio(); + Warping_ptr CreateWarping(); + Taper_ptr CreateTaper(); + Skew_ptr CreateSkew(); + Area_ptr CreateArea(); + Length_ptr CreateLength(); + MultiConnection_ptr CreateMultiConnection(); + + BelongToGeom_ptr CreateBelongToGeom(); + BelongToPlane_ptr CreateBelongToPlane(); + BelongToCylinder_ptr CreateBelongToCylinder(); + + FreeBorders_ptr CreateFreeBorders(); + FreeEdges_ptr CreateFreeEdges(); + + RangeOfIds_ptr CreateRangeOfIds(); + + LessThan_ptr CreateLessThan(); + MoreThan_ptr CreateMoreThan(); + EqualTo_ptr CreateEqualTo(); + + LogicalNOT_ptr CreateLogicalNOT(); + LogicalAND_ptr CreateLogicalAND(); + LogicalOR_ptr CreateLogicalOR(); + + Filter_ptr CreateFilter(); + + FilterLibrary_ptr LoadLibrary( const char* aFileName ); + FilterLibrary_ptr CreateLibrary(); + CORBA::Boolean DeleteLibrary( const char* aFileName ); +}; + + + +}; + + +#endif diff --git a/src/SMESH_I/SMESH_Gen_i.cxx b/src/SMESH_I/SMESH_Gen_i.cxx index fb6ed1949..5d1d45ed6 100644 --- a/src/SMESH_I/SMESH_Gen_i.cxx +++ b/src/SMESH_I/SMESH_Gen_i.cxx @@ -26,7 +26,6 @@ // Module : SMESH // $Header$ -using namespace std; #include #include #include @@ -63,19 +62,17 @@ using namespace std; #include "SMESHDS_Document.hxx" #include "SMESHDS_Group.hxx" -#include "SMESH_topo.hxx" +#include "SMESHDS_GroupOnGeom.hxx" #include "SMESH_Group.hxx" +#include "SMDS_EdgePosition.hxx" +#include "SMDS_FacePosition.hxx" + #include CORBA_SERVER_HEADER(SMESH_Group) #include CORBA_SERVER_HEADER(SMESH_Filter) -#include "SMESH_Filter_i.hxx" -#include "Document_Reader.h" #include "DriverMED_W_SMESHDS_Mesh.h" #include "DriverMED_R_SMESHDS_Mesh.h" -#include "DriverMED_R_SMESHDS_Document.h" -#include "DriverUNV_R_SMESHDS_Document.h" -#include "DriverDAT_R_SMESHDS_Document.h" #include "SALOMEDS_Tool.hxx" #include "SALOME_NamingService.hxx" @@ -89,137 +86,24 @@ using namespace std; #include "Utils_ExceptHandlers.hxx" #include +#include + +using namespace std; #define NUM_TMP_FILES 2 -// Tags definition =========================================================== -// Top level -long Tag_HypothesisRoot = 1; // hypotheses root -long Tag_AlgorithmsRoot = 2; // algorithms root -// Mesh/Submesh -long Tag_RefOnShape = 1; // references to shape -long Tag_RefOnAppliedHypothesis = 2; // applied hypotheses root -long Tag_RefOnAppliedAlgorithms = 3; // applied algorithms root -// Mesh only -long Tag_SubMeshOnVertex = 4; // sub-meshes roots by type -long Tag_SubMeshOnEdge = 5; // ... -long Tag_SubMeshOnFace = 6; // ... -long Tag_SubMeshOnSolid = 7; // ... -long Tag_SubMeshOnCompound = 8; // ... -long Tag_NodeGroups = 9; // Group roots by type -long Tag_EdgeGroups = 10; // ... -long Tag_FaceGroups = 11; // ... -long Tag_VolumeGroups = 12; // ... -// =========================================================================== +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif // Static variables definition CORBA::ORB_var SMESH_Gen_i::myOrb; PortableServer::POA_var SMESH_Gen_i::myPoa; SALOME_NamingService* SMESH_Gen_i::myNS = NULL; SALOME_LifeCycleCORBA* SMESH_Gen_i::myLCC = NULL; - -//============================================================================= -/*! - * FindMaxChildTag [ static internal ] - * - * Finds maximum child tag for the given object - */ -//============================================================================= - -static long FindMaxChildTag( SALOMEDS::SObject_ptr theSObject ) -{ - long aTag = 0; - if ( !theSObject->_is_nil() ) { - SALOMEDS::Study_var aStudy = theSObject->GetStudy(); - if ( !aStudy->_is_nil() ) { - SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator( theSObject ); - for ( ; anIter->More(); anIter->Next() ) { - long nTag = anIter->Value()->Tag(); - if ( nTag > aTag ) - aTag = nTag; - } - } - } - return aTag; -} - -//============================================================================= -/*! - * Get...Tag [ static ] - * - * Methods which determine SMESH data model structure - */ -//============================================================================= - -long SMESH_Gen_i::GetHypothesisRootTag() -{ - return Tag_HypothesisRoot; -} - -long SMESH_Gen_i::GetAlgorithmsRootTag() -{ - return Tag_AlgorithmsRoot; -} - -long SMESH_Gen_i::GetRefOnShapeTag() -{ - return Tag_RefOnShape; -} - -long SMESH_Gen_i::GetRefOnAppliedHypothesisTag() -{ - return Tag_RefOnAppliedHypothesis; -} - -long SMESH_Gen_i::GetRefOnAppliedAlgorithmsTag() -{ - return Tag_RefOnAppliedAlgorithms; -} - -long SMESH_Gen_i::GetSubMeshOnVertexTag() -{ - return Tag_SubMeshOnVertex; -} - -long SMESH_Gen_i::GetSubMeshOnEdgeTag() -{ - return Tag_SubMeshOnEdge; -} - -long SMESH_Gen_i::GetSubMeshOnFaceTag() -{ - return Tag_SubMeshOnFace; -} - -long SMESH_Gen_i::GetSubMeshOnSolidTag() -{ - return Tag_SubMeshOnSolid; -} - -long SMESH_Gen_i::GetSubMeshOnCompoundTag() -{ - return Tag_SubMeshOnCompound; -} - -long SMESH_Gen_i::GetNodeGroupsTag() -{ - return Tag_NodeGroups; -} - -long SMESH_Gen_i::GetEdgeGroupsTag() -{ - return Tag_EdgeGroups; -} - -long SMESH_Gen_i::GetFaceGroupsTag() -{ - return Tag_FaceGroups; -} - -long SMESH_Gen_i::GetVolumeGroupsTag() -{ - return Tag_VolumeGroups; -} +SMESH_Gen_i* SMESH_Gen_i::mySMESHGen = NULL; //============================================================================= /*! @@ -238,7 +122,7 @@ PortableServer::ServantBase_var SMESH_Gen_i::GetServant( CORBA::Object_ptr theOb return aServant; } catch (...) { - MESSAGE( "GetServant - Unknown exception was caught!!!" ); + INFOS( "GetServant - Unknown exception was caught!!!" ); return NULL; } } @@ -265,7 +149,7 @@ CORBA::Object_var SMESH_Gen_i::SObjectToObject( SALOMEDS::SObject_ptr theSObject } } catch( ... ) { - MESSAGE( "SObjectToObject - Unknown exception was caught!!!" ); + INFOS( "SObjectToObject - Unknown exception was caught!!!" ); } } return anObj; @@ -327,7 +211,7 @@ GEOM::GEOM_Gen_ptr SMESH_Gen_i::GetGeomEngine() { SMESH_Gen_i::SMESH_Gen_i() { - MESSAGE( "SMESH_Gen_i::SMESH_Gen_i : default constructor" ); + INFOS( "SMESH_Gen_i::SMESH_Gen_i : default constructor" ); } //============================================================================= @@ -345,7 +229,7 @@ SMESH_Gen_i::SMESH_Gen_i( CORBA::ORB_ptr orb, const char* interfaceName ) : Engines_Component_i( orb, poa, contId, instanceName, interfaceName ) { - MESSAGE( "SMESH_Gen_i::SMESH_Gen_i : standard constructor" ); + INFOS( "SMESH_Gen_i::SMESH_Gen_i : standard constructor" ); myOrb = CORBA::ORB::_duplicate(orb); myPoa = PortableServer::POA::_duplicate(poa); @@ -354,6 +238,7 @@ SMESH_Gen_i::SMESH_Gen_i( CORBA::ORB_ptr orb, _id = myPoa->activate_object( _thisObj ); myShapeReader = NULL; // shape reader + mySMESHGen = this; } //============================================================================= @@ -366,7 +251,7 @@ SMESH_Gen_i::SMESH_Gen_i( CORBA::ORB_ptr orb, SMESH_Gen_i::~SMESH_Gen_i() { - MESSAGE( "SMESH_Gen_i::~SMESH_Gen_i" ); + INFOS( "SMESH_Gen_i::~SMESH_Gen_i" ); // delete hypothesis creators map::iterator itHyp; @@ -387,21 +272,6 @@ SMESH_Gen_i::~SMESH_Gen_i() delete myShapeReader; } -//============================================================================= -/*! - * SMESH_Gen_i::CreateFilterManager - * - * Create filter manager - */ -//============================================================================= - -SMESH::FilterManager_ptr SMESH_Gen_i::CreateFilterManager() -{ - SMESH::FilterManager_i* aFilter = new SMESH::FilterManager_i(); - SMESH::FilterManager_var anObj = aFilter->_this(); - return anObj._retn(); -} - //============================================================================= /*! * SMESH_Gen_i::createHypothesis @@ -414,11 +284,8 @@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::createHypothesis(const char* theHypName throw (SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); - MESSAGE( "Create Hypothesis <" << theHypName << "> from " << theLibName); + if(MYDEBUG) MESSAGE( "Create Hypothesis <" << theHypName << "> from " << theLibName); - // get study context - StudyContext* myStudyContext = GetCurrentStudyContext(); - // create a new hypothesis object servant SMESH_Hypothesis_i* myHypothesis_i = 0; SMESH::SMESH_Hypothesis_var hypothesis_i; @@ -429,7 +296,7 @@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::createHypothesis(const char* theHypName if (myHypCreatorMap.find(string(theHypName)) == myHypCreatorMap.end()) { // load plugin library - MESSAGE("Loading server meshers plugin library ..."); + if(MYDEBUG) MESSAGE("Loading server meshers plugin library ..."); void* libHandle = dlopen (theLibName, RTLD_LAZY); if (!libHandle) { @@ -439,7 +306,7 @@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::createHypothesis(const char* theHypName } // get method, returning hypothesis creator - MESSAGE("Find GetHypothesisCreator() method ..."); + if(MYDEBUG) MESSAGE("Find GetHypothesisCreator() method ..."); typedef GenericHypothesisCreator_i* (*GetHypothesisCreator)(const char* theHypName); GetHypothesisCreator procHandle = (GetHypothesisCreator)dlsym( libHandle, "GetHypothesisCreator" ); @@ -450,7 +317,7 @@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::createHypothesis(const char* theHypName } // get hypothesis creator - MESSAGE("Get Hypothesis Creator for " << theHypName); + if(MYDEBUG) MESSAGE("Get Hypothesis Creator for " << theHypName); GenericHypothesisCreator_i* aCreator = procHandle(theHypName); if (!aCreator) { @@ -462,10 +329,9 @@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::createHypothesis(const char* theHypName } // create a new hypothesis object, store its ref. in studyContext - MESSAGE("Create Hypothesis " << theHypName); + if(MYDEBUG) MESSAGE("Create Hypothesis " << theHypName); myHypothesis_i = - myHypCreatorMap[string(theHypName)]->Create - (myPoa, myCurrentStudy->StudyId(), &myGen); + myHypCreatorMap[string(theHypName)]->Create (myPoa, GetCurrentStudyID(), &myGen); // _CS_gbo Explicit activation (no longer made in the constructor). myHypothesis_i->Activate(); myHypothesis_i->SetLibName(theLibName); // for persistency assurance @@ -480,9 +346,8 @@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::createHypothesis(const char* theHypName // activate the CORBA servant of hypothesis hypothesis_i = SMESH::SMESH_Hypothesis::_narrow( myHypothesis_i->_this() ); - string iorString = GetORB()->object_to_string( hypothesis_i ); - int nextId = myStudyContext->addObject( iorString ); - MESSAGE( "Add hypo to map with id = "<< nextId << " and IOR = " << iorString.c_str() ); + int nextId = RegisterObject( hypothesis_i ); + if(MYDEBUG) MESSAGE( "Add hypo to map with id = "<< nextId ); return hypothesis_i._retn(); } @@ -498,25 +363,19 @@ SMESH::SMESH_Mesh_ptr SMESH_Gen_i::createMesh() throw ( SALOME::SALOME_Exception ) { Unexpect aCatch(SALOME_SalomeException); - MESSAGE( "SMESH_Gen_i::createMesh" ); - - // get current study - StudyContext* myStudyContext = GetCurrentStudyContext(); + if(MYDEBUG) MESSAGE( "SMESH_Gen_i::createMesh" ); // Get or create the GEOM_Client instance try { // create a new mesh object servant, store it in a map in study context - SMESH_Mesh_i* meshServant = new SMESH_Mesh_i( GetPOA(), - this, - myCurrentStudy->StudyId() ); + SMESH_Mesh_i* meshServant = new SMESH_Mesh_i( GetPOA(), this, GetCurrentStudyID() ); // create a new mesh object - meshServant->SetImpl( myGen.CreateMesh( myCurrentStudy->StudyId() ) ); + meshServant->SetImpl( myGen.CreateMesh( GetCurrentStudyID() )); // activate the CORBA servant of Mesh - SMESH::SMESH_Mesh_var mesh = meshServant->_this(); - string iorString = GetORB()->object_to_string( mesh ); - int nextId = myStudyContext->addObject( iorString ); - MESSAGE( "Add mesh to map with id = "<< nextId << " and IOR = " << iorString.c_str() ); + SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( meshServant->_this() ); + int nextId = RegisterObject( mesh ); + if(MYDEBUG) MESSAGE( "Add mesh to map with id = "<< nextId); return mesh._retn(); } catch (SALOME_Exception& S_ex) { @@ -551,17 +410,19 @@ GEOM_Client* SMESH_Gen_i::GetShapeReader() void SMESH_Gen_i::SetCurrentStudy( SALOMEDS::Study_ptr theStudy ) { - MESSAGE( "SMESH_Gen_i::SetCurrentStudy" ); + if(MYDEBUG) MESSAGE( "SMESH_Gen_i::SetCurrentStudy" ); myCurrentStudy = SALOMEDS::Study::_duplicate( theStudy ); // create study context, if it doesn't exist and set current study - int studyId = myCurrentStudy->StudyId(); - MESSAGE( "SMESH_Gen_i::SetCurrentStudy: study Id = " << studyId ); + int studyId = GetCurrentStudyID(); + if(MYDEBUG) MESSAGE( "SMESH_Gen_i::SetCurrentStudy: study Id = " << studyId ); if ( myStudyContextMap.find( studyId ) == myStudyContextMap.end() ) { myStudyContextMap[ studyId ] = new StudyContext; } // set current study for geom engine + /* if ( !CORBA::is_nil( GetGeomEngine() ) ) GetGeomEngine()->GetCurrentStudy( myCurrentStudy->StudyId() ); + */ } //============================================================================= @@ -574,7 +435,7 @@ void SMESH_Gen_i::SetCurrentStudy( SALOMEDS::Study_ptr theStudy ) SALOMEDS::Study_ptr SMESH_Gen_i::GetCurrentStudy() { - MESSAGE( "SMESH_Gen_i::GetCurrentStudy: study Id = " << myCurrentStudy->StudyId() ); + if(MYDEBUG) MESSAGE( "SMESH_Gen_i::GetCurrentStudy: study Id = " << GetCurrentStudyID() ); return SALOMEDS::Study::_duplicate( myCurrentStudy ); } @@ -587,9 +448,11 @@ SALOMEDS::Study_ptr SMESH_Gen_i::GetCurrentStudy() //============================================================================= StudyContext* SMESH_Gen_i::GetCurrentStudyContext() { - ASSERT( !CORBA::is_nil( myCurrentStudy ) ) - ASSERT( myStudyContextMap.find( myCurrentStudy->StudyId() ) != myStudyContextMap.end() ); - return myStudyContextMap[ myCurrentStudy->StudyId() ]; + if ( !CORBA::is_nil( myCurrentStudy ) && + myStudyContextMap.find( GetCurrentStudyID() ) != myStudyContextMap.end() ) + return myStudyContextMap[ myCurrentStudy->StudyId() ]; + else + return 0; } //============================================================================= @@ -605,14 +468,13 @@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::CreateHypothesis( const char* theHypNam throw ( SALOME::SALOME_Exception ) { Unexpect aCatch(SALOME_SalomeException); - ASSERT( !CORBA::is_nil( myCurrentStudy ) ); // Create hypothesis/algorithm SMESH::SMESH_Hypothesis_var hyp = this->createHypothesis( theHypName, theLibName ); // Publish hypothesis/algorithm in the study - if ( this->CanPublishInStudy( hyp ) ) { - this->PublishInStudy( myCurrentStudy, SALOMEDS::SObject::_nil(), hyp, "" ); - } + if ( CanPublishInStudy( hyp ) ) + PublishHypothesis( myCurrentStudy, hyp ); + return hyp._retn(); } @@ -624,25 +486,49 @@ SMESH::SMESH_Hypothesis_ptr SMESH_Gen_i::CreateHypothesis( const char* theHypNam */ //============================================================================= -SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMesh( GEOM::GEOM_Shape_ptr theShape ) +SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMesh( GEOM::GEOM_Object_ptr theShapeObject ) throw ( SALOME::SALOME_Exception ) { Unexpect aCatch(SALOME_SalomeException); - MESSAGE( "SMESH_Gen_i::CreateMesh" ); - ASSERT( !CORBA::is_nil( myCurrentStudy ) ); + if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMesh" ); // create mesh SMESH::SMESH_Mesh_var mesh = this->createMesh(); - // publish mesh in the study - if ( this->CanPublishInStudy( mesh ) ) { - this->PublishInStudy( myCurrentStudy, SALOMEDS::SObject::_nil(), mesh.in(), "" ); - } // set shape SMESH_Mesh_i* meshServant = dynamic_cast( GetServant( mesh ).in() ); ASSERT( meshServant ); - meshServant->SetShape( theShape ); + meshServant->SetShape( theShapeObject ); + // publish mesh in the study + if ( CanPublishInStudy( mesh ) ) + PublishMesh( myCurrentStudy, mesh.in() ); return mesh._retn(); } - + +//============================================================================= +/*! + * SMESH_Gen_i::CreateMeshFromUNV + * + * Create mesh and import data from UNV file + */ +//============================================================================= + +SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromUNV( const char* theFileName ) + throw ( SALOME::SALOME_Exception ) +{ + Unexpect aCatch(SALOME_SalomeException); + if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshesFromUNV" ); + + SMESH::SMESH_Mesh_var aMesh = createMesh(); + string aFileName; // = boost::filesystem::path(theFileName).leaf(); + // publish mesh in the study + if ( CanPublishInStudy( aMesh ) ) + PublishMesh( myCurrentStudy, aMesh.in(), aFileName.c_str() ); + + SMESH_Mesh_i* aServant = dynamic_cast( GetServant( aMesh ).in() ); + ASSERT( aServant ); + aServant->ImportUNVFile( theFileName ); + return aMesh._retn(); +} + //============================================================================= /*! * SMESH_Gen_i::CreateMeshFromMED @@ -656,42 +542,67 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName, throw ( SALOME::SALOME_Exception ) { Unexpect aCatch(SALOME_SalomeException); - MESSAGE( "SMESH_Gen_i::CreateMeshFromMED" ); - ASSERT( !CORBA::is_nil( myCurrentStudy ) ); + if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshFromMED" ); // Retrieve mesh names from the file DriverMED_R_SMESHDS_Mesh myReader; myReader.SetFile( theFileName ); myReader.SetMeshId( -1 ); - list aNames = myReader.GetMeshNames(); - + Driver_Mesh::Status aStatus; + list aNames = myReader.GetMeshNames(aStatus); SMESH::mesh_array_var aResult = new SMESH::mesh_array(); - aResult->length( aNames.size() ); - int i = 0; - - // Iterate through all meshes and create mesh objects - theStatus = SMESH::DRS_OK; - for ( list::iterator it = aNames.begin(); it != aNames.end(); it++ ) { - // create mesh - SMESH::SMESH_Mesh_var mesh = createMesh(); + theStatus = (SMESH::DriverMED_ReadStatus)aStatus; + if(theStatus == SMESH::DRS_OK){ + aResult->length( aNames.size() ); + int i = 0; - // publish mesh in the study - if ( CanPublishInStudy( mesh ) ) { - PublishInStudy( myCurrentStudy, SALOMEDS::SObject::_nil(), mesh.in(), (*it).c_str() ); + // Iterate through all meshes and create mesh objects + for ( list::iterator it = aNames.begin(); it != aNames.end(); it++ ) { + // create mesh + SMESH::SMESH_Mesh_var mesh = createMesh(); + + // publish mesh in the study + if ( CanPublishInStudy( mesh ) ) + PublishMesh( myCurrentStudy, mesh.in(), (*it).c_str() ); + + // Read mesh data (groups are published automatically by ImportMEDFile()) + SMESH_Mesh_i* meshServant = dynamic_cast( GetServant( mesh ).in() ); + ASSERT( meshServant ); + SMESH::DriverMED_ReadStatus status1 = + meshServant->ImportMEDFile( theFileName, (*it).c_str() ); + if (status1 > theStatus) + theStatus = status1; + + aResult[i++] = SMESH::SMESH_Mesh::_duplicate( mesh ); } + } + return aResult._retn(); +} - // Read mesh data (groups are published automatically by ImportMEDFile()) - SMESH_Mesh_i* meshServant = dynamic_cast( GetServant( mesh ).in() ); - ASSERT( meshServant ); - SMESH::DriverMED_ReadStatus status1 = - meshServant->ImportMEDFile( theFileName, (*it).c_str() ); - if (status1 > theStatus) - theStatus = status1; +//============================================================================= +/*! + * SMESH_Gen_i::CreateMeshFromSTL + * + * Create mesh and import data from STL file + */ +//============================================================================= - aResult[i++] = SMESH::SMESH_Mesh::_duplicate( mesh ); - } +SMESH::SMESH_Mesh_ptr SMESH_Gen_i::CreateMeshesFromSTL( const char* theFileName ) + throw ( SALOME::SALOME_Exception ) +{ + Unexpect aCatch(SALOME_SalomeException); + if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMeshesFromSTL" ); - return aResult._retn(); + SMESH::SMESH_Mesh_var aMesh = createMesh(); + string aFileName; // = boost::filesystem::path(theFileName).leaf(); + // publish mesh in the study + if ( CanPublishInStudy( aMesh ) ) + PublishInStudy( myCurrentStudy, SALOMEDS::SObject::_nil(), aMesh.in(), aFileName.c_str() ); + + SMESH_Mesh_i* aServant = dynamic_cast( GetServant( aMesh ).in() ); + ASSERT( aServant ); + aServant->ImportSTLFile( theFileName ); + return aMesh._retn(); } //============================================================================= @@ -703,14 +614,14 @@ SMESH::mesh_array* SMESH_Gen_i::CreateMeshesFromMED( const char* theFileName, //============================================================================= CORBA::Boolean SMESH_Gen_i::IsReadyToCompute( SMESH::SMESH_Mesh_ptr theMesh, - GEOM::GEOM_Shape_ptr theShape ) + GEOM::GEOM_Object_ptr theShapeObject ) throw ( SALOME::SALOME_Exception ) { Unexpect aCatch(SALOME_SalomeException); - MESSAGE( "SMESH_Gen_i::IsReadyToCompute" ); + if(MYDEBUG) MESSAGE( "SMESH_Gen_i::IsReadyToCompute" ); - if ( CORBA::is_nil( theShape ) ) - THROW_SALOME_CORBA_EXCEPTION( "bad shape reference", + if ( CORBA::is_nil( theShapeObject ) ) + THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", SALOME::BAD_PARAM ); if ( CORBA::is_nil( theMesh ) ) @@ -723,14 +634,14 @@ CORBA::Boolean SMESH_Gen_i::IsReadyToCompute( SMESH::SMESH_Mesh_ptr theMesh, ASSERT( meshServant ); if ( meshServant ) { // get local TopoDS_Shape - TopoDS_Shape myLocShape = GetShapeReader()->GetShape( GetGeomEngine(), theShape ); + TopoDS_Shape myLocShape = GeomObjectToShape( theShapeObject ); // call implementation ::SMESH_Mesh& myLocMesh = meshServant->GetImpl(); return myGen.CheckAlgoState( myLocMesh, myLocShape ); } } catch ( SALOME_Exception& S_ex ) { - MESSAGE( "catch exception "<< S_ex.what() ); + INFOS( "catch exception "<< S_ex.what() ); } return false; } @@ -743,53 +654,52 @@ CORBA::Boolean SMESH_Gen_i::IsReadyToCompute( SMESH::SMESH_Mesh_ptr theMesh, */ //============================================================================= -SMESH::long_array* SMESH_Gen_i::GetSubShapesId( GEOM::GEOM_Shape_ptr theMainShape, - const SMESH::shape_array& theListOfSubShape ) +SMESH::long_array* SMESH_Gen_i::GetSubShapesId( GEOM::GEOM_Object_ptr theMainShapeObject, + const SMESH::object_array& theListOfSubShapeObject ) throw ( SALOME::SALOME_Exception ) { Unexpect aCatch(SALOME_SalomeException); - MESSAGE( "SMESH_Gen_i::GetSubShapesId" ); + if(MYDEBUG) MESSAGE( "SMESH_Gen_i::GetSubShapesId" ); SMESH::long_array_var shapesId = new SMESH::long_array; set setId; - if ( CORBA::is_nil( theMainShape ) ) - THROW_SALOME_CORBA_EXCEPTION( "bad shape reference", + if ( CORBA::is_nil( theMainShapeObject ) ) + THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", SALOME::BAD_PARAM ); try { - if (! myShapeReader) myShapeReader = new GEOM_Client(GetContainerRef()); - ASSERT(myShapeReader); - TopoDS_Shape myMainShape = GetShapeReader()->GetShape(GetGeomEngine(),theMainShape); + TopoDS_Shape myMainShape = GeomObjectToShape(theMainShapeObject); TopTools_IndexedMapOfShape myIndexToShape; TopExp::MapShapes(myMainShape,myIndexToShape); - for (int i=0; iGetShape(GetGeomEngine(),aShape); + GEOM::GEOM_Object_var aShapeObject + = GEOM::GEOM_Object::_narrow(theListOfSubShapeObject[i]); + if ( CORBA::is_nil( aShapeObject ) ) + THROW_SALOME_CORBA_EXCEPTION ("bad shape object reference", \ + SALOME::BAD_PARAM ); + + TopoDS_Shape locShape = GeomObjectToShape(aShapeObject); for (TopExp_Explorer exp(locShape,TopAbs_FACE); exp.More(); exp.Next()) { const TopoDS_Face& F = TopoDS::Face(exp.Current()); setId.insert(myIndexToShape.FindIndex(F)); - SCRUTE(myIndexToShape.FindIndex(F)); + if(MYDEBUG) SCRUTE(myIndexToShape.FindIndex(F)); } for (TopExp_Explorer exp(locShape,TopAbs_EDGE); exp.More(); exp.Next()) { const TopoDS_Edge& E = TopoDS::Edge(exp.Current()); setId.insert(myIndexToShape.FindIndex(E)); - SCRUTE(myIndexToShape.FindIndex(E)); + if(MYDEBUG) SCRUTE(myIndexToShape.FindIndex(E)); } for (TopExp_Explorer exp(locShape,TopAbs_VERTEX); exp.More(); exp.Next()) { const TopoDS_Vertex& V = TopoDS::Vertex(exp.Current()); setId.insert(myIndexToShape.FindIndex(V)); - SCRUTE(myIndexToShape.FindIndex(V)); + if(MYDEBUG) SCRUTE(myIndexToShape.FindIndex(V)); } } shapesId->length(setId.size()); @@ -797,9 +707,9 @@ SMESH::long_array* SMESH_Gen_i::GetSubShapesId( GEOM::GEOM_Shape_ptr theMai int i=0; for (iind = setId.begin(); iind != setId.end(); iind++) { - SCRUTE((*iind)); + if(MYDEBUG) SCRUTE((*iind)); shapesId[i] = (*iind); - SCRUTE(shapesId[i]); + if(MYDEBUG) SCRUTE(shapesId[i]); i++; } } @@ -820,14 +730,14 @@ SMESH::long_array* SMESH_Gen_i::GetSubShapesId( GEOM::GEOM_Shape_ptr theMai //============================================================================= CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh, - GEOM::GEOM_Shape_ptr theShape ) + GEOM::GEOM_Object_ptr theShapeObject ) throw ( SALOME::SALOME_Exception ) { Unexpect aCatch(SALOME_SalomeException); - MESSAGE( "SMESH_Gen_i::Compute" ); + if(MYDEBUG) MESSAGE( "SMESH_Gen_i::Compute" ); - if ( CORBA::is_nil( theShape ) ) - THROW_SALOME_CORBA_EXCEPTION( "bad shape reference", + if ( CORBA::is_nil( theShapeObject ) ) + THROW_SALOME_CORBA_EXCEPTION( "bad shape object reference", SALOME::BAD_PARAM ); if ( CORBA::is_nil( theMesh ) ) @@ -840,17 +750,17 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh, ASSERT( meshServant ); if ( meshServant ) { // get local TopoDS_Shape - TopoDS_Shape myLocShape = GetShapeReader()->GetShape( GetGeomEngine(), theShape ); - // call implementarion compute + TopoDS_Shape myLocShape = GeomObjectToShape( theShapeObject ); + // call implementation compute ::SMESH_Mesh& myLocMesh = meshServant->GetImpl(); return myGen.Compute( myLocMesh, myLocShape); } } catch ( SALOME_Exception& S_ex ) { - MESSAGE( "Compute(): catch exception "<< S_ex.what() ); + INFOS( "Compute(): catch exception "<< S_ex.what() ); } catch ( ... ) { - MESSAGE( "Compute(): unknown exception " ); + INFOS( "Compute(): unknown exception " ); } return false; } @@ -868,7 +778,13 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, { INFOS( "SMESH_Gen_i::Save" ); - ASSERT( theComponent->GetStudy()->StudyId() == myCurrentStudy->StudyId() ) +// ASSERT( theComponent->GetStudy()->StudyId() == myCurrentStudy->StudyId() ) + // san -- in case differs from theComponent's study, + // use that of the component + if ( myCurrentStudy->_is_nil() || + theComponent->GetStudy()->StudyId() != myCurrentStudy->StudyId() ) + SetCurrentStudy( theComponent->GetStudy() ); + StudyContext* myStudyContext = GetCurrentStudyContext(); // Declare a byte stream @@ -876,7 +792,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, // Obtain a temporary dir TCollection_AsciiString tmpDir = - ( isMultiFile ) ? TCollection_AsciiString( ( char* )theURL ) : SALOMEDS_Tool::GetTmpDir(); + ( isMultiFile ) ? TCollection_AsciiString( ( char* )theURL ) : ( char* )SALOMEDS_Tool::GetTmpDir().c_str(); // Create a sequence of files processed SALOMEDS::ListOfFileNames_var aFileSeq = new SALOMEDS::ListOfFileNames; @@ -884,7 +800,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, TCollection_AsciiString aStudyName( "" ); if ( isMultiFile ) - aStudyName = ( SALOMEDS_Tool::GetNameFromPath( myCurrentStudy->URL() ) ); + aStudyName = ( (char*)SALOMEDS_Tool::GetNameFromPath( myCurrentStudy->URL() ).c_str() ); // Set names of temporary files TCollection_AsciiString filename = @@ -1163,8 +1079,12 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, strcpy( name_meshgroup, "SubMeshes On Vertex" ); else if ( i == GetSubMeshOnEdgeTag() ) strcpy( name_meshgroup, "SubMeshes On Edge" ); + else if ( i == GetSubMeshOnWireTag() ) + strcpy( name_meshgroup, "SubMeshes On Wire" ); else if ( i == GetSubMeshOnFaceTag() ) strcpy( name_meshgroup, "SubMeshes On Face" ); + else if ( i == GetSubMeshOnShellTag() ) + strcpy( name_meshgroup, "SubMeshes On Shell" ); else if ( i == GetSubMeshOnSolidTag() ) strcpy( name_meshgroup, "SubMeshes On Solid" ); else if ( i == GetSubMeshOnCompoundTag() ) @@ -1191,7 +1111,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, // // Put submesh data to MED convertor // if ( myImpl->_mapSubMesh.find( mySubMesh->GetId() ) != myImpl->_mapSubMesh.end() ) { -// MESSAGE( "VSR - SMESH_Gen_i::Save(): saving submesh with ID = " +// if(MYDEBUG) MESSAGE( "VSR - SMESH_Gen_i::Save(): saving submesh with ID = " // << mySubMesh->GetId() << " to MED file" ); // ::SMESH_subMesh* aLocalSubmesh = myImpl->_mapSubMesh[mySubMesh->GetId()]; // myWriter.AddSubMesh( aLocalSubmesh->GetSubMeshDS(), subid ); @@ -1312,12 +1232,12 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, aGroup->CreateOnDisk(); SALOMEDS::ChildIterator_var it = myCurrentStudy->NewChildIterator( myGroupsBranch ); - int grpNb = 0; for ( ; it->More(); it->Next() ) { SALOMEDS::SObject_var mySObject = it->Value(); CORBA::Object_var aSubObject = SObjectToObject( mySObject ); if ( !CORBA::is_nil( aSubObject ) ) { - SMESH_Group_i* myGroupImpl = dynamic_cast( GetServant( aSubObject ).in() ); + SMESH_GroupBase_i* myGroupImpl = + dynamic_cast( GetServant( aSubObject ).in() ); if ( !myGroupImpl ) continue; @@ -1337,13 +1257,37 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, // Store the group contents into MED file if ( myLocMesh.GetGroup( myGroupImpl->GetLocalID() ) ) { - MESSAGE( "VSR - SMESH_Gen_i::Save(): saving group with StoreName = " + if(MYDEBUG) MESSAGE( "VSR - SMESH_Gen_i::Save(): saving group with StoreName = " << grpName << " to MED file" ); - SMESHDS_Group* aGrpDS = myLocMesh.GetGroup( myGroupImpl->GetLocalID() )->GetGroupDS(); - aGrpDS->SetStoreName( grpName ); + SMESHDS_GroupBase* aGrpBaseDS = + myLocMesh.GetGroup( myGroupImpl->GetLocalID() )->GetGroupDS(); + aGrpBaseDS->SetStoreName( grpName ); // Pass SMESHDS_Group to MED writer - myWriter.AddGroup( aGrpDS ); + SMESHDS_Group* aGrpDS = dynamic_cast( aGrpBaseDS ); + if ( aGrpDS ) + myWriter.AddGroup( aGrpDS ); + + // write reference on a shape if exists + SMESHDS_GroupOnGeom* aGeomGrp = + dynamic_cast( aGrpBaseDS ); + if ( aGeomGrp ) { + SALOMEDS::SObject_var mySubRef, myShape; + if (mySObject->FindSubObject( GetRefOnShapeTag(), mySubRef ) && + mySubRef->ReferencedObject( myShape )) + { + string myRefOnObject = myShape->GetID(); + if ( myRefOnObject.length() > 0 ) { + char aRefName[ 30 ]; + sprintf( aRefName, "Ref on shape %d", anId); + aSize[ 0 ] = myRefOnObject.length() + 1; + aDataset = new HDFdataset(aRefName, aGroup, HDF_STRING, aSize, 1); + aDataset->CreateOnDisk(); + aDataset->WriteOnDisk( ( char* )( myRefOnObject.c_str() ) ); + aDataset->CloseOnDisk(); + } + } + } } } } @@ -1351,9 +1295,144 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, } } - // Flush current mesh information into MED file - if ( strcmp( strHasData.c_str(), "1" ) == 0 ) - myWriter.Add(); + if ( strcmp( strHasData.c_str(), "1" ) == 0 ) + { + // Flush current mesh information into MED file + myWriter.Perform(); + + + // Store node positions on sub-shapes (SMDS_Position): + + aGroup = new HDFgroup( "Node Positions", aTopGroup ); + aGroup->CreateOnDisk(); + + // in aGroup, create 5 datasets to contain: + // "Nodes on Edges" - ID of node on edge + // "Edge positions" - U parameter on node on edge + // "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 + + // Find out nb of nodes on edges and faces + // Collect corresponing sub-meshes + int nbEdgeNodes = 0, nbFaceNodes = 0; + list aEdgeSM, aFaceSM; + // loop on SMESHDS_SubMesh'es + const map& aSubMeshes = mySMESHDSMesh->SubMeshes(); + map::const_iterator itSubM ( aSubMeshes.begin() ); + for ( ; itSubM != aSubMeshes.end() ; itSubM++ ) + { + SMESHDS_SubMesh* aSubMesh = (*itSubM).second; + if ( aSubMesh->IsComplexSubmesh() ) + continue; // submesh containing other submeshs + int nbNodes = aSubMesh->NbNodes(); + if ( nbNodes == 0 ) continue; + + int aShapeID = (*itSubM).first; + int aShapeType = mySMESHDSMesh->IndexToShape( aShapeID ).ShapeType(); + // write only SMDS_FacePosition and SMDS_EdgePosition + switch ( aShapeType ) { + case TopAbs_FACE: + nbFaceNodes += nbNodes; + aFaceSM.push_back( aSubMesh ); + break; + case TopAbs_EDGE: + nbEdgeNodes += nbNodes; + aEdgeSM.push_back( aSubMesh ); + break; + default: + continue; + } + } + // Treat positions on edges or faces + for ( int onFace = 0; onFace < 2; onFace++ ) + { + // Create arrays to store in datasets + int iNode = 0, nbNodes = ( onFace ? nbFaceNodes : nbEdgeNodes ); + if (!nbNodes) continue; + int* aNodeIDs = new int [ nbNodes ]; + double* aUPos = new double [ nbNodes ]; + double* aVPos = ( onFace ? new double[ nbNodes ] : 0 ); + + // Fill arrays + // loop on sub-meshes + list * pListSM = ( onFace ? &aFaceSM : &aEdgeSM ); + list::iterator itSM = pListSM->begin(); + for ( ; itSM != pListSM->end(); itSM++ ) + { + SMESHDS_SubMesh* aSubMesh = (*itSM); + if ( aSubMesh->IsComplexSubmesh() ) + continue; // submesh containing other submeshs + + SMDS_NodeIteratorPtr itNode = aSubMesh->GetNodes(); + // loop on nodes in aSubMesh + while ( itNode->more() ) + { + //node ID + const SMDS_MeshNode* node = itNode->next(); + aNodeIDs [ iNode ] = node->GetID(); + + // Position + const SMDS_PositionPtr pos = node->GetPosition(); + if ( onFace ) { // on FACE + const SMDS_FacePosition* fPos = + dynamic_cast( pos.get() ); + if ( fPos ) { + aUPos[ iNode ] = fPos->GetUParameter(); + aVPos[ iNode ] = fPos->GetVParameter(); + iNode++; + } + else + nbNodes--; + } + else { // on EDGE + const SMDS_EdgePosition* ePos = + dynamic_cast( pos.get() ); + if ( ePos ) { + aUPos[ iNode ] = ePos->GetUParameter(); + iNode++; + } + else + nbNodes--; + } + } // loop on nodes in aSubMesh + } // loop on sub-meshes + + // Write datasets + if ( nbNodes ) + { + aSize[ 0 ] = nbNodes; + // IDS + string aDSName( onFace ? "Nodes on Faces" : "Nodes on Edges"); + aDataset = new HDFdataset( (char*)aDSName.c_str(), aGroup, HDF_INT32, aSize, 1 ); + aDataset->CreateOnDisk(); + aDataset->WriteOnDisk( aNodeIDs ); + aDataset->CloseOnDisk(); + + // U Positions + aDSName = ( onFace ? "Face U positions" : "Edge positions"); + aDataset = new HDFdataset( (char*)aDSName.c_str(), aGroup, HDF_FLOAT64, aSize, 1); + aDataset->CreateOnDisk(); + aDataset->WriteOnDisk( aUPos ); + aDataset->CloseOnDisk(); + // V Positions + if ( onFace ) { + aDataset = new HDFdataset( "Face V positions", aGroup, HDF_FLOAT64, aSize, 1); + aDataset->CreateOnDisk(); + aDataset->WriteOnDisk( aVPos ); + aDataset->CloseOnDisk(); + } + } + delete [] aNodeIDs; + delete [] aUPos; + if ( aVPos ) delete [] aVPos; + + } // treat positions on edges or faces + + // close "Node Positions" group + aGroup->CloseOnDisk(); + + } // if ( hasData ) // close mesh HDF group aTopGroup->CloseOnDisk(); @@ -1389,7 +1468,7 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent, SALOMEDS::TMPFile* SMESH_Gen_i::SaveASCII( SALOMEDS::SComponent_ptr theComponent, const char* theURL, bool isMultiFile ) { - MESSAGE( "SMESH_Gen_i::SaveASCII" ); + if(MYDEBUG) MESSAGE( "SMESH_Gen_i::SaveASCII" ); SALOMEDS::TMPFile_var aStreamFile = Save( theComponent, theURL, isMultiFile ); return aStreamFile._retn(); } @@ -1430,12 +1509,15 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, { INFOS( "SMESH_Gen_i::Load" ); - ASSERT( theComponent->GetStudy()->StudyId() == myCurrentStudy->StudyId() ) + if ( myCurrentStudy->_is_nil() || + theComponent->GetStudy()->StudyId() != myCurrentStudy->StudyId() ) + SetCurrentStudy( theComponent->GetStudy() ); + StudyContext* myStudyContext = GetCurrentStudyContext(); // Get temporary files location TCollection_AsciiString tmpDir = - isMultiFile ? TCollection_AsciiString( ( char* )theURL ) : SALOMEDS_Tool::GetTmpDir(); + isMultiFile ? TCollection_AsciiString( ( char* )theURL ) : ( char* )SALOMEDS_Tool::GetTmpDir().c_str(); // Convert the stream into sequence of files to process SALOMEDS::ListOfFileNames_var aFileSeq = SALOMEDS_Tool::PutStreamToFiles( theStream, @@ -1443,7 +1525,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, isMultiFile ); TCollection_AsciiString aStudyName( "" ); if ( isMultiFile ) - aStudyName = ( SALOMEDS_Tool::GetNameFromPath( myCurrentStudy->URL() ) ); + aStudyName = ( (char*)SALOMEDS_Tool::GetNameFromPath( myCurrentStudy->URL() ).c_str() ); // Set names of temporary files TCollection_AsciiString filename = tmpDir + aStudyName + TCollection_AsciiString( "_SMESH.hdf" ); @@ -1464,7 +1546,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, aFile->OpenOnDisk( HDF_RDONLY ); } catch ( HDFexception ) { - MESSAGE( "Load(): " << filename << " not found!" ); + INFOS( "Load(): " << filename << " not found!" ); return false; } @@ -1522,7 +1604,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, size = aDataset->GetSize(); char* libname_str = new char[ size ]; aDataset->ReadFromDisk( libname_str ); - SCRUTE( libname_str ); + if(MYDEBUG) SCRUTE( libname_str ); libname = string( libname_str ); delete libname_str; aDataset->CloseOnDisk(); @@ -1544,7 +1626,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, // --> restore hypothesis from data if ( id > 0 && !hypname.empty()/* && !hypdata.empty()*/ ) { // VSR : persistent data can be empty - MESSAGE("VSR - load hypothesis : id = " << id << + if(MYDEBUG) MESSAGE("VSR - load hypothesis : id = " << id << ", name = " << hypname.c_str() << ", persistent string = " << hypdata.c_str()); SMESH::SMESH_Hypothesis_var myHyp; @@ -1552,7 +1634,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, myHyp = this->createHypothesis( hypname.c_str(), libname.c_str() ); } catch (...) { - MESSAGE( "Exception during hypothesis creation" ); + INFOS( "Exception during hypothesis creation" ); } SMESH_Hypothesis_i* myImpl = dynamic_cast( GetServant( myHyp ).in() ); @@ -1563,7 +1645,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, myStudyContext->mapOldToNew( id, newId ); } else - MESSAGE( "VSR - SMESH_Gen::Load - can't get servant" ); + if(MYDEBUG) MESSAGE( "VSR - SMESH_Gen::Load - can't get servant" ); } } } @@ -1619,7 +1701,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, size = aDataset->GetSize(); char* libname_str = new char[ size ]; aDataset->ReadFromDisk( libname_str ); - SCRUTE( libname_str ); + if(MYDEBUG) SCRUTE( libname_str ); libname = string( libname_str ); delete libname_str; aDataset->CloseOnDisk(); @@ -1631,7 +1713,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, size = aDataset->GetSize(); char* hypdata_str = new char[ size ]; aDataset->ReadFromDisk( hypdata_str ); - SCRUTE( hypdata_str ); + if(MYDEBUG) SCRUTE( hypdata_str ); hypdata = string( hypdata_str ); delete hypdata_str; aDataset->CloseOnDisk(); @@ -1642,7 +1724,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, // --> restore algorithm from data if ( id > 0 && !hypname.empty()/* && !hypdata.empty()*/ ) { // VSR : persistent data can be empty - MESSAGE("VSR - load algo : id = " << id << + if(MYDEBUG) MESSAGE("VSR - load algo : id = " << id << ", name = " << hypname.c_str() << ", persistent string = " << hypdata.c_str()); SMESH::SMESH_Hypothesis_var myHyp; @@ -1650,7 +1732,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, myHyp = this->createHypothesis( hypname.c_str(), libname.c_str() ); } catch (...) { - MESSAGE( "Exception during hypothesis creation" ); + INFOS( "Exception during hypothesis creation" ); } SMESH_Hypothesis_i* myImpl = dynamic_cast( GetServant( myHyp ).in() ); @@ -1661,7 +1743,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, myStudyContext->mapOldToNew( id, newId ); } else - MESSAGE( "VSR - SMESH_Gen::Load - can't get servant" ); + if(MYDEBUG) MESSAGE( "VSR - SMESH_Gen::Load - can't get servant" ); } } } @@ -1691,10 +1773,10 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, int aNbObjects = aTopGroup->nInternalObjects(); if ( aNbObjects > 0 ) { // create mesh - MESSAGE( "VSR - load mesh : id = " << id ); + if(MYDEBUG) MESSAGE( "VSR - load mesh : id = " << id ); SMESH::SMESH_Mesh_var myNewMesh = this->createMesh(); SMESH_Mesh_i* myNewMeshImpl = dynamic_cast( GetServant( myNewMesh ).in() ); - if ( !myNewMeshImpl ) + if ( !myNewMeshImpl ) continue; string iorString = GetORB()->object_to_string( myNewMesh ); int newId = myStudyContext->findId( iorString ); @@ -1716,13 +1798,13 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, // read mesh data from MED file myReader.SetMesh( mySMESHDSMesh ); myReader.SetMeshId( id ); - myReader.ReadMySelf(); + myReader.Perform(); hasData = true; } } // try to read and set reference to shape - GEOM::GEOM_Shape_var aShape; + GEOM::GEOM_Object_var aShapeObject; if ( aTopGroup->ExistInternalObject( "Ref on shape" ) ) { // load mesh "Ref on shape" - it's an entry to SObject aDataset = new HDFdataset( "Ref on shape", aTopGroup ); @@ -1739,9 +1821,9 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, CORBA::Object_var shapeObject = SObjectToObject( shapeSO ); if ( !CORBA::is_nil( shapeObject ) ) { - aShape = GEOM::GEOM_Shape::_narrow( shapeObject ); - if ( !aShape->_is_nil() ) - myNewMeshImpl->setShape( aShape ); + aShapeObject = GEOM::GEOM_Object::_narrow( shapeObject ); + if ( !aShapeObject->_is_nil() ) + myNewMeshImpl->SetShape( aShapeObject ); } } } @@ -1752,7 +1834,6 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, aGroup->OpenOnDisk(); // get number of applied hypotheses int aNbSubObjects = aGroup->nInternalObjects(); - MESSAGE( "VSR - number of applied hypotheses = " << aNbSubObjects ); for ( int j = 0; j < aNbSubObjects; j++ ) { char name_dataset[ HDF_NAME_MAX_LEN+1 ]; aGroup->InternalObjectIndentify( j, name_dataset ); @@ -1775,22 +1856,22 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, CORBA::Object_var hypObject = GetORB()->string_to_object( anIOR.c_str() ); if ( !CORBA::is_nil( hypObject ) ) { SMESH::SMESH_Hypothesis_var anHyp = SMESH::SMESH_Hypothesis::_narrow( hypObject ); - if ( !anHyp->_is_nil() && !aShape->_is_nil() ) - myNewMeshImpl->addHypothesis( aShape, anHyp ); + if ( !anHyp->_is_nil() && !aShapeObject->_is_nil() ) + myNewMeshImpl->addHypothesis( aShapeObject, anHyp ); } } } } aGroup->CloseOnDisk(); } - + // try to get applied algorithms if ( aTopGroup->ExistInternalObject( "Applied Algorithms" ) ) { aGroup = new HDFgroup( "Applied Algorithms", aTopGroup ); aGroup->OpenOnDisk(); // get number of applied algorithms int aNbSubObjects = aGroup->nInternalObjects(); - MESSAGE( "VSR - number of applied algos " << aNbSubObjects ); + if(MYDEBUG) MESSAGE( "VSR - number of applied algos " << aNbSubObjects ); for ( int j = 0; j < aNbSubObjects; j++ ) { char name_dataset[ HDF_NAME_MAX_LEN+1 ]; aGroup->InternalObjectIndentify( j, name_dataset ); @@ -1813,8 +1894,8 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, CORBA::Object_var hypObject = GetORB()->string_to_object( anIOR.c_str() ); if ( !CORBA::is_nil( hypObject ) ) { SMESH::SMESH_Hypothesis_var anHyp = SMESH::SMESH_Hypothesis::_narrow( hypObject ); - if ( !anHyp->_is_nil() && !aShape->_is_nil() ) - myNewMeshImpl->addHypothesis( aShape, anHyp ); + if ( !anHyp->_is_nil() && !aShapeObject->_is_nil() ) + myNewMeshImpl->addHypothesis( aShapeObject, anHyp ); } } } @@ -1829,8 +1910,12 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, strcpy( name_meshgroup, "SubMeshes On Vertex" ); else if ( j == GetSubMeshOnEdgeTag() ) strcpy( name_meshgroup, "SubMeshes On Edge" ); + else if ( j == GetSubMeshOnWireTag() ) + strcpy( name_meshgroup, "SubMeshes On Wire" ); else if ( j == GetSubMeshOnFaceTag() ) strcpy( name_meshgroup, "SubMeshes On Face" ); + else if ( j == GetSubMeshOnShellTag() ) + strcpy( name_meshgroup, "SubMeshes On Shell" ); else if ( j == GetSubMeshOnSolidTag() ) strcpy( name_meshgroup, "SubMeshes On Solid" ); else if ( j == GetSubMeshOnCompoundTag() ) @@ -1858,9 +1943,9 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, aSubGroup->OpenOnDisk(); // try to read and set reference to subshape - GEOM::GEOM_Shape_var aSubShape; + GEOM::GEOM_Object_var aSubShapeObject; SMESH::SMESH_subMesh_var aSubMesh; - + if ( aSubGroup->ExistInternalObject( "Ref on shape" ) ) { // load submesh "Ref on shape" - it's an entry to SObject aDataset = new HDFdataset( "Ref on shape", aSubGroup ); @@ -1873,10 +1958,10 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, SALOMEDS::SObject_var subShapeSO = myCurrentStudy->FindObjectID( refFromFile ); CORBA::Object_var subShapeObject = SObjectToObject( subShapeSO ); if ( !CORBA::is_nil( subShapeObject ) ) { - aSubShape = GEOM::GEOM_Shape::_narrow( subShapeObject ); - if ( !aSubShape->_is_nil() ) + aSubShapeObject = GEOM::GEOM_Object::_narrow( subShapeObject ); + if ( !aSubShapeObject->_is_nil() ) aSubMesh = SMESH::SMESH_subMesh::_duplicate - ( myNewMeshImpl->createSubMesh( aSubShape ) ); + ( myNewMeshImpl->createSubMesh( aSubShapeObject ) ); if ( aSubMesh->_is_nil() ) continue; string iorSubString = GetORB()->object_to_string( aSubMesh ); @@ -1892,12 +1977,12 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, // VSR: Get submesh data from MED convertor // int anInternalSubmeshId = aSubMesh->GetId(); // this is not a persistent ID, it's an internal one computed from sub-shape // if (myNewMeshImpl->_mapSubMesh.find(anInternalSubmeshId) != myNewMeshImpl->_mapSubMesh.end()) { -// MESSAGE("VSR - SMESH_Gen_i::Load(): loading from MED file submesh with ID = " << +// if(MYDEBUG) MESSAGE("VSR - SMESH_Gen_i::Load(): loading from MED file submesh with ID = " << // subid << " for subshape # " << anInternalSubmeshId); // SMESHDS_SubMesh* aSubMeshDS = // myNewMeshImpl->_mapSubMesh[anInternalSubmeshId]->CreateSubMeshDS(); // if ( !aSubMeshDS ) { -// MESSAGE("VSR - SMESH_Gen_i::Load(): FAILED to create a submesh for subshape # " << +// if(MYDEBUG) MESSAGE("VSR - SMESH_Gen_i::Load(): FAILED to create a submesh for subshape # " << // anInternalSubmeshId << " in current mesh!"); // } // else @@ -1931,8 +2016,8 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, CORBA::Object_var hypObject = GetORB()->string_to_object( anIOR.c_str() ); if ( !CORBA::is_nil( hypObject ) ) { SMESH::SMESH_Hypothesis_var anHyp = SMESH::SMESH_Hypothesis::_narrow( hypObject ); - if ( !anHyp->_is_nil() && !aShape->_is_nil() ) - myNewMeshImpl->addHypothesis( aSubShape, anHyp ); + if ( !anHyp->_is_nil() && !aShapeObject->_is_nil() ) + myNewMeshImpl->addHypothesis( aSubShapeObject, anHyp ); } } } @@ -1968,8 +2053,8 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, CORBA::Object_var hypObject = GetORB()->string_to_object( anIOR.c_str() ); if ( !CORBA::is_nil( hypObject ) ) { SMESH::SMESH_Hypothesis_var anHyp = SMESH::SMESH_Hypothesis::_narrow( hypObject ); - if ( !anHyp->_is_nil() && !aShape->_is_nil() ) - myNewMeshImpl->addHypothesis( aSubShape, anHyp ); + if ( !anHyp->_is_nil() && !aShapeObject->_is_nil() ) + myNewMeshImpl->addHypothesis( aSubShapeObject, anHyp ); } } } @@ -1987,23 +2072,122 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, } } - if(hasData){ + if(hasData) { // Read sub-meshes from MED - MESSAGE("JFA - Create all sub-meshes"); + if(MYDEBUG) MESSAGE("JFA - Create all sub-meshes"); myReader.CreateAllSubMeshes(); - } + + + // Read node positions on sub-shapes (SMDS_Position) + + if ( aTopGroup->ExistInternalObject( "Node Positions" )) + { + // There are 5 datasets to read: + // "Nodes on Edges" - ID of node on edge + // "Edge positions" - U parameter on node on edge + // "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"; + //char* aFid_DSName = "Nodes on Faces"; + //char* aFv_DSName = "Face V positions"; + + // data to retrieve + int nbEids = 0, nbFids = 0; + int *aEids = 0, *aFids = 0; + double *aEpos = 0, *aFupos = 0, *aFvpos = 0; + + // open a group + aGroup = new HDFgroup( "Node Positions", aTopGroup ); + aGroup->OpenOnDisk(); + + // loop on 5 data sets + int aNbObjects = aGroup->nInternalObjects(); + for ( int i = 0; i < aNbObjects; i++ ) + { + // identify dataset + char aDSName[ HDF_NAME_MAX_LEN+1 ]; + aGroup->InternalObjectIndentify( i, aDSName ); + // read data + aDataset = new HDFdataset( aDSName, aGroup ); + aDataset->OpenOnDisk(); + if ( aDataset->GetType() == HDF_FLOAT64 ) // Positions + { + double* pos = new double [ aDataset->GetSize() ]; + aDataset->ReadFromDisk( pos ); + // which one? + if ( strncmp( aDSName, aEu_DSName, strlen( aEu_DSName )) == 0 ) + aEpos = pos; + else if ( strncmp( aDSName, aFu_DSName, strlen( aFu_DSName )) == 0 ) + aFupos = pos; + else + aFvpos = pos; + } + else // NODE IDS + { + int* ids = new int [ aDataset->GetSize() ]; + aDataset->ReadFromDisk( ids ); + // on face or nodes? + if ( strncmp( aDSName, aEid_DSName, strlen( aEid_DSName )) == 0 ) { + aEids = ids; + nbEids = aDataset->GetSize(); + } + else { + aFids = ids; + nbFids = aDataset->GetSize(); + } + } + } // loop on 5 datasets + + // Set node positions on edges or faces + for ( int onFace = 0; onFace < 2; onFace++ ) + { + int nbNodes = ( onFace ? nbFids : nbEids ); + if ( nbNodes == 0 ) continue; + int* aNodeIDs = ( onFace ? aFids : aEids ); + double* aUPos = ( onFace ? aFupos : aEpos ); + double* aVPos = ( onFace ? aFvpos : 0 ); + // loop on node IDs + for ( int iNode = 0; iNode < nbNodes; iNode++ ) + { + const SMDS_MeshNode* node = mySMESHDSMesh->FindNode( aNodeIDs[ iNode ]); + ASSERT( node ); + SMDS_PositionPtr aPos = node->GetPosition(); + ASSERT( aPos ) + if ( onFace ) { + ASSERT( aPos->GetTypeOfPosition() == SMDS_TOP_FACE ); + SMDS_FacePosition* fPos = const_cast + ( static_cast( aPos.get() )); + fPos->SetUParameter( aUPos[ iNode ]); + fPos->SetVParameter( aVPos[ iNode ]); + } + else { + ASSERT( aPos->GetTypeOfPosition() == SMDS_TOP_EDGE ); + SMDS_EdgePosition* fPos = const_cast + ( static_cast( aPos.get() )); + fPos->SetUParameter( aUPos[ iNode ]); + } + } + } + if ( aEids ) delete [] aEids; + if ( aFids ) delete [] aFids; + if ( aEpos ) delete [] aEpos; + if ( aFupos ) delete [] aFupos; + if ( aFvpos ) delete [] aFvpos; + + aGroup->CloseOnDisk(); + + } // if ( aTopGroup->ExistInternalObject( "Node Positions" ) ) + } // if ( hasData ) // Recompute State (as computed sub-meshes are restored from MED) - if ( !aShape->_is_nil() ) { + if ( !aShapeObject->_is_nil() ) { MESSAGE("JFA - Compute State Engine ..."); -// map::iterator anAllSubMeshes = myNewMeshImpl->_mapSubMesh.begin(); -// for (; anAllSubMeshes != myNewMeshImpl->_mapSubMesh.end(); anAllSubMeshes++) -// { -// (*anAllSubMeshes).second->GetSubMeshDS(); // init SMESH_subMesh::_meshDS -// (*anAllSubMeshes).second->ComputeStateEngine(SMESH_subMesh::SUBMESH_RESTORED); -// } - TopoDS_Shape myLocShape = GetShapeReader()->GetShape( GetGeomEngine(), aShape ); - myNewMeshImpl->GetImpl().GetSubMesh(myLocShape)->ComputeStateEngine(SMESH_subMesh::SUBMESH_RESTORED); + TopoDS_Shape myLocShape = GeomObjectToShape( aShapeObject ); + myNewMeshImpl->GetImpl().GetSubMesh(myLocShape)->ComputeStateEngine + (SMESH_subMesh::SUBMESH_RESTORED); MESSAGE("JFA - Compute State Engine finished"); } @@ -2041,11 +2225,33 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, char* nameFromFile = new char[ size ]; aDataset->ReadFromDisk( nameFromFile ); aDataset->CloseOnDisk(); - + + // Try to find a shape reference + TopoDS_Shape aShape; + char aRefName[ 30 ]; + sprintf( aRefName, "Ref on shape %d", subid); + if ( aGroup->ExistInternalObject( aRefName ) ) { + // load mesh "Ref on shape" - it's an entry to SObject + aDataset = new HDFdataset( aRefName, aGroup ); + aDataset->OpenOnDisk(); + size = aDataset->GetSize(); + char* refFromFile = new char[ size ]; + aDataset->ReadFromDisk( refFromFile ); + aDataset->CloseOnDisk(); + if ( strlen( refFromFile ) > 0 ) { + SALOMEDS::SObject_var shapeSO = myCurrentStudy->FindObjectID( refFromFile ); + CORBA::Object_var shapeObject = SObjectToObject( shapeSO ); + if ( !CORBA::is_nil( shapeObject ) ) { + aShapeObject = GEOM::GEOM_Object::_narrow( shapeObject ); + if ( !aShapeObject->_is_nil() ) + aShape = GeomObjectToShape( aShapeObject ); + } + } + } // Create group servant - SMESH::SMESH_Group_var aNewGroup = SMESH::SMESH_Group::_duplicate - ( myNewMeshImpl->createGroup( (SMESH::ElementType)(ii - GetNodeGroupsTag() + 1), - nameFromFile ) ); + SMESH::ElementType type = (SMESH::ElementType)(ii - GetNodeGroupsTag() + 1); + SMESH::SMESH_GroupBase_var aNewGroup = SMESH::SMESH_GroupBase::_duplicate + ( myNewMeshImpl->createGroup( type, nameFromFile, aShape ) ); // Obtain a SMESHDS_Group object if ( aNewGroup->_is_nil() ) continue; @@ -2054,7 +2260,8 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, int newSubId = myStudyContext->findId( iorSubString ); myStudyContext->mapOldToNew( subid, newSubId ); - SMESH_Group_i* aGroupImpl = dynamic_cast( GetServant( aNewGroup ).in() ); + SMESH_GroupBase_i* aGroupImpl = + dynamic_cast( GetServant( aNewGroup ).in() ); if ( !aGroupImpl ) continue; @@ -2062,11 +2269,13 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent, if ( !aLocalGroup ) continue; - SMESHDS_Group* aGroupDS = aLocalGroup->GetGroupDS(); - aGroupDS->SetStoreName( name_dataset ); + SMESHDS_GroupBase* aGroupBaseDS = aLocalGroup->GetGroupDS(); + aGroupBaseDS->SetStoreName( name_dataset ); // Fill group with contents from MED file - myReader.GetGroup( aGroupDS ); + SMESHDS_Group* aGrp = dynamic_cast( aGroupBaseDS ); + if ( aGrp ) + myReader.GetGroup( aGrp ); } } aGroup->CloseOnDisk(); @@ -2102,7 +2311,7 @@ bool SMESH_Gen_i::LoadASCII( SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream, const char* theURL, bool isMultiFile ) { - MESSAGE( "SMESH_Gen_i::LoadASCII" ); + if(MYDEBUG) MESSAGE( "SMESH_Gen_i::LoadASCII" ); return Load( theComponent, theStream, theURL, isMultiFile ); } @@ -2116,10 +2325,10 @@ bool SMESH_Gen_i::LoadASCII( SALOMEDS::SComponent_ptr theComponent, void SMESH_Gen_i::Close( SALOMEDS::SComponent_ptr theComponent ) { - MESSAGE( "SMESH_Gen_i::Close" ); + if(MYDEBUG) MESSAGE( "SMESH_Gen_i::Close" ); // Clear study contexts data - int studyId = myCurrentStudy->StudyId(); + int studyId = GetCurrentStudyID(); if ( myStudyContextMap.find( studyId ) != myStudyContextMap.end() ) { delete myStudyContextMap[ studyId ]; myStudyContextMap.erase( studyId ); @@ -2137,8 +2346,8 @@ void SMESH_Gen_i::Close( SALOMEDS::SComponent_ptr theComponent ) char* SMESH_Gen_i::ComponentDataType() { - MESSAGE( "SMESH_Gen_i::ComponentDataType" ); - return strdup( "SMESH" ); + if(MYDEBUG) MESSAGE( "SMESH_Gen_i::ComponentDataType" ); + return CORBA::string_dup( "SMESH" ); } @@ -2150,24 +2359,24 @@ char* SMESH_Gen_i::ComponentDataType() */ //============================================================================= -char* SMESH_Gen_i::IORToLocalPersistentID( SALOMEDS::SObject_ptr theSObject, +char* SMESH_Gen_i::IORToLocalPersistentID( SALOMEDS::SObject_ptr /*theSObject*/, const char* IORString, - CORBA::Boolean isMultiFile, - CORBA::Boolean isASCII ) + CORBA::Boolean /*isMultiFile*/, + CORBA::Boolean /*isASCII*/ ) { - MESSAGE( "SMESH_Gen_i::IORToLocalPersistentID" ); + if(MYDEBUG) MESSAGE( "SMESH_Gen_i::IORToLocalPersistentID" ); StudyContext* myStudyContext = GetCurrentStudyContext(); - if ( strcmp( IORString, "" ) != 0 ) { + if ( myStudyContext && strcmp( IORString, "" ) != 0 ) { int anId = myStudyContext->findId( IORString ); if ( anId ) { - MESSAGE( "VSR " << anId ) + if(MYDEBUG) MESSAGE( "VSR " << anId ) char strId[ 20 ]; sprintf( strId, "%d", anId ); return CORBA::string_dup( strId ); } } - return strdup( "" ); + return CORBA::string_dup( "" ); } //============================================================================= @@ -2178,309 +2387,34 @@ char* SMESH_Gen_i::IORToLocalPersistentID( SALOMEDS::SObject_ptr theSObject, */ //============================================================================= -char* SMESH_Gen_i::LocalPersistentIDToIOR( SALOMEDS::SObject_ptr theSObject, +char* SMESH_Gen_i::LocalPersistentIDToIOR( SALOMEDS::SObject_ptr /*theSObject*/, const char* aLocalPersistentID, - CORBA::Boolean isMultiFile, - CORBA::Boolean isASCII ) + CORBA::Boolean /*isMultiFile*/, + CORBA::Boolean /*isASCII*/ ) { - MESSAGE( "SMESH_Gen_i::LocalPersistentIDToIOR(): id = " << aLocalPersistentID ); + if(MYDEBUG) MESSAGE( "SMESH_Gen_i::LocalPersistentIDToIOR(): id = " << aLocalPersistentID ); StudyContext* myStudyContext = GetCurrentStudyContext(); - if ( strcmp( aLocalPersistentID, "" ) != 0 ) { + if ( myStudyContext && strcmp( aLocalPersistentID, "" ) != 0 ) { int anId = atoi( aLocalPersistentID ); return CORBA::string_dup( myStudyContext->getIORbyOldId( anId ).c_str() ); } - return strdup( "" ); + return CORBA::string_dup( "" ); } -//============================================================================= -/*! - * SMESH_Gen_i::CanPublishInStudy - * - * Returns true if object can be published in the study - */ -//============================================================================= +//======================================================================= +//function : RegisterObject +//purpose : +//======================================================================= -bool SMESH_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR) +int SMESH_Gen_i::RegisterObject(CORBA::Object_ptr theObject) { - SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(theIOR); - if( !aMesh->_is_nil() ) - return true; - - SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(theIOR); - if( !aSubMesh->_is_nil() ) - return true; - - SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow(theIOR); - if( !aHyp->_is_nil() ) - return true; - - SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_narrow(theIOR); - if( !aGroup->_is_nil() ) - return true; - - return false; -} - -//============================================================================= -/*! - * SMESH_Gen_i::PublishInStudy - * - * Publish object in the study - */ -//============================================================================= - -SALOMEDS::SObject_ptr SMESH_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy, - SALOMEDS::SObject_ptr theSObject, - CORBA::Object_ptr theIOR, - const char* theName) -throw (SALOME::SALOME_Exception) -{ - Unexpect aCatch(SALOME_SalomeException); - MESSAGE( "********** SMESH_Gen_i::PublishInStudy()" ); - SALOMEDS::SObject_var aSO; - - // san - first try to find SObject corresponding to SMESH component in theStudy - // It is dangerous to use FindComponent("MESH") for this, as some other component - // of type "MESH" might be present in theStudy. - // So component's user name obtained from ModuleCatalog is passed to FindObject()... - SALOME_ModuleCatalog::ModuleCatalog_var aCat = - SALOME_ModuleCatalog::ModuleCatalog::_narrow( GetNS()->Resolve("/Kernel/ModulCatalog") ); - if ( CORBA::is_nil( aCat ) ) - return aSO._retn(); - - SALOME_ModuleCatalog::Acomponent_var aComp = aCat->GetComponent( "SMESH" ); - if ( CORBA::is_nil( aComp ) ) - return aSO._retn(); - - SALOMEDS::SComponent_var father = - SALOMEDS::SComponent::_narrow( theStudy->FindObject( strdup( aComp->componentusername() ) ) ); - SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); - - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributePixMap_var aPixmap; - - if ( father->_is_nil() ) { - father = aStudyBuilder->NewComponent( "MESH" ); - anAttr = aStudyBuilder->FindOrCreateAttribute( father, "AttributeName" ); - aName = SALOMEDS::AttributeName::_narrow( anAttr ); - aName ->SetValue( strdup( aComp->componentusername() ) ); - anAttr = aStudyBuilder->FindOrCreateAttribute( father, "AttributePixMap" ); - aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr ); - aPixmap ->SetPixMap( "ICON_OBJBROWSER_SMESH" ); - aStudyBuilder->DefineComponentInstance( father, SMESH_Gen::_this() ); - } - - if ( father->_is_nil() ) - return aSO._retn(); - - SALOMEDS::AttributeIOR_var anIOR; - SALOMEDS::AttributeSelectable_var aSelAttr; - TCollection_AsciiString anObjName("obj"); - - // Publishing a mesh - SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( theIOR ); - if( !aMesh->_is_nil() ) { - // Find correct free tag - long aTag = FindMaxChildTag( father.in() ); - if ( aTag <= GetAlgorithmsRootTag() ) - aTag = GetAlgorithmsRootTag() + 1; - else - aTag++; - // Add New Mesh - SALOMEDS::SObject_var newMesh = aStudyBuilder->NewObjectToTag( father, aTag ); - anAttr = aStudyBuilder->FindOrCreateAttribute( newMesh, "AttributePixMap" ); - aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr ); - aPixmap ->SetPixMap( "ICON_SMESH_TREE_MESH" ); - anAttr = aStudyBuilder->FindOrCreateAttribute( newMesh, "AttributeIOR" ); - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - anIOR ->SetValue( GetORB()->object_to_string( aMesh ) ); - aSO = SALOMEDS::SObject::_narrow( newMesh ); - anObjName = TCollection_AsciiString( "Mesh" ); - } - - // Publishing a sub-mesh - SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( theIOR ); - if( aSO->_is_nil() && !aSubMesh->_is_nil() ) { - // try to obtain a parent mesh's SObject - MESSAGE( "********** SMESH_Gen_i::PublishInStudy(): publishing submesh..." ); - SALOMEDS::SObject_var aParentSO; - SMESH::SMESH_Mesh_var aParentMesh; - SMESH_subMesh_i* aServant = dynamic_cast( GetServant( aSubMesh ).in() ); - if ( aServant != NULL ) { - aParentMesh = aServant->_mesh_i->_this(); - if ( !aParentMesh->_is_nil() ) { - aParentSO = theStudy->FindObjectIOR( GetORB()->object_to_string( aParentMesh ) ); - } - } - - // Find submesh sub-tree tag - if ( !aParentSO->_is_nil() ) { - long aRootTag = GetSubMeshOnVertexTag(); - char* aRootName = ""; - - SMESH_Mesh_i* aMeshServant = aServant->_mesh_i; - if ( aMeshServant->_mapSubMesh.find( aServant->GetId() ) != aMeshServant->_mapSubMesh.end() ) { - MESSAGE( "********** SMESH_Gen_i::PublishInStudy(): local submesh found" ) - SMESH_subMesh* aLocalSubMesh = aMeshServant->_mapSubMesh[aServant->GetId()]; - switch ( aLocalSubMesh->GetSubShape().ShapeType() ) { - case TopAbs_VERTEX: - aRootTag = GetSubMeshOnVertexTag(); - aRootName = "SubMeshes on Vertex"; - break; - case TopAbs_EDGE: - aRootTag = GetSubMeshOnEdgeTag(); - aRootName = "SubMeshes on Edge"; - break; - case TopAbs_FACE: - aRootTag = GetSubMeshOnFaceTag(); - aRootName = "SubMeshes on Face"; - break; - case TopAbs_SOLID: - aRootTag = GetSubMeshOnSolidTag(); - aRootName = "SubMeshes on Solid"; - break; - default: - aRootTag = GetSubMeshOnCompoundTag(); - aRootName = "SubMeshes on Compound"; - break; - } - } - - // Find or create submesh root - SALOMEDS::SObject_var aRootSO; - if ( !aParentSO->FindSubObject ( aRootTag, aRootSO ) ) { - MESSAGE( "********** SMESH_Gen_i::PublishInStudy(): creating submesh root..." ) - aRootSO = aStudyBuilder->NewObjectToTag( aParentSO, aRootTag ); - anAttr = aStudyBuilder->FindOrCreateAttribute( aRootSO, "AttributeName" ); - aName = SALOMEDS::AttributeName::_narrow( anAttr ); - aName ->SetValue( aRootName ); - anAttr = aStudyBuilder->FindOrCreateAttribute( aRootSO, "AttributeSelectable" ); - aSelAttr = SALOMEDS::AttributeSelectable::_narrow( anAttr ); - aSelAttr ->SetSelectable( false ); - } - - // Add new submesh to corresponding sub-tree - MESSAGE( "********** SMESH_Gen_i::PublishInStudy(): adding submesh to study..." ) - SALOMEDS::SObject_var newMesh = aStudyBuilder->NewObject( aRootSO ); - anAttr = aStudyBuilder->FindOrCreateAttribute( newMesh, "AttributePixMap" ); - aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr ); - aPixmap ->SetPixMap( "ICON_SMESH_TREE_MESH" ); - anAttr = aStudyBuilder->FindOrCreateAttribute( newMesh, "AttributeIOR" ); - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - anIOR ->SetValue( GetORB()->object_to_string( aSubMesh ) ); - aSO = SALOMEDS::SObject::_narrow( newMesh ); - anObjName = TCollection_AsciiString( "SubMesh" ); - } - } - - // Publishing a hypothesis or algorithm - SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( theIOR ); - if( aSO->_is_nil() && !aHyp->_is_nil() ) { - //Find or Create Hypothesis root - SALOMEDS::SObject_var HypothesisRoot; - Standard_Integer aRootTag = - SMESH::SMESH_Algo::_narrow( theIOR )->_is_nil() ? GetHypothesisRootTag() : GetAlgorithmsRootTag(); - - if ( !father->FindSubObject ( aRootTag, HypothesisRoot ) ) { - HypothesisRoot = aStudyBuilder->NewObjectToTag( father, aRootTag ); - anAttr = aStudyBuilder->FindOrCreateAttribute( HypothesisRoot, "AttributeName" ); - aName = SALOMEDS::AttributeName::_narrow( anAttr ); - aName ->SetValue( aRootTag == GetHypothesisRootTag() ? "Hypotheses" : "Algorithms" ); - anAttr = aStudyBuilder->FindOrCreateAttribute( HypothesisRoot, "AttributeSelectable" ); - aSelAttr = SALOMEDS::AttributeSelectable::_narrow( anAttr ); - aSelAttr ->SetSelectable( false ); - anAttr = aStudyBuilder->FindOrCreateAttribute( HypothesisRoot, "AttributePixMap" ); - aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr ); - aPixmap ->SetPixMap( aRootTag == GetHypothesisRootTag() ? "ICON_SMESH_TREE_HYPO" : "ICON_SMESH_TREE_ALGO" ); - } - - // Add New Hypothesis - string aPmName; - SALOMEDS::SObject_var newHypo = aStudyBuilder->NewObject( HypothesisRoot ); - anAttr = aStudyBuilder->FindOrCreateAttribute( newHypo, "AttributePixMap" ); - aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr ); - aPmName = ( aRootTag == GetHypothesisRootTag() ? "ICON_SMESH_TREE_HYPO_" : "ICON_SMESH_TREE_ALGO_" ); - aPmName += aHyp->GetName(); - aPixmap ->SetPixMap( aPmName.c_str() ); - anAttr = aStudyBuilder->FindOrCreateAttribute( newHypo, "AttributeIOR" ); - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - anIOR ->SetValue( GetORB()->object_to_string( aHyp ) ); - aSO = SALOMEDS::SObject::_narrow( newHypo ); - anObjName = TCollection_AsciiString( aHyp->GetName() ); - } - - // Publishing a group - SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_narrow(theIOR); - if( aSO->_is_nil() && !aGroup->_is_nil() ) { - // try to obtain a parent mesh's SObject - MESSAGE( "********** SMESH_Gen_i::PublishInStudy(): publishing group..." ); - SALOMEDS::SObject_var aParentSO; - SMESH::SMESH_Mesh_var aParentMesh; - SMESH_Group_i* aServant = dynamic_cast( GetServant( aGroup ).in() ); - if ( aServant != NULL ) { - aParentMesh = SMESH::SMESH_Mesh::_narrow( GetPOA()->servant_to_reference( aServant->GetMeshServant() ) ); - if ( !aParentMesh->_is_nil() ) { - MESSAGE( "********** SMESH_Gen_i::PublishInStudy(): publishing group: refernce to mesh is OK" ); - string anIOR = GetORB()->object_to_string( aParentMesh ); - MESSAGE( "********** SMESH_Gen_i::PublishInStudy(): publishing group: mesh IOR = "<FindObjectIOR( anIOR.c_str() ); - } - } - - // Find proper group sub-tree tag - if ( !aParentSO->_is_nil() ) { - MESSAGE( "********** SMESH_Gen_i::PublishInStudy(): publishing group: parent mesh found" ); - int aType = (int)aGroup->GetType(); - const char* aRootNames[] = { "Compound Groups", "Groups of Nodes", "Groups of Edges", "Groups of Faces", "Groups of Volumes" }; - - // Currently, groups with heterogenous content are not supported - if ( aType != SMESH::ALL ) { - MESSAGE( "********** SMESH_Gen_i::PublishInStudy(): publishing group: group type OK" ); - long aRootTag = GetNodeGroupsTag() + aType - 1; - - // Find or create groups root - SALOMEDS::SObject_var aRootSO; - if ( !aParentSO->FindSubObject ( aRootTag, aRootSO ) ) { - MESSAGE( "********** SMESH_Gen_i::PublishInStudy(): creating groups root..." ) - aRootSO = aStudyBuilder->NewObjectToTag( aParentSO, aRootTag ); - anAttr = aStudyBuilder->FindOrCreateAttribute( aRootSO, "AttributeName" ); - aName = SALOMEDS::AttributeName::_narrow( anAttr ); - aName ->SetValue( aRootNames[aType] ); - anAttr = aStudyBuilder->FindOrCreateAttribute( aRootSO, "AttributeSelectable" ); - aSelAttr = SALOMEDS::AttributeSelectable::_narrow( anAttr ); - aSelAttr ->SetSelectable( false ); - } - - // Add new group to corresponding sub-tree - MESSAGE( "********** SMESH_Gen_i::PublishInStudy(): adding group to study..." ) - SALOMEDS::SObject_var aGroupSO = aStudyBuilder->NewObject( aRootSO ); - anAttr = aStudyBuilder->FindOrCreateAttribute( aGroupSO, "AttributePixMap" ); - aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr ); - aPixmap ->SetPixMap( "ICON_SMESH_TREE_GROUP" ); - anAttr = aStudyBuilder->FindOrCreateAttribute( aGroupSO, "AttributeIOR" ); - anIOR = SALOMEDS::AttributeIOR::_narrow( anAttr ); - anIOR ->SetValue( GetORB()->object_to_string( aGroup ) ); - aSO = SALOMEDS::SObject::_narrow( aGroupSO ); - anObjName = TCollection_AsciiString( "Group" ); - } - } - } - - // Setting SObject's name - if ( !aSO->_is_nil() ) { - if ( strlen( theName ) == 0 ) - anObjName += TCollection_AsciiString( "_" ) + TCollection_AsciiString( aSO->Tag() ); - else - anObjName = TCollection_AsciiString( strdup( theName ) ); - anAttr = aStudyBuilder->FindOrCreateAttribute( aSO, "AttributeName" ); - aName = SALOMEDS::AttributeName::_narrow( anAttr ); - aName ->SetValue( anObjName.ToCString() ); + StudyContext* myStudyContext = GetCurrentStudyContext(); + if ( myStudyContext && !CORBA::is_nil( theObject )) { + string iorString = GetORB()->object_to_string( theObject ); + return myStudyContext->addObject( iorString ); } - - MESSAGE( "********** SMESH_Gen_i::PublishInStudy(): COMPLETED" ) - return aSO._retn(); + return 0; } //============================================================================= @@ -2499,10 +2433,9 @@ extern "C" const char* instanceName, const char* interfaceName ) { - MESSAGE( "PortableServer::ObjectId* SMESHEngine_factory()" ); - SCRUTE(interfaceName); - SMESH_Gen_i * mySMESH_Gen - = new SMESH_Gen_i(orb, poa, contId, instanceName, interfaceName); - return mySMESH_Gen->getId() ; + if(MYDEBUG) MESSAGE( "PortableServer::ObjectId* SMESHEngine_factory()" ); + if(MYDEBUG) SCRUTE(interfaceName); + SMESH_Gen_i* aSMESHGen = new SMESH_Gen_i(orb, poa, contId, instanceName, interfaceName); + return aSMESHGen->getId() ; } } diff --git a/src/SMESH_I/SMESH_Gen_i.hxx b/src/SMESH_I/SMESH_Gen_i.hxx index 77e3adf43..a93301653 100644 --- a/src/SMESH_I/SMESH_Gen_i.hxx +++ b/src/SMESH_I/SMESH_Gen_i.hxx @@ -34,7 +34,6 @@ #include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_Hypothesis) #include CORBA_CLIENT_HEADER(GEOM_Gen) -#include CORBA_CLIENT_HEADER(GEOM_Shape) #include CORBA_CLIENT_HEADER(SALOMEDS) #include CORBA_CLIENT_HEADER(SALOMEDS_Attributes) @@ -44,7 +43,6 @@ #include "SALOME_NamingService.hxx" #include "SMESH_Gen.hxx" -#include "SMESH_topo.hxx" #include "GEOM_Client.hxx" #include @@ -124,6 +122,8 @@ class SMESH_Gen_i: public virtual Engines_Component_i { public: + // Get last created instance of the class + static SMESH_Gen_i* GetSMESHGen() { return mySMESHGen;} // Get ORB object static CORBA::ORB_var GetORB() { return myOrb;} // Get SMESH module's POA object @@ -138,7 +138,14 @@ public: static PortableServer::ServantBase_var GetServant( CORBA::Object_ptr theObject ); // Get CORBA object corresponding to the SALOMEDS::SObject static CORBA::Object_var SObjectToObject( SALOMEDS::SObject_ptr theSObject ); - + // Get the SALOMEDS::SObject corresponding to a CORBA object + static SALOMEDS::SObject_ptr ObjectToSObject(SALOMEDS::Study_ptr theStudy, + CORBA::Object_ptr theObject); + // Get GEOM Object correspoding to TopoDS_Shape + GEOM::GEOM_Object_ptr ShapeToGeomObject (const TopoDS_Shape& theShape ); + // Get TopoDS_Shape correspoding to GEOM_Object + TopoDS_Shape GeomObjectToShape(GEOM::GEOM_Object_ptr theGeomObject); + // Default constructor SMESH_Gen_i(); // Standard constructor @@ -165,7 +172,11 @@ public: throw ( SALOME::SALOME_Exception ); // Create empty mesh on a shape - SMESH::SMESH_Mesh_ptr CreateMesh( GEOM::GEOM_Shape_ptr theShape ) + SMESH::SMESH_Mesh_ptr CreateMesh( GEOM::GEOM_Object_ptr theShapeObject ) + throw ( SALOME::SALOME_Exception ); + + // Create mesh(es) and import data from UNV file + SMESH::SMESH_Mesh_ptr CreateMeshesFromUNV( const char* theFileName ) throw ( SALOME::SALOME_Exception ); // Create mesh(es) and import data from MED file @@ -173,19 +184,23 @@ public: SMESH::DriverMED_ReadStatus& theStatus ) throw ( SALOME::SALOME_Exception ); + // Create mesh(es) and import data from STL file + SMESH::SMESH_Mesh_ptr CreateMeshesFromSTL( const char* theFileName ) + throw ( SALOME::SALOME_Exception ); + // Compute mesh on a shape CORBA::Boolean Compute( SMESH::SMESH_Mesh_ptr theMesh, - GEOM::GEOM_Shape_ptr theShape ) + GEOM::GEOM_Object_ptr theShapeObject ) throw ( SALOME::SALOME_Exception ); // Returns true if mesh contains enough data to be computed CORBA::Boolean IsReadyToCompute( SMESH::SMESH_Mesh_ptr theMesh, - GEOM::GEOM_Shape_ptr theShape ) + GEOM::GEOM_Object_ptr theShapeObject ) throw ( SALOME::SALOME_Exception ); // Get sub-shapes unique ID's list - SMESH::long_array* GetSubShapesId( GEOM::GEOM_Shape_ptr theMainShape, - const SMESH::shape_array& theListOfSubShape ) + SMESH::long_array* GetSubShapesId( GEOM::GEOM_Object_ptr theMainShapeObject, + const SMESH::object_array& theListOfSubShape ) throw ( SALOME::SALOME_Exception ); @@ -195,8 +210,8 @@ public: // Save SMESH data SALOMEDS::TMPFile* Save( SALOMEDS::SComponent_ptr theComponent, - const char* theURL, - bool isMultiFile ); + const char* theURL, + bool isMultiFile ); // Load SMESH data bool Load( SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream, @@ -215,6 +230,9 @@ public: // Create filter manager SMESH::FilterManager_ptr CreateFilterManager(); + // Return a pattern mesher + SMESH::SMESH_Pattern_ptr GetPattern(); + // Clears study-connected data when it is closed void Close( SALOMEDS::SComponent_ptr theComponent ); @@ -273,14 +291,56 @@ public: static long GetSubMeshOnFaceTag(); static long GetSubMeshOnSolidTag(); static long GetSubMeshOnCompoundTag(); + static long GetSubMeshOnWireTag(); + static long GetSubMeshOnShellTag(); static long GetNodeGroupsTag(); static long GetEdgeGroupsTag(); static long GetFaceGroupsTag(); static long GetVolumeGroupsTag(); + // publishing methods + SALOMEDS::SComponent_ptr PublishComponent(SALOMEDS::Study_ptr theStudy); + SALOMEDS::SObject_ptr PublishMesh (SALOMEDS::Study_ptr theStudy, + SMESH::SMESH_Mesh_ptr theMesh, + const char* theName = 0); + SALOMEDS::SObject_ptr PublishHypothesis (SALOMEDS::Study_ptr theStudy, + SMESH::SMESH_Hypothesis_ptr theHyp, + const char* theName = 0); + SALOMEDS::SObject_ptr PublishSubMesh (SALOMEDS::Study_ptr theStudy, + SMESH::SMESH_Mesh_ptr theMesh, + SMESH::SMESH_subMesh_ptr theSubMesh, + GEOM::GEOM_Object_ptr theShapeObject, + const char* theName = 0); + SALOMEDS::SObject_ptr PublishGroup (SALOMEDS::Study_ptr theStudy, + SMESH::SMESH_Mesh_ptr theMesh, + SMESH::SMESH_GroupBase_ptr theGroup, + GEOM::GEOM_Object_ptr theShapeObject, + const char* theName = 0); + bool AddHypothesisToShape(SALOMEDS::Study_ptr theStudy, + SMESH::SMESH_Mesh_ptr theMesh, + GEOM::GEOM_Object_ptr theShapeObject, + SMESH::SMESH_Hypothesis_ptr theHyp); + bool RemoveHypothesisFromShape(SALOMEDS::Study_ptr theStudy, + SMESH::SMESH_Mesh_ptr theMesh, + GEOM::GEOM_Object_ptr theShapeObject, + SMESH::SMESH_Hypothesis_ptr theHyp); + SALOMEDS::SObject_ptr GetMeshOrSubmeshByShape (SALOMEDS::Study_ptr theStudy, + SMESH::SMESH_Mesh_ptr theMesh, + GEOM::GEOM_Object_ptr theShape); + static void SetName(SALOMEDS::SObject_ptr theSObject, + const char* theName, + const char* theDefaultName = 0); + // Get study context StudyContext* GetCurrentStudyContext(); - + + // Register an object in a StudyContext; return object id + int RegisterObject(CORBA::Object_ptr theObject); + + // Get current study ID + int GetCurrentStudyID() + { return myCurrentStudy->_is_nil() ? -1 : myCurrentStudy->StudyId(); } + private: // Create hypothesis of given type SMESH::SMESH_Hypothesis_ptr createHypothesis( const char* theHypName, @@ -299,7 +359,7 @@ private: static PortableServer::POA_var myPoa; // POA reference static SALOME_NamingService* myNS; // Naming Service static SALOME_LifeCycleCORBA* myLCC; // Life Cycle CORBA - + static SMESH_Gen_i* mySMESHGen; // Point to last created instance of the class ::SMESH_Gen myGen; // SMESH_Gen local implementation // hypotheses managing diff --git a/src/SMESH_I/SMESH_Gen_i_1.cxx b/src/SMESH_I/SMESH_Gen_i_1.cxx new file mode 100644 index 000000000..dd9c3893f --- /dev/null +++ b/src/SMESH_I/SMESH_Gen_i_1.cxx @@ -0,0 +1,850 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// File : SMESH_Gen_i_1.cxx +// Created : Thu Oct 21 17:24:06 2004 +// Author : Edward AGAPOV (eap) +// Module : SMESH +// $Header: + +#include "SMESH_Gen_i.hxx" + +#include "SMESH_Mesh_i.hxx" +#include "SMESH_Hypothesis_i.hxx" +#include "SMESH_Algo_i.hxx" +#include "SMESH_Group_i.hxx" + +#include CORBA_CLIENT_HEADER(SALOME_ModuleCatalog) + +#include "utilities.h" +#include "Utils_ExceptHandlers.hxx" + +#include + +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif + +// Tags definition =========================================================== +// Top level +long Tag_HypothesisRoot = 1; // hypotheses root +long Tag_AlgorithmsRoot = 2; // algorithms root +// Mesh/Submesh +long Tag_RefOnShape = 1; // references to shape +long Tag_RefOnAppliedHypothesis = 2; // applied hypotheses root +long Tag_RefOnAppliedAlgorithms = 3; // applied algorithms root +// Mesh only +long Tag_SubMeshOnVertex = 4; // sub-meshes roots by type +long Tag_SubMeshOnEdge = 5; // ... +long Tag_SubMeshOnWire = 6; // ... +long Tag_SubMeshOnFace = 7; // ... +long Tag_SubMeshOnShell = 8; // ... +long Tag_SubMeshOnSolid = 9; // ... +long Tag_SubMeshOnCompound = 10; // ... +long Tag_NodeGroups = 11; // Group roots by type +long Tag_EdgeGroups = 12; // ... +long Tag_FaceGroups = 13; // ... +long Tag_VolumeGroups = 14; // ... +// =========================================================================== + +//============================================================================= +/*! + * Get...Tag [ static ] + * + * Methods which determine SMESH data model structure + */ +//============================================================================= + +long SMESH_Gen_i::GetHypothesisRootTag() +{ + return Tag_HypothesisRoot; +} + +long SMESH_Gen_i::GetAlgorithmsRootTag() +{ + return Tag_AlgorithmsRoot; +} + +long SMESH_Gen_i::GetRefOnShapeTag() +{ + return Tag_RefOnShape; +} + +long SMESH_Gen_i::GetRefOnAppliedHypothesisTag() +{ + return Tag_RefOnAppliedHypothesis; +} + +long SMESH_Gen_i::GetRefOnAppliedAlgorithmsTag() +{ + return Tag_RefOnAppliedAlgorithms; +} + +long SMESH_Gen_i::GetSubMeshOnVertexTag() +{ + return Tag_SubMeshOnVertex; +} + +long SMESH_Gen_i::GetSubMeshOnEdgeTag() +{ + return Tag_SubMeshOnEdge; +} + +long SMESH_Gen_i::GetSubMeshOnFaceTag() +{ + return Tag_SubMeshOnFace; +} + +long SMESH_Gen_i::GetSubMeshOnSolidTag() +{ + return Tag_SubMeshOnSolid; +} + +long SMESH_Gen_i::GetSubMeshOnCompoundTag() +{ + return Tag_SubMeshOnCompound; +} + +long SMESH_Gen_i::GetSubMeshOnWireTag() +{ + return Tag_SubMeshOnWire; +} + +long SMESH_Gen_i::GetSubMeshOnShellTag() +{ + return Tag_SubMeshOnShell; +} + +long SMESH_Gen_i::GetNodeGroupsTag() +{ + return Tag_NodeGroups; +} + +long SMESH_Gen_i::GetEdgeGroupsTag() +{ + return Tag_EdgeGroups; +} + +long SMESH_Gen_i::GetFaceGroupsTag() +{ + return Tag_FaceGroups; +} + +long SMESH_Gen_i::GetVolumeGroupsTag() +{ + return Tag_VolumeGroups; +} + +//============================================================================= +/*! + * SMESH_Gen_i::CanPublishInStudy + * + * Returns true if object can be published in the study + */ +//============================================================================= + +bool SMESH_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR) +{ + if(MYDEBUG) MESSAGE("CanPublishInStudy"); + SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(theIOR); + if( !aMesh->_is_nil() ) + return true; + + SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(theIOR); + if( !aSubMesh->_is_nil() ) + return true; + + SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow(theIOR); + if( !aHyp->_is_nil() ) + return true; + + SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(theIOR); + if( !aGroup->_is_nil() ) + return true; + + if(MYDEBUG) MESSAGE("CanPublishInStudy--CANT"); + return false; +} + +//======================================================================= +//function : ObjectToSObject +//purpose : +//======================================================================= + +SALOMEDS::SObject_ptr SMESH_Gen_i::ObjectToSObject(SALOMEDS::Study_ptr theStudy, + CORBA::Object_ptr theObject) +{ + SALOMEDS::SObject_var aSO; + if ( !CORBA::is_nil( theStudy ) && !CORBA::is_nil( theObject )) + aSO = theStudy->FindObjectIOR( SMESH_Gen_i::GetORB()->object_to_string( theObject ) ); + return aSO._retn(); +} + +//======================================================================= +//function : objectToServant +//purpose : +//======================================================================= + +template static inline T* objectToServant( CORBA::Object_ptr theIOR ) +{ + return dynamic_cast( SMESH_Gen_i::GetServant( theIOR ).in() ); +} + +//======================================================================= +//function : ShapeToGeomObject +//purpose : +//======================================================================= + +GEOM::GEOM_Object_ptr SMESH_Gen_i::ShapeToGeomObject (const TopoDS_Shape& theShape ) +{ + GEOM::GEOM_Object_var aShapeObj; + if ( !theShape.IsNull() ) { + GEOM_Client* aClient = GetShapeReader(); + TCollection_AsciiString IOR; + if ( aClient && aClient->Find( theShape, IOR )) + aShapeObj = GEOM::GEOM_Object::_narrow + ( GetORB()->string_to_object( IOR.ToCString() ) ); + } + return aShapeObj._retn(); +} + +//======================================================================= +//function : GeomObjectToShape +//purpose : +//======================================================================= + +TopoDS_Shape SMESH_Gen_i::GeomObjectToShape(GEOM::GEOM_Object_ptr theGeomObject) +{ + TopoDS_Shape S; + if ( !theGeomObject->_is_nil() ) { + GEOM_Client* aClient = GetShapeReader(); + GEOM::GEOM_Gen_var aGeomEngine = GetGeomEngine(); + if ( aClient && !aGeomEngine->_is_nil () ) + S = aClient->GetShape( aGeomEngine, theGeomObject ); + } + return S; +} + +//======================================================================= +//function : publish +//purpose : +//======================================================================= + +static SALOMEDS::SObject_ptr publish(SALOMEDS::Study_ptr theStudy, + CORBA::Object_ptr theIOR, + SALOMEDS::SObject_ptr theFatherObject, + const int theTag = 0, + const char* thePixMap = 0, + const bool theSelectable = true) +{ + SALOMEDS::SObject_var SO = SMESH_Gen_i::ObjectToSObject( theStudy, theIOR ); + SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); + if ( SO->_is_nil() ) { + if ( theTag == 0 ) + SO = aStudyBuilder->NewObject( theFatherObject ); + else if ( !theFatherObject->FindSubObject( theTag, SO )) + SO = aStudyBuilder->NewObjectToTag( theFatherObject, theTag ); + } + + SALOMEDS::GenericAttribute_var anAttr; + if ( !CORBA::is_nil( theIOR )) { + anAttr = aStudyBuilder->FindOrCreateAttribute( SO, "AttributeIOR" ); + SALOMEDS::AttributeIOR::_narrow(anAttr)->SetValue + ( SMESH_Gen_i::GetORB()->object_to_string( theIOR ) ); + } + if ( thePixMap ) { + anAttr = aStudyBuilder->FindOrCreateAttribute( SO, "AttributePixMap" ); + SALOMEDS::AttributePixMap::_narrow( anAttr )->SetPixMap( thePixMap ); + } + if ( !theSelectable ) { + anAttr = aStudyBuilder->FindOrCreateAttribute( SO, "AttributeSelectable" ); + SALOMEDS::AttributeSelectable::_narrow( anAttr )->SetSelectable( false ); + } + return SO._retn(); +} + +//======================================================================= +//function : setName +//purpose : +//======================================================================= + +void SMESH_Gen_i::SetName(SALOMEDS::SObject_ptr theSObject, + const char* theName, + const char* theDefaultName) +{ + if ( !theSObject->_is_nil() ) { + SALOMEDS::StudyBuilder_var aStudyBuilder = theSObject->GetStudy()->NewBuilder(); + SALOMEDS::GenericAttribute_var anAttr = + aStudyBuilder->FindOrCreateAttribute( theSObject, "AttributeName" ); + SALOMEDS::AttributeName_var aNameAttr = SALOMEDS::AttributeName::_narrow( anAttr ); + if ( theName && strlen( theName ) != 0 ) + aNameAttr->SetValue( theName ); + else { + CORBA::String_var curName = CORBA::string_dup( aNameAttr->Value() ); + if ( strlen( curName ) == 0 ) { + TCollection_AsciiString aName( (char*) theDefaultName ); + aName += TCollection_AsciiString("_") + TCollection_AsciiString( theSObject->Tag() ); + aNameAttr->SetValue( aName.ToCString() ); + } + } + } +} + +//======================================================================= +//function : addReference +//purpose : +//======================================================================= + +static void addReference (SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theSObject, + CORBA::Object_ptr theToObject, + int theTag = 0) +{ + SALOMEDS::SObject_var aToObjSO = SMESH_Gen_i::ObjectToSObject( theStudy, theToObject ); + if ( !aToObjSO->_is_nil() && !theSObject->_is_nil() ) { + SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); + SALOMEDS::SObject_var aReferenceSO; + if ( !theTag ) { + bool isReferred = false; + SALOMEDS::ChildIterator_var anIter = theStudy->NewChildIterator( theSObject ); + for ( ; !isReferred && anIter->More(); anIter->Next() ) { + if ( anIter->Value()->ReferencedObject( aReferenceSO ) && + strcmp( aReferenceSO->GetID(), aToObjSO->GetID() ) == 0 ) + isReferred = true; + } + if ( !isReferred ) { + aReferenceSO = aStudyBuilder->NewObject( theSObject ); + aStudyBuilder->Addreference( aReferenceSO, aToObjSO ); + } + } + else { + if ( !theSObject->FindSubObject( theTag, aReferenceSO )) + aReferenceSO = aStudyBuilder->NewObjectToTag( theSObject, theTag ); + aStudyBuilder->Addreference( aReferenceSO, aToObjSO ); + } + } +} + +//============================================================================= +/*! + * SMESH_Gen_i::PublishInStudy + * + * Publish object in the study + */ +//============================================================================= + +SALOMEDS::SObject_ptr SMESH_Gen_i::PublishInStudy(SALOMEDS::Study_ptr theStudy, + SALOMEDS::SObject_ptr theSObject, + CORBA::Object_ptr theIOR, + const char* theName) + throw (SALOME::SALOME_Exception) +{ + Unexpect aCatch(SALOME_SalomeException); + SALOMEDS::SObject_var aSO; + if ( CORBA::is_nil( theStudy ) || CORBA::is_nil( theIOR )) + return aSO._retn(); + if(MYDEBUG) MESSAGE("PublishInStudy"); + + // Publishing a mesh + SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow( theIOR ); + if( !aMesh->_is_nil() ) + aSO = PublishMesh( theStudy, aMesh, theName ); + + // Publishing a sub-mesh + SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow( theIOR ); + if( aSO->_is_nil() && !aSubMesh->_is_nil() ) { + GEOM::GEOM_Object_var aShapeObject = aSubMesh->GetSubShape(); + aMesh = aSubMesh->GetFather(); + aSO = PublishSubMesh( theStudy, aMesh, aSubMesh, aShapeObject, theName ); + } + + // Publishing a hypothesis or algorithm + SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( theIOR ); + if ( aSO->_is_nil() && !aHyp->_is_nil() ) + aSO = PublishHypothesis( theStudy, aHyp ); + + // Publishing a group + SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(theIOR); + if ( aSO->_is_nil() && !aGroup->_is_nil() ) { + GEOM::GEOM_Object_var aShapeObject; + aMesh = aGroup->GetMesh(); + aSO = PublishGroup( theStudy, aMesh, aGroup, aShapeObject, theName ); + } + if(MYDEBUG) MESSAGE("PublishInStudy_END"); + + return aSO._retn(); +} + +//======================================================================= +//function : PublishComponent +//purpose : +//======================================================================= + +SALOMEDS::SComponent_ptr SMESH_Gen_i::PublishComponent(SALOMEDS::Study_ptr theStudy) +{ + if ( CORBA::is_nil( theStudy )) + return SALOMEDS::SComponent::_nil(); + if(MYDEBUG) MESSAGE("PublishComponent"); + + SALOMEDS::SComponent_var father = + SALOMEDS::SComponent::_narrow( theStudy->FindComponent( ComponentDataType() ) ); + if ( !CORBA::is_nil( father ) ) + return father._retn(); + + SALOME_ModuleCatalog::ModuleCatalog_var aCat = + SALOME_ModuleCatalog::ModuleCatalog::_narrow( GetNS()->Resolve("/Kernel/ModulCatalog") ); + if ( CORBA::is_nil( aCat ) ) + return father._retn(); + + SALOME_ModuleCatalog::Acomponent_var aComp = aCat->GetComponent( ComponentDataType() ); + if ( CORBA::is_nil( aComp ) ) + return father._retn(); + + SALOMEDS::StudyBuilder_var aStudyBuilder = theStudy->NewBuilder(); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributePixMap_var aPixmap; + + father = aStudyBuilder->NewComponent( ComponentDataType() ); + aStudyBuilder->DefineComponentInstance( father, SMESH_Gen::_this() ); + anAttr = aStudyBuilder->FindOrCreateAttribute( father, "AttributePixMap" ); + aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr ); + aPixmap ->SetPixMap( "ICON_OBJBROWSER_SMESH" ); + SetName( father, aComp->componentusername(), "MESH" ); + if(MYDEBUG) MESSAGE("PublishComponent--END"); + + return father._retn(); +} + +//============================================================================= +/*! + * findMaxChildTag [ static internal ] + * + * Finds maximum child tag for the given object + */ +//============================================================================= + +static long findMaxChildTag( SALOMEDS::SObject_ptr theSObject ) +{ + long aTag = 0; + if ( !theSObject->_is_nil() ) { + SALOMEDS::Study_var aStudy = theSObject->GetStudy(); + if ( !aStudy->_is_nil() ) { + SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator( theSObject ); + for ( ; anIter->More(); anIter->Next() ) { + long nTag = anIter->Value()->Tag(); + if ( nTag > aTag ) + aTag = nTag; + } + } + } + return aTag; +} + +//======================================================================= +//function : PublishMesh +//purpose : +//======================================================================= + +SALOMEDS::SObject_ptr SMESH_Gen_i::PublishMesh (SALOMEDS::Study_ptr theStudy, + SMESH::SMESH_Mesh_ptr theMesh, + const char* theName) +{ + if ( CORBA::is_nil( theStudy ) || + CORBA::is_nil( theMesh )) + return SALOMEDS::SComponent::_nil(); + if(MYDEBUG) MESSAGE("PublishMesh--IN"); + + // find or publish a mesh + + SALOMEDS::SObject_var aMeshSO = ObjectToSObject( theStudy, theMesh ); + if ( aMeshSO->_is_nil() ) + { + SALOMEDS::SComponent_var father = PublishComponent( theStudy ); + if ( father->_is_nil() ) + return aMeshSO._retn(); + + // Find correct free tag + long aTag = findMaxChildTag( father.in() ); + if ( aTag <= GetAlgorithmsRootTag() ) + aTag = GetAlgorithmsRootTag() + 1; + else + aTag++; + + aMeshSO = publish (theStudy, theMesh, father, aTag, "ICON_SMESH_TREE_MESH" ); + if ( aMeshSO->_is_nil() ) + return aMeshSO._retn(); + } + SetName( aMeshSO, theName, "Mesh" ); + + // Add shape reference + + GEOM::GEOM_Object_var aShapeObject = theMesh->GetShapeToMesh(); + if ( !CORBA::is_nil( aShapeObject )) { + addReference( theStudy, aMeshSO, aShapeObject, GetRefOnShapeTag() ); + + // Publish global hypotheses + + SMESH::ListOfHypothesis * hypList = theMesh->GetHypothesisList( aShapeObject ); + if ( hypList ) + for ( int i = 0; i < hypList->length(); i++ ) { + SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( (*hypList)[ i ]); + PublishHypothesis( theStudy, aHyp ); + AddHypothesisToShape( theStudy, theMesh, aShapeObject, aHyp ); + } + } + + // Publish submeshes + + SMESH_Mesh_i* mesh_i = objectToServant( theMesh ); + if ( !mesh_i ) + return aMeshSO._retn(); + map& subMap = mesh_i->_mapSubMesh_i; + map::iterator subIt = subMap.begin(); + for ( ; subIt != subMap.end(); subIt++ ) { + SMESH::SMESH_subMesh_ptr aSubMesh = (*subIt).second->_this(); + if ( !CORBA::is_nil( aSubMesh )) { + aShapeObject = aSubMesh->GetSubShape(); + PublishSubMesh( theStudy, theMesh, aSubMesh, aShapeObject ); + } + } + + // Publish groups + const map& grMap = mesh_i->getGroups(); + map::const_iterator it = grMap.begin(); + for ( ; it != grMap.end(); it++ ) + { + SMESH::SMESH_GroupBase_ptr aGroup = (*it).second; + if ( !aGroup->_is_nil() ) { + GEOM::GEOM_Object_var aShapeObj; + SMESH::SMESH_GroupOnGeom_var aGeomGroup = + SMESH::SMESH_GroupOnGeom::_narrow( aGroup ); + if ( !aGeomGroup->_is_nil() ) + aShapeObj = aGeomGroup->GetShape(); + PublishGroup( theStudy, theMesh, aGroup, aShapeObj ); + } + } + + if(MYDEBUG) MESSAGE("PublishMesh_END"); + return aMeshSO._retn(); +} + +//======================================================================= +//function : PublishSubMesh +//purpose : +//======================================================================= + +SALOMEDS::SObject_ptr SMESH_Gen_i::PublishSubMesh (SALOMEDS::Study_ptr theStudy, + SMESH::SMESH_Mesh_ptr theMesh, + SMESH::SMESH_subMesh_ptr theSubMesh, + GEOM::GEOM_Object_ptr theShapeObject, + const char* theName) +{ + if (theStudy->_is_nil() || theMesh->_is_nil() || + theSubMesh->_is_nil() || theShapeObject->_is_nil() ) + return SALOMEDS::SObject::_nil(); + + SALOMEDS::SObject_var aSubMeshSO = ObjectToSObject( theStudy, theSubMesh ); + if ( aSubMeshSO->_is_nil() ) + { + SALOMEDS::SObject_var aMeshSO = ObjectToSObject( theStudy, theMesh ); + if ( aMeshSO->_is_nil() ) { + aMeshSO = PublishMesh( theStudy, theMesh ); + if ( aMeshSO->_is_nil()) + return SALOMEDS::SObject::_nil(); + } + // Find submesh sub-tree tag + long aRootTag; + char* aRootName = ""; + switch ( theShapeObject->GetShapeType() ) { + case GEOM::VERTEX: + aRootTag = GetSubMeshOnVertexTag(); + aRootName = "SubMeshes on Vertex"; + break; + case GEOM::EDGE: + aRootTag = GetSubMeshOnEdgeTag(); + aRootName = "SubMeshes on Edge"; + break; + case GEOM::WIRE: + aRootTag = GetSubMeshOnWireTag(); + aRootName = "SubMeshes on Wire"; + break; + case GEOM::FACE: + aRootTag = GetSubMeshOnFaceTag(); + aRootName = "SubMeshes on Face"; + break; + case GEOM::SHELL: + aRootTag = GetSubMeshOnShellTag(); + aRootName = "SubMeshes on Shell"; + break; + case GEOM::SOLID: + aRootTag = GetSubMeshOnSolidTag(); + aRootName = "SubMeshes on Solid"; + break; + default: + aRootTag = GetSubMeshOnCompoundTag(); + aRootName = "SubMeshes on Compound"; + break; + } + + // Find or create submesh root + SALOMEDS::SObject_var aRootSO = publish (theStudy, CORBA::Object::_nil(), + aMeshSO, aRootTag, 0, false ); + SetName( aRootSO, aRootName ); + + // Add new submesh to corresponding sub-tree + aSubMeshSO = publish (theStudy, theSubMesh, aRootSO, 0, "ICON_SMESH_TREE_MESH"); + if ( aSubMeshSO->_is_nil() ) + return aSubMeshSO._retn(); + } + SetName( aSubMeshSO, theName, "SubMesh" ); + + // Add reference to theShapeObject + + addReference( theStudy, aSubMeshSO, theShapeObject, 1 ); + + // Publish hypothesis + + SMESH::ListOfHypothesis * hypList = theMesh->GetHypothesisList( theShapeObject ); + if ( hypList ) + for ( int i = 0; i < hypList->length(); i++ ) { + SMESH::SMESH_Hypothesis_var aHyp = SMESH::SMESH_Hypothesis::_narrow( (*hypList)[ i ]); + PublishHypothesis( theStudy, aHyp ); + AddHypothesisToShape( theStudy, theMesh, theShapeObject, aHyp ); + } + + return aSubMeshSO._retn(); +} + +//======================================================================= +//function : PublishGroup +//purpose : +//======================================================================= + +SALOMEDS::SObject_ptr SMESH_Gen_i::PublishGroup (SALOMEDS::Study_ptr theStudy, + SMESH::SMESH_Mesh_ptr theMesh, + SMESH::SMESH_GroupBase_ptr theGroup, + GEOM::GEOM_Object_ptr theShapeObject, + const char* theName) +{ + if (theStudy->_is_nil() || theMesh->_is_nil() || theGroup->_is_nil() ) + return SALOMEDS::SObject::_nil(); + + SALOMEDS::SObject_var aGroupSO = ObjectToSObject( theStudy, theGroup ); + if ( aGroupSO->_is_nil() ) + { + SALOMEDS::SObject_var aMeshSO = ObjectToSObject( theStudy, theMesh ); + if ( aMeshSO->_is_nil() ) { + aMeshSO = PublishInStudy( theStudy, SALOMEDS::SObject::_nil(), theMesh, ""); + if ( aMeshSO->_is_nil()) + return SALOMEDS::SObject::_nil(); + } + int aType = (int)theGroup->GetType(); + const char* aRootNames[] = { + "Compound Groups", "Groups of Nodes", + "Groups of Edges", "Groups of Faces", "Groups of Volumes" }; + + // Currently, groups with heterogenous content are not supported + if ( aType != SMESH::ALL ) { + long aRootTag = GetNodeGroupsTag() + aType - 1; + + // Find or create groups root + SALOMEDS::SObject_var aRootSO = publish (theStudy, CORBA::Object::_nil(), + aMeshSO, aRootTag, 0, false ); + if ( aType < 5 ) + SetName( aRootSO, aRootNames[aType] ); + + // Add new group to corresponding sub-tree + aGroupSO = publish (theStudy, theGroup, aRootSO, 0, "ICON_SMESH_TREE_GROUP" ); + } + if ( aGroupSO->_is_nil() ) + return aGroupSO._retn(); + } + + SetName( aGroupSO, theName, "Group" ); + + //Add reference to geometry + if ( !theShapeObject->_is_nil() ) + addReference( theStudy, aGroupSO, theShapeObject, 1 ); + + return aGroupSO._retn(); +} + +//======================================================================= +//function : PublishHypothesis +//purpose : +//======================================================================= + +SALOMEDS::SObject_ptr + SMESH_Gen_i::PublishHypothesis (SALOMEDS::Study_ptr theStudy, + SMESH::SMESH_Hypothesis_ptr theHyp, + const char* theName) +{ + if(MYDEBUG) MESSAGE("PublishHypothesis") + if (theStudy->_is_nil() || theHyp->_is_nil()) + return SALOMEDS::SObject::_nil(); + + SALOMEDS::SObject_var aHypSO = ObjectToSObject( theStudy, theHyp ); + if ( aHypSO->_is_nil() ) + { + SALOMEDS::SComponent_var father = PublishComponent( theStudy ); + if ( father->_is_nil() ) + return aHypSO._retn(); + + //Find or Create Hypothesis root + bool isAlgo = ( !SMESH::SMESH_Algo::_narrow( theHyp )->_is_nil() ); + int aRootTag = isAlgo ? GetAlgorithmsRootTag() : GetHypothesisRootTag(); + SALOMEDS::SObject_var aRootSO = + publish (theStudy, CORBA::Object::_nil(),father, aRootTag, + isAlgo ? "ICON_SMESH_TREE_ALGO" : "ICON_SMESH_TREE_HYPO", false); + SetName( aRootSO, isAlgo ? "Algorithms" : "Hypotheses" ); + + // Add New Hypothesis + string aPmName = isAlgo ? "ICON_SMESH_TREE_ALGO_" : "ICON_SMESH_TREE_HYPO_"; + aPmName += theHyp->GetName(); + aHypSO = publish( theStudy, theHyp, aRootSO, 0, aPmName.c_str() ); + } + + if ( !aHypSO->_is_nil() ) { + CORBA::String_var aHypName = CORBA::string_dup( theHyp->GetName() ); + SetName( aHypSO, theName, aHypName ); + } + + if(MYDEBUG) MESSAGE("PublishHypothesis--END") + return aHypSO._retn(); +} + +//======================================================================= +//function : GetMeshOrSubmeshByShape +//purpose : +//======================================================================= + +SALOMEDS::SObject_ptr + SMESH_Gen_i::GetMeshOrSubmeshByShape (SALOMEDS::Study_ptr theStudy, + SMESH::SMESH_Mesh_ptr theMesh, + GEOM::GEOM_Object_ptr theShape) +{ + if(MYDEBUG) MESSAGE("GetMeshOrSubmeshByShape") + SALOMEDS::SObject_var aMeshOrSubMesh; + if ( theShape->_is_nil() || theMesh->_is_nil() ) + return aMeshOrSubMesh._retn(); + + TopoDS_Shape aShape = GeomObjectToShape( theShape ); + SMESH_Mesh_i* mesh_i = objectToServant( theMesh ); + + if ( !aShape.IsNull() && mesh_i && mesh_i->GetImpl().GetMeshDS() ) { + SMESHDS_Mesh* meshDS = mesh_i->GetImpl().GetMeshDS(); + if ( aShape.IsSame( meshDS->ShapeToMesh() )) + aMeshOrSubMesh = ObjectToSObject( theStudy, theMesh ); + else { + int shapeID = meshDS->ShapeToIndex( aShape ); + SMESH::SMESH_subMesh_var aSubMesh = mesh_i->getSubMesh(shapeID); + if ( !aSubMesh->_is_nil() ) + aMeshOrSubMesh = ObjectToSObject( theStudy, aSubMesh ); + } + } + if(MYDEBUG) MESSAGE("GetMeshOrSubmeshByShape--END") + return aMeshOrSubMesh._retn(); +} + +//======================================================================= +//function : AddHypothesisToShape +//purpose : +//======================================================================= + +bool SMESH_Gen_i::AddHypothesisToShape(SALOMEDS::Study_ptr theStudy, + SMESH::SMESH_Mesh_ptr theMesh, + GEOM::GEOM_Object_ptr theShape, + SMESH::SMESH_Hypothesis_ptr theHyp) +{ + if(MYDEBUG) MESSAGE("AddHypothesisToShape") + if (theStudy->_is_nil() || theMesh->_is_nil() || + theHyp->_is_nil() || theShape->_is_nil() ) + return false; + + SALOMEDS::SObject_var aMeshSO = ObjectToSObject( theStudy, theMesh ); + if ( aMeshSO->_is_nil() ) + aMeshSO = PublishMesh( theStudy, theMesh ); + SALOMEDS::SObject_var aHypSO = PublishHypothesis( theStudy, theHyp ); + if ( aMeshSO->_is_nil() || aHypSO->_is_nil()) + return false; + + // Find a mesh or submesh refering to theShape + SALOMEDS::SObject_var aMeshOrSubMesh = + GetMeshOrSubmeshByShape( theStudy, theMesh, theShape ); + if ( aMeshOrSubMesh->_is_nil() ) + return false; + + //Find or Create Applied Hypothesis root + bool aIsAlgo = !SMESH::SMESH_Algo::_narrow( theHyp )->_is_nil(); + SALOMEDS::SObject_var AHR = + publish (theStudy, CORBA::Object::_nil(), aMeshOrSubMesh, + aIsAlgo ? GetRefOnAppliedAlgorithmsTag() : GetRefOnAppliedHypothesisTag(), + aIsAlgo ? "ICON_SMESH_TREE_ALGO" : "ICON_SMESH_TREE_HYPO", false); + SetName( AHR, aIsAlgo ? "Applied algorithms" : "Applied hypotheses" ); + if ( AHR->_is_nil() ) + return false; + + addReference( theStudy, AHR, theHyp ); + if(MYDEBUG) MESSAGE("AddHypothesisToShape--END") + return true; +} + +//======================================================================= +//function : RemoveHypothesisFromShape +//purpose : +//======================================================================= + +bool SMESH_Gen_i::RemoveHypothesisFromShape(SALOMEDS::Study_ptr theStudy, + SMESH::SMESH_Mesh_ptr theMesh, + GEOM::GEOM_Object_ptr theShape, + SMESH::SMESH_Hypothesis_ptr theHyp) +{ + if (theStudy->_is_nil() || theMesh->_is_nil() || + theHyp->_is_nil() || theShape->_is_nil() ) + return false; + + SALOMEDS::SObject_var aHypSO = ObjectToSObject( theStudy, theHyp ); + if ( aHypSO->_is_nil() ) + return false; + + // Find a mesh or submesh refering to theShape + SALOMEDS::SObject_var aMeshOrSubMesh = + GetMeshOrSubmeshByShape( theStudy, theMesh, theShape ); + if ( aMeshOrSubMesh->_is_nil() ) + return false; + + // Find and remove a reference to aHypSO + SALOMEDS::SObject_var aRef, anObj; + CORBA::String_var anID = CORBA::string_dup( aHypSO->GetID() ); + SALOMEDS::ChildIterator_var it = theStudy->NewChildIterator( aMeshOrSubMesh ); + for ( it->InitEx( true ); it->More(); it->Next() ) { + anObj = it->Value(); + if (anObj->ReferencedObject( aRef ) && strcmp( aRef->GetID(), anID ) == 0 ) { + theStudy->NewBuilder()->RemoveObject( anObj ); + break; + } + } + return true; +} + diff --git a/src/SMESH_I/SMESH_Group_i.cxx b/src/SMESH_I/SMESH_Group_i.cxx index 81a495137..11dbe143b 100644 --- a/src/SMESH_I/SMESH_Group_i.cxx +++ b/src/SMESH_I/SMESH_Group_i.cxx @@ -25,13 +25,15 @@ // Module : SMESH // $Header$ + #include "SMESH_Group_i.hxx" #include "SMESH_Mesh_i.hxx" #include "SMESH_Gen_i.hxx" -#include -#include -#include -#include +#include "SMESH_Group.hxx" +#include "SMESHDS_Group.hxx" +#include "SMESHDS_GroupOnGeom.hxx" +#include "SMDSAbs_ElementType.hxx" +#include "utilities.h" //============================================================================= /*! @@ -39,7 +41,7 @@ */ //============================================================================= -SMESH_Group_i::SMESH_Group_i( PortableServer::POA_ptr thePOA, SMESH_Mesh_i* theMeshServant, const int theLocalID ) +SMESH_GroupBase_i::SMESH_GroupBase_i( PortableServer::POA_ptr thePOA, SMESH_Mesh_i* theMeshServant, const int theLocalID ) : SALOME::GenericObj_i( thePOA ), myMeshServant( theMeshServant ), myLocalID( theLocalID ) @@ -47,6 +49,15 @@ SMESH_Group_i::SMESH_Group_i( PortableServer::POA_ptr thePOA, SMESH_Mesh_i* theM thePOA->activate_object( this ); } +SMESH_Group_i::SMESH_Group_i( PortableServer::POA_ptr thePOA, SMESH_Mesh_i* theMeshServant, const int theLocalID ) +: SMESH_GroupBase_i( thePOA, theMeshServant, theLocalID ) +{ +} + +SMESH_GroupOnGeom_i::SMESH_GroupOnGeom_i( PortableServer::POA_ptr thePOA, SMESH_Mesh_i* theMeshServant, const int theLocalID ) +: SMESH_GroupBase_i( thePOA, theMeshServant, theLocalID ) +{ +} //============================================================================= /*! @@ -54,13 +65,39 @@ SMESH_Group_i::SMESH_Group_i( PortableServer::POA_ptr thePOA, SMESH_Mesh_i* theM */ //============================================================================= -SMESH_Group_i::~SMESH_Group_i() +SMESH_GroupBase_i::~SMESH_GroupBase_i() { - MESSAGE("~SMESH_Group_i;" ); + MESSAGE("~SMESH_GroupBase_i;" ); if ( myMeshServant ) myMeshServant->removeGroup(myLocalID); } +//======================================================================= +//function : GetSmeshGroup +//purpose : +//======================================================================= + +::SMESH_Group* SMESH_GroupBase_i::GetSmeshGroup() const +{ + if ( myMeshServant ) { + ::SMESH_Mesh& aMesh = myMeshServant->GetImpl(); + return aMesh.GetGroup(myLocalID); + } + return 0; +} + +//======================================================================= +//function : GetGroupDS +//purpose : +//======================================================================= + +SMESHDS_GroupBase* SMESH_GroupBase_i::GetGroupDS() const +{ + ::SMESH_Group* aGroup = GetSmeshGroup(); + if ( aGroup ) + return aGroup->GetGroupDS(); + return 0; +} //============================================================================= /*! @@ -68,72 +105,55 @@ SMESH_Group_i::~SMESH_Group_i() */ //============================================================================= -void SMESH_Group_i::SetName( const char* theName ) +void SMESH_GroupBase_i::SetName( const char* theName ) { - if ( myMeshServant ) { - ::SMESH_Mesh& aMesh = myMeshServant->GetImpl(); - ::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID); - if (aGroup) { - aGroup->SetName(theName); - - // Update group name in a study - SALOMEDS::Study_var aStudy = myMeshServant->GetGen()->GetCurrentStudy(); - if ( !aStudy->_is_nil() ) { - SALOMEDS::SObject_var aGroupSO = aStudy->FindObjectIOR( SMESH_Gen_i::GetORB()->object_to_string( _this() ) ); - if ( !aGroupSO->_is_nil() ) { - SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder(); - aBuilder->SetName( aGroupSO, theName ); - } - } - return; - } + ::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 ); + return; } MESSAGE("can't set name of a vague group"); } - //============================================================================= /*! * */ //============================================================================= -char* SMESH_Group_i::GetName() +char* SMESH_GroupBase_i::GetName() { - if ( myMeshServant ) { - ::SMESH_Mesh& aMesh = myMeshServant->GetImpl(); - ::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID); - if (aGroup) - return CORBA::string_dup (aGroup->GetName()); - } + ::SMESH_Group* aGroup = GetSmeshGroup(); + if (aGroup) + return CORBA::string_dup (aGroup->GetName()); MESSAGE("get name of a vague group"); return CORBA::string_dup( "NO_NAME" ); } - //============================================================================= /*! * */ //============================================================================= -SMESH::ElementType SMESH_Group_i::GetType() +SMESH::ElementType SMESH_GroupBase_i::GetType() { - if ( myMeshServant ) { - ::SMESH_Mesh& aMesh = myMeshServant->GetImpl(); - ::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID); - if (aGroup) { - SMDSAbs_ElementType aSMDSType = aGroup->GetGroupDS()->GetType(); - SMESH::ElementType aType; - switch (aSMDSType) { - case SMDSAbs_Node: aType = SMESH::NODE; break; - case SMDSAbs_Edge: aType = SMESH::EDGE; break; - case SMDSAbs_Face: aType = SMESH::FACE; break; - case SMDSAbs_Volume: aType = SMESH::VOLUME; break; - default: aType = SMESH::ALL; break; - } - return aType; + SMESHDS_GroupBase* aGroupDS = GetGroupDS(); + if (aGroupDS) { + SMDSAbs_ElementType aSMDSType = aGroupDS->GetType(); + SMESH::ElementType aType; + switch (aSMDSType) { + case SMDSAbs_Node: aType = SMESH::NODE; break; + case SMDSAbs_Edge: aType = SMESH::EDGE; break; + case SMDSAbs_Face: aType = SMESH::FACE; break; + case SMDSAbs_Volume: aType = SMESH::VOLUME; break; + default: aType = SMESH::ALL; break; } + return aType; } MESSAGE("get type of a vague group"); return SMESH::ALL; @@ -146,42 +166,30 @@ SMESH::ElementType SMESH_Group_i::GetType() */ //============================================================================= -CORBA::Long SMESH_Group_i::Size() +CORBA::Long SMESH_GroupBase_i::Size() { - if ( myMeshServant ) { - ::SMESH_Mesh& aMesh = myMeshServant->GetImpl(); - ::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID); - if (aGroup) { - int aSize = aGroup->GetGroupDS()->Extent(); - return aSize; - } - } + SMESHDS_GroupBase* aGroupDS = GetGroupDS(); + if (aGroupDS) + return aGroupDS->Extent(); MESSAGE("get size of a vague group"); return 0; } - //============================================================================= /*! * */ //============================================================================= -CORBA::Boolean SMESH_Group_i::IsEmpty() +CORBA::Boolean SMESH_GroupBase_i::IsEmpty() { - if ( myMeshServant ) { - ::SMESH_Mesh& aMesh = myMeshServant->GetImpl(); - ::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID); - if (aGroup) { - bool isEmpty = aGroup->GetGroupDS()->IsEmpty(); - return isEmpty; - } - } + SMESHDS_GroupBase* aGroupDS = GetGroupDS(); + if (aGroupDS) + return aGroupDS->IsEmpty(); MESSAGE("checking IsEmpty of a vague group"); return true; } - //============================================================================= /*! * @@ -190,42 +198,29 @@ CORBA::Boolean SMESH_Group_i::IsEmpty() void SMESH_Group_i::Clear() { - if ( myMeshServant ) { - ::SMESH_Mesh& aMesh = myMeshServant->GetImpl(); - ::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID); - if (aGroup) { - // a SMDS group forgets its type after clearing, so we must re-set it - SMDSAbs_ElementType aSMDSType = aGroup->GetGroupDS()->GetType(); - aGroup->GetGroupDS()->Clear(); - aGroup->GetGroupDS()->SetType(aSMDSType); - return; - } + SMESHDS_Group* aGroupDS = dynamic_cast( GetGroupDS() ); + if (aGroupDS) { + aGroupDS->Clear(); + return; } MESSAGE("attempt to clear a vague group"); } - //============================================================================= /*! * */ //============================================================================= -CORBA::Boolean SMESH_Group_i::Contains( CORBA::Long theID ) +CORBA::Boolean SMESH_GroupBase_i::Contains( CORBA::Long theID ) { - if ( myMeshServant ) { - ::SMESH_Mesh& aMesh = myMeshServant->GetImpl(); - ::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID); - if (aGroup) { - bool res = aGroup->GetGroupDS()->Contains(theID); - return res; - } - } + SMESHDS_GroupBase* aGroupDS = GetGroupDS(); + if (aGroupDS) + return aGroupDS->Contains(theID); MESSAGE("attempt to check contents of a vague group"); return false; } - //============================================================================= /*! * @@ -234,72 +229,56 @@ CORBA::Boolean SMESH_Group_i::Contains( CORBA::Long theID ) CORBA::Long SMESH_Group_i::Add( const SMESH::long_array& theIDs ) { - if ( myMeshServant ) { - ::SMESH_Mesh& aMesh = myMeshServant->GetImpl(); - ::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID); - if (aGroup) { - SMESHDS_Group* aGroupDS = aGroup->GetGroupDS(); - int nbAdd = 0; - for (int i = 0; i < theIDs.length(); i++) { - int anID = (int) theIDs[i]; - if (aGroupDS->Add(anID)) - nbAdd++; - } - return nbAdd; + SMESHDS_Group* aGroupDS = dynamic_cast( GetGroupDS() ); + if (aGroupDS) { + int nbAdd = 0; + for (int i = 0; i < theIDs.length(); i++) { + int anID = (int) theIDs[i]; + if (aGroupDS->Add(anID)) + nbAdd++; } + return nbAdd; } MESSAGE("attempt to add elements to a vague group"); return 0; } - //============================================================================= /*! * */ //============================================================================= -CORBA::Long SMESH_Group_i::GetID( CORBA::Long theIndex ) +CORBA::Long SMESH_GroupBase_i::GetID( CORBA::Long theIndex ) { - if ( myMeshServant ) { - ::SMESH_Mesh& aMesh = myMeshServant->GetImpl(); - ::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID); - if (aGroup) { - int anID = aGroup->GetGroupDS()->GetID(theIndex); - return anID; - } - } + SMESHDS_GroupBase* aGroupDS = GetGroupDS(); + if (aGroupDS) + return aGroupDS->GetID(theIndex); MESSAGE("attempt to iterate on a vague group"); return -1; } - //============================================================================= /*! * */ //============================================================================= -SMESH::long_array* SMESH_Group_i::GetListOfID() +SMESH::long_array* SMESH_GroupBase_i::GetListOfID() { SMESH::long_array_var aRes = new SMESH::long_array(); - if ( myMeshServant ) { - ::SMESH_Mesh& aMesh = myMeshServant->GetImpl(); - ::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID); - if (aGroup) { - SMESHDS_Group* aGroupDS = aGroup->GetGroupDS(); - int aSize = aGroupDS->Extent(); - aRes->length(aSize); - for (int i = 0; i < aSize; i++) - aRes[i] = aGroupDS->GetID(i+1); - return aRes._retn(); - } + SMESHDS_GroupBase* aGroupDS = GetGroupDS(); + if (aGroupDS) { + int aSize = aGroupDS->Extent(); + aRes->length(aSize); + for (int i = 0; i < aSize; i++) + aRes[i] = aGroupDS->GetID(i+1); + return aRes._retn(); } MESSAGE("get list of IDs of a vague group"); return aRes._retn(); } - //============================================================================= /*! * @@ -308,51 +287,57 @@ SMESH::long_array* SMESH_Group_i::GetListOfID() CORBA::Long SMESH_Group_i::Remove( const SMESH::long_array& theIDs ) { - if ( myMeshServant ) { - ::SMESH_Mesh& aMesh = myMeshServant->GetImpl(); - ::SMESH_Group* aGroup = aMesh.GetGroup(myLocalID); - if (aGroup) { - // a SMDS group forgets its type after clearing, so we must re-set it - // if the group becomes empty - SMDSAbs_ElementType aSMDSType = aGroup->GetGroupDS()->GetType(); - SMESHDS_Group* aGroupDS = aGroup->GetGroupDS(); - int nbDel = 0; - for (int i = 0; i < theIDs.length(); i++) { - int anID = (int) theIDs[i]; - if (aGroupDS->Remove(anID)) - nbDel++; - } - if (aGroupDS->IsEmpty()) - aGroupDS->SetType(aSMDSType); - return nbDel; + SMESHDS_Group* aGroupDS = dynamic_cast( GetGroupDS() ); + if (aGroupDS) { + int nbDel = 0; + for (int i = 0; i < theIDs.length(); i++) { + int anID = (int) theIDs[i]; + if (aGroupDS->Remove(anID)) + nbDel++; } + return nbDel; } MESSAGE("attempt to remove elements from a vague group"); return 0; } - //============================================================================= /*! * */ //============================================================================= -SMESH::SMESH_Mesh_ptr SMESH_Group_i::GetMesh() +SMESH::SMESH_Mesh_ptr SMESH_GroupBase_i::GetMesh() { - MESSAGE("SMESH_Group_i::GetMesh(): mesh servant = " << myMeshServant ); SMESH::SMESH_Mesh_var aMesh; if ( myMeshServant ) aMesh = SMESH::SMESH_Mesh::_narrow( myMeshServant->_this() ); return aMesh._retn(); } - //============================================================================= /*! * */ //============================================================================= -int SMESH_Group_i::GetLocalID() +SMESH::long_array* SMESH_GroupBase_i::GetIDs() +{ + SMESH::long_array_var aResult = GetListOfID(); + return aResult._retn(); +} + +//======================================================================= +//function : GetShape +//purpose : +//======================================================================= + +GEOM::GEOM_Object_ptr SMESH_GroupOnGeom_i::GetShape() { - return myLocalID; + GEOM::GEOM_Object_var aGeomObj; + SMESHDS_GroupOnGeom* aGroupDS = dynamic_cast( GetGroupDS() ); + if ( aGroupDS ) { + SMESH_Gen_i* aGen = GetMeshServant()->GetGen(); + aGeomObj = aGen->ShapeToGeomObject( aGroupDS->GetShape() ); + } + return aGeomObj._retn(); } + diff --git a/src/SMESH_I/SMESH_Group_i.hxx b/src/SMESH_I/SMESH_Group_i.hxx index 2c7c1d36f..7e16691a6 100644 --- a/src/SMESH_I/SMESH_Group_i.hxx +++ b/src/SMESH_I/SMESH_Group_i.hxx @@ -25,58 +25,90 @@ // Module : SMESH // $Header$ + #ifndef SMESH_Group_i_HeaderFile #define SMESH_Group_i_HeaderFile #include #include CORBA_SERVER_HEADER(SMESH_Group) #include CORBA_SERVER_HEADER(SMESH_Mesh) +#include CORBA_CLIENT_HEADER(GEOM_Gen) #include "SALOME_GenericObj_i.hh" class SMESH_Mesh_i; - -class SMESH_Group_i: - public virtual POA_SMESH::SMESH_Group, +class ::SMESH_Group; +class SMESHDS_GroupBase; + +// =========== +// Group Base +// =========== +class SMESH_GroupBase_i: + public virtual POA_SMESH::SMESH_GroupBase, public virtual SALOME::GenericObj_i { -public: - SMESH_Group_i( PortableServer::POA_ptr thePOA, SMESH_Mesh_i* theMeshServant, const int theLocalID ); - virtual ~SMESH_Group_i(); + public: + SMESH_GroupBase_i(PortableServer::POA_ptr thePOA, + SMESH_Mesh_i* theMeshServant, + const int theLocalID ); + virtual ~SMESH_GroupBase_i(); // CORBA interface implementation - void SetName( const char* theName ); - + void SetName(const char* name); char* GetName(); - SMESH::ElementType GetType(); - CORBA::Long Size(); - CORBA::Boolean IsEmpty(); + CORBA::Boolean Contains(CORBA::Long elem_id); + CORBA::Long GetID(CORBA::Long elem_index); + SMESH::long_array* GetListOfID(); + SMESH::SMESH_Mesh_ptr GetMesh(); - void Clear(); + // Inherited from SMESH_IDSource interface + virtual SMESH::long_array* GetIDs(); - CORBA::Boolean Contains( CORBA::Long theID ); + // Internal C++ interface + int GetLocalID() const { return myLocalID; } + SMESH_Mesh_i* GetMeshServant() const { return myMeshServant; } + ::SMESH_Group* GetSmeshGroup() const; + SMESHDS_GroupBase* GetGroupDS() const; - CORBA::Long Add( const SMESH::long_array& theIDs ); +private: + SMESH_Mesh_i* myMeshServant; + int myLocalID; +}; - CORBA::Long GetID( CORBA::Long theIndex ); +// ====== +// Group +// ====== - SMESH::long_array* GetListOfID(); +class SMESH_Group_i: + public SMESH_GroupBase_i, + public virtual POA_SMESH::SMESH_Group, + public virtual SALOME::GenericObj_i +{ + public: + SMESH_Group_i( PortableServer::POA_ptr thePOA, SMESH_Mesh_i* theMeshServant, const int theLocalID ); + // CORBA interface implementation + void Clear(); + CORBA::Long Add( const SMESH::long_array& theIDs ); CORBA::Long Remove( const SMESH::long_array& theIDs ); +}; - SMESH::SMESH_Mesh_ptr GetMesh(); - - // Internal C++ interface - int GetLocalID(); +// ========================= +// Group linked to geometry +// ========================= - SMESH_Mesh_i* GetMeshServant() { return myMeshServant; } +class SMESH_GroupOnGeom_i: + public SMESH_GroupBase_i, + public virtual POA_SMESH::SMESH_GroupOnGeom, + public virtual SALOME::GenericObj_i +{ + public: + SMESH_GroupOnGeom_i( PortableServer::POA_ptr thePOA, SMESH_Mesh_i* theMeshServant, const int theLocalID ); -private: - SMESH_Mesh_i* myMeshServant; - int myLocalID; + // CORBA interface implementation + GEOM::GEOM_Object_ptr GetShape(); }; - #endif diff --git a/src/SMESH_I/SMESH_MEDFamily_i.cxx b/src/SMESH_I/SMESH_MEDFamily_i.cxx index cd8a66742..6e2508962 100644 --- a/src/SMESH_I/SMESH_MEDFamily_i.cxx +++ b/src/SMESH_I/SMESH_MEDFamily_i.cxx @@ -161,7 +161,7 @@ CORBA::Long SMESH_MEDFamily_i::getAttributeIdentifier(CORBA::Long i) MESSAGE("Les familles SMESH n ont pas d attribut"); THROW_SALOME_CORBA_EXCEPTION("No attributes"\ ,SALOME::BAD_PARAM); - if (_numberOfAttribute = 0) + if (_numberOfAttribute == 0) { MESSAGE("Les familles SMESH n ont pas d attribut"); THROW_SALOME_CORBA_EXCEPTION("No attributes"\ @@ -208,7 +208,7 @@ CORBA::Long SMESH_MEDFamily_i::getAttributeValue(CORBA::Long i) if (_subMeshDS==NULL) THROW_SALOME_CORBA_EXCEPTION("No associated Family",\ SALOME::INTERNAL_ERROR); - if (_numberOfAttribute = 0) + if (_numberOfAttribute == 0) { MESSAGE("Les familles SMESH n ont pas d attribut"); THROW_SALOME_CORBA_EXCEPTION("No attributes"\ @@ -229,7 +229,7 @@ SALOME_MED::string_array * SMESH_MEDFamily_i::getAttributesDescriptions() if (_subMeshDS==NULL) THROW_SALOME_CORBA_EXCEPTION("No associated Family",\ SALOME::INTERNAL_ERROR); - if (_numberOfAttribute = 0) + if (_numberOfAttribute == 0) { MESSAGE("Les familles SMESH n ont pas d attribut"); THROW_SALOME_CORBA_EXCEPTION("No attributes"\ @@ -253,7 +253,7 @@ char * SMESH_MEDFamily_i::getAttributeDescription( CORBA::Long i) if (_subMeshDS==NULL) THROW_SALOME_CORBA_EXCEPTION("No associated Family",\ SALOME::INTERNAL_ERROR); - if (_numberOfAttribute = 0) + if (_numberOfAttribute == 0) { MESSAGE("Les familles SMESH n ont pas d attribut"); THROW_SALOME_CORBA_EXCEPTION("No attributes"\ diff --git a/src/SMESH_I/SMESH_MEDFamily_i.hxx b/src/SMESH_I/SMESH_MEDFamily_i.hxx index 05ed02971..a5a8a52df 100644 --- a/src/SMESH_I/SMESH_MEDFamily_i.hxx +++ b/src/SMESH_I/SMESH_MEDFamily_i.hxx @@ -57,7 +57,13 @@ public : SMESH_MEDFamily_i(int identifier, SMESH_subMesh_i* sm, string name, string description, SALOME_MED::medEntityMesh entity ); SMESH_MEDFamily_i(const SMESH_MEDFamily_i & f); - + + // IDL Methods + void setProtocol(SALOME::TypeOfCommunication typ) {} + void release() {} + SALOME::Sender_ptr getSenderForNumber(long int) {return SALOME::Sender::_nil();} + SALOME::Sender_ptr getSenderForNumberIndex() {return SALOME::Sender::_nil();} + CORBA::Long getIdentifier() throw (SALOME::SALOME_Exception); CORBA::Long getNumberOfAttributes() diff --git a/src/SMESH_I/SMESH_MEDMesh_i.cxx b/src/SMESH_I/SMESH_MEDMesh_i.cxx index 82917f4ad..3f1c017d4 100644 --- a/src/SMESH_I/SMESH_MEDMesh_i.cxx +++ b/src/SMESH_I/SMESH_MEDMesh_i.cxx @@ -24,7 +24,6 @@ // File : SMESH_MEDMesh_i.cxx // Module : SMESH -using namespace std; #include "SMESH_MEDMesh_i.hxx" #include "SMESH_Mesh_i.hxx" @@ -61,6 +60,8 @@ extern "C" #include } +using namespace std; + //============================================================================= /*! * Default constructor diff --git a/src/SMESH_I/SMESH_MEDMesh_i.hxx b/src/SMESH_I/SMESH_MEDMesh_i.hxx index 9e9814e20..1c9308e1d 100644 --- a/src/SMESH_I/SMESH_MEDMesh_i.hxx +++ b/src/SMESH_I/SMESH_MEDMesh_i.hxx @@ -75,6 +75,11 @@ class SMESH_MEDMesh_i: ~SMESH_MEDMesh_i(); // IDL Methods + void setProtocol(SALOME::TypeOfCommunication typ) {} + void release() {} + SALOME::Sender_ptr getSenderForCoordinates(long int) {return SALOME::Sender::_nil();} + SALOME::Sender_ptr getSenderForConnectivity(long int, long int, long int, long int) {return SALOME::Sender::_nil();} + char *getName() throw(SALOME::SALOME_Exception); CORBA::Long getSpaceDimension() throw(SALOME::SALOME_Exception); diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index 99b27b0bb..8cdfa30f3 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -26,17 +26,24 @@ // Module : SMESH // $Header$ -using namespace std; #include "SMESH_MeshEditor_i.hxx" #include "SMDS_MeshEdge.hxx" #include "SMDS_MeshFace.hxx" #include "SMDS_MeshVolume.hxx" +#include "SMESH_MeshEditor.hxx" + +#include "SMESH_Gen_i.hxx" +#include "SMESH_Filter_i.hxx" + #include "utilities.h" -#include -#include +#include +#include +#include + +using namespace std; //============================================================================= /*! @@ -44,9 +51,9 @@ using namespace std; */ //============================================================================= -SMESH_MeshEditor_i::SMESH_MeshEditor_i(SMESHDS_Mesh* theMesh) +SMESH_MeshEditor_i::SMESH_MeshEditor_i(SMESH_Mesh* theMesh) { - _myMeshDS = theMesh; + _myMesh = theMesh; }; //============================================================================= @@ -58,19 +65,12 @@ SMESH_MeshEditor_i::SMESH_MeshEditor_i(SMESHDS_Mesh* theMesh) CORBA::Boolean SMESH_MeshEditor_i::RemoveElements(const SMESH:: long_array & IDsOfElements) { - for (int i = 0; i < IDsOfElements.length(); i++) - { - CORBA::Long index = IDsOfElements[i]; - const SMDS_MeshElement * elem = _myMeshDS->FindElement(index); - // an element may be removed as a result of preceding - // loop removal - if ( elem ) - { - _myMeshDS->RemoveElement( elem ); - MESSAGE("Element " << index << " was removed"); - } - } - return true; + ::SMESH_MeshEditor anEditor( _myMesh ); + list< int > IdList; + for (int i = 0; i < IDsOfElements.length(); i++) + IdList.push_back( IDsOfElements[i] ); + + return anEditor.Remove( IdList, false ); }; //============================================================================= @@ -82,20 +82,12 @@ CORBA::Boolean SMESH_MeshEditor_i::RemoveElements(const SMESH:: CORBA::Boolean SMESH_MeshEditor_i::RemoveNodes(const SMESH:: long_array & IDsOfNodes) { - // It's nodes' turn to die - for (int i = 0; i < IDsOfNodes.length(); i++) - { - const SMDS_MeshNode * node=_myMeshDS->FindNode(IDsOfNodes[i]); - if(node==NULL) - { - MESSAGE("SMESH_MeshEditor_i::RemoveNodes: Node "<RemoveNode(node); - MESSAGE("Node " << IDsOfNodes[i] << " was removed") - } - return true; + ::SMESH_MeshEditor anEditor( _myMesh ); + list< int > IdList; + for (int i = 0; i < IDsOfNodes.length(); i++) + IdList.push_back( IDsOfNodes[i] ); + + return anEditor.Remove( IdList, true ); }; //============================================================================= @@ -111,7 +103,7 @@ CORBA::Boolean SMESH_MeshEditor_i::AddEdge(const SMESH::long_array & IDsOfNodes) { CORBA::Long index1 = IDsOfNodes[0]; CORBA::Long index2 = IDsOfNodes[1]; - _myMeshDS->AddEdge(_myMeshDS->FindNode(index1), _myMeshDS->FindNode(index2)); + GetMeshDS()->AddEdge(GetMeshDS()->FindNode(index1), GetMeshDS()->FindNode(index2)); } return true; } @@ -126,7 +118,7 @@ CORBA::Boolean SMESH_MeshEditor_i::AddNode(CORBA::Double x, CORBA::Double y, CORBA::Double z) { MESSAGE(" AddNode " << x << " , " << y << " , " << z) - int idNode = _myMeshDS->AddNode(x, y, z)->GetID(); + int idNode = GetMeshDS()->AddNode(x, y, z)->GetID(); MESSAGE(" idNode " << idNode) return true; } @@ -140,14 +132,14 @@ CORBA::Boolean SMESH_MeshEditor_i::AddFace(const SMESH::long_array & IDsOfNodes) { int NbNodes = IDsOfNodes.length(); const SMDS_MeshNode* nodes[4]; - for(int i=0;iFindNode(IDsOfNodes[i]); + for(int i=0;iFindNode(IDsOfNodes[i]); if (NbNodes == 3) { - _myMeshDS->AddFace(nodes[0], nodes[1], nodes[2]); + GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2]); } else if (NbNodes == 4) { - _myMeshDS->AddFace(nodes[0], nodes[1], nodes[2], nodes[3]); + GetMeshDS()->AddFace(nodes[0], nodes[1], nodes[2], nodes[3]); } return true; }; @@ -163,14 +155,778 @@ CORBA::Boolean SMESH_MeshEditor_i::AddVolume(const SMESH:: { int NbNodes = IDsOfNodes.length(); const SMDS_MeshNode* n[8]; - for(int i=0;iFindNode(IDsOfNodes[i]); + for(int i=0;iFindNode(IDsOfNodes[i]); switch(NbNodes) { - case 4:_myMeshDS->AddVolume(n[0],n[1],n[2],n[3]); break; - case 5:_myMeshDS->AddVolume(n[0],n[1],n[2],n[3],n[4]); break; - case 6:_myMeshDS->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5]); break; - case 8:_myMeshDS->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7]); break; + case 4:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3]); break; + case 5:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4]); break; + case 6:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5]); break; + case 8:GetMeshDS()->AddVolume(n[0],n[1],n[2],n[3],n[4],n[5],n[6],n[7]); break; } return true; }; + +//============================================================================= +/*! + * + */ +//============================================================================= + +CORBA::Boolean SMESH_MeshEditor_i::MoveNode(CORBA::Long NodeID, + CORBA::Double x, + CORBA::Double y, + CORBA::Double z) +{ + const SMDS_MeshNode * node = GetMeshDS()->FindNode( NodeID ); + if ( !node ) + return false; + + GetMeshDS()->MoveNode(node, x, y, z); + + return true; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +CORBA::Boolean SMESH_MeshEditor_i::InverseDiag(CORBA::Long NodeID1, + CORBA::Long NodeID2) +{ + const SMDS_MeshNode * n1 = GetMeshDS()->FindNode( NodeID1 ); + const SMDS_MeshNode * n2 = GetMeshDS()->FindNode( NodeID2 ); + if ( !n1 || !n2 ) + return false; + + ::SMESH_MeshEditor aMeshEditor( _myMesh ); + return aMeshEditor.InverseDiag ( n1, n2 ); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +CORBA::Boolean SMESH_MeshEditor_i::DeleteDiag(CORBA::Long NodeID1, + CORBA::Long NodeID2) +{ + const SMDS_MeshNode * n1 = GetMeshDS()->FindNode( NodeID1 ); + const SMDS_MeshNode * n2 = GetMeshDS()->FindNode( NodeID2 ); + if ( !n1 || !n2 ) + return false; + + ::SMESH_MeshEditor aMeshEditor( _myMesh ); + return aMeshEditor.DeleteDiag ( n1, n2 ); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +CORBA::Boolean SMESH_MeshEditor_i::Reorient(const SMESH::long_array & IDsOfElements) +{ + ::SMESH_MeshEditor anEditor( _myMesh ); + for (int i = 0; i < IDsOfElements.length(); i++) + { + CORBA::Long index = IDsOfElements[i]; + const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index); + if ( elem ) + anEditor.Reorient( elem ); + } + return true; +} + + +//============================================================================= +/*! + * + */ +//============================================================================= + +CORBA::Boolean SMESH_MeshEditor_i::ReorientObject(SMESH::SMESH_IDSource_ptr theObject) +{ + SMESH::long_array_var anElementsId = theObject->GetIDs(); + Reorient(anElementsId); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +CORBA::Boolean + SMESH_MeshEditor_i::TriToQuad (const SMESH::long_array & IDsOfElements, + SMESH::NumericalFunctor_ptr Criterion, + CORBA::Double MaxAngle) +{ + set faces; + for (int i = 0; i < IDsOfElements.length(); i++) + { + CORBA::Long index = IDsOfElements[i]; + const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index); + if ( elem && elem->GetType() == SMDSAbs_Face) + faces.insert( elem ); + } + SMESH::NumericalFunctor_i* aNumericalFunctor = + dynamic_cast( SMESH_Gen_i::GetServant( Criterion ).in() ); + SMESH::Controls::NumericalFunctorPtr aCrit; + if ( !aNumericalFunctor ) + aCrit.reset( new SMESH::Controls::AspectRatio() ); + else + aCrit = aNumericalFunctor->GetNumericalFunctor(); + + ::SMESH_MeshEditor anEditor( _myMesh ); + return anEditor.TriToQuad( faces, aCrit, MaxAngle ); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +CORBA::Boolean + SMESH_MeshEditor_i::TriToQuadObject (SMESH::SMESH_IDSource_ptr theObject, + SMESH::NumericalFunctor_ptr Criterion, + CORBA::Double MaxAngle) +{ + SMESH::long_array_var anElementsId = theObject->GetIDs(); + TriToQuad(anElementsId, Criterion, MaxAngle); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +CORBA::Boolean + SMESH_MeshEditor_i::QuadToTri(const SMESH::long_array & IDsOfElements, + SMESH::NumericalFunctor_ptr Criterion) +{ + set faces; + for (int i = 0; i < IDsOfElements.length(); i++) + { + CORBA::Long index = IDsOfElements[i]; + const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index); + if ( elem && elem->GetType() == SMDSAbs_Face) + faces.insert( elem ); + } + SMESH::NumericalFunctor_i* aNumericalFunctor = + dynamic_cast( SMESH_Gen_i::GetServant( Criterion ).in() ); + SMESH::Controls::NumericalFunctorPtr aCrit; + if ( !aNumericalFunctor ) + aCrit.reset( new SMESH::Controls::AspectRatio() ); + else + aCrit = aNumericalFunctor->GetNumericalFunctor(); + + ::SMESH_MeshEditor anEditor( _myMesh ); + return anEditor.QuadToTri( faces, aCrit ); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +CORBA::Boolean + SMESH_MeshEditor_i::SplitQuad(const SMESH::long_array & IDsOfElements, + CORBA::Boolean Diag13) +{ + set faces; + for (int i = 0; i < IDsOfElements.length(); i++) + { + CORBA::Long index = IDsOfElements[i]; + const SMDS_MeshElement * elem = GetMeshDS()->FindElement(index); + if ( elem && elem->GetType() == SMDSAbs_Face) + faces.insert( elem ); + } + + ::SMESH_MeshEditor anEditor( _myMesh ); + return anEditor.QuadToTri( faces, Diag13 ); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +CORBA::Boolean + SMESH_MeshEditor_i::SplitQuadObject(SMESH::SMESH_IDSource_ptr theObject, + CORBA::Boolean Diag13) +{ + SMESH::long_array_var anElementsId = theObject->GetIDs(); + SplitQuad(anElementsId, Diag13); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +CORBA::Boolean + SMESH_MeshEditor_i::Smooth(const SMESH::long_array & IDsOfElements, + const SMESH::long_array & IDsOfFixedNodes, + CORBA::Long MaxNbOfIterations, + CORBA::Double MaxAspectRatio, + SMESH::SMESH_MeshEditor::Smooth_Method Method) +{ + SMESHDS_Mesh* aMesh = GetMeshDS(); + + set elements; + for (int i = 0; i < IDsOfElements.length(); i++) + { + CORBA::Long index = IDsOfElements[i]; + const SMDS_MeshElement * elem = aMesh->FindElement(index); + if ( elem && elem->GetType() == SMDSAbs_Face) + elements.insert( elem ); + } + + set fixedNodes; + for (int i = 0; i < IDsOfFixedNodes.length(); i++) + { + CORBA::Long index = IDsOfFixedNodes[i]; + const SMDS_MeshNode * node = aMesh->FindNode(index); + if ( node ) + fixedNodes.insert( node ); + } + ::SMESH_MeshEditor::SmoothMethod method = ::SMESH_MeshEditor::LAPLACIAN; + if ( Method != SMESH::SMESH_MeshEditor::LAPLACIAN_SMOOTH ) + method = ::SMESH_MeshEditor::CENTROIDAL; + + ::SMESH_MeshEditor anEditor( _myMesh ); + anEditor.Smooth( elements, fixedNodes, method, MaxNbOfIterations, MaxAspectRatio ); + + return true; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +CORBA::Boolean + SMESH_MeshEditor_i::SmoothObject(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::long_array & IDsOfFixedNodes, + CORBA::Long MaxNbOfIterations, + CORBA::Double MaxAspectRatio, + SMESH::SMESH_MeshEditor::Smooth_Method Method) +{ + SMESH::long_array_var anElementsId = theObject->GetIDs(); + return Smooth(anElementsId, IDsOfFixedNodes, MaxNbOfIterations, MaxAspectRatio, Method); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void SMESH_MeshEditor_i::RenumberNodes() +{ + GetMeshDS()->Renumber( true ); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void SMESH_MeshEditor_i::RenumberElements() +{ + GetMeshDS()->Renumber( false ); +} + +//======================================================================= +//function : RotationSweep +//purpose : +//======================================================================= + +void SMESH_MeshEditor_i::RotationSweep(const SMESH::long_array & theIDsOfElements, + const SMESH::AxisStruct & theAxis, + CORBA::Double theAngleInRadians, + CORBA::Long theNbOfSteps, + CORBA::Double theTolerance) +{ + SMESHDS_Mesh* aMesh = GetMeshDS(); + + set elements; + for (int i = 0; i < theIDsOfElements.length(); i++) + { + CORBA::Long index = theIDsOfElements[i]; + const SMDS_MeshElement * elem = aMesh->FindElement(index); + if ( elem ) + elements.insert( elem ); + } + gp_Ax1 Ax1 (gp_Pnt( theAxis.x, theAxis.y, theAxis.z ), + gp_Vec( theAxis.vx, theAxis.vy, theAxis.vz )); + + ::SMESH_MeshEditor anEditor( _myMesh ); + anEditor.RotationSweep (elements, Ax1, theAngleInRadians, + theNbOfSteps, theTolerance); +} + +//======================================================================= +//function : RotationSweepObject +//purpose : +//======================================================================= + +void SMESH_MeshEditor_i::RotationSweepObject(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::AxisStruct & theAxis, + CORBA::Double theAngleInRadians, + CORBA::Long theNbOfSteps, + CORBA::Double theTolerance) +{ + SMESH::long_array_var anElementsId = theObject->GetIDs(); + RotationSweep(anElementsId, theAxis, theAngleInRadians, theNbOfSteps, theTolerance); +} + +//======================================================================= +//function : ExtrusionSweep +//purpose : +//======================================================================= + +void SMESH_MeshEditor_i::ExtrusionSweep(const SMESH::long_array & theIDsOfElements, + const SMESH::DirStruct & theStepVector, + CORBA::Long theNbOfSteps) +{ + SMESHDS_Mesh* aMesh = GetMeshDS(); + + set elements; + for (int i = 0; i < theIDsOfElements.length(); i++) + { + CORBA::Long index = theIDsOfElements[i]; + const SMDS_MeshElement * elem = aMesh->FindElement(index); + if ( elem ) + elements.insert( elem ); + } + const SMESH::PointStruct * P = &theStepVector.PS; + gp_Vec stepVec( P->x, P->y, P->z ); + + ::SMESH_MeshEditor anEditor( _myMesh ); + anEditor.ExtrusionSweep (elements, stepVec, theNbOfSteps); +} + + +//======================================================================= +//function : ExtrusionSweepObject +//purpose : +//======================================================================= + +void SMESH_MeshEditor_i::ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::DirStruct & theStepVector, + CORBA::Long theNbOfSteps) +{ + SMESH::long_array_var anElementsId = theObject->GetIDs(); + ExtrusionSweep(anElementsId, theStepVector, theNbOfSteps); +} + +//======================================================================= +//function : Mirror +//purpose : +//======================================================================= + +void SMESH_MeshEditor_i::Mirror(const SMESH::long_array & theIDsOfElements, + const SMESH::AxisStruct & theAxis, + SMESH::SMESH_MeshEditor::MirrorType theMirrorType, + CORBA::Boolean theCopy) +{ + SMESHDS_Mesh* aMesh = GetMeshDS(); + + set elements; + for (int i = 0; i < theIDsOfElements.length(); i++) + { + CORBA::Long index = theIDsOfElements[i]; + const SMDS_MeshElement * elem = aMesh->FindElement(index); + if ( elem ) + elements.insert( elem ); + } + gp_Pnt P ( theAxis.x, theAxis.y, theAxis.z ); + gp_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz ); + + gp_Trsf aTrsf; + switch ( theMirrorType ) { + case SMESH::SMESH_MeshEditor::POINT: + aTrsf.SetMirror( P ); + break; + case SMESH::SMESH_MeshEditor::AXIS: + aTrsf.SetMirror( gp_Ax1( P, V )); + break; + default: + aTrsf.SetMirror( gp_Ax2( P, V )); + } + + ::SMESH_MeshEditor anEditor( _myMesh ); + anEditor.Transform (elements, aTrsf, theCopy); +} + +//======================================================================= +//function : MirrorObject +//purpose : +//======================================================================= + +void SMESH_MeshEditor_i::MirrorObject(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::AxisStruct & theAxis, + SMESH::SMESH_MeshEditor::MirrorType theMirrorType, + CORBA::Boolean theCopy) +{ + SMESH::long_array_var anElementsId = theObject->GetIDs(); + Mirror(anElementsId, theAxis, theMirrorType, theCopy); +} + +//======================================================================= +//function : Translate +//purpose : +//======================================================================= + +void SMESH_MeshEditor_i::Translate(const SMESH::long_array & theIDsOfElements, + const SMESH::DirStruct & theVector, + CORBA::Boolean theCopy) +{ + SMESHDS_Mesh* aMesh = GetMeshDS(); + + set elements; + for (int i = 0; i < theIDsOfElements.length(); i++) + { + CORBA::Long index = theIDsOfElements[i]; + const SMDS_MeshElement * elem = aMesh->FindElement(index); + if ( elem ) + elements.insert( elem ); + } + gp_Trsf aTrsf; + const SMESH::PointStruct * P = &theVector.PS; + aTrsf.SetTranslation( gp_Vec( P->x, P->y, P->z )); + + ::SMESH_MeshEditor anEditor( _myMesh ); + anEditor.Transform (elements, aTrsf, theCopy); +} + +//======================================================================= +//function : TranslateObject +//purpose : +//======================================================================= + +void SMESH_MeshEditor_i::TranslateObject(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::DirStruct & theVector, + CORBA::Boolean theCopy) +{ + SMESH::long_array_var anElementsId = theObject->GetIDs(); + Translate(anElementsId, theVector, theCopy); +} + +//======================================================================= +//function : Rotate +//purpose : +//======================================================================= + +void SMESH_MeshEditor_i::Rotate(const SMESH::long_array & theIDsOfElements, + const SMESH::AxisStruct & theAxis, + CORBA::Double theAngle, + CORBA::Boolean theCopy) +{ + SMESHDS_Mesh* aMesh = GetMeshDS(); + + set elements; + for (int i = 0; i < theIDsOfElements.length(); i++) + { + CORBA::Long index = theIDsOfElements[i]; + const SMDS_MeshElement * elem = aMesh->FindElement(index); + if ( elem ) + elements.insert( elem ); + } + gp_Pnt P ( theAxis.x, theAxis.y, theAxis.z ); + gp_Vec V ( theAxis.vx, theAxis.vy, theAxis.vz ); + + gp_Trsf aTrsf; + aTrsf.SetRotation( gp_Ax1( P, V ), theAngle); + + + ::SMESH_MeshEditor anEditor( _myMesh ); + anEditor.Transform (elements, aTrsf, theCopy); +} + +//======================================================================= +//function : RotateObject +//purpose : +//======================================================================= + +void SMESH_MeshEditor_i::RotateObject(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::AxisStruct & theAxis, + CORBA::Double theAngle, + CORBA::Boolean theCopy) +{ + SMESH::long_array_var anElementsId = theObject->GetIDs(); + Rotate(anElementsId, theAxis, theAngle, theCopy); +} + +//======================================================================= +//function : FindCoincidentNodes +//purpose : +//======================================================================= + +void SMESH_MeshEditor_i::FindCoincidentNodes (CORBA::Double Tolerance, + SMESH::array_of_long_array_out GroupsOfNodes) +{ + ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes; + ::SMESH_MeshEditor anEditor( _myMesh ); + anEditor.FindCoincidentNodes( Tolerance, aListOfListOfNodes ); + + GroupsOfNodes = new SMESH::array_of_long_array; + GroupsOfNodes->length( aListOfListOfNodes.size() ); + ::SMESH_MeshEditor::TListOfListOfNodes::iterator llIt = aListOfListOfNodes.begin(); + for ( CORBA::Long i = 0; llIt != aListOfListOfNodes.end(); llIt++, i++ ) + { + list< const SMDS_MeshNode* >& aListOfNodes = *llIt; + list< const SMDS_MeshNode* >::iterator lIt = aListOfNodes.begin();; + SMESH::long_array& aGroup = GroupsOfNodes[ i ]; + aGroup.length( aListOfNodes.size() ); + for ( int j = 0; lIt != aListOfNodes.end(); lIt++, j++ ) + aGroup[ j ] = (*lIt)->GetID(); + } +} + +//======================================================================= +//function : MergeNodes +//purpose : +//======================================================================= + +void SMESH_MeshEditor_i::MergeNodes (const SMESH::array_of_long_array& GroupsOfNodes) +{ + SMESHDS_Mesh* aMesh = GetMeshDS(); + + ::SMESH_MeshEditor::TListOfListOfNodes aListOfListOfNodes; + list elements; + for (int i = 0; i < GroupsOfNodes.length(); i++) + { + const SMESH::long_array& aNodeGroup = GroupsOfNodes[ i ]; + aListOfListOfNodes.push_back( list< const SMDS_MeshNode* >() ); + list< const SMDS_MeshNode* >& aListOfNodes = aListOfListOfNodes.back(); + for ( int j = 0; j < aNodeGroup.length(); j++ ) + { + CORBA::Long index = aNodeGroup[ j ]; + const SMDS_MeshNode * node = aMesh->FindNode(index); + if ( node ) + aListOfNodes.push_back( node ); + } + if ( aListOfNodes.size() < 2 ) + aListOfListOfNodes.pop_back(); + } + ::SMESH_MeshEditor anEditor( _myMesh ); + anEditor.MergeNodes( aListOfListOfNodes ); +} + +//======================================================================= +//function : MergeEqualElements +//purpose : +//======================================================================= + +void SMESH_MeshEditor_i::MergeEqualElements() +{ + ::SMESH_MeshEditor anEditor( _myMesh ); + anEditor.MergeEqualElements(); +} + +//======================================================================= +//function : operator +//purpose : +//======================================================================= + +#define RETCASE(enm) case ::SMESH_MeshEditor::enm: return SMESH::SMESH_MeshEditor::enm; + +SMESH::SMESH_MeshEditor::Sew_Error convError( const::SMESH_MeshEditor::Sew_Error e ) +{ + switch ( e ) { + RETCASE( SEW_OK ); + RETCASE( SEW_BORDER1_NOT_FOUND ); + RETCASE( SEW_BORDER2_NOT_FOUND ); + RETCASE( SEW_BOTH_BORDERS_NOT_FOUND ); + RETCASE( SEW_BAD_SIDE_NODES ); + RETCASE( SEW_VOLUMES_TO_SPLIT ); + RETCASE( SEW_DIFF_NB_OF_ELEMENTS ); + RETCASE( SEW_TOPO_DIFF_SETS_OF_ELEMENTS ); + RETCASE( SEW_BAD_SIDE1_NODES ); + RETCASE( SEW_BAD_SIDE2_NODES ); + } + return SMESH::SMESH_MeshEditor::SEW_OK; +} + +//======================================================================= +//function : SewFreeBorders +//purpose : +//======================================================================= + +SMESH::SMESH_MeshEditor::Sew_Error + SMESH_MeshEditor_i::SewFreeBorders(CORBA::Long FirstNodeID1, + CORBA::Long SecondNodeID1, + CORBA::Long LastNodeID1, + CORBA::Long FirstNodeID2, + CORBA::Long SecondNodeID2, + CORBA::Long LastNodeID2) +{ + SMESHDS_Mesh* aMesh = GetMeshDS(); + + const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeID1 ); + const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeID1 ); + const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeID1 ); + const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeID2 ); + const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( SecondNodeID2 ); + const SMDS_MeshNode* aSide2ThirdNode = aMesh->FindNode( LastNodeID2 ); + + if (!aBorderFirstNode || + !aBorderSecondNode|| + !aBorderLastNode) + return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND; + if (!aSide2FirstNode || + !aSide2SecondNode || + !aSide2ThirdNode) + return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND; + + ::SMESH_MeshEditor anEditor( _myMesh ); + return convError( anEditor.SewFreeBorder (aBorderFirstNode, + aBorderSecondNode, + aBorderLastNode, + aSide2FirstNode, + aSide2SecondNode, + aSide2ThirdNode, + true)); +} + +//======================================================================= +//function : SewConformFreeBorders +//purpose : +//======================================================================= + +SMESH::SMESH_MeshEditor::Sew_Error + SMESH_MeshEditor_i::SewConformFreeBorders(CORBA::Long FirstNodeID1, + CORBA::Long SecondNodeID1, + CORBA::Long LastNodeID1, + CORBA::Long FirstNodeID2, + CORBA::Long SecondNodeID2) +{ + SMESHDS_Mesh* aMesh = GetMeshDS(); + + const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeID1 ); + const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeID1 ); + const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeID1 ); + const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeID2 ); + const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( SecondNodeID2 ); + const SMDS_MeshNode* aSide2ThirdNode = 0; + + if (!aBorderFirstNode || + !aBorderSecondNode|| + !aBorderLastNode ) + return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND; + if (!aSide2FirstNode || + !aSide2SecondNode) + return SMESH::SMESH_MeshEditor::SEW_BORDER2_NOT_FOUND; + + ::SMESH_MeshEditor anEditor( _myMesh ); + return convError( anEditor.SewFreeBorder (aBorderFirstNode, + aBorderSecondNode, + aBorderLastNode, + aSide2FirstNode, + aSide2SecondNode, + aSide2ThirdNode, + true )); +} + +//======================================================================= +//function : SewBorderToSide +//purpose : +//======================================================================= + +SMESH::SMESH_MeshEditor::Sew_Error + SMESH_MeshEditor_i::SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder, + CORBA::Long SecondNodeIDOnFreeBorder, + CORBA::Long LastNodeIDOnFreeBorder, + CORBA::Long FirstNodeIDOnSide, + CORBA::Long LastNodeIDOnSide) +{ + SMESHDS_Mesh* aMesh = GetMeshDS(); + + const SMDS_MeshNode* aBorderFirstNode = aMesh->FindNode( FirstNodeIDOnFreeBorder ); + const SMDS_MeshNode* aBorderSecondNode = aMesh->FindNode( SecondNodeIDOnFreeBorder ); + const SMDS_MeshNode* aBorderLastNode = aMesh->FindNode( LastNodeIDOnFreeBorder ); + const SMDS_MeshNode* aSide2FirstNode = aMesh->FindNode( FirstNodeIDOnSide ); + const SMDS_MeshNode* aSide2SecondNode = aMesh->FindNode( LastNodeIDOnSide ); + const SMDS_MeshNode* aSide2ThirdNode = 0; + + if (!aBorderFirstNode || + !aBorderSecondNode|| + !aBorderLastNode ) + return SMESH::SMESH_MeshEditor::SEW_BORDER1_NOT_FOUND; + if (!aSide2FirstNode || + !aSide2SecondNode) + return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE_NODES; + + ::SMESH_MeshEditor anEditor( _myMesh ); + return convError( anEditor.SewFreeBorder (aBorderFirstNode, + aBorderSecondNode, + aBorderLastNode, + aSide2FirstNode, + aSide2SecondNode, + aSide2ThirdNode, + false)); +} + +//======================================================================= +//function : SewSideElements +//purpose : +//======================================================================= + +SMESH::SMESH_MeshEditor::Sew_Error + SMESH_MeshEditor_i::SewSideElements(const SMESH::long_array& IDsOfSide1Elements, + const SMESH::long_array& IDsOfSide2Elements, + CORBA::Long NodeID1OfSide1ToMerge, + CORBA::Long NodeID1OfSide2ToMerge, + CORBA::Long NodeID2OfSide1ToMerge, + CORBA::Long NodeID2OfSide2ToMerge) +{ + SMESHDS_Mesh* aMesh = GetMeshDS(); + + const SMDS_MeshNode* aFirstNode1ToMerge = aMesh->FindNode( NodeID1OfSide1ToMerge ); + const SMDS_MeshNode* aFirstNode2ToMerge = aMesh->FindNode( NodeID1OfSide2ToMerge ); + const SMDS_MeshNode* aSecondNode1ToMerge = aMesh->FindNode( NodeID2OfSide1ToMerge ); + const SMDS_MeshNode* aSecondNode2ToMerge = aMesh->FindNode( NodeID2OfSide2ToMerge ); + + if (!aFirstNode1ToMerge || + !aFirstNode2ToMerge ) + return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE1_NODES; + if (!aSecondNode1ToMerge|| + !aSecondNode2ToMerge) + return SMESH::SMESH_MeshEditor::SEW_BAD_SIDE2_NODES; + + set aSide1Elems, aSide2Elems; + for (int i = 0; i < IDsOfSide1Elements.length(); i++) + { + CORBA::Long index = IDsOfSide1Elements[i]; + const SMDS_MeshElement * elem = aMesh->FindElement(index); + if ( elem ) + aSide1Elems.insert( elem ); + } + for (int i = 0; i < IDsOfSide2Elements.length(); i++) + { + CORBA::Long index = IDsOfSide2Elements[i]; + const SMDS_MeshElement * elem = aMesh->FindElement(index); + if ( elem ) + aSide2Elems.insert( elem ); + } + ::SMESH_MeshEditor anEditor( _myMesh ); + return convError( anEditor.SewSideElements (aSide1Elems, aSide2Elems, + aFirstNode1ToMerge, + aFirstNode2ToMerge, + aSecondNode1ToMerge, + aSecondNode2ToMerge)); +} diff --git a/src/SMESH_I/SMESH_MeshEditor_i.hxx b/src/SMESH_I/SMESH_MeshEditor_i.hxx index 0c75c7de0..2923617bd 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.hxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.hxx @@ -32,29 +32,137 @@ #include #include CORBA_SERVER_HEADER(SMESH_Mesh) -#include "SMESHDS_Mesh.hxx" +#include "SMESH_Mesh.hxx" class SMESH_MeshEditor_i: public POA_SMESH::SMESH_MeshEditor { - public: - SMESH_MeshEditor_i(SMESHDS_Mesh * theMesh); + public: + SMESH_MeshEditor_i(SMESH_Mesh * theMesh); - virtual ~ SMESH_MeshEditor_i() - { - }; + virtual ~ SMESH_MeshEditor_i() + { + }; - // --- CORBA - CORBA::Boolean RemoveElements(const SMESH::long_array & IDsOfElements); - CORBA::Boolean RemoveNodes(const SMESH::long_array & IDsOfNodes); + // --- CORBA + CORBA::Boolean RemoveElements(const SMESH::long_array & IDsOfElements); + CORBA::Boolean RemoveNodes(const SMESH::long_array & IDsOfNodes); - CORBA::Boolean AddNode(CORBA::Double x, CORBA::Double y, CORBA::Double z); - CORBA::Boolean AddEdge(const SMESH::long_array & IDsOfNodes); - CORBA::Boolean AddFace(const SMESH::long_array & IDsOfNodes); - CORBA::Boolean AddVolume(const SMESH::long_array & IDsOfNodes); + CORBA::Boolean AddNode(CORBA::Double x, CORBA::Double y, CORBA::Double z); + CORBA::Boolean AddEdge(const SMESH::long_array & IDsOfNodes); + CORBA::Boolean AddFace(const SMESH::long_array & IDsOfNodes); + CORBA::Boolean AddVolume(const SMESH::long_array & IDsOfNodes); + CORBA::Boolean MoveNode(CORBA::Long NodeID, + CORBA::Double x, CORBA::Double y, CORBA::Double z); - private: - SMESH::SMESH_subMesh_var _myMesh; - SMESHDS_Mesh *_myMeshDS; + CORBA::Boolean InverseDiag(CORBA::Long NodeID1, CORBA::Long NodeID2); + CORBA::Boolean DeleteDiag(CORBA::Long NodeID1, CORBA::Long NodeID2); + CORBA::Boolean Reorient(const SMESH::long_array & IDsOfElements); + CORBA::Boolean ReorientObject(SMESH::SMESH_IDSource_ptr theObject); + + CORBA::Boolean TriToQuad(const SMESH::long_array & IDsOfElements, + SMESH::NumericalFunctor_ptr Criterion, + CORBA::Double MaxAngle); + CORBA::Boolean TriToQuadObject(SMESH::SMESH_IDSource_ptr theObject, + SMESH::NumericalFunctor_ptr Criterion, + CORBA::Double MaxAngle); + CORBA::Boolean QuadToTri(const SMESH::long_array & IDsOfElements, + SMESH::NumericalFunctor_ptr Criterion); + CORBA::Boolean SplitQuad(const SMESH::long_array & IDsOfElements, + CORBA::Boolean Diag13); + CORBA::Boolean SplitQuadObject(SMESH::SMESH_IDSource_ptr theObject, + CORBA::Boolean Diag13); + + CORBA::Boolean Smooth(const SMESH::long_array & IDsOfElements, + const SMESH::long_array & IDsOfFixedNodes, + CORBA::Long MaxNbOfIterations, + CORBA::Double MaxAspectRatio, + SMESH::SMESH_MeshEditor::Smooth_Method Method); + CORBA::Boolean SmoothObject(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::long_array & IDsOfFixedNodes, + CORBA::Long MaxNbOfIterations, + CORBA::Double MaxAspectRatio, + SMESH::SMESH_MeshEditor::Smooth_Method Method); + + + void RenumberNodes(); + void RenumberElements(); + + void RotationSweep(const SMESH::long_array & IDsOfElements, + const SMESH::AxisStruct & Axis, + CORBA::Double AngleInRadians, + CORBA::Long NbOfSteps, + CORBA::Double Tolerance); + void RotationSweepObject(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::AxisStruct & Axis, + CORBA::Double AngleInRadians, + CORBA::Long NbOfSteps, + CORBA::Double Tolerance); + + void ExtrusionSweep(const SMESH::long_array & IDsOfElements, + const SMESH::DirStruct & StepVector, + CORBA::Long NbOfSteps); + void ExtrusionSweepObject(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::DirStruct & StepVector, + CORBA::Long NbOfSteps); + + void Mirror(const SMESH::long_array & IDsOfElements, + const SMESH::AxisStruct & Axis, + SMESH::SMESH_MeshEditor::MirrorType MirrorType, + CORBA::Boolean Copy); + void MirrorObject(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::AxisStruct & Axis, + SMESH::SMESH_MeshEditor::MirrorType MirrorType, + CORBA::Boolean Copy); + void Translate(const SMESH::long_array & IDsOfElements, + const SMESH::DirStruct & Vector, + CORBA::Boolean Copy); + void TranslateObject(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::DirStruct & Vector, + CORBA::Boolean Copy); + void Rotate(const SMESH::long_array & IDsOfElements, + const SMESH::AxisStruct & Axis, + CORBA::Double Angle, + CORBA::Boolean Copy); + void RotateObject(SMESH::SMESH_IDSource_ptr theObject, + const SMESH::AxisStruct & Axis, + CORBA::Double Angle, + CORBA::Boolean Copy); + + void FindCoincidentNodes (CORBA::Double Tolerance, + SMESH::array_of_long_array_out GroupsOfNodes); + void MergeNodes (const SMESH::array_of_long_array& GroupsOfNodes); + void MergeEqualElements(); + + SMESH::SMESH_MeshEditor::Sew_Error + SewFreeBorders(CORBA::Long FirstNodeID1, + CORBA::Long SecondNodeID1, + CORBA::Long LastNodeID1, + CORBA::Long FirstNodeID2, + CORBA::Long SecondNodeID2, + CORBA::Long LastNodeID2); + SMESH::SMESH_MeshEditor::Sew_Error + SewConformFreeBorders(CORBA::Long FirstNodeID1, + CORBA::Long SecondNodeID1, + CORBA::Long LastNodeID1, + CORBA::Long FirstNodeID2, + CORBA::Long SecondNodeID2); + SMESH::SMESH_MeshEditor::Sew_Error + SewBorderToSide(CORBA::Long FirstNodeIDOnFreeBorder, + CORBA::Long SecondNodeIDOnFreeBorder, + CORBA::Long LastNodeIDOnFreeBorder, + CORBA::Long FirstNodeIDOnSide, + CORBA::Long LastNodeIDOnSide); + SMESH::SMESH_MeshEditor::Sew_Error + SewSideElements(const SMESH::long_array& IDsOfSide1Elements, + const SMESH::long_array& IDsOfSide2Elements, + CORBA::Long NodeID1OfSide1ToMerge, + CORBA::Long NodeID1OfSide2ToMerge, + CORBA::Long NodeID2OfSide1ToMerge, + CORBA::Long NodeID2OfSide2ToMerge); + + private: + SMESHDS_Mesh * GetMeshDS() { return _myMesh->GetMeshDS(); } + SMESH_Mesh *_myMesh; }; #endif diff --git a/src/SMESH_I/SMESH_Mesh_i.cxx b/src/SMESH_I/SMESH_Mesh_i.cxx index 650ff36bb..851f61310 100644 --- a/src/SMESH_I/SMESH_Mesh_i.cxx +++ b/src/SMESH_I/SMESH_Mesh_i.cxx @@ -26,11 +26,11 @@ // Module : SMESH // $Header$ -using namespace std; #include "SMESH_Mesh_i.hxx" #include "SMESH_subMesh_i.hxx" #include "SMESH_MEDMesh_i.hxx" #include "SMESH_Group_i.hxx" +#include "SMESH_Filter_i.hxx" #include "Utils_CorbaException.hxx" #include "Utils_ExceptHandlers.hxx" @@ -41,6 +41,9 @@ using namespace std; #include "OpUtil.hxx" #include "TCollection_AsciiString.hxx" +#include +#include +#include #include "SMESHDS_Command.hxx" #include "SMESHDS_CommandType.hxx" #include "SMESH_MeshEditor_i.hxx" @@ -52,24 +55,16 @@ using namespace std; // _CS_gbo_050504 Ajout explicite du sstream pour ostringstream #include +#ifdef _DEBUG_ +static int MYDEBUG = 0; +#else +static int MYDEBUG = 0; +#endif -//**** SMESHDS en champ +using namespace std; int SMESH_Mesh_i::myIdGenerator = 0; -//============================================================================= -/*! - * - */ -//============================================================================= - -SMESH_Mesh_i::SMESH_Mesh_i() - : SALOME::GenericObj_i( PortableServer::POA::_nil() ) -{ - MESSAGE("SMESH_Mesh_i: default constructor, not for use"); - ASSERT(0); -} - //============================================================================= /*! * Constructor @@ -81,23 +76,13 @@ SMESH_Mesh_i::SMESH_Mesh_i( PortableServer::POA_ptr thePOA, CORBA::Long studyId ) : SALOME::GenericObj_i( thePOA ) { - MESSAGE("SMESH_Mesh_i"); + INFOS("SMESH_Mesh_i"); _gen_i = gen_i; _id = myIdGenerator++; _studyId = studyId; thePOA->activate_object( this ); } -/* -SMESH_Mesh_i::SMESH_Mesh_i(SMESH_Gen_i* gen_i, - CORBA::Long studyId, - int localId) -{ - MESSAGE("SMESH_Mesh_i"); - _gen_i = gen_i; - _id = localId; - _studyId = studyId; -} -*/ + //============================================================================= /*! * Destructor @@ -106,12 +91,15 @@ SMESH_Mesh_i::SMESH_Mesh_i(SMESH_Gen_i* gen_i, SMESH_Mesh_i::~SMESH_Mesh_i() { - MESSAGE("~SMESH_Mesh_i"); - map::iterator it; + INFOS("~SMESH_Mesh_i"); + map::iterator it; for ( it = _mapGroups.begin(); it != _mapGroups.end(); it++ ) { - SMESH_Group_i* aGroup = dynamic_cast( SMESH_Gen_i::GetServant( it->second ).in() ); + SMESH_GroupBase_i* aGroup = dynamic_cast( SMESH_Gen_i::GetServant( it->second ).in() ); if ( aGroup ) { - _impl->RemoveGroup( aGroup->GetLocalID() ); + + // this method is colled from destructor of group (PAL6331) + //_impl->RemoveGroup( aGroup->GetLocalID() ); + aGroup->Destroy(); } } @@ -128,58 +116,37 @@ SMESH_Mesh_i::~SMESH_Mesh_i() */ //============================================================================= -void SMESH_Mesh_i::SetShape( GEOM::GEOM_Shape_ptr theShape ) +void SMESH_Mesh_i::SetShape( GEOM::GEOM_Object_ptr theShapeObject ) throw (SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); try { - setShape( theShape ); + _impl->ShapeToMesh( _gen_i->GeomObjectToShape( theShapeObject )); } catch(SALOME_Exception & S_ex) { THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM); - } - - SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy(); - if ( aStudy->_is_nil() ) - return; - - // Create a reference to - SALOMEDS::SObject_var aMeshSO = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( _this() ) ) ) ); - SALOMEDS::SObject_var aShapeSO = aStudy->FindObjectIOR( SMESH_Gen_i::GetORB()->object_to_string( theShape ) ); - - SALOMEDS::SObject_var anObj, aRef; - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder(); - long aTag = SMESH_Gen_i::GetRefOnShapeTag(); - - if ( aMeshSO->FindSubObject( aTag, anObj ) ) { - if ( anObj->ReferencedObject( aRef ) ) { - if ( strcmp( aRef->GetID(), aShapeSO->GetID() ) == 0 ) { - // Setting the same shape twice forbidden - return; - } - } - } - else { - anObj = aBuilder->NewObjectToTag( aMeshSO, aTag ); } - aBuilder->Addreference( anObj, aShapeSO ); } -//============================================================================= -/*! - * setShape - * - * Sets shape to the mesh implementation - */ -//============================================================================= +//======================================================================= +//function : GetShapeToMesh +//purpose : +//======================================================================= -bool SMESH_Mesh_i::setShape( GEOM::GEOM_Shape_ptr theShape ) +GEOM::GEOM_Object_ptr SMESH_Mesh_i::GetShapeToMesh() + throw (SALOME::SALOME_Exception) { - TopoDS_Shape aLocShape = _gen_i->GetShapeReader()->GetShape( SMESH_Gen_i::GetGeomEngine(), theShape ); - _impl->ShapeToMesh( aLocShape ); - return true; + Unexpect aCatch(SALOME_SalomeException); + GEOM::GEOM_Object_var aShapeObj; + try { + TopoDS_Shape S = _impl->GetMeshDS()->ShapeToMesh(); + if ( !S.IsNull() ) + aShapeObj = _gen_i->ShapeToGeomObject( S ); + } + catch(SALOME_Exception & S_ex) { + THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM); + } + return aShapeObj._retn(); } //============================================================================= @@ -217,8 +184,8 @@ static SMESH::DriverMED_ReadStatus ConvertDriverMEDReadStatus (int theStatus) //============================================================================= SMESH::DriverMED_ReadStatus - SMESH_Mesh_i::ImportMEDFile( const char* theFileName, const char* theMeshName ) - throw ( SALOME::SALOME_Exception ) +SMESH_Mesh_i::ImportMEDFile( const char* theFileName, const char* theMeshName ) + throw ( SALOME::SALOME_Exception ) { Unexpect aCatch(SALOME_SalomeException); int status; @@ -233,22 +200,51 @@ SMESH::DriverMED_ReadStatus } SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy(); - if ( aStudy->_is_nil() ) - return ConvertDriverMEDReadStatus(status); - - // publishing of the groups in the study (sub-meshes are out of scope of MED import) - map::iterator it = _mapGroups.begin(); - for (; it != _mapGroups.end(); it++ ) { - SMESH::SMESH_Group_var aGroup = SMESH::SMESH_Group::_duplicate( it->second ); - if ( _gen_i->CanPublishInStudy( aGroup ) ) - _gen_i->PublishInStudy( aStudy, - SALOMEDS::SObject::_nil(), - aGroup, - aGroup->GetName() ); + if ( !aStudy->_is_nil() ) { + // publishing of the groups in the study (sub-meshes are out of scope of MED import) + map::iterator it = _mapGroups.begin(); + for (; it != _mapGroups.end(); it++ ) { + SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_duplicate( it->second ); + _gen_i->PublishGroup( aStudy, _this(), aGroup, + GEOM::GEOM_Object::_nil(), aGroup->GetName()); + } } return ConvertDriverMEDReadStatus(status); } +//============================================================================= +/*! + * ImportUNVFile + * + * Imports mesh data from MED file + */ +//============================================================================= + +int SMESH_Mesh_i::ImportUNVFile( const char* theFileName ) + throw ( SALOME::SALOME_Exception ) +{ + // Read mesh with name = into SMESH_Mesh + _impl->UNVToMesh( theFileName ); + + return 1; +} + +//============================================================================= +/*! + * ImportSTLFile + * + * Imports mesh data from STL file + */ +//============================================================================= +int SMESH_Mesh_i::ImportSTLFile( const char* theFileName ) + throw ( SALOME::SALOME_Exception ) +{ + // Read mesh with name = into SMESH_Mesh + _impl->STLToMesh( theFileName ); + + return 1; +} + //============================================================================= /*! * importMEDFile @@ -270,10 +266,8 @@ int SMESH_Mesh_i::importMEDFile( const char* theFileName, const char* theMeshNam _mapGroups[*it] = SMESH::SMESH_Group::_duplicate( aGroup ); // register CORBA object for persistence - StudyContext* myStudyContext = _gen_i->GetCurrentStudyContext(); - string iorString = SMESH_Gen_i::GetORB()->object_to_string( aGroup ); - int nextId = myStudyContext->addObject( iorString ); - MESSAGE( "Add group to map with id = "<< nextId << " and IOR = " << iorString.c_str() ); + int nextId = _gen_i->RegisterObject( aGroup ); + if(MYDEBUG) MESSAGE( "Add group to map with id = "<< nextId); } return status; @@ -323,67 +317,18 @@ static SMESH::Hypothesis_Status ConvertHypothesisStatus */ //============================================================================= -SMESH::Hypothesis_Status SMESH_Mesh_i::AddHypothesis(GEOM::GEOM_Shape_ptr aSubShape, +SMESH::Hypothesis_Status SMESH_Mesh_i::AddHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject, SMESH::SMESH_Hypothesis_ptr anHyp) throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); - SMESH_Hypothesis::Hypothesis_Status status = addHypothesis( aSubShape, anHyp ); - - if ( !SMESH_Hypothesis::IsStatusFatal(status) ) { - SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy(); - - if ( !aStudy->_is_nil() ) { - // Detect whether refers to this mesh or its sub-mesh - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - SALOMEDS::SObject_var aMeshSO = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( _this() ) ) ) ); - SALOMEDS::SObject_var aMorSM, aRef; - CORBA::String_var aShapeIOR = CORBA::string_dup( SMESH_Gen_i::GetORB()->object_to_string( aSubShape ) ); - SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator( aMeshSO ); - - for ( it->InitEx( true ); it->More(); it->Next() ) { - SALOMEDS::SObject_var anObj = it->Value(); - if ( anObj->ReferencedObject( aRef ) ) { - if ( aRef->FindAttribute( anAttr, "AttributeIOR" ) ) { - anIOR = SALOMEDS::AttributeIOR::_narrow( anAttr ); - if ( strcmp( anIOR->Value(), aShapeIOR ) == 0 ) { - aMorSM = anObj->GetFather(); - break; - } - } - } - } + SMESH_Hypothesis::Hypothesis_Status status = addHypothesis( aSubShapeObject, anHyp ); - bool aIsAlgo = !SMESH::SMESH_Algo::_narrow( anHyp )->_is_nil(); - SALOMEDS::SObject_var aHypSO = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( anHyp ) ) ) ); - if ( !aMorSM->_is_nil() && !aHypSO->_is_nil() ) { - //Find or Create Applied Hypothesis root - SALOMEDS::SObject_var AHR; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeSelectable_var aSelAttr; - SALOMEDS::AttributePixMap_var aPixmap; - SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder(); - long aTag = aIsAlgo ? SMESH_Gen_i::GetRefOnAppliedAlgorithmsTag() : SMESH_Gen_i::GetRefOnAppliedHypothesisTag(); - - if ( !aMorSM->FindSubObject( aTag, AHR ) ) { - AHR = aBuilder->NewObjectToTag( aMorSM, aTag ); - anAttr = aBuilder->FindOrCreateAttribute( AHR, "AttributeName" ); - aName = SALOMEDS::AttributeName::_narrow( anAttr ); - aName ->SetValue( aIsAlgo ? "Applied algorithms" : "Applied hypotheses" ); - anAttr = aBuilder->FindOrCreateAttribute( AHR, "AttributeSelectable" ); - aSelAttr = SALOMEDS::AttributeSelectable::_narrow( anAttr ); - aSelAttr ->SetSelectable( false ); - anAttr = aBuilder->FindOrCreateAttribute( AHR, "AttributePixMap" ); - aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr ); - aPixmap ->SetPixMap( aIsAlgo ? "ICON_SMESH_TREE_ALGO" : "ICON_SMESH_TREE_HYPO" ); - } + if ( !SMESH_Hypothesis::IsStatusFatal(status) ) + _gen_i->AddHypothesisToShape(_gen_i->GetCurrentStudy(), _this(), + aSubShapeObject, anHyp ); - SALOMEDS::SObject_var SO = aBuilder->NewObject( AHR ); - aBuilder->Addreference( SO, aHypSO ); - } - } - } + if(MYDEBUG) MESSAGE( " AddHypothesis(): status = " << status ); return ConvertHypothesisStatus(status); } @@ -395,37 +340,41 @@ SMESH::Hypothesis_Status SMESH_Mesh_i::AddHypothesis(GEOM::GEOM_Shape_ptr aSubSh //============================================================================= SMESH_Hypothesis::Hypothesis_Status - SMESH_Mesh_i::addHypothesis(GEOM::GEOM_Shape_ptr aSubShape, + SMESH_Mesh_i::addHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject, SMESH::SMESH_Hypothesis_ptr anHyp) { - MESSAGE("addHypothesis"); - // **** proposer liste de subShape (selection multiple) + if(MYDEBUG) MESSAGE("addHypothesis"); - GEOM::GEOM_Shape_var mySubShape = GEOM::GEOM_Shape::_narrow(aSubShape); - if (CORBA::is_nil(mySubShape)) - THROW_SALOME_CORBA_EXCEPTION("bad subShape reference", - SALOME::BAD_PARAM); + if (CORBA::is_nil(aSubShapeObject)) + THROW_SALOME_CORBA_EXCEPTION("bad subShape reference", + SALOME::BAD_PARAM); - SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow(anHyp); - if (CORBA::is_nil(myHyp)) - THROW_SALOME_CORBA_EXCEPTION("bad hypothesis reference", - SALOME::BAD_PARAM); + SMESH::SMESH_Hypothesis_var myHyp = SMESH::SMESH_Hypothesis::_narrow(anHyp); + if (CORBA::is_nil(myHyp)) + THROW_SALOME_CORBA_EXCEPTION("bad hypothesis reference", + SALOME::BAD_PARAM); - SMESH_Hypothesis::Hypothesis_Status status = SMESH_Hypothesis::HYP_OK; - try - { - TopoDS_Shape myLocSubShape = - _gen_i->GetShapeReader()->GetShape(SMESH_Gen_i::GetGeomEngine(), mySubShape); - int hypId = myHyp->GetId(); - status = _impl->AddHypothesis(myLocSubShape, hypId); - if ( !SMESH_Hypothesis::IsStatusFatal(status) ) - _mapHypo[hypId] = myHyp; - } - catch(SALOME_Exception & S_ex) - { - THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM); - } - return status; + SMESH_Hypothesis::Hypothesis_Status status = SMESH_Hypothesis::HYP_OK; + try + { + TopoDS_Shape myLocSubShape = _gen_i->GeomObjectToShape( aSubShapeObject); + int hypId = myHyp->GetId(); + status = _impl->AddHypothesis(myLocSubShape, hypId); + if ( !SMESH_Hypothesis::IsStatusFatal(status) ) { + _mapHypo[hypId] = myHyp; + // assure there is a corresponding submesh + if ( !_impl->IsMainShape( myLocSubShape )) { + int shapeId = _impl->GetMeshDS()->ShapeToIndex( myLocSubShape ); + if ( _mapSubMesh_i.find( shapeId ) == _mapSubMesh_i.end() ) + createSubMesh( aSubShapeObject ); + } + } + } + catch(SALOME_Exception & S_ex) + { + THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM); + } + return status; } //============================================================================= @@ -434,91 +383,33 @@ SMESH_Hypothesis::Hypothesis_Status */ //============================================================================= -SMESH::Hypothesis_Status SMESH_Mesh_i::RemoveHypothesis(GEOM::GEOM_Shape_ptr aSubShape, +SMESH::Hypothesis_Status SMESH_Mesh_i::RemoveHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject, SMESH::SMESH_Hypothesis_ptr anHyp) throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); - SMESH_Hypothesis::Hypothesis_Status status = removeHypothesis( aSubShape, anHyp ); - - if ( !SMESH_Hypothesis::IsStatusFatal(status) ) { - SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy(); - - if ( !aStudy->_is_nil() ) { - // Detect whether refers to this mesh or its sub-mesh - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeIOR_var anIOR; - SALOMEDS::SObject_var aMeshSO = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( _this() ) ) ) ); - if ( aMeshSO->_is_nil() ) - return SMESH::HYP_UNKNOWN_FATAL; - - SALOMEDS::SObject_var aMorSM, aRef; - CORBA::String_var aShapeIOR = CORBA::string_dup( SMESH_Gen_i::GetORB()->object_to_string( aSubShape ) ); - SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator( aMeshSO ); - - for ( it->InitEx( true ); it->More(); it->Next() ) { - SALOMEDS::SObject_var anObj = it->Value(); - if ( anObj->ReferencedObject( aRef ) ) { - if ( aRef->FindAttribute( anAttr, "AttributeIOR" ) ) { - anIOR = SALOMEDS::AttributeIOR::_narrow( anAttr ); - if ( strcmp( anIOR->Value(), aShapeIOR ) == 0 ) { - aMorSM = anObj->GetFather(); - break; - } - } - } - } + SMESH_Hypothesis::Hypothesis_Status status = removeHypothesis( aSubShapeObject, anHyp ); - bool aIsAlgo = !SMESH::SMESH_Algo::_narrow( anHyp )->_is_nil(); - SALOMEDS::SObject_var aHypSO = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( anHyp ) ) ) ); - if ( !aMorSM->_is_nil() && !aHypSO->_is_nil() ) { - // Remove a refernce to hypothesis or algorithm - SALOMEDS::SObject_var AHR; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeSelectable_var aSelAttr; - SALOMEDS::AttributePixMap_var aPixmap; - SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder(); - CORBA::String_var aHypIOR = CORBA::string_dup( SMESH_Gen_i::GetORB()->object_to_string( anHyp ) ); - long aTag = aIsAlgo ? SMESH_Gen_i::GetRefOnAppliedAlgorithmsTag() : SMESH_Gen_i::GetRefOnAppliedHypothesisTag(); - - if ( aMorSM->FindSubObject( aTag, AHR ) ) { - SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator( AHR ); - for ( ; it->More(); it->Next() ) { - SALOMEDS::SObject_var anObj = it->Value(); - if ( anObj->ReferencedObject( aRef ) ) { - if ( aRef->FindAttribute( anAttr, "AttributeIOR" ) ) { - anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - if ( strcmp( anIOR->Value(), aHypIOR ) == 0 ) { - aBuilder->RemoveObject( anObj ); - break; - } - } - } - } - } - } - } - } + if ( !SMESH_Hypothesis::IsStatusFatal(status) ) + _gen_i->RemoveHypothesisFromShape(_gen_i->GetCurrentStudy(), _this(), + aSubShapeObject, anHyp ); return ConvertHypothesisStatus(status); } - //============================================================================= /*! * */ //============================================================================= -SMESH_Hypothesis::Hypothesis_Status - SMESH_Mesh_i::removeHypothesis(GEOM::GEOM_Shape_ptr aSubShape, +SMESH_Hypothesis::Hypothesis_Status SMESH_Mesh_i::removeHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject, SMESH::SMESH_Hypothesis_ptr anHyp) { - MESSAGE("removeHypothesis()"); + if(MYDEBUG) MESSAGE("removeHypothesis()"); // **** proposer liste de subShape (selection multiple) - GEOM::GEOM_Shape_var mySubShape = GEOM::GEOM_Shape::_narrow(aSubShape); - if (CORBA::is_nil(mySubShape)) + if (CORBA::is_nil(aSubShapeObject)) THROW_SALOME_CORBA_EXCEPTION("bad subShape reference", SALOME::BAD_PARAM); @@ -530,8 +421,7 @@ SMESH_Hypothesis::Hypothesis_Status SMESH_Hypothesis::Hypothesis_Status status = SMESH_Hypothesis::HYP_OK; try { - TopoDS_Shape myLocSubShape = - _gen_i->GetShapeReader()->GetShape(SMESH_Gen_i::GetGeomEngine(), mySubShape); + TopoDS_Shape myLocSubShape = _gen_i->GeomObjectToShape(aSubShapeObject); int hypId = myHyp->GetId(); status = _impl->RemoveHypothesis(myLocSubShape, hypId); if ( !SMESH_Hypothesis::IsStatusFatal(status) ) @@ -551,22 +441,19 @@ SMESH_Hypothesis::Hypothesis_Status //============================================================================= SMESH::ListOfHypothesis * - SMESH_Mesh_i::GetHypothesisList(GEOM::GEOM_Shape_ptr aSubShape) + SMESH_Mesh_i::GetHypothesisList(GEOM::GEOM_Object_ptr aSubShapeObject) throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); - MESSAGE("GetHypothesisList"); - GEOM::GEOM_Shape_var mySubShape = GEOM::GEOM_Shape::_narrow(aSubShape); - if (CORBA::is_nil(mySubShape)) + if (MYDEBUG) MESSAGE("GetHypothesisList"); + if (CORBA::is_nil(aSubShapeObject)) THROW_SALOME_CORBA_EXCEPTION("bad subShape reference", SALOME::BAD_PARAM); SMESH::ListOfHypothesis_var aList = new SMESH::ListOfHypothesis(); try { - TopoDS_Shape myLocSubShape - = _gen_i->GetShapeReader()->GetShape(SMESH_Gen_i::GetGeomEngine(), mySubShape); - + TopoDS_Shape myLocSubShape = _gen_i->GeomObjectToShape(aSubShapeObject); const list& aLocalList = _impl->GetHypothesisList( myLocSubShape ); int i = 0, n = aLocalList.size(); aList->length( n ); @@ -591,59 +478,40 @@ throw(SALOME::SALOME_Exception) * */ //============================================================================= -SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::GetSubMesh(GEOM::GEOM_Shape_ptr aSubShape, - const char* theName ) +SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::GetSubMesh(GEOM::GEOM_Object_ptr aSubShapeObject, + const char* theName ) throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); - MESSAGE("SMESH_Mesh_i::GetElementsOnShape"); - GEOM::GEOM_Shape_var mySubShape = GEOM::GEOM_Shape::_narrow(aSubShape); - if (CORBA::is_nil(mySubShape)) + MESSAGE("SMESH_Mesh_i::GetSubMesh"); + if (CORBA::is_nil(aSubShapeObject)) THROW_SALOME_CORBA_EXCEPTION("bad subShape reference", SALOME::BAD_PARAM); - int subMeshId = 0; + SMESH::SMESH_subMesh_var subMesh; + SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(_this()); try { - TopoDS_Shape myLocSubShape - = _gen_i->GetShapeReader()->GetShape(SMESH_Gen_i::GetGeomEngine(), mySubShape); + TopoDS_Shape myLocSubShape = _gen_i->GeomObjectToShape(aSubShapeObject); //Get or Create the SMESH_subMesh object implementation - ::SMESH_subMesh * mySubMesh = _impl->GetSubMesh(myLocSubShape); - subMeshId = mySubMesh->GetId(); - + int subMeshId = _impl->GetMeshDS()->ShapeToIndex( myLocSubShape ); + subMesh = getSubMesh( subMeshId ); + // create a new subMesh object servant if there is none for the shape - - if (_mapSubMesh.find(subMeshId) == _mapSubMesh.end()) { - SMESH::SMESH_subMesh_var subMesh = createSubMesh( aSubShape ); - if ( _gen_i->CanPublishInStudy( subMesh ) ) { - SALOMEDS::SObject_var aSubmeshSO = _gen_i->PublishInStudy( _gen_i->GetCurrentStudy(), - SALOMEDS::SObject::_nil(), - subMesh, - theName ); - - // Add reference to to the study - SALOMEDS::Study_var aStudy = _gen_i->GetCurrentStudy(); - SALOMEDS::SObject_var aShapeSO = aStudy->FindObjectIOR( SMESH_Gen_i::GetORB()->object_to_string( aSubShape ) ); - if ( !aSubmeshSO->_is_nil() && !aShapeSO->_is_nil() ) { - MESSAGE( "********** SMESH_Mesh_i::GetSubMesh(): adding shape reference..." ) - SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder(); - SALOMEDS::SObject_var SO = aBuilder->NewObjectToTag( aSubmeshSO, SMESH_Gen_i::GetRefOnShapeTag() ); - aBuilder->Addreference( SO, aShapeSO ); - MESSAGE( "********** SMESH_Mesh_i::GetSubMesh(): shape reference added" ) - } - } - } + if ( subMesh->_is_nil() ) + subMesh = createSubMesh( aSubShapeObject ); + + if ( _gen_i->CanPublishInStudy( subMesh )) + _gen_i->PublishSubMesh (_gen_i->GetCurrentStudy(), aMesh, + subMesh, aSubShapeObject, theName ); } catch(SALOME_Exception & S_ex) { THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM); } - - ASSERT(_mapSubMeshIor.find(subMeshId) != _mapSubMeshIor.end()); - return SMESH::SMESH_subMesh::_duplicate(_mapSubMeshIor[subMeshId]); + return subMesh; } - //============================================================================= /*! * @@ -653,26 +521,26 @@ SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::GetSubMesh(GEOM::GEOM_Shape_ptr aSubShape void SMESH_Mesh_i::RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh ) throw (SALOME::SALOME_Exception) { - MESSAGE("SMESH_Mesh_i::RemoveSubMesh"); + if(MYDEBUG) MESSAGE("SMESH_Mesh_i::RemoveSubMesh"); if ( theSubMesh->_is_nil() ) return; - GEOM::GEOM_Shape_var aSubShape; + GEOM::GEOM_Object_var aSubShapeObject; SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy(); if ( !aStudy->_is_nil() ) { // Remove submesh's SObject - SALOMEDS::SObject_var anSO = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( theSubMesh ) ) ) ); + SALOMEDS::SObject_var anSO = _gen_i->ObjectToSObject( aStudy, theSubMesh ); if ( !anSO->_is_nil() ) { long aTag = SMESH_Gen_i::GetRefOnShapeTag(); SALOMEDS::SObject_var anObj, aRef; if ( anSO->FindSubObject( aTag, anObj ) && anObj->ReferencedObject( aRef ) ) - aSubShape = GEOM::GEOM_Shape::_narrow( aRef->GetObject() ); + aSubShapeObject = GEOM::GEOM_Object::_narrow( aRef->GetObject() ); aStudy->NewBuilder()->RemoveObjectWithChildren( anSO ); } } - removeSubMesh( theSubMesh, aSubShape.in() ); + removeSubMesh( theSubMesh, aSubShapeObject.in() ); } @@ -683,19 +551,15 @@ void SMESH_Mesh_i::RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh ) //============================================================================= SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateGroup( SMESH::ElementType theElemType, - const char* theName ) + const char* theName ) throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); - SMESH::SMESH_Group_var aNewGroup = createGroup( theElemType, theName ); - - // Groups should be put under separate roots according to their type (nodes, edges, faces, volumes) - if ( _gen_i->CanPublishInStudy( aNewGroup ) ) { - SALOMEDS::SObject_var aGroupSO = _gen_i->PublishInStudy( _gen_i->GetCurrentStudy(), - SALOMEDS::SObject::_nil(), - aNewGroup, - theName ); - } + SMESH::SMESH_Group_var aNewGroup = + SMESH::SMESH_Group::_narrow( createGroup( theElemType, theName )); + + _gen_i->PublishGroup( _gen_i->GetCurrentStudy(), _this(), + aNewGroup, GEOM::GEOM_Object::_nil(), theName); return aNewGroup._retn(); } @@ -706,21 +570,46 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::CreateGroup( SMESH::ElementType theElemType * */ //============================================================================= +SMESH::SMESH_GroupOnGeom_ptr SMESH_Mesh_i::CreateGroupFromGEOM( SMESH::ElementType theElemType, + const char* theName, + GEOM::GEOM_Object_ptr theGeomObj) + throw(SALOME::SALOME_Exception) +{ + Unexpect aCatch(SALOME_SalomeException); + SMESH::SMESH_GroupOnGeom_var aNewGroup; + + TopoDS_Shape aShape = _gen_i->GeomObjectToShape( theGeomObj ); + if ( !aShape.IsNull() ) { + aNewGroup = SMESH::SMESH_GroupOnGeom::_narrow + ( createGroup( theElemType, theName, aShape )); + if ( _gen_i->CanPublishInStudy( aNewGroup ) ) + _gen_i->PublishGroup( _gen_i->GetCurrentStudy(), _this(), + aNewGroup, theGeomObj, theName ); + } -void SMESH_Mesh_i::RemoveGroup( SMESH::SMESH_Group_ptr theGroup ) - throw (SALOME::SALOME_Exception) + return aNewGroup._retn(); +} +//============================================================================= +/*! + * + */ +//============================================================================= + +void SMESH_Mesh_i::RemoveGroup( SMESH::SMESH_GroupBase_ptr theGroup ) + throw (SALOME::SALOME_Exception) { if ( theGroup->_is_nil() ) return; - SMESH_Group_i* aGroup = dynamic_cast( SMESH_Gen_i::GetServant( theGroup ).in() ); + SMESH_GroupBase_i* aGroup = + dynamic_cast( SMESH_Gen_i::GetServant( theGroup ).in() ); if ( !aGroup ) return; SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy(); if ( !aStudy->_is_nil() ) { // Remove group's SObject - SALOMEDS::SObject_var aGroupSO = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( theGroup ) ) ) ); + SALOMEDS::SObject_var aGroupSO = _gen_i->ObjectToSObject( aStudy, theGroup ); if ( !aGroupSO->_is_nil() ) aStudy->NewBuilder()->RemoveObject( aGroupSO ); } @@ -729,6 +618,176 @@ void SMESH_Mesh_i::RemoveGroup( SMESH::SMESH_Group_ptr theGroup ) removeGroup( aGroup->GetLocalID() ); } +//============================================================================= +/*! RemoveGroupWithContents + * Remove group with its contents + */ +//============================================================================= +void SMESH_Mesh_i::RemoveGroupWithContents( SMESH::SMESH_GroupBase_ptr theGroup ) + throw (SALOME::SALOME_Exception) +{ + if ( theGroup->_is_nil() ) + return; + + SMESH_GroupBase_i* aGroup = + dynamic_cast( SMESH_Gen_i::GetServant( theGroup ).in() ); + if ( !aGroup ) + return; + + SMESH::long_array_var anIds = aGroup->GetListOfID(); + SMESH::SMESH_MeshEditor_var aMeshEditor = SMESH_Mesh_i::GetMeshEditor(); + + if ( aGroup->GetType() == SMESH::NODE ) + aMeshEditor->RemoveNodes( anIds ); + else + aMeshEditor->RemoveElements( anIds ); + + RemoveGroup( theGroup ); +} + +//============================================================================= +/*! UnionGroups + * New group is created. All mesh elements that are + * present in initial groups are added to the new one + */ +//============================================================================= +SMESH::SMESH_Group_ptr SMESH_Mesh_i::UnionGroups( SMESH::SMESH_GroupBase_ptr theGroup1, + SMESH::SMESH_GroupBase_ptr theGroup2, + const char* theName ) + throw (SALOME::SALOME_Exception) +{ + try + { + SMESH::SMESH_Group_var aResGrp; + + if ( theGroup1->_is_nil() || theGroup2->_is_nil() || + theGroup1->GetType() != theGroup2->GetType() ) + return SMESH::SMESH_Group::_nil(); + + aResGrp = CreateGroup( theGroup1->GetType(), theName ); + if ( aResGrp->_is_nil() ) + return SMESH::SMESH_Group::_nil(); + + SMESH::long_array_var anIds1 = theGroup1->GetListOfID(); + SMESH::long_array_var anIds2 = theGroup2->GetListOfID(); + + TColStd_MapOfInteger aResMap; + + for ( int i1 = 0, n1 = anIds1->length(); i1 < n1; i1++ ) + aResMap.Add( anIds1[ i1 ] ); + + for ( int i2 = 0, n2 = anIds2->length(); i2 < n2; i2++ ) + aResMap.Add( anIds2[ i2 ] ); + + SMESH::long_array_var aResIds = new SMESH::long_array; + aResIds->length( aResMap.Extent() ); + + int resI = 0; + TColStd_MapIteratorOfMapOfInteger anIter( aResMap ); + for( ; anIter.More(); anIter.Next() ) + aResIds[ resI++ ] = anIter.Key(); + + aResGrp->Add( aResIds ); + + return aResGrp._retn(); + } + catch( ... ) + { + return SMESH::SMESH_Group::_nil(); + } +} + +//============================================================================= +/*! IntersectGroups + * New group is created. All mesh elements that are + * present in both initial groups are added to the new one. + */ +//============================================================================= +SMESH::SMESH_Group_ptr SMESH_Mesh_i::IntersectGroups( SMESH::SMESH_GroupBase_ptr theGroup1, + SMESH::SMESH_GroupBase_ptr theGroup2, + const char* theName ) + throw (SALOME::SALOME_Exception) +{ + SMESH::SMESH_Group_var aResGrp; + + if ( theGroup1->_is_nil() || theGroup2->_is_nil() || + theGroup1->GetType() != theGroup2->GetType() ) + return aResGrp; + + aResGrp = CreateGroup( theGroup1->GetType(), theName ); + if ( aResGrp->_is_nil() ) + return aResGrp; + + SMESH::long_array_var anIds1 = theGroup1->GetListOfID(); + SMESH::long_array_var anIds2 = theGroup2->GetListOfID(); + + TColStd_MapOfInteger aMap1; + + for ( int i1 = 0, n1 = anIds1->length(); i1 < n1; i1++ ) + aMap1.Add( anIds1[ i1 ] ); + + TColStd_SequenceOfInteger aSeq; + + for ( int i2 = 0, n2 = anIds2->length(); i2 < n2; i2++ ) + if ( aMap1.Contains( anIds2[ i2 ] ) ) + aSeq.Append( anIds2[ i2 ] ); + + SMESH::long_array_var aResIds = new SMESH::long_array; + aResIds->length( aSeq.Length() ); + + for ( int resI = 0, resN = aSeq.Length(); resI < resN; resI++ ) + aResIds[ resI ] = aSeq( resI + 1 ); + + aResGrp->Add( aResIds ); + + return aResGrp._retn(); +} + +//============================================================================= +/*! CutGroups + * New group is created. All mesh elements that are present in + * main group but do not present in tool group are added to the new one + */ +//============================================================================= +SMESH::SMESH_Group_ptr SMESH_Mesh_i::CutGroups( SMESH::SMESH_GroupBase_ptr theGroup1, + SMESH::SMESH_GroupBase_ptr theGroup2, + const char* theName ) + throw (SALOME::SALOME_Exception) +{ + SMESH::SMESH_Group_var aResGrp; + + if ( theGroup1->_is_nil() || theGroup2->_is_nil() || + theGroup1->GetType() != theGroup2->GetType() ) + return aResGrp; + + aResGrp = CreateGroup( theGroup1->GetType(), theName ); + if ( aResGrp->_is_nil() ) + return aResGrp; + + SMESH::long_array_var anIds1 = theGroup1->GetListOfID(); + SMESH::long_array_var anIds2 = theGroup2->GetListOfID(); + + TColStd_MapOfInteger aMap2; + + 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 ] ) ) + aSeq.Append( anIds1[ i1 ] ); + + SMESH::long_array_var aResIds = new SMESH::long_array; + aResIds->length( aSeq.Length() ); + + for ( int resI = 0, resN = aSeq.Length(); resI < resN; resI++ ) + aResIds[ resI ] = aSeq( resI + 1 ); + + aResGrp->Add( aResIds ); + + return aResGrp._retn(); +} //============================================================================= /*! @@ -736,30 +795,42 @@ void SMESH_Mesh_i::RemoveGroup( SMESH::SMESH_Group_ptr theGroup ) */ //============================================================================= -SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::createSubMesh( GEOM::GEOM_Shape_ptr theSubShape ) { - - TopoDS_Shape myLocSubShape = _gen_i->GetShapeReader()->GetShape(SMESH_Gen_i::GetGeomEngine(), theSubShape); +SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::createSubMesh( GEOM::GEOM_Object_ptr theSubShapeObject ) +{ + if(MYDEBUG) MESSAGE( "createSubMesh" ); + TopoDS_Shape myLocSubShape = _gen_i->GeomObjectToShape(theSubShapeObject); ::SMESH_subMesh * mySubMesh = _impl->GetSubMesh(myLocSubShape); - int subMeshId = mySubMesh->GetId(); + int subMeshId = _impl->GetMeshDS()->ShapeToIndex( myLocSubShape ); SMESH_subMesh_i *subMeshServant = new SMESH_subMesh_i(myPOA, _gen_i, this, subMeshId); SMESH::SMESH_subMesh_var subMesh = SMESH::SMESH_subMesh::_narrow(subMeshServant->_this()); _mapSubMesh[subMeshId] = mySubMesh; _mapSubMesh_i[subMeshId] = subMeshServant; - _mapSubMeshIor[subMeshId] - = SMESH::SMESH_subMesh::_duplicate(subMesh); + _mapSubMeshIor[subMeshId] = SMESH::SMESH_subMesh::_duplicate(subMesh); // register CORBA object for persistence - StudyContext* myStudyContext = _gen_i->GetCurrentStudyContext(); - string iorString = SMESH_Gen_i::GetORB()->object_to_string( subMesh ); - int nextId = myStudyContext->addObject( iorString ); - MESSAGE( "Add submesh to map with id = "<< nextId << " and IOR = " << iorString.c_str() ); + int nextId = _gen_i->RegisterObject( subMesh ); + if(MYDEBUG) MESSAGE( "Add submesh to map with id = "<< nextId); return subMesh._retn(); } +//======================================================================= +//function : getSubMesh +//purpose : +//======================================================================= + +SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::getSubMesh(int shapeID) +{ + map::iterator it = _mapSubMeshIor.find( shapeID ); + if ( it == _mapSubMeshIor.end() ) + return SMESH::SMESH_subMesh::_nil(); + + return SMESH::SMESH_subMesh::_duplicate( (*it).second ); +} + //============================================================================= /*! @@ -767,20 +838,21 @@ SMESH::SMESH_subMesh_ptr SMESH_Mesh_i::createSubMesh( GEOM::GEOM_Shape_ptr theSu */ //============================================================================= -void SMESH_Mesh_i::removeSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh, GEOM::GEOM_Shape_ptr theSubShape ) +void SMESH_Mesh_i::removeSubMesh (SMESH::SMESH_subMesh_ptr theSubMesh, + GEOM::GEOM_Object_ptr theSubShapeObject ) { MESSAGE("SMESH_Mesh_i::removeSubMesh()"); - if ( theSubMesh->_is_nil() || theSubShape->_is_nil() ) + if ( theSubMesh->_is_nil() || theSubShapeObject->_is_nil() ) return; try { - SMESH::ListOfHypothesis_var aHypList = GetHypothesisList( theSubShape ); + SMESH::ListOfHypothesis_var aHypList = GetHypothesisList( theSubShapeObject ); for ( int i = 0, n = aHypList->length(); i < n; i++ ) { - removeHypothesis( theSubShape, aHypList[i] ); + removeHypothesis( theSubShapeObject, aHypList[i] ); } } catch( const SALOME::SALOME_Exception& ) { - MESSAGE("SMESH_Mesh_i::removeSubMesh(): exception caught!"); + INFOS("SMESH_Mesh_i::removeSubMesh(): exception caught!"); } int subMeshId = theSubMesh->GetId(); @@ -788,7 +860,7 @@ void SMESH_Mesh_i::removeSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh, GEOM::GEO _mapSubMesh.erase(subMeshId); _mapSubMesh_i.erase(subMeshId); _mapSubMeshIor.erase(subMeshId); - MESSAGE("SMESH_Mesh_i::removeSubMesh() completed"); + if(MYDEBUG) MESSAGE("SMESH_Mesh_i::removeSubMesh() completed"); } //============================================================================= @@ -797,25 +869,28 @@ void SMESH_Mesh_i::removeSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh, GEOM::GEO */ //============================================================================= -SMESH::SMESH_Group_ptr SMESH_Mesh_i::createGroup( SMESH::ElementType theElemType, const char* theName ) +SMESH::SMESH_GroupBase_ptr SMESH_Mesh_i::createGroup (SMESH::ElementType theElemType, + const char* theName, + const TopoDS_Shape& theShape ) { int anId; - SMESH::SMESH_Group_var aGroup; - if ( _impl->AddGroup( (SMDSAbs_ElementType)theElemType, theName, anId ) ) { - SMESH_Group_i* aGroupImpl = new SMESH_Group_i( SMESH_Gen_i::GetPOA(), this, anId ); - aGroup = SMESH::SMESH_Group::_narrow( aGroupImpl->_this() ); - _mapGroups[anId] = SMESH::SMESH_Group::_duplicate( aGroup ); + SMESH::SMESH_GroupBase_var aGroup; + if ( _impl->AddGroup( (SMDSAbs_ElementType)theElemType, theName, anId, theShape )) { + SMESH_GroupBase_i* aGroupImpl; + if ( !theShape.IsNull() ) + aGroupImpl = new SMESH_GroupOnGeom_i( SMESH_Gen_i::GetPOA(), this, anId ); + else + aGroupImpl = new SMESH_Group_i( SMESH_Gen_i::GetPOA(), this, anId ); + aGroup = SMESH::SMESH_GroupBase::_narrow( aGroupImpl->_this() ); + _mapGroups[anId] = SMESH::SMESH_GroupBase::_duplicate( aGroup ); // register CORBA object for persistence - StudyContext* myStudyContext = _gen_i->GetCurrentStudyContext(); - string iorString = SMESH_Gen_i::GetORB()->object_to_string( aGroup ); - int nextId = myStudyContext->addObject( iorString ); - MESSAGE( "Add group to map with id = "<< nextId << " and IOR = " << iorString.c_str() ); + int nextId = _gen_i->RegisterObject( aGroup ); + if(MYDEBUG) MESSAGE( "Add group to map with id = "<< nextId); } return aGroup._retn(); } - //============================================================================= /*! * SMESH_Mesh_i::removeGroup @@ -826,7 +901,7 @@ SMESH::SMESH_Group_ptr SMESH_Mesh_i::createGroup( SMESH::ElementType theElemType void SMESH_Mesh_i::removeGroup( const int theId ) { - MESSAGE("SMESH_Mesh_i::removeGroup()" ); + if(MYDEBUG) MESSAGE("SMESH_Mesh_i::removeGroup()" ); if ( _mapGroups.find( theId ) != _mapGroups.end() ) { _mapGroups.erase( theId ); _impl->RemoveGroup( theId ); @@ -843,179 +918,57 @@ void SMESH_Mesh_i::removeGroup( const int theId ) SMESH::log_array * SMESH_Mesh_i::GetLog(CORBA::Boolean clearAfterGet) throw(SALOME::SALOME_Exception) { - MESSAGE("SMESH_Mesh_i::GetLog"); - - SMESH::log_array_var aLog; - try - { - list < SMESHDS_Command * >logDS = _impl->GetLog(); - aLog = new SMESH::log_array; - int indexLog = 0; - int lg = logDS.size(); - SCRUTE(lg); - aLog->length(lg); - list < SMESHDS_Command * >::iterator its = logDS.begin(); - while (its != logDS.end()) - { - SMESHDS_Command *com = *its; - int comType = com->GetType(); - //SCRUTE(comType); - int lgcom = com->GetNumber(); - //SCRUTE(lgcom); - const list < int >&intList = com->GetIndexes(); - int inum = intList.size(); - //SCRUTE(inum); - list < int >::const_iterator ii = intList.begin(); - const list < double >&coordList = com->GetCoords(); - int rnum = coordList.size(); - //SCRUTE(rnum); - list < double >::const_iterator ir = coordList.begin(); - aLog[indexLog].commandType = comType; - aLog[indexLog].number = lgcom; - aLog[indexLog].coords.length(rnum); - aLog[indexLog].indexes.length(inum); - for (int i = 0; i < rnum; i++) - { - aLog[indexLog].coords[i] = *ir; - //MESSAGE(" "<ClearLog(); - } - catch(SALOME_Exception & S_ex) - { - THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM); - } - return aLog._retn(); + if(MYDEBUG) MESSAGE("SMESH_Mesh_i::GetLog"); + + SMESH::log_array_var aLog; + try{ + list < SMESHDS_Command * >logDS = _impl->GetLog(); + aLog = new SMESH::log_array; + int indexLog = 0; + int lg = logDS.size(); + SCRUTE(lg); + aLog->length(lg); + list < SMESHDS_Command * >::iterator its = logDS.begin(); + while(its != logDS.end()){ + SMESHDS_Command *com = *its; + int comType = com->GetType(); + //SCRUTE(comType); + int lgcom = com->GetNumber(); + //SCRUTE(lgcom); + const list < int >&intList = com->GetIndexes(); + int inum = intList.size(); + //SCRUTE(inum); + list < int >::const_iterator ii = intList.begin(); + const list < double >&coordList = com->GetCoords(); + int rnum = coordList.size(); + //SCRUTE(rnum); + list < double >::const_iterator ir = coordList.begin(); + aLog[indexLog].commandType = comType; + aLog[indexLog].number = lgcom; + aLog[indexLog].coords.length(rnum); + aLog[indexLog].indexes.length(inum); + for(int i = 0; i < rnum; i++){ + aLog[indexLog].coords[i] = *ir; + //MESSAGE(" "<ClearLog(); + } + catch(SALOME_Exception & S_ex){ + THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM); + } + return aLog._retn(); } -// SMESH::string_array* SMESH_Mesh_i::GetLog(CORBA::Boolean clearAfterGet) -// throw (SALOME::SALOME_Exception) -// { -// MESSAGE("SMESH_Mesh_i::GetLog"); - -// SMESH::string_array_var aLog; -// try -// { -// const SMESHDS_ListOfCommand& logDS =_impl->GetLog(); -// aLog = new SMESH::string_array; -// int logSize = 0; -// int indexLog = 0; -// int lg = logDS.Extent(); -// SCRUTE(lg); -// SMESHDS_ListIteratorOfListOfCommand its(logDS); -// while(its.More()) -// { -// Handle(SMESHDS_Command) com = its.Value(); -// int comType = com->GetType(); -// SCRUTE(comType); -// int lgcom = com->GetNumber(); -// SCRUTE(lgcom); -// logSize += lgcom; -// aLog->length(logSize); -// SCRUTE(logSize); -// const TColStd_ListOfInteger& intList = com->GetIndexes(); -// TColStd_ListIteratorOfListOfInteger ii(intList); -// const TColStd_ListOfReal& coordList = com->GetCoords(); -// TColStd_ListIteratorOfListOfReal ir(coordList); -// for (int icom = 1; icom <= lgcom; icom++) -// { -// ostringstream S; -// switch (comType) -// { -// case SMESHDS_AddNode: -// S << "AddNode " << ii.Value(); ii.Next(); -// S << " " << ir.Value(); ir.Next(); -// S << " " << ir.Value(); ir.Next(); -// S << " " << ir.Value(); ir.Next(); -// break; -// case SMESHDS_AddEdge: -// S << "AddEdge " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// break; -// case SMESHDS_AddTriangle: -// S << "AddFace " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// break; -// case SMESHDS_AddQuadrangle: -// S << "AddFace " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// break; -// case SMESHDS_AddTetrahedron: -// S << "AddVolume " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// break; -// case SMESHDS_AddPyramid: -// S << "AddVolume " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// break; -// case SMESHDS_AddPrism: -// S << "AddVolume " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// break; -// case SMESHDS_AddHexahedron: -// S << "AddVolume " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// S << " " << ii.Value(); ii.Next(); -// break; -// case SMESHDS_RemoveNode: -// S << "RemoveNode " << ii.Value(); ii.Next(); -// break; -// case SMESHDS_RemoveElement: -// S << "RemoveElement " << ii.Value(); ii.Next(); -// break; -// default: -// ASSERT(0); -// break; -// } -// string ch = S.str(); -// SCRUTE(ch); -// aLog[indexLog++] = CORBA::string_dup(ch.c_str()); -// } -// its.Next(); -// } -// if (clearAfterGet) _impl->ClearLog(); -// } -// catch (SALOME_Exception& S_ex) -// { -// THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM); -// } -// return aLog._retn(); -// } //============================================================================= /*! @@ -1025,8 +978,8 @@ throw(SALOME::SALOME_Exception) void SMESH_Mesh_i::ClearLog() throw(SALOME::SALOME_Exception) { - MESSAGE("SMESH_Mesh_i::ClearLog"); - // **** + if(MYDEBUG) MESSAGE("SMESH_Mesh_i::ClearLog"); + // **** } //============================================================================= @@ -1037,8 +990,8 @@ void SMESH_Mesh_i::ClearLog() throw(SALOME::SALOME_Exception) CORBA::Long SMESH_Mesh_i::GetId()throw(SALOME::SALOME_Exception) { - MESSAGE("SMESH_Mesh_i::GetId"); - return _id; + if(MYDEBUG) MESSAGE("SMESH_Mesh_i::GetId"); + return _id; } //============================================================================= @@ -1049,7 +1002,7 @@ CORBA::Long SMESH_Mesh_i::GetId()throw(SALOME::SALOME_Exception) CORBA::Long SMESH_Mesh_i::GetStudyId()throw(SALOME::SALOME_Exception) { - return _studyId; + return _studyId; } //============================================================================= @@ -1060,8 +1013,8 @@ CORBA::Long SMESH_Mesh_i::GetStudyId()throw(SALOME::SALOME_Exception) void SMESH_Mesh_i::SetImpl(::SMESH_Mesh * impl) { - MESSAGE("SMESH_Mesh_i::SetImpl"); - _impl = impl; + if(MYDEBUG) MESSAGE("SMESH_Mesh_i::SetImpl"); + _impl = impl; } //============================================================================= @@ -1072,8 +1025,8 @@ void SMESH_Mesh_i::SetImpl(::SMESH_Mesh * impl) ::SMESH_Mesh & SMESH_Mesh_i::GetImpl() { - MESSAGE("SMESH_Mesh_i::GetImpl()"); - return *_impl; + if(MYDEBUG) MESSAGE("SMESH_Mesh_i::GetImpl()"); + return *_impl; } @@ -1085,8 +1038,7 @@ void SMESH_Mesh_i::SetImpl(::SMESH_Mesh * impl) SMESH::SMESH_MeshEditor_ptr SMESH_Mesh_i::GetMeshEditor() { - SMESH_MeshEditor_i *aMeshEditor = - new SMESH_MeshEditor_i(_impl->GetMeshDS()); + SMESH_MeshEditor_i *aMeshEditor = new SMESH_MeshEditor_i( _impl ); SMESH::SMESH_MeshEditor_var aMesh = aMeshEditor->_this(); return aMesh._retn(); } @@ -1100,43 +1052,53 @@ SMESH::SMESH_MeshEditor_ptr SMESH_Mesh_i::GetMeshEditor() void SMESH_Mesh_i::ExportMED(const char *file, CORBA::Boolean auto_groups) throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); - SALOMEDS::Study_ptr aStudy = _gen_i->GetCurrentStudy(); - if ( aStudy->_is_nil() ) - return; - char* aMeshName = NULL; - SALOMEDS::SObject_var aMeshSO = SALOMEDS::SObject::_narrow( aStudy->FindObjectIOR( ( SMESH_Gen_i::GetORB()->object_to_string( _this() ) ) ) ); - if ( !aMeshSO->_is_nil() ) - { + 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()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - SALOMEDS::AttributeExternalFileDef_var aFileName; - anAttr=aStudyBuilder->FindOrCreateAttribute(aMeshSO, "AttributeExternalFileDef"); - aFileName = SALOMEDS::AttributeExternalFileDef::_narrow(anAttr); - ASSERT(!aFileName->_is_nil()); - aFileName->SetValue(file); - SALOMEDS::AttributeFileType_var aFileType; - anAttr=aStudyBuilder->FindOrCreateAttribute(aMeshSO, "AttributeFileType"); - aFileType = SALOMEDS::AttributeFileType::_narrow(anAttr); - ASSERT(!aFileType->_is_nil()); - aFileType->SetValue("FICHIERMED"); + + // asv : 27.10.04 : fix of 6903: check for StudyLocked before adding attributes + if ( !aStudy->GetProperties()->IsLocked() ) + { + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); + SALOMEDS::AttributeExternalFileDef_var aFileName; + anAttr=aStudyBuilder->FindOrCreateAttribute(aMeshSO, "AttributeExternalFileDef"); + aFileName = SALOMEDS::AttributeExternalFileDef::_narrow(anAttr); + ASSERT(!aFileName->_is_nil()); + aFileName->SetValue(file); + SALOMEDS::AttributeFileType_var aFileType; + anAttr=aStudyBuilder->FindOrCreateAttribute(aMeshSO, "AttributeFileType"); + aFileType = SALOMEDS::AttributeFileType::_narrow(anAttr); + ASSERT(!aFileType->_is_nil()); + aFileType->SetValue("FICHIERMED"); + } } + } _impl->ExportMED( file, aMeshName, auto_groups ); } void SMESH_Mesh_i::ExportDAT(const char *file) throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); - _impl->ExportDAT(file); + _impl->ExportDAT(file); } void SMESH_Mesh_i::ExportUNV(const char *file) throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); - _impl->ExportUNV(file); + _impl->ExportUNV(file); +} + +void SMESH_Mesh_i::ExportSTL(const char *file, const bool isascii) throw(SALOME::SALOME_Exception) +{ + Unexpect aCatch(SALOME_SalomeException); + _impl->ExportSTL(file, isascii); } //============================================================================= @@ -1148,9 +1110,9 @@ void SMESH_Mesh_i::ExportUNV(const char *file) throw(SALOME::SALOME_Exception) SALOME_MED::MESH_ptr SMESH_Mesh_i::GetMEDMesh()throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); - SMESH_MEDMesh_i *aMedMesh = new SMESH_MEDMesh_i(this); - SALOME_MED::MESH_var aMesh = aMedMesh->_this(); - return aMesh._retn(); + SMESH_MEDMesh_i *aMedMesh = new SMESH_MEDMesh_i(this); + SALOME_MED::MESH_var aMesh = aMedMesh->_this(); + return aMesh._retn(); } //============================================================================= @@ -1161,7 +1123,7 @@ SALOME_MED::MESH_ptr SMESH_Mesh_i::GetMEDMesh()throw(SALOME::SALOME_Exception) CORBA::Long SMESH_Mesh_i::NbNodes()throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); - return _impl->NbNodes(); + return _impl->NbNodes(); } //============================================================================= @@ -1172,7 +1134,7 @@ CORBA::Long SMESH_Mesh_i::NbNodes()throw(SALOME::SALOME_Exception) CORBA::Long SMESH_Mesh_i::NbEdges()throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); - return _impl->NbEdges(); + return _impl->NbEdges(); } //============================================================================= @@ -1183,19 +1145,19 @@ CORBA::Long SMESH_Mesh_i::NbEdges()throw(SALOME::SALOME_Exception) CORBA::Long SMESH_Mesh_i::NbFaces()throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); - return _impl->NbFaces(); + return _impl->NbFaces(); } CORBA::Long SMESH_Mesh_i::NbTriangles()throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); - return _impl->NbTriangles(); + return _impl->NbTriangles(); } CORBA::Long SMESH_Mesh_i::NbQuadrangles()throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); - return _impl->NbQuadrangles(); + return _impl->NbQuadrangles(); } //============================================================================= @@ -1206,31 +1168,31 @@ CORBA::Long SMESH_Mesh_i::NbQuadrangles()throw(SALOME::SALOME_Exception) CORBA::Long SMESH_Mesh_i::NbVolumes()throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); - return _impl->NbVolumes(); + return _impl->NbVolumes(); } CORBA::Long SMESH_Mesh_i::NbTetras()throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); - return _impl->NbTetras(); + return _impl->NbTetras(); } CORBA::Long SMESH_Mesh_i::NbHexas()throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); - return _impl->NbHexas(); + return _impl->NbHexas(); } CORBA::Long SMESH_Mesh_i::NbPyramids()throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); - return _impl->NbPyramids(); + return _impl->NbPyramids(); } CORBA::Long SMESH_Mesh_i::NbPrisms()throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); - return _impl->NbPrisms(); + return _impl->NbPrisms(); } //============================================================================= @@ -1241,7 +1203,7 @@ CORBA::Long SMESH_Mesh_i::NbPrisms()throw(SALOME::SALOME_Exception) CORBA::Long SMESH_Mesh_i::NbSubMesh()throw(SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); - return _impl->NbSubMesh(); + return _impl->NbSubMesh(); } //============================================================================= @@ -1255,3 +1217,23 @@ char* SMESH_Mesh_i::Dump() _impl->Dump( os ); return CORBA::string_dup( os.str().c_str() ); } + +//============================================================================= +/*! + * + */ +//============================================================================= +SMESH::long_array* SMESH_Mesh_i::GetIDs() +{ + SMESH::long_array_var aResult = new SMESH::long_array(); + SMESHDS_Mesh* aSMESHDS_Mesh = _impl->GetMeshDS(); + int aMinId = aSMESHDS_Mesh->MinElementID(); + int aMaxId = aSMESHDS_Mesh->MaxElementID(); + + aResult->length(aMaxId - aMinId + 1); + + for (int i = 0, id = aMinId; id <= aMaxId; id++ ) + aResult[i++] = id; + + return aResult._retn(); +} diff --git a/src/SMESH_I/SMESH_Mesh_i.hxx b/src/SMESH_I/SMESH_Mesh_i.hxx index 48243c177..0b010c474 100644 --- a/src/SMESH_I/SMESH_Mesh_i.hxx +++ b/src/SMESH_I/SMESH_Mesh_i.hxx @@ -34,28 +34,27 @@ #include CORBA_SERVER_HEADER(SMESH_Group) #include CORBA_SERVER_HEADER(SMESH_Hypothesis) #include CORBA_CLIENT_HEADER(GEOM_Gen) -#include CORBA_CLIENT_HEADER(GEOM_Shape) #include CORBA_CLIENT_HEADER(MED) -class SMESH_Gen_i; -class SMESH_Group_i; - #include "SMESH_Hypothesis.hxx" #include "SMESH_Mesh.hxx" #include "SMESH_subMesh_i.hxx" #include "SMESH_subMesh.hxx" -#include "SMESH_topo.hxx" - -#include #include "SALOME_GenericObj_i.hh" +class SMESH_Gen_i; +class SMESH_GroupBase_i; + +#include + class SMESH_Mesh_i: public virtual POA_SMESH::SMESH_Mesh, public virtual SALOME::GenericObj_i { -public: SMESH_Mesh_i(); + SMESH_Mesh_i(const SMESH_Mesh_i&); +public: SMESH_Mesh_i( PortableServer::POA_ptr thePOA, SMESH_Gen_i* myGen_i, CORBA::Long studyId ); @@ -63,21 +62,24 @@ public: virtual ~SMESH_Mesh_i(); // --- CORBA - void SetShape( GEOM::GEOM_Shape_ptr theShape ) + void SetShape( GEOM::GEOM_Object_ptr theShapeObject ) + throw (SALOME::SALOME_Exception); + + GEOM::GEOM_Object_ptr GetShapeToMesh() throw (SALOME::SALOME_Exception); - SMESH::Hypothesis_Status AddHypothesis(GEOM::GEOM_Shape_ptr aSubShape, + SMESH::Hypothesis_Status AddHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject, SMESH::SMESH_Hypothesis_ptr anHyp) throw (SALOME::SALOME_Exception); - SMESH::Hypothesis_Status RemoveHypothesis(GEOM::GEOM_Shape_ptr aSubShape, + SMESH::Hypothesis_Status RemoveHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject, SMESH::SMESH_Hypothesis_ptr anHyp) throw (SALOME::SALOME_Exception); - SMESH::ListOfHypothesis* GetHypothesisList(GEOM::GEOM_Shape_ptr aSubShape) + SMESH::ListOfHypothesis* GetHypothesisList(GEOM::GEOM_Object_ptr aSubShapeObject) throw (SALOME::SALOME_Exception); - SMESH::SMESH_subMesh_ptr GetSubMesh(GEOM::GEOM_Shape_ptr aSubShape, const char* theName) + SMESH::SMESH_subMesh_ptr GetSubMesh(GEOM::GEOM_Object_ptr aSubShapeObject, const char* theName) throw (SALOME::SALOME_Exception); void RemoveSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh ) @@ -86,7 +88,30 @@ public: SMESH::SMESH_Group_ptr CreateGroup( SMESH::ElementType theElemType, const char* theName ) throw (SALOME::SALOME_Exception); - void RemoveGroup( SMESH::SMESH_Group_ptr theGroup ) + SMESH::SMESH_GroupOnGeom_ptr CreateGroupFromGEOM(SMESH::ElementType theElemType, + const char* theName, + GEOM::GEOM_Object_ptr theGeomObj ) + throw (SALOME::SALOME_Exception); + + void RemoveGroup( SMESH::SMESH_GroupBase_ptr theGroup ) + throw (SALOME::SALOME_Exception); + + void RemoveGroupWithContents( SMESH::SMESH_GroupBase_ptr theGroup ) + throw (SALOME::SALOME_Exception); + + SMESH::SMESH_Group_ptr UnionGroups( SMESH::SMESH_GroupBase_ptr theGroup1, + SMESH::SMESH_GroupBase_ptr theGroup2, + 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 CutGroups( SMESH::SMESH_GroupBase_ptr theGroup1, + SMESH::SMESH_GroupBase_ptr theGroup2, + const char* theName ) throw (SALOME::SALOME_Exception); // SMESH::string_array* GetLog(CORBA::Boolean clearAfterGet) @@ -113,6 +138,12 @@ public: SMESH_Gen_i* GetGen() { return _gen_i; } + int ImportUNVFile( const char* theFileName ) + throw (SALOME::SALOME_Exception); + + int ImportSTLFile( const char* theFileName ) + throw (SALOME::SALOME_Exception); + /*! * consult DriverMED_R_SMESHDS_Mesh::ReadStatus for returned value */ @@ -125,6 +156,8 @@ public: throw (SALOME::SALOME_Exception); void ExportUNV( const char* file ) throw (SALOME::SALOME_Exception); + void ExportSTL( const char* file, const bool isascii ) + throw (SALOME::SALOME_Exception); SALOME_MED::MESH_ptr GetMEDMesh() throw (SALOME::SALOME_Exception); @@ -166,24 +199,33 @@ public: // Internal methods not available through CORBA // They are called by corresponding interface methods - SMESH_Hypothesis::Hypothesis_Status addHypothesis(GEOM::GEOM_Shape_ptr aSubShape, + SMESH_Hypothesis::Hypothesis_Status addHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject, SMESH::SMESH_Hypothesis_ptr anHyp); - SMESH_Hypothesis::Hypothesis_Status removeHypothesis(GEOM::GEOM_Shape_ptr aSubShape, + SMESH_Hypothesis::Hypothesis_Status removeHypothesis(GEOM::GEOM_Object_ptr aSubShapeObject, SMESH::SMESH_Hypothesis_ptr anHyp); - bool setShape( GEOM::GEOM_Shape_ptr theShape ); - int importMEDFile( const char* theFileName, const char* theMeshName ); - SMESH::SMESH_subMesh_ptr createSubMesh( GEOM::GEOM_Shape_ptr theSubShape ); + SMESH::SMESH_subMesh_ptr createSubMesh( GEOM::GEOM_Object_ptr theSubShapeObject ); - void removeSubMesh( SMESH::SMESH_subMesh_ptr theSubMesh, GEOM::GEOM_Shape_ptr theSubShape ); + void removeSubMesh(SMESH::SMESH_subMesh_ptr theSubMesh, + GEOM::GEOM_Object_ptr theSubShapeObject ); - SMESH::SMESH_Group_ptr createGroup( SMESH::ElementType theElemType, const char* theName ); + SMESH::SMESH_GroupBase_ptr createGroup(SMESH::ElementType theElemType, + const char* theName, + const TopoDS_Shape& theShape = TopoDS_Shape()); void removeGroup( const int theId ); + SMESH::SMESH_subMesh_ptr getSubMesh(int shapeID); + // return an existing subMesh object for the shapeID. shapeID == submeshID. + + const map& getGroups() { return _mapGroups; } + // return an existing group object. + + virtual SMESH::long_array* GetIDs(); + map _mapSubMesh_i; //NRI map _mapSubMesh; //NRI @@ -194,7 +236,7 @@ private: int _id; // id given by creator (unique within the creator instance) int _studyId; map _mapSubMeshIor; - map _mapGroups; + map _mapGroups; map _mapHypo; }; diff --git a/src/SMESH_I/SMESH_Pattern_i.cxx b/src/SMESH_I/SMESH_Pattern_i.cxx new file mode 100644 index 000000000..206d497ba --- /dev/null +++ b/src/SMESH_I/SMESH_Pattern_i.cxx @@ -0,0 +1,359 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESH_Pattern_i.cxx +// Created : Fri Aug 20 16:15:49 2004 +// Author : Edward AGAPOV (eap) +// $Header: + +#include "SMESH_Pattern_i.hxx" + +#include "GEOM_Client.hxx" +#include "SMESH_Gen_i.hxx" +#include "SMESH_Mesh.hxx" +#include "SMESH_Mesh_i.hxx" + +#include +#include +#include + +#include + +//============================================================================= +/*! + * SMESH_Gen_i::GetPattern + * + * Create pattern mapper + */ +//============================================================================= + +SMESH::SMESH_Pattern_ptr SMESH_Gen_i::GetPattern() +{ + SMESH_Pattern_i* i = new SMESH_Pattern_i( this ); + SMESH::SMESH_Pattern_var anObj = i->_this(); + return anObj._retn(); +} + +//======================================================================= +//function : SMESH_Pattern_i +//purpose : +//======================================================================= + +SMESH_Pattern_i::SMESH_Pattern_i( SMESH_Gen_i* theGen_i ): + myGen( theGen_i ) +{ +} + +//======================================================================= +//function : getShape +//purpose : +//======================================================================= + +TopoDS_Shape SMESH_Pattern_i::getShape( GEOM::GEOM_Object_ptr & theGeomObject ) +{ + return myGen->GetShapeReader()->GetShape( SMESH_Gen_i::GetGeomEngine(), theGeomObject ); +} + +//======================================================================= +//function : getMesh +//purpose : +//======================================================================= + +::SMESH_Mesh* SMESH_Pattern_i::getMesh( SMESH::SMESH_Mesh_ptr & theMesh ) +{ + SMESH_Mesh_i* anImplPtr = + dynamic_cast( SMESH_Gen_i::GetServant( theMesh ).in() ); + if ( anImplPtr ) + return & anImplPtr->GetImpl(); + + return 0; +} + +//======================================================================= +//function : LoadFromFile +//purpose : +//======================================================================= + +CORBA::Boolean SMESH_Pattern_i::LoadFromFile(const char* theFileContents) +{ + return myPattern.Load( theFileContents ); +} + +//======================================================================= +//function : LoadFromFace +//purpose : +//======================================================================= + +CORBA::Boolean SMESH_Pattern_i::LoadFromFace(SMESH::SMESH_Mesh_ptr theMesh, + GEOM::GEOM_Object_ptr theFace, + CORBA::Boolean theProject) +{ + if ( theMesh->_is_nil() || theFace->_is_nil() ) + return false; + + ::SMESH_Mesh* aMesh = getMesh( theMesh ); + if ( !aMesh ) + return false; + + TopoDS_Face aFace = TopoDS::Face( getShape( theFace )); + if ( aFace.IsNull() ) + return false; + + return myPattern.Load( aMesh, aFace, theProject ); +} + +//======================================================================= +//function : LoadFrom3DBlock +//purpose : +//======================================================================= + +CORBA::Boolean SMESH_Pattern_i::LoadFrom3DBlock(SMESH::SMESH_Mesh_ptr theMesh, + GEOM::GEOM_Object_ptr theBlock) +{ + if ( theMesh->_is_nil() || theBlock->_is_nil() ) + return false; + + ::SMESH_Mesh* aMesh = getMesh( theMesh ); + if ( !aMesh ) + return false; + + TopoDS_Shape aShape = getShape( theBlock ); + if ( aShape.IsNull()) + return false; + + TopExp_Explorer exp ( aShape, TopAbs_SHELL ); + if ( !exp.More() ) + return false; + + return myPattern.Load( aMesh, TopoDS::Shell( exp.Current() )); +} + +//======================================================================= +//function : ApplyToFace +//purpose : +//======================================================================= + +SMESH::point_array* SMESH_Pattern_i::ApplyToFace(GEOM::GEOM_Object_ptr theFace, + GEOM::GEOM_Object_ptr theVertexOnKeyPoint1, + CORBA::Boolean theReverse) +{ + SMESH::point_array_var points = new SMESH::point_array; + list xyzList; + + TopoDS_Shape F = getShape( theFace ); + TopoDS_Shape V = getShape( theVertexOnKeyPoint1 ); + + if (!F.IsNull() && F.ShapeType() == TopAbs_FACE && + !V.IsNull() && V.ShapeType() == TopAbs_VERTEX + && + myPattern.Apply( TopoDS::Face( F ), TopoDS::Vertex( V ), theReverse ) && + myPattern.GetMappedPoints( xyzList )) + { + points->length( xyzList.size() ); + list::iterator xyzIt = xyzList.begin(); + for ( int i = 0; xyzIt != xyzList.end(); xyzIt++ ) { + SMESH::PointStruct & p = points[ i++ ]; + (*xyzIt)->Coord( p.x, p.y, p.z ); + } + } + + return points._retn(); +} + +//======================================================================= +//function : ApplyTo3DBlock +//purpose : +//======================================================================= + +SMESH::point_array* SMESH_Pattern_i::ApplyTo3DBlock(GEOM::GEOM_Object_ptr theBlock, + GEOM::GEOM_Object_ptr theVertex000, + GEOM::GEOM_Object_ptr theVertex001) +{ + SMESH::point_array_var points = new SMESH::point_array; + list xyzList; + + TopExp_Explorer exp( getShape( theBlock ), TopAbs_SHELL ); + TopoDS_Shape V000 = getShape( theVertex000 ); + TopoDS_Shape V001 = getShape( theVertex001 ); + + if (exp.More() && + !V000.IsNull() && V000.ShapeType() == TopAbs_VERTEX && + !V001.IsNull() && V001.ShapeType() == TopAbs_VERTEX + && + myPattern.Apply(TopoDS::Shell( exp.Current() ), + TopoDS::Vertex( V000 ), + TopoDS::Vertex( V001 )) && + myPattern.GetMappedPoints( xyzList )) + { + points->length( xyzList.size() ); + list::iterator xyzIt = xyzList.begin(); + for ( int i = 0; xyzIt != xyzList.end(); xyzIt++ ) { + SMESH::PointStruct & p = points[ i++ ]; + (*xyzIt)->Coord( p.x, p.y, p.z ); + } + } + + return points._retn(); +} + +//======================================================================= +//function : MakeMesh +//purpose : +//======================================================================= + +CORBA::Boolean SMESH_Pattern_i::MakeMesh(SMESH::SMESH_Mesh_ptr theMesh) +{ + ::SMESH_Mesh* aMesh = getMesh( theMesh ); + if ( !aMesh ) + return false; + + return myPattern.MakeMesh( aMesh ); +} + +//======================================================================= +//function : GetString +//purpose : +//======================================================================= + +char* SMESH_Pattern_i::GetString() +{ + ostringstream os; + myPattern.Save( os ); + + return CORBA::string_dup( os.str().c_str() ); +} + +//======================================================================= +//function : Is2D +//purpose : +//======================================================================= + +CORBA::Boolean SMESH_Pattern_i::Is2D() +{ + return myPattern.Is2D(); +} + +//======================================================================= +//function : GetPoints +//purpose : +//======================================================================= + +SMESH::point_array* SMESH_Pattern_i::GetPoints() +{ + SMESH::point_array_var points = new SMESH::point_array; + list xyzList; + + if (myPattern.GetPoints( xyzList )) + { + points->length( xyzList.size() ); + list::iterator xyzIt = xyzList.begin(); + for ( int i = 0; xyzIt != xyzList.end(); xyzIt++ ) { + SMESH::PointStruct & p = points[ i++ ]; + (*xyzIt)->Coord( p.x, p.y, p.z ); + } + } + + return points._retn(); +} + +//======================================================================= +//function : GetKeyPoints +//purpose : +//======================================================================= + +SMESH::long_array* SMESH_Pattern_i::GetKeyPoints() +{ + SMESH::long_array_var ids = new SMESH::long_array; + if ( myPattern.IsLoaded() ) { + const list< int > & idList = myPattern.GetKeyPointIDs(); + ids->length( idList.size() ); + list< int >::const_iterator iIt = idList.begin(); + for ( int i = 0; iIt != idList.end(); iIt++, i++ ) + ids[ i ] = *iIt; + } + return ids._retn(); +} + +//======================================================================= +//function : GetElementPoints +//purpose : +//======================================================================= + +SMESH::array_of_long_array* SMESH_Pattern_i::GetElementPoints() +{ + SMESH::array_of_long_array_var arrayOfArray = new SMESH::array_of_long_array; + + const list< list< int > >& listOfIdList = myPattern.GetElementPointIDs(); + arrayOfArray->length( listOfIdList.size() ); + list< list< int > >::const_iterator llIt = listOfIdList.begin(); + for ( int i = 0 ; llIt != listOfIdList.end(); llIt++, i++ ) + { + const list< int > & idList = (*llIt); + SMESH::long_array& ids = arrayOfArray[ i ]; + ids.length( idList.size() ); + list< int >::const_iterator iIt = idList.begin(); + for ( int j = 0; iIt != idList.end(); iIt++, j++ ) + ids[ j ] = *iIt; + } + return arrayOfArray._retn(); +} + +//======================================================================= +//function : GetErrorCode +//purpose : +//======================================================================= + +#define RETCASE(enm) case ::SMESH_Pattern::enm: return SMESH::SMESH_Pattern::enm; + +SMESH::SMESH_Pattern::ErrorCode SMESH_Pattern_i::GetErrorCode() +{ + switch ( myPattern.GetErrorCode() ) { + RETCASE( ERR_OK ); + RETCASE( ERR_READ_NB_POINTS ); + RETCASE( ERR_READ_POINT_COORDS ); + RETCASE( ERR_READ_TOO_FEW_POINTS ); + RETCASE( ERR_READ_3D_COORD ); + RETCASE( ERR_READ_NO_KEYPOINT ); + RETCASE( ERR_READ_BAD_INDEX ); + RETCASE( ERR_READ_ELEM_POINTS ); + RETCASE( ERR_READ_NO_ELEMS ); + RETCASE( ERR_READ_BAD_KEY_POINT ); + RETCASE( ERR_SAVE_NOT_LOADED ); + RETCASE( ERR_LOAD_EMPTY_SUBMESH ); + RETCASE( ERR_LOADF_NARROW_FACE ); + RETCASE( ERR_LOADF_CLOSED_FACE ); + RETCASE( ERR_LOADV_BAD_SHAPE ); + RETCASE( ERR_LOADV_COMPUTE_PARAMS ); + RETCASE( ERR_APPL_NOT_LOADED ); + RETCASE( ERR_APPL_BAD_DIMENTION ); + RETCASE( ERR_APPL_BAD_NB_VERTICES ); + RETCASE( ERR_APPLF_BAD_TOPOLOGY ); + RETCASE( ERR_APPLF_BAD_VERTEX ); + RETCASE( ERR_APPLF_INTERNAL_EEROR ); + RETCASE( ERR_APPLV_BAD_SHAPE ); + RETCASE( ERR_MAKEM_NOT_COMPUTED ); + default:; + }; + return SMESH::SMESH_Pattern::ERR_OK; +} + diff --git a/src/SMESH_I/SMESH_Pattern_i.hxx b/src/SMESH_I/SMESH_Pattern_i.hxx new file mode 100644 index 000000000..70520d877 --- /dev/null +++ b/src/SMESH_I/SMESH_Pattern_i.hxx @@ -0,0 +1,93 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : SMESH_Pattern_i.hxx +// Created : Fri Aug 20 16:03:15 2004 +// Author : Edward AGAPOV (eap) + +// $Header: + +#ifndef SMESH_Pattern_I_HeaderFile +#define SMESH_Pattern_I_HeaderFile + +#include "SALOMEconfig.h" +#include CORBA_SERVER_HEADER(SMESH_Pattern) +#include CORBA_SERVER_HEADER(SMESH_Mesh) +#include CORBA_CLIENT_HEADER(GEOM_Gen) + +#include +#include "SMESH_Pattern.hxx" + +class SMESH_Gen_i; +class SMESH_Mesh; + +class SMESH_Pattern_i: + public virtual POA_SMESH::SMESH_Pattern +{ + public: + + SMESH_Pattern_i (SMESH_Gen_i* theGen_i); + + CORBA::Boolean LoadFromFile(const char* theFileContents); + + CORBA::Boolean LoadFromFace(SMESH::SMESH_Mesh_ptr theMesh, + GEOM::GEOM_Object_ptr theFace, + CORBA::Boolean theProject); + + CORBA::Boolean LoadFrom3DBlock(SMESH::SMESH_Mesh_ptr theMesh, + GEOM::GEOM_Object_ptr theBlock); + + SMESH::point_array* ApplyToFace(GEOM::GEOM_Object_ptr theFace, + GEOM::GEOM_Object_ptr theVertexOnKeyPoint1, + CORBA::Boolean theReverse); + + SMESH::point_array* ApplyTo3DBlock(GEOM::GEOM_Object_ptr theBlock, + GEOM::GEOM_Object_ptr theVertex000, + GEOM::GEOM_Object_ptr theVertex001); + + CORBA::Boolean MakeMesh(SMESH::SMESH_Mesh_ptr theMesh); + + SMESH::SMESH_Pattern::ErrorCode GetErrorCode(); + + char* GetString(); + + CORBA::Boolean Is2D(); + + SMESH::point_array* GetPoints(); + + SMESH::long_array* GetKeyPoints(); + + SMESH::array_of_long_array* GetElementPoints(); + + + private: + + TopoDS_Shape getShape( GEOM::GEOM_Object_ptr & theGeomObject ); + + ::SMESH_Mesh* getMesh( SMESH::SMESH_Mesh_ptr & theMesh ); + + ::SMESH_Pattern myPattern; + + SMESH_Gen_i* myGen; +}; +#endif diff --git a/src/SMESH_I/SMESH_subMesh_i.cxx b/src/SMESH_I/SMESH_subMesh_i.cxx index 8c6563ffd..3ea9c4c0d 100644 --- a/src/SMESH_I/SMESH_subMesh_i.cxx +++ b/src/SMESH_I/SMESH_subMesh_i.cxx @@ -26,7 +26,6 @@ // Module : SMESH // $Header$ -using namespace std; using namespace std; #include "SMESH_subMesh_i.hxx" #include "SMESH_Gen_i.hxx" @@ -108,7 +107,7 @@ CORBA::Long SMESH_subMesh_i::GetNumberOfElements() */ //============================================================================= -CORBA::Long SMESH_subMesh_i::GetNumberOfNodes() +CORBA::Long SMESH_subMesh_i::GetNumberOfNodes(CORBA::Boolean all) throw (SALOME::SALOME_Exception) { Unexpect aCatch(SALOME_SalomeException); @@ -120,6 +119,18 @@ CORBA::Long SMESH_subMesh_i::GetNumberOfNodes() if ( aSubMeshDS == NULL ) return 0; + if ( all ) { // all nodes of submesh elements + set nodeIds; + SMDS_ElemIteratorPtr eIt = aSubMeshDS->GetElements(); + while ( eIt->more() ) { + const SMDS_MeshElement* anElem = eIt->next(); + SMDS_ElemIteratorPtr nIt = anElem->nodesIterator(); + while ( nIt->more() ) + nodeIds.insert( nIt->next()->GetID() ); + } + return nodeIds.size(); + } + return aSubMeshDS->NbNodes(); } @@ -172,20 +183,37 @@ SMESH::long_array* SMESH_subMesh_i::GetElementsByType( SMESH::ElementType theEle if ( aSubMeshDS == NULL ) return aResult._retn(); - int i = 0; + // No sense in returning ids of elements along with ids of nodes: + // when theElemType == SMESH::ALL, return node ids only if + // there are no elements + bool retNodes = (theElemType == SMESH::NODE || + (theElemType == SMESH::ALL && aSubMeshDS->NbElements() == 0)); + + // PAL5440, return all nodes belonging to elements of submesh + set nodeIds; + if ( retNodes ) { + SMDS_ElemIteratorPtr eIt = aSubMeshDS->GetElements(); + while ( eIt->more() ) { + const SMDS_MeshElement* anElem = eIt->next(); + SMDS_ElemIteratorPtr nIt = anElem->nodesIterator(); + while ( nIt->more() ) + nodeIds.insert( nIt->next()->GetID() ); + } + } + if ( theElemType == SMESH::ALL ) - aResult->length( aSubMeshDS->NbElements() + aSubMeshDS->NbNodes() ); + aResult->length( aSubMeshDS->NbElements() + nodeIds.size()); else if ( theElemType == SMESH::NODE ) - aResult->length( aSubMeshDS->NbNodes() ); + aResult->length( nodeIds.size() ); else aResult->length( aSubMeshDS->NbElements() ); - int n = aResult->length(); + int i = 0, n = aResult->length(); - if ( theElemType == SMESH::ALL || theElemType == SMESH::NODE ) { - SMDS_NodeIteratorPtr anIt = aSubMeshDS->GetNodes(); - while ( i < n && anIt->more() ) - aResult[i++] = anIt->next()->GetID(); + if ( retNodes && !nodeIds.empty() ) { + set::iterator idIt = nodeIds.begin(); + for ( ; i < n && idIt != nodeIds.end() ; i++, idIt++ ) + aResult[i] = *idIt; } if ( theElemType == SMESH::ALL || theElemType != SMESH::NODE ) { @@ -256,6 +284,29 @@ CORBA::Long SMESH_subMesh_i::GetId() return _localId; } +//======================================================================= +//function : GetSubShape +//purpose : +//======================================================================= + +GEOM::GEOM_Object_ptr SMESH_subMesh_i::GetSubShape() + throw (SALOME::SALOME_Exception) +{ + Unexpect aCatch(SALOME_SalomeException); + GEOM::GEOM_Object_var aShapeObj; + try { + if ( _mesh_i->_mapSubMesh.find( _localId ) != _mesh_i->_mapSubMesh.end()) { + TopoDS_Shape S = _mesh_i->_mapSubMesh[ _localId ]->GetSubShape(); + if ( !S.IsNull() ) + aShapeObj = _gen_i->ShapeToGeomObject( S ); + } + } + catch(SALOME_Exception & S_ex) { + THROW_SALOME_CORBA_EXCEPTION(S_ex.what(), SALOME::BAD_PARAM); + } + return aShapeObj._retn(); +} + //============================================================================= /*! * @@ -274,4 +325,17 @@ SALOME_MED::FAMILY_ptr SMESH_subMesh_i::GetFamily() if ( families[i]->getIdentifier() == ( _localId ) ) return families[i]; } + + return SALOME_MED::FAMILY::_nil(); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +SMESH::long_array* SMESH_subMesh_i::GetIDs() +{ + SMESH::long_array_var aResult = GetElementsId(); + return aResult._retn(); } diff --git a/src/SMESH_I/SMESH_subMesh_i.hxx b/src/SMESH_I/SMESH_subMesh_i.hxx index 9b456af4b..acbcd6399 100644 --- a/src/SMESH_I/SMESH_subMesh_i.hxx +++ b/src/SMESH_I/SMESH_subMesh_i.hxx @@ -33,7 +33,6 @@ #include CORBA_SERVER_HEADER(SMESH_Mesh) #include CORBA_SERVER_HEADER(SMESH_Hypothesis) #include CORBA_CLIENT_HEADER(GEOM_Gen) -#include CORBA_CLIENT_HEADER(GEOM_Shape) #include CORBA_CLIENT_HEADER(MED) #include "SALOME_GenericObj_i.hh" @@ -56,7 +55,7 @@ public: CORBA::Long GetNumberOfElements() throw (SALOME::SALOME_Exception); - CORBA::Long GetNumberOfNodes() + CORBA::Long GetNumberOfNodes( CORBA::Boolean all ) throw (SALOME::SALOME_Exception); SMESH::long_array* GetElementsId() @@ -71,11 +70,16 @@ public: SMESH::SMESH_Mesh_ptr GetFather() throw (SALOME::SALOME_Exception); + GEOM::GEOM_Object_ptr GetSubShape() + throw (SALOME::SALOME_Exception); + CORBA::Long GetId(); SALOME_MED::FAMILY_ptr GetFamily() throw (SALOME::SALOME_Exception); + virtual SMESH::long_array* GetIDs(); + SMESH_Mesh_i* _mesh_i; //NRI protected: diff --git a/src/SMESH_I/SMESH_test.py b/src/SMESH_I/SMESH_test.py index e823f9028..0cc3a94bf 100644 --- a/src/SMESH_I/SMESH_test.py +++ b/src/SMESH_I/SMESH_test.py @@ -1,151 +1,127 @@ # 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org # # # # File : SMESH_test.py # Module : SMESH -import SMESH -import StdMeshers - -import smeshpy import salome -from salome import sg -import math -#import SMESH_BasicHypothesis_idl - import geompy +import smeshpy -geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") -myBuilder = salome.myStudy.NewBuilder() -from geompy import gg - -ShapeTypeCompSolid = 1 -ShapeTypeSolid = 2 -ShapeTypeShell = 3 -ShapeTypeFace = 4 -ShapeTypeWire = 5 -ShapeTypeEdge = 6 -ShapeTypeVertex = 7 +import SMESH +import StdMeshers # ---- define a box box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) -idb = geompy.addToStudy(box,"box") +idb = geompy.addToStudy(box, "box") # ---- add first face of box in study -subShapeList=geompy.SubShapeAll(box,ShapeTypeFace) -face=subShapeList[0] -name = geompy.SubShapeName( face._get_Name(), box._get_Name() ) -print name -idf=geompy.addToStudyInFather(box,face,name) +subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) +face = subShapeList[0] +name = geompy.SubShapeName(face, box) +idf = geompy.addToStudyInFather(box, face, name) # ---- add shell from box in study -subShellList=geompy.SubShapeAll(box,ShapeTypeShell) +subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"]) shell = subShellList[0] -name = geompy.SubShapeName( shell._get_Name(), box._get_Name() ) -print name -ids=geompy.addToStudyInFather(box,shell,name) +name = geompy.SubShapeName(shell, box) +ids = geompy.addToStudyInFather(box, shell, name) # ---- add first edge of face in study -edgeList = geompy.SubShapeAll(face,ShapeTypeEdge) -edge=edgeList[0]; -name = geompy.SubShapeName( edge._get_Name(), face._get_Name() ) -print name -ide=geompy.addToStudyInFather(face,edge,name) +edgeList = geompy.SubShapeAll(face, geompy.ShapeType["EDGE"]) +edge = edgeList[0]; +name = geompy.SubShapeName(edge, face) +ide = geompy.addToStudyInFather(face, edge, name) # ---- launch SMESH, init a Mesh with the box -gen=smeshpy.smeshpy() -mesh=gen.CreateMesh(idb) -# ---- create Hypothesis +gen = smeshpy.smeshpy() +mesh = gen.CreateMesh(idb) print "-------------------------- create Hypothesis" + print "-------------------------- LocalLength" -hyp1=gen.CreateHypothesis("LocalLength","libStdMeshersEngine.so") -print hyp1.GetName() -print hyp1.GetId() -hypo1 = hyp1._narrow(StdMeshers.StdMeshers_LocalLength) + +hypo1 = gen.CreateHypothesis("LocalLength", "libStdMeshersEngine.so") +print hypo1.GetName() +print hypo1.GetId() print hypo1.GetLength() hypo1.SetLength(100) print hypo1.GetLength() print "-------------------------- bidon" -hyp3=gen.CreateHypothesis("bidon","") + +hyp3 = gen.CreateHypothesis("bidon", "") print "-------------------------- NumberOfSegments" -hyp3=gen.CreateHypothesis("NumberOfSegments","libStdMeshersEngine.so") -hypo3=hyp3._narrow(StdMeshers.StdMeshers_NumberOfSegments) + +hypo3 = gen.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") hypo3.SetNumberOfSegments(7) print hypo3.GetName() print hypo3.GetNumberOfSegments() print hypo3.GetId() print "-------------------------- MaxElementArea" -hyp4=gen.CreateHypothesis("MaxElementArea","libStdMeshersEngine.so") -hypo4=hyp4._narrow(StdMeshers.StdMeshers_MaxElementArea) + +hypo4 = gen.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so") hypo4.SetMaxElementArea(5000) print hypo4.GetName() print hypo4.GetMaxElementArea() print hypo4.GetId() print "-------------------------- Regular_1D" -alg1=gen.CreateHypothesis("Regular_1D","libStdMeshersEngine.so") -print alg1.GetName() -print alg1.GetId() -algo1=alg1._narrow(SMESH.SMESH_Algo) -listHyp=algo1.GetCompatibleHypothesis() + +algo_1 = gen.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so") +print algo_1.GetName() +print algo_1.GetId() +listHyp = algo_1.GetCompatibleHypothesis() for hyp in listHyp: print hyp - -algo_1=alg1._narrow(StdMeshers.StdMeshers_Regular_1D) print algo_1.GetId() print "-------------------------- MEFISTO_2D" -alg2=gen.CreateHypothesis("MEFISTO_2D","libStdMeshersEngine.so") -print alg2.GetName() -print alg2.GetId() -algo2=alg2._narrow(SMESH.SMESH_Algo) -listHyp=algo2.GetCompatibleHypothesis() + +algo_2 = gen.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so") +print algo_2.GetName() +print algo_2.GetId() +listHyp = algo_2.GetCompatibleHypothesis() for hyp in listHyp: print hyp -algo_2=alg2._narrow(StdMeshers.StdMeshers_MEFISTO_2D) print algo_2.GetId() -# ---- add hypothesis to edge - print "-------------------------- add hypothesis to edge" -edge=salome.IDToObject(ide) -submesh=mesh.GetElementsOnShape(edge) -ret=mesh.AddHypothesis(edge,algo_1) + +edge = salome.IDToObject(ide) +submesh = mesh.GetSubMesh(edge, "SubMeshEdge") +ret = mesh.AddHypothesis(edge,algo_1) print ret -ret=mesh.AddHypothesis(edge,hypo1) +ret = mesh.AddHypothesis(edge,hypo1) print ret -# ---- compute edge - ##print "-------------------------- compute edge" ##ret=gen.Compute(mesh,ide) ##print ret @@ -153,26 +129,24 @@ print ret ##for a in log: ## print a -# ---- add hypothesis to box - print "-------------------------- add hypothesis to box" -box=salome.IDToObject(idb) -submesh=mesh.GetElementsOnShape(box) -ret=mesh.AddHypothesis(box,algo_1) + +box = salome.IDToObject(idb) +submesh = mesh.GetSubMesh(box, "SubMeshBox") +ret = mesh.AddHypothesis(box,algo_1) print ret -ret=mesh.AddHypothesis(box,hypo1) +ret = mesh.AddHypothesis(box,hypo1) print ret -ret=mesh.AddHypothesis(box,algo_2) +ret = mesh.AddHypothesis(box,algo_2) print ret -ret=mesh.AddHypothesis(box,hypo4) +ret = mesh.AddHypothesis(box,hypo4) print ret -# ---- compute face +print "-------------------------- compute" -print "-------------------------- compute face" -ret=gen.Compute(mesh,idf) +ret = gen.Compute(mesh,idf) print ret -log=mesh.GetLog(1); +log = mesh.GetLog(1); for a in log: print "-------" ii = 0 @@ -210,8 +184,6 @@ for a in log: ii = ii+1 print "AddTriangle %i - %i %i %i" % (ind, i1, i2, i3) -# ---- compute box - ##print "-------------------------- compute box" ##ret=gen.Compute(mesh,idb) ##print ret @@ -226,4 +198,3 @@ for a in log: ##print ret ##ret=gen.Compute(mesh,ids) ##print ret - diff --git a/src/SMESH_SWIG/Makefile.in b/src/SMESH_SWIG/Makefile.in index 343100a93..bf8573669 100644 --- a/src/SMESH_SWIG/Makefile.in +++ b/src/SMESH_SWIG/Makefile.in @@ -39,6 +39,22 @@ LIB_SRC = SWIG_DEF = libSMESH_Swig.i EXPORT_PYSCRIPTS = libSMESH_Swig.py \ + meshpy.py \ + batchmode_smesh.py \ + batchmode_mefisto.py \ + cube2pyGibi.py \ + cube2geometry.py \ + cube2partition.py \ + grid4pyGibi.py \ + grid4partition.py \ + grid3partition.py \ + grid17partition.py \ + hole1geometry.py \ + hole1partition.py \ + hole1pyGibi.py \ + hole2pyGibi.py \ + cyl2geometry.py \ + cyl2complementary.py \ SMESH_test0.py\ SMESH_test1.py \ SMESH_test2.py \ @@ -46,23 +62,23 @@ EXPORT_PYSCRIPTS = libSMESH_Swig.py \ SMESH_test4.py \ SMESH_mechanic.py \ SMESH_mechanic_tetra.py \ + SMESH_mechanic_editor.py \ SMESH_fixation.py \ SMESH_fixation_hexa.py \ SMESH_fixation_tetra.py \ - batchmode_smesh.py \ SMESH_box_tetra.py \ SMESH_box2_tetra.py \ SMESH_box3_tetra.py \ SMESH_flight_skin.py \ SMESH_Partition1_tetra.py\ - batchmode_mefisto.py \ SMESH_controls.py \ - SMESH_freebord.py + SMESH_freebord.py \ + SMESH_blocks.py \ + SMESH_GroupFromGeom.py LIB_CLIENT_IDL = SALOMEDS.idl \ SALOME_Exception.idl \ GEOM_Gen.idl \ - GEOM_Shape.idl \ SMESH_Gen.idl \ SMESH_Mesh.idl \ SMESH_Hypothesis.idl \ @@ -71,11 +87,12 @@ LIB_CLIENT_IDL = SALOMEDS.idl \ SALOME_ModuleCatalog.idl \ SALOME_Component.idl \ SALOME_GenericObj.idl \ - MED.idl + MED.idl \ + SALOME_Comm.idl EXPORT_SHAREDPYSCRIPTS=SMESH_shared_modules.py -CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) -DHAVE_CONFIG_H +CPPFLAGS+=$(QT_INCLUDES) $(PYTHON_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome -DHAVE_CONFIG_H LIBS+= $(PYTHON_LIBS) LDFLAGS+= -lSMESHGUI -L${KERNEL_ROOT_DIR}/lib/salome -lSalomeGenericObj diff --git a/src/SMESH_SWIG/SMESH_BelongToGeom.py b/src/SMESH_SWIG/SMESH_BelongToGeom.py new file mode 100644 index 000000000..c4ee39dcd --- /dev/null +++ b/src/SMESH_SWIG/SMESH_BelongToGeom.py @@ -0,0 +1,28 @@ +import SMESH +from SMESH_test1 import * + +def CheckBelongToGeomFilter(theMeshGen, theMesh, theShape, theSubShape, theElemType): + import geompy + if theShape != theSubShape: + aName = str(theSubShape) + geompy.addToStudyInFather(theShape,theSubShape,aName) + + theMeshGen.Compute(theMesh,theShape) + + aFilterMgr = theMeshGen.CreateFilterManager() + aFilter = aFilterMgr.CreateFilter() + + aBelongToGeom = aFilterMgr.CreateBelongToGeom() + aBelongToGeom.SetGeom(theSubShape) + aBelongToGeom.SetElementType(theElemType) + + aFilter.SetPredicate(aBelongToGeom) + return aFilter.GetElementsId(theMesh) + +anElemType = SMESH.ALL; +print "anElemType =", anElemType +#anIds = CheckBelongToGeomFilter(smesh,mesh,box,subShapeList[1],SMESH.FACE) +anIds = CheckBelongToGeomFilter(smesh,mesh,box,box,SMESH.FACE) +print "anIds = ", anIds + +salome.sg.updateObjBrowser(1); diff --git a/src/SMESH_SWIG/SMESH_GroupFromGeom.py b/src/SMESH_SWIG/SMESH_GroupFromGeom.py new file mode 100644 index 000000000..3647c77d2 --- /dev/null +++ b/src/SMESH_SWIG/SMESH_GroupFromGeom.py @@ -0,0 +1,49 @@ +# 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : SMESH_GroupFromGeom.py +# Module : SMESH + +from SMESH_test1 import * +import SMESH + +# Compute the mesh created in SMESH_test1 + +smesh.Compute(mesh, box) + +# Create geometry groups on plane: +aGeomGroup1 = geompy.CreateGroup(face , geompy.ShapeType["FACE"]) +geompy.AddObject(aGeomGroup1, 1) + +aGeomGroup2 = geompy.CreateGroup(face , geompy.ShapeType["EDGE"]) + +geompy.AddObject(aGeomGroup2, 3) +geompy.AddObject(aGeomGroup2, 6) +geompy.AddObject(aGeomGroup2, 8) +geompy.AddObject(aGeomGroup2, 10) + +geompy.addToStudy(aGeomGroup1, "Group on Faces") +geompy.addToStudy(aGeomGroup2, "Group on Edges") + +aSmeshGroup1 = mesh.CreateGroupFromGEOM(SMESH.FACE, "SMESHGroup1", aGeomGroup1) +aSmeshGroup2 = mesh.CreateGroupFromGEOM(SMESH.EDGE, "SMESHGroup2", aGeomGroup2) + +salome.sg.updateObjBrowser(1); diff --git a/src/SMESH_SWIG/SMESH_Partition1_tetra.py b/src/SMESH_SWIG/SMESH_Partition1_tetra.py index fd72c8e18..e9bb55fa7 100644 --- a/src/SMESH_SWIG/SMESH_Partition1_tetra.py +++ b/src/SMESH_SWIG/SMESH_Partition1_tetra.py @@ -7,18 +7,16 @@ import salome import geompy +from math import sqrt import StdMeshers import NETGENPlugin -geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") - -geom.GetCurrentStudy(salome.myStudy._get_StudyId()) smesh.SetCurrentStudy(salome.myStudy) smeshgui = salome.ImportComponentGUI("SMESH") -smeshgui.Init(salome.myStudyId); +smeshgui.Init(salome.myStudyId) #--------------------------------------------------------------- @@ -31,7 +29,6 @@ cc_width = 0.11 # Epaisseur du complement de colisage # -- cc_radius = colis_radius + cc_width -from math import sqrt colis_center = sqrt(2.0)*colis_step/2 # -- @@ -43,101 +40,79 @@ boolean_section = 4 # -- -barier = geompy.MakeCylinder( - geom.MakePointStruct(0.,0.,0.), - geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)), - barier_radius, - barier_height) +p0 = geompy.MakeVertex(0.,0.,0.) +vz = geompy.MakeVectorDXDYDZ(0.,0.,1.) # -- -colis = geompy.MakeCylinder( - geom.MakePointStruct(0.,0.,0.), - geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)), - colis_radius, - barier_height) +barier = geompy.MakeCylinder(p0, vz, barier_radius, barier_height) -cc = geompy.MakeCylinder( - geom.MakePointStruct(0.,0.,0.), - geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)), - cc_radius, - barier_height) +# -- -colis_cc = geompy.MakeCompound( - [colis._get_Name(), cc._get_Name()]) +colis = geompy.MakeCylinder(p0, vz, colis_radius, barier_height) +cc = geompy.MakeCylinder(p0, vz, cc_radius, barier_height) -colis_cc = geompy.MakeTranslation( - colis_cc, colis_center, 0.0, 0.0) +colis_cc = geompy.MakeCompound([colis, cc]) +colis_cc = geompy.MakeTranslation(colis_cc, colis_center, 0.0, 0.0) -colis_cc_multi = geompy.MakeMultiRotation1D( - colis_cc, - geom.MakeDirection(geom.MakePointStruct(0.,0.,1.)), - geom.MakePointStruct(0.,0.,0.), - 4) +colis_cc_multi = geompy.MultiRotate1D(colis_cc, vz, 4) # -- -alveole = geompy.Partition( - [colis_cc_multi._get_Name(), barier._get_Name()]) - -ShapeTypeShell = 3 -ShapeTypeFace = 4 -ShapeTypeEdge = 6 +alveole = geompy.MakePartition([colis_cc_multi, barier]) print "Analysis of the geometry to mesh (right after the Partition) :" -subShellList=geompy.SubShapeAll(alveole,ShapeTypeShell) -subFaceList=geompy.SubShapeAll(alveole,ShapeTypeFace) -subEdgeList=geompy.SubShapeAll(alveole,ShapeTypeEdge) +subShellList = geompy.SubShapeAll(alveole, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(alveole, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(alveole, geompy.ShapeType["EDGE"]) -print "number of Shells in alveole : ",len(subShellList) -print "number of Faces in alveole : ",len(subFaceList) -print "number of Edges in alveole : ",len(subEdgeList) +print "number of Shells in alveole : ", len(subShellList) +print "number of Faces in alveole : ", len(subFaceList) +print "number of Edges in alveole : ", len(subEdgeList) -subshapes = geompy.SubShapeAll( alveole, geompy.ShapeType["SHAPE"] ) +subshapes = geompy.SubShapeAll(alveole, geompy.ShapeType["SHAPE"]) ## there are 9 subshapes -comp1 = geompy.MakeCompound( [ subshapes[0]._get_Name(), subshapes[1]._get_Name() ] ); -comp2 = geompy.MakeCompound( [ subshapes[2]._get_Name(), subshapes[3]._get_Name() ] ); -comp3 = geompy.MakeCompound( [ subshapes[4]._get_Name(), subshapes[5]._get_Name() ] ); -comp4 = geompy.MakeCompound( [ subshapes[6]._get_Name(), subshapes[7]._get_Name() ] ); +comp1 = geompy.MakeCompound( [ subshapes[0], subshapes[1] ] ) +comp2 = geompy.MakeCompound( [ subshapes[2], subshapes[3] ] ) +comp3 = geompy.MakeCompound( [ subshapes[4], subshapes[5] ] ) +comp4 = geompy.MakeCompound( [ subshapes[6], subshapes[7] ] ) -compIORs = [] -compIORs.append( comp1._get_Name() ); -compIORs.append( comp2._get_Name() ); -compIORs.append( comp3._get_Name() ); -compIORs.append( comp4._get_Name() ); -comp = geompy.MakeCompound( compIORs ); +compGOs = [] +compGOs.append( comp1 ) +compGOs.append( comp2 ) +compGOs.append( comp3 ) +compGOs.append( comp4 ) +comp = geompy.MakeCompound( compGOs ) -alveole = geompy.MakeCompound( [ comp._get_Name(), subshapes[8]._get_Name() ]); - -idalveole= geompy.addToStudy(alveole, "alveole") +alveole = geompy.MakeCompound( [ comp, subshapes[8] ]) + +idalveole = geompy.addToStudy(alveole, "alveole") print "Analysis of the geometry to mesh (right after the MakeCompound) :" -subShellList=geompy.SubShapeAll(alveole,ShapeTypeShell) -subFaceList=geompy.SubShapeAll(alveole,ShapeTypeFace) -subEdgeList=geompy.SubShapeAll(alveole,ShapeTypeEdge) +subShellList = geompy.SubShapeAll(alveole, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(alveole, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(alveole, geompy.ShapeType["EDGE"]) -print "number of Shells in alveole : ",len(subShellList) -print "number of Faces in alveole : ",len(subFaceList) -print "number of Edges in alveole : ",len(subEdgeList) +print "number of Shells in alveole : ", len(subShellList) +print "number of Faces in alveole : ", len(subFaceList) +print "number of Edges in alveole : ", len(subEdgeList) -status=geompy.CheckShape(alveole) +status = geompy.CheckShape(alveole) print " check status ", status # ---- launch SMESH -# ---- create Hypothesis - print "-------------------------- create Hypothesis (In this case global hypothesis are used)" print "-------------------------- NumberOfSegments" numberOfSegments = 10 -hypNbSeg=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") +hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") hypNbSeg.SetNumberOfSegments(numberOfSegments) print hypNbSeg.GetName() print hypNbSeg.GetId() @@ -149,7 +124,7 @@ print "-------------------------- MaxElementArea" maxElementArea = 0.1 -hypArea=smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so") +hypArea = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so") hypArea.SetMaxElementArea(maxElementArea) print hypArea.GetName() print hypArea.GetId() @@ -161,7 +136,7 @@ print "-------------------------- MaxElementVolume" maxElementVolume = 0.5 -hypVolume=smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so") +hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so") hypVolume.SetMaxElementVolume(maxElementVolume) print hypVolume.GetName() print hypVolume.GetId() @@ -169,8 +144,6 @@ print hypVolume.GetMaxElementVolume() smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_0.5") -# ---- create Algorithms - print "-------------------------- create Algorithms" print "-------------------------- Regular_1D" @@ -180,18 +153,18 @@ smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation") print "-------------------------- MEFISTO_2D" -mefisto2D=smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so") +mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so") smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D") print "-------------------------- NETGEN_3D" -netgen3D=smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so") +netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so") smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D") # ---- init a Mesh with the alveole shape_mesh = salome.IDToObject( idalveole ) -mesh=smesh.CreateMesh(shape_mesh) +mesh = smesh.CreateMesh(shape_mesh) smeshgui.SetName(salome.ObjectToID(mesh), "MeshAlveole") # ---- add hypothesis to alveole @@ -208,20 +181,20 @@ mesh.AddHypothesis(shape_mesh,netgen3D) mesh.AddHypothesis(shape_mesh,hypVolume) print "-------------------------- compute the mesh of alveole " -ret=smesh.Compute(mesh,shape_mesh) +ret = smesh.Compute(mesh,shape_mesh) if ret != 0: log=mesh.GetLog(0) # no erase trace for linelog in log: print linelog print "Information about the Mesh_mechanic:" - print "Number of nodes : ", mesh.NbNodes() - print "Number of edges : ", mesh.NbEdges() - print "Number of faces : ", mesh.NbFaces() - print "Number of triangles : ", mesh.NbTriangles() - print "Number of volumes: ", mesh.NbVolumes() - print "Number of tetrahedrons: ", mesh.NbTetras() + print "Number of nodes : ", mesh.NbNodes() + print "Number of edges : ", mesh.NbEdges() + print "Number of faces : ", mesh.NbFaces() + print "Number of triangles : ", mesh.NbTriangles() + print "Number of volumes : ", mesh.NbVolumes() + print "Number of tetrahedrons: ", mesh.NbTetras() else: print "problem when computing the mesh" - + salome.sg.updateObjBrowser(1) diff --git a/src/SMESH_SWIG/SMESH_blocks.py b/src/SMESH_SWIG/SMESH_blocks.py new file mode 100644 index 000000000..0430867fb --- /dev/null +++ b/src/SMESH_SWIG/SMESH_blocks.py @@ -0,0 +1,43 @@ +# SMESH SMESH_SWIG : binding of C++ implementaion with Python +# +# Copyright (C) 2003 CEA +# +# 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.org +# +# +# +# File : SMESH_blocks.py +# Author : Julia DOROVSKIKH +# Module : SMESH +# $Header$ + +import salome +import geompy +import math + +import GEOM_Spanner + +isBlocksTest = 0 # False +isMeshTest = 1 # True +hasGUI = 1 # True + +smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") +smesh.SetCurrentStudy(salome.myStudy) + +GEOM_Spanner.MakeSpanner(salome, geompy, math, isBlocksTest, isMeshTest, smesh, hasGUI) + +salome.sg.updateObjBrowser(1); diff --git a/src/SMESH_SWIG/SMESH_box2_tetra.py b/src/SMESH_SWIG/SMESH_box2_tetra.py index d5e6979f6..e8a4afd9f 100644 --- a/src/SMESH_SWIG/SMESH_box2_tetra.py +++ b/src/SMESH_SWIG/SMESH_box2_tetra.py @@ -9,62 +9,53 @@ import geompy import StdMeshers import NETGENPlugin -geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") smeshgui = salome.ImportComponentGUI("SMESH") smeshgui.Init(salome.myStudyId); -ShapeTypeShell = 3 -ShapeTypeFace = 4 -ShapeTypeEdge = 6 - # ---- define 2 boxes box1 and box2 box1 = geompy.MakeBox(0., 0., 0., 100., 200., 300.) -idbox1 = geompy.addToStudy(box1,"box1") +idbox1 = geompy.addToStudy(box1, "box1") print "Analysis of the geometry box1 :" -subShellList=geompy.SubShapeAll(box1,ShapeTypeShell) -subFaceList=geompy.SubShapeAll(box1,ShapeTypeFace) -subEdgeList=geompy.SubShapeAll(box1,ShapeTypeEdge) +subShellList = geompy.SubShapeAll(box1, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(box1, geompy.ShapeType["EDGE"]) -print "number of Shells in box1 : ",len(subShellList) -print "number of Faces in box1 : ",len(subFaceList) -print "number of Edges in box1 : ",len(subEdgeList) +print "number of Shells in box1 : ", len(subShellList) +print "number of Faces in box1 : ", len(subFaceList) +print "number of Edges in box1 : ", len(subEdgeList) box2 = geompy.MakeBox(100., 0., 0., 200., 200., 300.) -idbox2 = geompy.addToStudy(box2,"box2") +idbox2 = geompy.addToStudy(box2, "box2") print "Analysis of the geometry box2 :" -subShellList=geompy.SubShapeAll(box2,ShapeTypeShell) -subFaceList=geompy.SubShapeAll(box2,ShapeTypeFace) -subEdgeList=geompy.SubShapeAll(box2,ShapeTypeEdge) - -print "number of Shells in box2 : ",len(subShellList) -print "number of Faces in box2 : ",len(subFaceList) -print "number of Edges in box2 : ",len(subEdgeList) +subShellList = geompy.SubShapeAll(box2, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(box2, geompy.ShapeType["EDGE"]) -blocs = [] -blocs.append(box1._get_Name()) -blocs.append(box2._get_Name()) +print "number of Shells in box2 : ", len(subShellList) +print "number of Faces in box2 : ", len(subFaceList) +print "number of Edges in box2 : ", len(subEdgeList) # append the tow boxes to make ine shel, referrencing only once # the internal interface -shell = geompy.Partition(blocs) -idshell = geompy.addToStudy(shell,"shell") +shell = geompy.MakePartition([box1, box2]) +idshell = geompy.addToStudy(shell, "shell") print "Analysis of the geometry shell (union of box1 and box2) :" -subShellList=geompy.SubShapeAll(shell,ShapeTypeShell) -subFaceList=geompy.SubShapeAll(shell,ShapeTypeFace) -subEdgeList=geompy.SubShapeAll(shell,ShapeTypeEdge) +subShellList = geompy.SubShapeAll(shell, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(shell, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(shell, geompy.ShapeType["EDGE"]) -print "number of Shells in shell : ",len(subShellList) -print "number of Faces in shell : ",len(subFaceList) -print "number of Edges in shell : ",len(subEdgeList) +print "number of Shells in shell : ", len(subShellList) +print "number of Faces in shell : ", len(subFaceList) +print "number of Edges in shell : ", len(subEdgeList) ### ---------------------------- SMESH -------------------------------------- @@ -77,7 +68,7 @@ print "-------------------------- NumberOfSegments" numberOfSegments = 10 -hypNbSeg=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") +hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") hypNbSeg.SetNumberOfSegments(numberOfSegments) print hypNbSeg.GetName() @@ -90,7 +81,7 @@ print "-------------------------- MaxElementArea" maxElementArea = 500 -hypArea=smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so") +hypArea = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so") hypArea.SetMaxElementArea(maxElementArea) print hypArea.GetName() @@ -103,7 +94,7 @@ print "-------------------------- MaxElementVolume" maxElementVolume = 500 -hypVolume=smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so") +hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so") hypVolume.SetMaxElementVolume(maxElementVolume) print hypVolume.GetName() @@ -118,17 +109,17 @@ print "-------------------------- create Algorithms" print "-------------------------- Regular_1D" -regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so") +regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so") smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation") print "-------------------------- MEFISTO_2D" -mefisto2D=smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so") +mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so") smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D") print "-------------------------- NETGEN_3D" -netgen3D=smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so") +netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so") smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D") # ---- init a Mesh with the shell @@ -152,10 +143,10 @@ mesh.AddHypothesis(shell,hypVolume) salome.sg.updateObjBrowser(1) print "-------------------------- compute shell" -ret= smesh.Compute(mesh,shell) +ret = smesh.Compute(mesh,shell) print ret if ret != 0: - log=mesh.GetLog(0) # no erase trace + log = mesh.GetLog(0) # no erase trace for linelog in log: print linelog print "Information about the MeshBox2:" diff --git a/src/SMESH_SWIG/SMESH_box3_tetra.py b/src/SMESH_SWIG/SMESH_box3_tetra.py index adb7d4944..af4082774 100644 --- a/src/SMESH_SWIG/SMESH_box3_tetra.py +++ b/src/SMESH_SWIG/SMESH_box3_tetra.py @@ -10,73 +10,63 @@ import geompy import StdMeshers import NETGENPlugin -geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") smeshgui = salome.ImportComponentGUI("SMESH") smeshgui.Init(salome.myStudyId); -ShapeTypeShell = 3 -ShapeTypeFace = 4 -ShapeTypeEdge = 6 - # ---- define 3 boxes box1, box2 and box3 box1 = geompy.MakeBox(0., 0., 0., 100., 200., 300.) -idbox1 = geompy.addToStudy(box1,"box1") +idbox1 = geompy.addToStudy(box1, "box1") print "Analysis of the geometry box1 :" -subShellList=geompy.SubShapeAll(box1,ShapeTypeShell) -subFaceList=geompy.SubShapeAll(box1,ShapeTypeFace) -subEdgeList=geompy.SubShapeAll(box1,ShapeTypeEdge) +subShellList = geompy.SubShapeAll(box1, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(box1, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(box1, geompy.ShapeType["EDGE"]) -print "number of Shells in box1 : ",len(subShellList) -print "number of Faces in box1 : ",len(subFaceList) -print "number of Edges in box1 : ",len(subEdgeList) +print "number of Shells in box1 : ", len(subShellList) +print "number of Faces in box1 : ", len(subFaceList) +print "number of Edges in box1 : ", len(subEdgeList) box2 = geompy.MakeBox(100., 0., 0., 200., 200., 300.) -idbox2 = geompy.addToStudy(box2,"box2") +idbox2 = geompy.addToStudy(box2, "box2") print "Analysis of the geometry box2 :" -subShellList=geompy.SubShapeAll(box2,ShapeTypeShell) -subFaceList=geompy.SubShapeAll(box2,ShapeTypeFace) -subEdgeList=geompy.SubShapeAll(box2,ShapeTypeEdge) +subShellList = geompy.SubShapeAll(box2, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(box2, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(box2, geompy.ShapeType["EDGE"]) -print "number of Shells in box2 : ",len(subShellList) -print "number of Faces in box2 : ",len(subFaceList) -print "number of Edges in box2 : ",len(subEdgeList) +print "number of Shells in box2 : ", len(subShellList) +print "number of Faces in box2 : ", len(subFaceList) +print "number of Edges in box2 : ", len(subEdgeList) box3 = geompy.MakeBox(0., 0., 300., 200., 200., 500.) -idbox3 = geompy.addToStudy(box3,"box3") +idbox3 = geompy.addToStudy(box3, "box3") print "Analysis of the geometry box3 :" -subShellList=geompy.SubShapeAll(box3,ShapeTypeShell) -subFaceList=geompy.SubShapeAll(box3,ShapeTypeFace) -subEdgeList=geompy.SubShapeAll(box3,ShapeTypeEdge) - -print "number of Shells in box3 : ",len(subShellList) -print "number of Faces in box3 : ",len(subFaceList) -print "number of Edges in box3 : ",len(subEdgeList) +subShellList = geompy.SubShapeAll(box3, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(box3, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(box3, geompy.ShapeType["EDGE"]) -blocs = [] -blocs.append(box1._get_Name()) -blocs.append(box2._get_Name()) -blocs.append(box3._get_Name()) +print "number of Shells in box3 : ", len(subShellList) +print "number of Faces in box3 : ", len(subFaceList) +print "number of Edges in box3 : ", len(subEdgeList) -shell = geompy.Partition(blocs) +shell = geompy.MakePartition([box1, box2, box3]) idshell = geompy.addToStudy(shell,"shell") print "Analysis of the geometry shell (union of box1, box2 and box3) :" -subShellList=geompy.SubShapeAll(shell,ShapeTypeShell) -subFaceList=geompy.SubShapeAll(shell,ShapeTypeFace) -subEdgeList=geompy.SubShapeAll(shell,ShapeTypeEdge) +subShellList = geompy.SubShapeAll(shell, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(shell, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(shell, geompy.ShapeType["EDGE"]) -print "number of Shells in shell : ",len(subShellList) -print "number of Faces in shell : ",len(subFaceList) -print "number of Edges in shell : ",len(subEdgeList) +print "number of Shells in shell : ", len(subShellList) +print "number of Faces in shell : ", len(subFaceList) +print "number of Edges in shell : ", len(subEdgeList) ### ---------------------------- SMESH -------------------------------------- @@ -89,7 +79,7 @@ print "-------------------------- NumberOfSegments" numberOfSegments = 10 -hypNbSeg=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") +hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") hypNbSeg.SetNumberOfSegments(numberOfSegments) print hypNbSeg.GetName() @@ -102,7 +92,7 @@ print "-------------------------- MaxElementArea" maxElementArea = 500 -hypArea=smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so") +hypArea = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so") hypArea.SetMaxElementArea(maxElementArea) print hypArea.GetName() @@ -115,7 +105,7 @@ print "-------------------------- MaxElementVolume" maxElementVolume = 500 -hypVolume=smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so") +hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so") hypVolume.SetMaxElementVolume(maxElementVolume) print hypVolume.GetName() @@ -130,17 +120,17 @@ print "-------------------------- create Algorithms" print "-------------------------- Regular_1D" -regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so") +regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so") smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation") print "-------------------------- MEFISTO_2D" -mefisto2D=smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so") +mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so") smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D") print "-------------------------- NETGEN_3D" -netgen3D=smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so") +netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so") smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D") # ---- init a Mesh with the shell @@ -164,10 +154,10 @@ mesh.AddHypothesis(shell,hypVolume) salome.sg.updateObjBrowser(1) print "-------------------------- compute shell" -ret= smesh.Compute(mesh,shell) +ret = smesh.Compute(mesh,shell) print ret if ret != 0: - log=mesh.GetLog(0) # no erase trace + log = mesh.GetLog(0) # no erase trace for linelog in log: print linelog print "Information about the MeshBox3:" diff --git a/src/SMESH_SWIG/SMESH_box_tetra.py b/src/SMESH_SWIG/SMESH_box_tetra.py index 38effb777..72b45e12b 100644 --- a/src/SMESH_SWIG/SMESH_box_tetra.py +++ b/src/SMESH_SWIG/SMESH_box_tetra.py @@ -9,31 +9,25 @@ import geompy import StdMeshers import NETGENPlugin -geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") smeshgui = salome.ImportComponentGUI("SMESH") smeshgui.Init(salome.myStudyId); -# ----------------------------------------------------------------------------- -ShapeTypeShell = 3 -ShapeTypeFace = 4 -ShapeTypeEdge = 6 - # ---- define a boxe box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) -idbox = geompy.addToStudy(box,"box") +idbox = geompy.addToStudy(box, "box") print "Analysis of the geometry box :" -subShellList=geompy.SubShapeAll(box,ShapeTypeShell) -subFaceList=geompy.SubShapeAll(box,ShapeTypeFace) -subEdgeList=geompy.SubShapeAll(box,ShapeTypeEdge) +subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(box, geompy.ShapeType["EDGE"]) -print "number of Shells in box : ",len(subShellList) -print "number of Faces in box : ",len(subFaceList) -print "number of Edges in box : ",len(subEdgeList) +print "number of Shells in box : ", len(subShellList) +print "number of Faces in box : ", len(subFaceList) +print "number of Edges in box : ", len(subEdgeList) ### ---------------------------- SMESH -------------------------------------- @@ -46,7 +40,7 @@ print "-------------------------- NumberOfSegments" numberOfSegments = 10 -hypNbSeg=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") +hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") hypNbSeg.SetNumberOfSegments(numberOfSegments) print hypNbSeg.GetName() @@ -59,7 +53,7 @@ print "-------------------------- MaxElementArea" maxElementArea = 500 -hypArea=smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so") +hypArea = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so") hypArea.SetMaxElementArea(maxElementArea) print hypArea.GetName() @@ -72,7 +66,7 @@ print "-------------------------- MaxElementVolume" maxElementVolume = 500 -hypVolume=smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so") +hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so") hypVolume.SetMaxElementVolume(maxElementVolume) print hypVolume.GetName() @@ -87,17 +81,17 @@ print "-------------------------- create Algorithms" print "-------------------------- Regular_1D" -regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so") +regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so") smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation") print "-------------------------- MEFISTO_2D" -mefisto2D=smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so") +mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so") smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D") print "-------------------------- NETGEN_3D" -netgen3D=smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so") +netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so") smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D") # ---- init a Mesh with the boxe @@ -121,10 +115,10 @@ mesh.AddHypothesis(box,hypVolume) salome.sg.updateObjBrowser(1) print "-------------------------- compute the mesh of the boxe" -ret=smesh.Compute(mesh,box) +ret = smesh.Compute(mesh,box) print ret if ret != 0: - log=mesh.GetLog(0) # no erase trace + log = mesh.GetLog(0) # no erase trace for linelog in log: print linelog print "Information about the MeshBox:" diff --git a/src/SMESH_SWIG/SMESH_controls.py b/src/SMESH_SWIG/SMESH_controls.py index 83c950178..1d5080d87 100644 --- a/src/SMESH_SWIG/SMESH_controls.py +++ b/src/SMESH_SWIG/SMESH_controls.py @@ -97,7 +97,7 @@ print "Criterion: Aspect Ratio > 1.3 Nb = ", len( anIds ) # create group aGroup = mesh.CreateGroup( SMESH.FACE, "Aspect Ratio > 1.3" ) -aGroup.Add( anIds ) +aGroup.Add( anIds ) # Criterion : MINIMUM ANGLE < 30 @@ -207,21 +207,3 @@ aGroup.Add( anIds ) salome.sg.updateObjBrowser(1) - - - - - - - - - - - - - - - - - - diff --git a/src/SMESH_SWIG/SMESH_fixation.py b/src/SMESH_SWIG/SMESH_fixation.py index 9158ee567..b10fcc81f 100644 --- a/src/SMESH_SWIG/SMESH_fixation.py +++ b/src/SMESH_SWIG/SMESH_fixation.py @@ -1,21 +1,21 @@ # 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org # # # @@ -28,49 +28,16 @@ import salome import geompy import math -geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") - -ShapeTypeCompSolid = 1 -ShapeTypeSolid = 2 -ShapeTypeShell = 3 -ShapeTypeFace = 4 -ShapeTypeWire = 5 -ShapeTypeEdge = 6 -ShapeTypeVertex = 7 - # ----------------------------------------------------------------------------- def MakeFace(lstEdges) : """ - Creates a face from 4 edges + Creates a planar face from 4 edges """ - lstWire = [] - for edge in lstEdges : - lstWire.append(edge._get_Name()) - wire = geom.MakeWire(lstWire) - face = geom.MakeFace(wire, 1) + wire = geompy.MakeWire(lstEdges) + face = geompy.MakeFace(wire, 1) return face -def MakeShell(lstFaces) : - """ - Creates a shell from 6 faces - """ - lstShell = [] - for face in lstFaces : - lstShell.append(face._get_Name()) - shell = geom.MakeSewing(lstShell, 0.00001) - return shell - -def MakeCompound(lstShells) : - """ - Creates a compound from several shells - """ - lstCompound = [] - for shell in lstShells : - lstCompound.append(shell._get_Name()) - compound = geom.MakeCompound(lstCompound) - return compound - # ----------------------------------------------------------------------------- # ---- dimensions @@ -99,51 +66,40 @@ rayonConge = 150 - epaisseurFlanc epaisseurFond = 162 rayonTrou = 75 -posAxeTrou = hauteurFlanc -(180 + rayonTrou) +posAxeTrou = hauteurFlanc - (180 + rayonTrou) marge = 10 tol3d = 1.e-3 # ---- points, directions de base -p0 = geom.MakePointStruct(0., 0., 0.) -px = geom.MakePointStruct(100., 0., 0.) -vx = geom.MakeDirection(px) -py = geom.MakePointStruct(0., 100., 0.) -vy = geom.MakeDirection(py) -pz = geom.MakePointStruct(0., 0., 100.) -vz = geom.MakeDirection(pz) +p0 = geompy.MakeVertex(0., 0., 0.) + +vx = geompy.MakeVectorDXDYDZ(100., 0., 0.) +vy = geompy.MakeVectorDXDYDZ(0., 100., 0.) +vz = geompy.MakeVectorDXDYDZ(0., 0., 100.) # ---- ellipse du flanc -he = hauteurFlanc -2*rayonConge +he = hauteurFlanc - 2*rayonConge re = 0.5*(largeurPlq - epaisseurFond) - rayonConge sine = re/he -cose = math.sqrt(1.-sine*sine) -pe = geom.MakePointStruct(sine, 0., cose) -ve = geom.MakeDirection(pe) -cyl0 = geom.MakeCylinder(p0, ve, re, 2*he) -axecy = geom.MakeAxisStruct(0., 0., 0.,sine, 0., cose) -cyl1 = geom.MakeRotation(cyl0, axecy, 0.5) -cyle = geom.MakeTranslation(cyl1, - -marge*sine, 0., -marge*cose) -boxe = geom.MakeBox(0., 0., 0., 3*he, -2*re, 3*he) -#idcyle = geompy.addToStudy(cyle, "cyle") -#idboxe = geompy.addToStudy(boxe, "boxe") -cylcoup = geom.MakeBoolean(cyle, boxe, 2) -#idcylcoup = geompy.addToStudy(cylcoup, "cylcoup") +cose = math.sqrt(1. - sine*sine) + +ve = geompy.MakeVectorDXDYDZ(sine, 0., cose) +cyl0 = geompy.MakeCylinder(p0, ve, re, 2*he) +cyl1 = geompy.MakeRotation(cyl0, ve, 0.5) +cyle = geompy.MakeTranslation(cyl1, -marge*sine, 0., -marge*cose) + +pbe = geompy.MakeVertex(3*he, -2*re, 3*he) +boxe = geompy.MakeBoxTwoPnt(p0, pbe) + +cylcoup = geompy.MakeBoolean(cyle, boxe, 2) + aretes = [] -aretes = geom.SubShapeAllSorted(cylcoup, ShapeTypeEdge) +aretes = geompy.SubShapeAllSorted(cylcoup, geompy.ShapeType["EDGE"]) -##eid=0 -##for edge in aretes: -## edname="arete%d"%eid -## idedge=geompy.addToStudy(edge,edname) -## eid=eid+1 - -shape = geom.MakeCopy(aretes[0]) -#idarete = geompy.addToStudy(shape, "arete") -aShape = geom.MakeTranslation(shape, - 0., rayonConge +re, epaisseurPlq +2*rayonConge) +shape = geompy.MakeCopy(aretes[0]) +aShape = geompy.MakeTranslation(shape, 0., rayonConge + re, epaisseurPlq + 2*rayonConge) # ----------------------------------------------------------------------------- @@ -152,74 +108,73 @@ aShape = geom.MakeTranslation(shape, # ---- cotes x -x0 = 0. +x0 = 0. x0h = rayonConge -x1 = rayonConge + epaisseurFlanc -xc = longueurPlq/2 -x2 = longueurPlq - rayonConge - epaisseurFlanc +x1 = rayonConge + epaisseurFlanc +xc = longueurPlq/2 +x2 = longueurPlq - rayonConge - epaisseurFlanc x3h = longueurPlq - rayonConge -x3 = longueurPlq +x3 = longueurPlq # ---- cotes y -y0 = 0. +y0 = 0. y0h = rayonConge -y1 = largeurPlq - epaisseurFond -y1m = y1 -marge -y2 = largeurPlq +y1 = largeurPlq - epaisseurFond +y1m = y1 - marge +y2 = largeurPlq y2p = largeurPlq + marge # ---- cotes z -z0 = 0. -z1m = epaisseurPlq -marge -z1 = epaisseurPlq -z2 = epaisseurPlq + rayonConge -z3 = epaisseurPlq + 2*rayonConge -z4 = epaisseurPlq + hauteurFlanc +z0 = 0. +z1m = epaisseurPlq - marge +z1 = epaisseurPlq +z2 = epaisseurPlq + rayonConge +z3 = epaisseurPlq + 2*rayonConge +z4 = epaisseurPlq + hauteurFlanc z4p = epaisseurPlq + hauteurFlanc + marge -zc = epaisseurPlq + posAxeTrou -zc2 = epaisseurPlq + (posAxeTrou -rayonTrou)/3 -zc3 = epaisseurPlq + 2*(posAxeTrou -rayonTrou)/3 +zc = epaisseurPlq + posAxeTrou +zc2 = epaisseurPlq + (posAxeTrou - rayonTrou)/3 +zc3 = epaisseurPlq + 2*(posAxeTrou - rayonTrou)/3 # ---- decoupe du fond -p11 = geom.MakePointStruct(x1, y1m, z1) -p12 = geom.MakePointStruct(x1, y1m, z2) -p13 = geom.MakePointStruct(x1, y1m, z3) -p14 = geom.MakePointStruct(x1, y1m, z4) -pc1 = geom.MakePointStruct(xc, y1m, z1) -pc2 = geom.MakePointStruct(xc, y1m, zc2) -pc3 = geom.MakePointStruct(xc, y1m, zc3) -pcc = geom.MakePointStruct(xc, y1m, zc) -pc4 = geom.MakePointStruct(xc, y1m, z4) -p21 = geom.MakePointStruct(x2, y1m, z1) -p22 = geom.MakePointStruct(x2, y1m, z2) -p23 = geom.MakePointStruct(x2, y1m, z3) -p24 = geom.MakePointStruct(x2, y1m, z4) -pcf = geom.MakePointStruct(xc, y2p, zc) - -arc2 = geom.MakeArc(p12,pc2,p22) -arc3 = geom.MakeArc(p13,pc3,p23) - -segz1 = geom.MakeVector(p11,p21) -#segz4 = geom.MakeVector(p14,p24) -segz41 = geom.MakeVector(p14,pc4) -segz42 = geom.MakeVector(pc4,p24) -segx11 = geom.MakeVector(p11,p12) -segx12 = geom.MakeVector(p12,p13) -segx13 = geom.MakeVector(p13,p14) -segxc2 = geom.MakeVector(pc1,pc2) -segxc3 = geom.MakeVector(pc2,pc3) -segxc4 = geom.MakeVector(pcc,pc4) -segx21 = geom.MakeVector(p21,p22) -segx22 = geom.MakeVector(p22,p23) -segx23 = geom.MakeVector(p23,p24) -segx1c1 = geom.MakeVector(p13,pcc) -segx1c2 = geom.MakeVector(p14,pcc) -segx2c1 = geom.MakeVector(p23,pcc) -segx2c2 = geom.MakeVector(p24,pcc) +p11 = geompy.MakeVertex(x1, y1m, z1) +p12 = geompy.MakeVertex(x1, y1m, z2) +p13 = geompy.MakeVertex(x1, y1m, z3) +p14 = geompy.MakeVertex(x1, y1m, z4) +pc1 = geompy.MakeVertex(xc, y1m, z1) +pc2 = geompy.MakeVertex(xc, y1m, zc2) +pc3 = geompy.MakeVertex(xc, y1m, zc3) +pcc = geompy.MakeVertex(xc, y1m, zc) +pc4 = geompy.MakeVertex(xc, y1m, z4) +p21 = geompy.MakeVertex(x2, y1m, z1) +p22 = geompy.MakeVertex(x2, y1m, z2) +p23 = geompy.MakeVertex(x2, y1m, z3) +p24 = geompy.MakeVertex(x2, y1m, z4) +pcf = geompy.MakeVertex(xc, y2p, zc) + +arc2 = geompy.MakeArc(p12,pc2,p22) +arc3 = geompy.MakeArc(p13,pc3,p23) + +segz1 = geompy.MakeVector(p11,p21) +segz41 = geompy.MakeVector(p14,pc4) +segz42 = geompy.MakeVector(pc4,p24) +segx11 = geompy.MakeVector(p11,p12) +segx12 = geompy.MakeVector(p12,p13) +segx13 = geompy.MakeVector(p13,p14) +segxc2 = geompy.MakeVector(pc1,pc2) +segxc3 = geompy.MakeVector(pc2,pc3) +segxc4 = geompy.MakeVector(pcc,pc4) +segx21 = geompy.MakeVector(p21,p22) +segx22 = geompy.MakeVector(p22,p23) +segx23 = geompy.MakeVector(p23,p24) +segx1c1 = geompy.MakeVector(p13,pcc) +segx1c2 = geompy.MakeVector(p14,pcc) +segx2c1 = geompy.MakeVector(p23,pcc) +segx2c2 = geompy.MakeVector(p24,pcc) facef = [] facef.append(MakeFace([segx13,segx1c2,segx1c1])) @@ -230,117 +185,110 @@ facef.append(MakeFace([segx1c1,arc3,segx2c1])) facef.append(MakeFace([segx12,arc2,segx22,arc3])) facef.append(MakeFace([segx11,segz1,segx21,arc2])) -decf =[] +vcccf = geompy.MakeVector(pcc, pcf) +hcccf = y2p - y1m +decf = [] for face in facef: - decf.append(geom.MakePrism(face,pcc,pcf)) - -axeCyl = geom.MakeAxisStruct( 0.5*longueurPlq, - 0., - epaisseurPlq + posAxeTrou, - 0., - largeurPlq, - 0.) -pAxe1 = geom.MakePointStruct(xc, 0., zc) -cylFond = geom.MakeCylinder(pAxe1, vy, rayonTrou, 1.1*largeurPlq) -cylFond2 = geom.MakeRotation(geom.MakeCopy(cylFond),axeCyl,math.pi) -#idcylfond2 = geompy.addToStudy(cylFond2,"cylFond2") - -fondec =[] + decf.append(geompy.MakePrismVecH(face,vcccf,hcccf)) + +pc = geompy.MakeVertex(xc, 0., zc) +py2 = geompy.MakeVertex(xc, y2, zc) +axeCyl = geompy.MakeVector(pc, py2) + +cylFond = geompy.MakeCylinder(pc, vy, rayonTrou, 1.1*largeurPlq) +cylFond2 = geompy.MakeRotation(cylFond, axeCyl, math.pi) + +fondec = [] for id in (0,1,2,3): - fondec.append(geom.MakeBoolean(decf[id],cylFond2,2)) -fondec.append(geom.MakeBoolean(decf[4],cylFond,2)) + fondec.append(geompy.MakeBoolean(decf[id], cylFond2, 2)) +fondec.append(geompy.MakeBoolean(decf[4], cylFond, 2)) for id in (5,6): fondec.append(decf[id]) -bcut1=geom.MakeBox(x0,y0,z0, xc,y2p,z4p) -bcut2=geom.MakeBox(xc,y0,z0, x3,y2p,z4p) +p_xcy2pz4p = geompy.MakeVertex(xc,y2p,z4p) +p_x3y2pz4p = geompy.MakeVertex(x3,y2p,z4p) +pxc = geompy.MakeVertex(xc,y0,z0) +bcut1 = geompy.MakeBoxTwoPnt(p0, p_xcy2pz4p) +bcut2 = geompy.MakeBoxTwoPnt(pxc, p_x3y2pz4p) + fondec2 = [] for id in (0,1,2,3): fondec2.append(fondec[id]) for id in (4,5,6): - fondec2.append(geom.MakeBoolean(fondec[id],bcut1,1)) - fondec2.append(geom.MakeBoolean(fondec[id],bcut2,1)) - -##iff=0 -##for ff in fondec2: -## idfo = geompy.addToStudy(ff, "ff%d"%(iff)) -## iff = iff +1 + fondec2.append(geompy.MakeBoolean(fondec[id], bcut1, 1)) + fondec2.append(geompy.MakeBoolean(fondec[id], bcut2, 1)) # ----- autres blocs de decoupe -bcong1=geom.MakeBox(x0,y0,z1, x1,y1,z2) -bcong2=geom.MakeBox(x0,y1,z1, x1,y2,z2) -bcong3=geom.MakeBox(x2,y0,z1, x3,y1,z2) -bcong4=geom.MakeBox(x2,y1,z1, x3,y2,z2) - -pcylx0 = geom.MakePointStruct(0., -marge, z2) -cylcongx0 = geom.MakeCylinder(pcylx0, vy, rayonConge, largeurPlq +2*marge) -#idcylcongx0 = geompy.addToStudy(cylcongx0,"cylcongx0") -pcylx3 = geom.MakePointStruct(longueurPlq, -marge, z2) -cylcongx3 = geom.MakeCylinder(pcylx3, vy, rayonConge, largeurPlq +2*marge) -#idcylcongx3 = geompy.addToStudy(cylcongx3,"cylcongx3") -pcyly0 = geom.MakePointStruct(-marge, 0., z2) -cylcongy0 = geom.MakeCylinder(pcyly0, vx, rayonConge, longueurPlq +2*marge) -#idcylcongy0 = geompy.addToStudy(cylcongy0,"cylcongy0") - -bcong1=geom.MakeBoolean(bcong1,cylcongx0,2) -bcong2=geom.MakeBoolean(bcong2,cylcongx0,2) -bcong1=geom.MakeBoolean(bcong1,cylcongy0,2) +bcong1 = geompy.MakeBox(x0,y0,z1, x1,y1,z2) +bcong2 = geompy.MakeBox(x0,y1,z1, x1,y2,z2) +bcong3 = geompy.MakeBox(x2,y0,z1, x3,y1,z2) +bcong4 = geompy.MakeBox(x2,y1,z1, x3,y2,z2) + +pcylx0 = geompy.MakeVertex(0., -marge, z2) +pcylx3 = geompy.MakeVertex(longueurPlq, -marge, z2) +pcyly0 = geompy.MakeVertex(-marge, 0., z2) + +cylcongx0 = geompy.MakeCylinder(pcylx0, vy, rayonConge, largeurPlq + 2*marge) +cylcongx3 = geompy.MakeCylinder(pcylx3, vy, rayonConge, largeurPlq + 2*marge) +cylcongy0 = geompy.MakeCylinder(pcyly0, vx, rayonConge, longueurPlq + 2*marge) + +bcong1 = geompy.MakeBoolean(bcong1,cylcongx0,2) +bcong2 = geompy.MakeBoolean(bcong2,cylcongx0,2) +bcong1 = geompy.MakeBoolean(bcong1,cylcongy0,2) #NRI : inverse order of BOP -bcong3=geom.MakeBoolean(bcong3,cylcongy0,2) -bcong3=geom.MakeBoolean(bcong3,cylcongx3,2) -bcong4=geom.MakeBoolean(bcong4,cylcongx3,2) - -pf1 = geom.MakePointStruct(0., y0h, z3) -pf2 = geom.MakePointStruct(0., y1, z3) -pf3 = geom.MakePointStruct(0., y1, z4) -pf4 = geom.MakePointStruct(0.,0.5*(largeurPlq - epaisseurFond) , z4) -vf1 = geom.MakeEdge(pf1,pf2) -vf2 = geom.MakeEdge(pf2,pf3) -vf3 = geom.MakeEdge(pf3,pf4) +bcong3 = geompy.MakeBoolean(bcong3,cylcongy0,2) +bcong3 = geompy.MakeBoolean(bcong3,cylcongx3,2) +bcong4 = geompy.MakeBoolean(bcong4,cylcongx3,2) + +pf1 = geompy.MakeVertex(0., y0h, z3) +pf2 = geompy.MakeVertex(0., y1, z3) +pf3 = geompy.MakeVertex(0., y1, z4) +pf4 = geompy.MakeVertex(0., 0.5*(largeurPlq - epaisseurFond) , z4) + +vf1 = geompy.MakeEdge(pf1, pf2) +vf2 = geompy.MakeEdge(pf2, pf3) +vf3 = geompy.MakeEdge(pf3, pf4) + faceFlanc = MakeFace([vf1,vf2,vf3,aShape]) -#idfaceFlanc = geompy.addToStudy(faceFlanc,"faceFlanc") -pfe = geom.MakePointStruct(epaisseurFlanc, 0., 0.) -flanc1 = geom.MakePrism(faceFlanc, p0, pfe) -flanc2 = geom.MakeCopy(flanc1) -flanc1 = geom.MakeTranslation(flanc1, - rayonConge,0.,0.) -flanc2 = geom.MakeTranslation(flanc2, - longueurPlq-rayonConge-epaisseurFlanc,0.,0.) + +flanc1 = geompy.MakePrismVecH(faceFlanc, vx, epaisseurFlanc) +flanc2 = geompy.MakeCopy(flanc1) +flanc1 = geompy.MakeTranslation(flanc1, rayonConge, 0., 0.) +flanc2 = geompy.MakeTranslation(flanc2, longueurPlq - rayonConge - epaisseurFlanc, 0., 0.) # ---- constitution et decoupe des blocs -boxfond2 = geom.MakeBox(x0, y1, z0, x3, y2, z4p) -#idboxfond2 = geompy.addToStudy(boxfond2,"boxfond2") +boxfond2 = geompy.MakeBox(x0, y1, z0, x3, y2, z4p) blocs = [] for dec in fondec2: - blocs.append(geom.MakeBoolean(boxfond2, dec, 1)) -blocs.append(geom.MakeBox(x0,y1,z0, x1,y2,z1)) -blocs.append(geom.MakeBox(x1,y1,z0, xc,y2,z1)) -blocs.append(geom.MakeBox(xc,y1,z0, x2,y2,z1)) -blocs.append(geom.MakeBox(x2,y1,z0, x3,y2,z1)) -blocs.append(geom.MakeBox(x0,y0,z0, x1,y1,z1)) -blocs.append(geom.MakeBox(x1,y0,z0, xc,y1,z1)) -blocs.append(geom.MakeBox(xc,y0,z0, x2,y1,z1)) -blocs.append(geom.MakeBox(x2,y0,z0, x3,y1,z1)) + blocs.append(geompy.MakeBoolean(boxfond2, dec, 1)) + +blocs.append(geompy.MakeBox(x0,y1,z0, x1,y2,z1)) +blocs.append(geompy.MakeBox(x1,y1,z0, xc,y2,z1)) +blocs.append(geompy.MakeBox(xc,y1,z0, x2,y2,z1)) +blocs.append(geompy.MakeBox(x2,y1,z0, x3,y2,z1)) +blocs.append(geompy.MakeBox(x0,y0,z0, x1,y1,z1)) +blocs.append(geompy.MakeBox(x1,y0,z0, xc,y1,z1)) +blocs.append(geompy.MakeBox(xc,y0,z0, x2,y1,z1)) +blocs.append(geompy.MakeBox(x2,y0,z0, x3,y1,z1)) blocs.append(bcong2) blocs.append(bcong4) blocs.append(bcong1) blocs.append(bcong3) -blocs.append(geom.MakeBox(x0h,y1, z2, x1, y2, z3)) -blocs.append(geom.MakeBox(x2, y1, z2, x3h,y2, z3)) -blocs.append(geom.MakeBox(x0h,y0h,z2, x1, y1, z3)) -blocs.append(geom.MakeBox(x2, y0h,z2, x3h,y1, z3)) -blocs.append(geom.MakeBox(x0h,y1, z3, x1, y2, z4)) -blocs.append(geom.MakeBox(x2, y1, z3, x3h,y2, z4)) +blocs.append(geompy.MakeBox(x0h,y1, z2, x1, y2, z3)) +blocs.append(geompy.MakeBox(x2, y1, z2, x3h,y2, z3)) +blocs.append(geompy.MakeBox(x0h,y0h,z2, x1, y1, z3)) +blocs.append(geompy.MakeBox(x2, y0h,z2, x3h,y1, z3)) +blocs.append(geompy.MakeBox(x0h,y1, z3, x1, y2, z4)) +blocs.append(geompy.MakeBox(x2, y1, z3, x3h,y2, z4)) blocs.append(flanc1) blocs.append(flanc2) - -compbloc = MakeCompound(blocs) -idcomp = geompy.addToStudy(compbloc,"compbloc") -# ---- eliminer les faces en double, solid-->shell +compbloc = geompy.MakeCompound(blocs) +idcomp = geompy.addToStudy(compbloc, "compbloc") -compshell = geom.MakeGlueFaces(compbloc,tol3d) -idcomp = geompy.addToStudy(compshell,"compshell") +# ---- eliminer les faces en double, solid-->shell +compshell = geompy.MakeGlueFaces(compbloc,tol3d) +idcomp = geompy.addToStudy(compshell, "compshell") diff --git a/src/SMESH_SWIG/SMESH_fixation_hexa.py b/src/SMESH_SWIG/SMESH_fixation_hexa.py index 2d12c7f47..1845b2218 100644 --- a/src/SMESH_SWIG/SMESH_fixation_hexa.py +++ b/src/SMESH_SWIG/SMESH_fixation_hexa.py @@ -13,20 +13,16 @@ idcomp = SMESH_fixation.idcomp geompy = SMESH_fixation.geompy salome = SMESH_fixation.salome -ShapeTypeShell = 3 -ShapeTypeFace = 4 -ShapeTypeEdge = 6 - print "Analysis of the geometry to be meshed :" -subShellList=geompy.SubShapeAll(compshell,ShapeTypeShell) -subFaceList=geompy.SubShapeAll(compshell,ShapeTypeFace) -subEdgeList=geompy.SubShapeAll(compshell,ShapeTypeEdge) +subShellList = geompy.SubShapeAll(compshell, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(compshell, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(compshell, geompy.ShapeType["EDGE"]) -print "number of Shells in compshell : ",len(subShellList) -print "number of Faces in compshell : ",len(subFaceList) -print "number of Edges in compshell : ",len(subEdgeList) +print "number of Shells in compshell : ", len(subShellList) +print "number of Faces in compshell : ", len(subFaceList) +print "number of Edges in compshell : ", len(subEdgeList) -status=geompy.CheckShape(compshell) +status = geompy.CheckShape(compshell) print " check status ", status ### ---------------------------- SMESH -------------------------------------- @@ -35,15 +31,13 @@ smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") smeshgui = salome.ImportComponentGUI("SMESH") smeshgui.Init(salome.myStudyId) -### ---- create Hypothesis - print "-------------------------- create Hypothesis" print "-------------------------- NumberOfSegments" numberOfSegments = 5 -hypNbSeg=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") +hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") hypNbSeg.SetNumberOfSegments(numberOfSegments) print hypNbSeg.GetName() @@ -52,37 +46,33 @@ print hypNbSeg.GetNumberOfSegments() smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_5") -# ---- create Algorithms - print "-------------------------- create Algorithms" print "-------------------------- Regular_1D" -regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so") +regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so") smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation") print "-------------------------- Quadrangle_2D" -quad2D=smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so") +quad2D = smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so") smeshgui.SetName(salome.ObjectToID(quad2D), "Quadrangle_2D") print "-------------------------- Hexa_3D" -hexa3D=smesh.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so") +hexa3D = smesh.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so") smeshgui.SetName(salome.ObjectToID(hexa3D), "Hexa_3D") # ---- init a Mesh with the compshell shape_mesh = salome.IDToObject( idcomp ) -mesh=smesh.CreateMesh(shape_mesh) +mesh = smesh.CreateMesh(shape_mesh) smeshgui.SetName(salome.ObjectToID(mesh), "MeshCompShell") -# ---- add hypothesis to compshell - print "-------------------------- add hypothesis to compshell" mesh.AddHypothesis(shape_mesh,regular1D) @@ -94,10 +84,10 @@ mesh.AddHypothesis(shape_mesh,hexa3D) salome.sg.updateObjBrowser(1) print "-------------------------- compute compshell" -ret=smesh.Compute(mesh, shape_mesh) +ret = smesh.Compute(mesh, shape_mesh) print ret if ret != 0: - log=mesh.GetLog(0) # no erase trace + log = mesh.GetLog(0) # no erase trace for linelog in log: print linelog print "Information about the MeshcompShel:" diff --git a/src/SMESH_SWIG/SMESH_fixation_tetra.py b/src/SMESH_SWIG/SMESH_fixation_tetra.py index d429fe958..2d588bbd9 100644 --- a/src/SMESH_SWIG/SMESH_fixation_tetra.py +++ b/src/SMESH_SWIG/SMESH_fixation_tetra.py @@ -13,20 +13,16 @@ idcomp = SMESH_fixation.idcomp geompy = SMESH_fixation.geompy salome = SMESH_fixation.salome -ShapeTypeShell = 3 -ShapeTypeFace = 4 -ShapeTypeEdge = 6 - print "Analysis of the geometry to be meshed :" -subShellList=geompy.SubShapeAll(compshell,ShapeTypeShell) -subFaceList=geompy.SubShapeAll(compshell,ShapeTypeFace) -subEdgeList=geompy.SubShapeAll(compshell,ShapeTypeEdge) +subShellList = geompy.SubShapeAll(compshell, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(compshell, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(compshell, geompy.ShapeType["EDGE"]) -print "number of Shells in compshell : ",len(subShellList) -print "number of Faces in compshell : ",len(subFaceList) -print "number of Edges in compshell : ",len(subEdgeList) +print "number of Shells in compshell : ", len(subShellList) +print "number of Faces in compshell : ", len(subFaceList) +print "number of Edges in compshell : ", len(subEdgeList) -status=geompy.CheckShape(compshell) +status = geompy.CheckShape(compshell) print " check status ", status ### ---------------------------- SMESH -------------------------------------- @@ -35,15 +31,13 @@ smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") smeshgui = salome.ImportComponentGUI("SMESH") smeshgui.Init(salome.myStudyId) -### ---- create Hypothesis - print "-------------------------- create Hypothesis" print "-------------------------- NumberOfSegments" numberOfSegments = 5 -hypNbSeg=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") +hypNbSeg = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") hypNbSeg.SetNumberOfSegments(numberOfSegments) print hypNbSeg.GetName() @@ -62,7 +56,8 @@ print "-------------------------- MaxElementArea" ## print hypArea.GetId() ## print hypArea.GetMaxElementArea() ## smeshgui.SetName(salome.ObjectToID(hypArea), "MaxElementArea_160") -hypLengthFromEdges=smesh.CreateHypothesis("LengthFromEdges", "libStdMeshersEngine.so") + +hypLengthFromEdges = smesh.CreateHypothesis("LengthFromEdges", "libStdMeshersEngine.so") smeshgui.SetName(salome.ObjectToID(hypLengthFromEdges), "LengthFromEdges") @@ -70,7 +65,7 @@ print "-------------------------- MaxElementVolume" maxElementVolume = 1000 -hypVolume=smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so") +hypVolume = smesh.CreateHypothesis("MaxElementVolume", "libStdMeshersEngine.so") hypVolume.SetMaxElementVolume(maxElementVolume) print hypVolume.GetName() @@ -79,35 +74,31 @@ print hypVolume.GetMaxElementVolume() smeshgui.SetName(salome.ObjectToID(hypVolume), "MaxElementVolume_1000") -# ---- create Algorithms - print "-------------------------- create Algorithms" print "-------------------------- Regular_1D" -regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so") +regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so") smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation") print "-------------------------- MEFISTO_2D" -mefisto2D=smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so") +mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so") smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D") print "-------------------------- NETGEN_3D" -netgen3D=smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so") +netgen3D = smesh.CreateHypothesis("NETGEN_3D", "libNETGENEngine.so") smeshgui.SetName(salome.ObjectToID(netgen3D), "NETGEN_3D") # ---- init a Mesh with the compshell -mesh=smesh.CreateMesh(compshell) +mesh = smesh.CreateMesh(compshell) smeshgui.SetName(salome.ObjectToID(mesh), "MeshcompShel") -# ---- add hypothesis to compshell - print "-------------------------- add hypothesis to compshell" mesh.AddHypothesis(compshell,regular1D) @@ -122,10 +113,10 @@ mesh.AddHypothesis(compshell,hypVolume) salome.sg.updateObjBrowser(1) print "-------------------------- compute compshell" -ret=smesh.Compute(mesh,compshell) +ret = smesh.Compute(mesh,compshell) print ret if ret != 0: - log=mesh.GetLog(0) # no erase trace + log = mesh.GetLog(0) # no erase trace for linelog in log: print linelog print "Information about the MeshcompShel:" diff --git a/src/SMESH_SWIG/SMESH_flight_skin.py b/src/SMESH_SWIG/SMESH_flight_skin.py index 6165621b9..fa3b8ef12 100644 --- a/src/SMESH_SWIG/SMESH_flight_skin.py +++ b/src/SMESH_SWIG/SMESH_flight_skin.py @@ -7,93 +7,83 @@ import os import salome import geompy - import StdMeshers -geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") smeshgui = salome.ImportComponentGUI("SMESH") -smeshgui.Init(salome.myStudyId); +smeshgui.Init(salome.myStudyId) # ---------------------------- GEOM -------------------------------------- -ShapeTypeShell = 3 -ShapeTypeFace = 4 -ShapeTypeEdge = 6 - # import a BRep #before running this script, please be sure about #the path the file fileName -filePath=os.environ["SMESH_ROOT_DIR"] -filePath=filePath+"/share/salome/resources/" +filePath = os.environ["SMESH_ROOT_DIR"] +filePath = filePath + "/share/salome/resources/" filename = "flight_solid.brep" filename = filePath + filename -shape = geompy.ImportBREP(filename) -idShape = geompy.addToStudy(shape,"flight") +shape = geompy.Import(filename, "BREP") +idShape = geompy.addToStudy(shape, "flight") print "Analysis of the geometry flight :" -subShellList=geompy.SubShapeAll(shape,ShapeTypeShell) -subFaceList=geompy.SubShapeAll(shape,ShapeTypeFace) -subEdgeList=geompy.SubShapeAll(shape,ShapeTypeEdge) +subShellList = geompy.SubShapeAll(shape, geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(shape, geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(shape, geompy.ShapeType["EDGE"]) -print "number of Shells in flight : ",len(subShellList) -print "number of Faces in flight : ",len(subFaceList) -print "number of Edges in flight : ",len(subEdgeList) +print "number of Shells in flight : ", len(subShellList) +print "number of Faces in flight : ", len(subFaceList) +print "number of Edges in flight : ", len(subEdgeList) ### ---------------------------- SMESH -------------------------------------- -# ---- create Hypothesis - print "-------------------------- create Hypothesis" print "-------------------------- LocalLength" lengthOfSegments = 0.3 -hypLength=smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so") +hypLength = smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so") hypLength.SetLength(lengthOfSegments) print hypLength.GetName() -print hypLength.GetId() +print hypLength.GetId() print hypLength.GetLength() smeshgui.SetName(salome.ObjectToID(hypLength), "LocalLength_0.3") print "-------------------------- LengthFromEdges" -hypLengthFromEdge=smesh.CreateHypothesis("LengthFromEdges", "libStdMeshersEngine.so") +hypLengthFromEdge = smesh.CreateHypothesis("LengthFromEdges", "libStdMeshersEngine.so") print hypLengthFromEdge.GetName() print hypLengthFromEdge.GetId() smeshgui.SetName(salome.ObjectToID(hypLengthFromEdge), "LengthFromEdge") -# ---- create Algorithms - print "-------------------------- create Algorithms" print "-------------------------- Regular_1D" -regular1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so") +regular1D = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so") smeshgui.SetName(salome.ObjectToID(regular1D), "Wire Discretisation") print "-------------------------- MEFISTO_2D" -mefisto2D=smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so") +mefisto2D = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so") smeshgui.SetName(salome.ObjectToID(mefisto2D), "MEFISTO_2D") # ---- init a Mesh with the shell shape_mesh = salome.IDToObject( idShape ) -mesh=smesh.CreateMesh(shape_mesh) +mesh = smesh.CreateMesh(shape_mesh) smeshgui.SetName(salome.ObjectToID(mesh), "MeshFlight") # ---- add hypothesis to flight @@ -109,10 +99,10 @@ salome.sg.updateObjBrowser(1) print "-------------------------- compute the skin flight" -ret=smesh.Compute(mesh,shape_mesh) +ret = smesh.Compute(mesh,shape_mesh) print ret if ret != 0: - log=mesh.GetLog(0) # no erase trace + log = mesh.GetLog(0) # no erase trace for linelog in log: print linelog print "Information about the Mesh_mechanic_tetra:" diff --git a/src/SMESH_SWIG/SMESH_freebord.py b/src/SMESH_SWIG/SMESH_freebord.py index d24e34070..d240a354f 100644 --- a/src/SMESH_SWIG/SMESH_freebord.py +++ b/src/SMESH_SWIG/SMESH_freebord.py @@ -1,34 +1,22 @@ import salome -from geompy import gg import geompy import SMESH - import StdMeshers -ShapeTypeCompSolid = 1 -ShapeTypeSolid = 2 -ShapeTypeShell = 3 -ShapeTypeFace = 4 -ShapeTypeWire = 5 -ShapeTypeEdge = 6 -ShapeTypeVertex = 7 - -geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") - -geom.GetCurrentStudy(salome.myStudy._get_StudyId()) smesh.SetCurrentStudy(salome.myStudy) # Create box without one plane box = geompy.MakeBox(0., 0., 0., 10., 20., 30.) -subShapeList = geompy.SubShapeAll(box,ShapeTypeFace) +subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) FaceList = [] for i in range( 5 ): - FaceList.append( subShapeList[ i ]._get_Name() ) + FaceList.append( subShapeList[ i ] ) -aBox = geompy.MakeSewing( FaceList, 1. ) +aComp = geompy.MakeCompound( FaceList ) +aBox = geompy.Sew( aComp, 1. ) idbox = geompy.addToStudy( aBox, "box" ) aBox = salome.IDToObject( idbox ) diff --git a/src/SMESH_SWIG/SMESH_mechanic.py b/src/SMESH_SWIG/SMESH_mechanic.py index 3011c0c82..7c1fdbd22 100644 --- a/src/SMESH_SWIG/SMESH_mechanic.py +++ b/src/SMESH_SWIG/SMESH_mechanic.py @@ -1,21 +1,21 @@ # 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org # # # @@ -24,44 +24,30 @@ # Module : SMESH # $Header$ +#------------------------------------------------------------------------- + import salome import geompy -geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") -smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") - -geom.GetCurrentStudy(salome.myStudy._get_StudyId()) -smesh.SetCurrentStudy(salome.myStudy) - -smeshgui = salome.ImportComponentGUI("SMESH") -smeshgui.Init(salome.myStudyId); - import StdMeshers # ---------------------------- GEOM -------------------------------------- -ShapeTypeCompSolid = 1 -ShapeTypeSolid = 2 -ShapeTypeShell = 3 -ShapeTypeFace = 4 -ShapeTypeWire = 5 -ShapeTypeEdge = 6 -ShapeTypeVertex = 7 # ---- define contigous arcs and segment to define a closed wire -p1 = geom.MakePointStruct( 100.0, 0.0, 0.0 ) -p2 = geom.MakePointStruct( 50.0, 50.0, 0.0 ) -p3 = geom.MakePointStruct( 100.0, 100.0, 0.0 ) -arc1 = geom.MakeArc( p1, p2, p3 ) +p1 = geompy.MakeVertex( 100.0, 0.0, 0.0 ) +p2 = geompy.MakeVertex( 50.0, 50.0, 0.0 ) +p3 = geompy.MakeVertex( 100.0, 100.0, 0.0 ) +arc1 = geompy.MakeArc( p1, p2, p3 ) -p4 = geom.MakePointStruct( 170.0, 100.0, 0.0 ) -seg1 = geom.MakeVector( p3, p4 ) +p4 = geompy.MakeVertex( 170.0, 100.0, 0.0 ) +seg1 = geompy.MakeVector( p3, p4 ) -p5 = geom.MakePointStruct( 200.0, 70.0, 0.0 ) -p6 = geom.MakePointStruct( 170.0, 40.0, 0.0 ) -arc2 = geom.MakeArc( p4, p5, p6 ) +p5 = geompy.MakeVertex( 200.0, 70.0, 0.0 ) +p6 = geompy.MakeVertex( 170.0, 40.0, 0.0 ) +arc2 = geompy.MakeArc( p4, p5, p6 ) -p7 = geom.MakePointStruct( 120.0, 30.0, 0.0 ) -arc3 = geom.MakeArc( p6, p7, p1 ) +p7 = geompy.MakeVertex( 120.0, 30.0, 0.0 ) +arc3 = geompy.MakeArc( p6, p7, p1 ) # ---- define a closed wire with arcs and segment List1 = [] @@ -70,225 +56,202 @@ List1.append( seg1 ) List1.append( arc2 ) List1.append( arc3 ) -ListIOR1 = [] -for S in List1 : - ListIOR1.append( S._get_Name() ) -wire1 = geom.MakeWire( ListIOR1 ) - -Id_wire1 = geompy.addToStudy( wire1, "wire1") +wire1 = geompy.MakeWire( List1 ) +Id_wire1 = geompy.addToStudy( wire1, "wire1" ) # ---- define a planar face with wire WantPlanarFace = 1 #True -face1 = geom.MakeFace( wire1, WantPlanarFace ) -Id_face1 = geompy.addToStudy( face1, "face1") +face1 = geompy.MakeFace( wire1, WantPlanarFace ) +Id_face1 = geompy.addToStudy( face1, "face1" ) # ---- create a shape by extrusion -pO = geom.MakePointStruct( 0.0, 0.0, 0.0 ) -pz = geom.MakePointStruct( 0.0, 0.0, 100.0 ) +pO = geompy.MakeVertex( 0.0, 0.0, 0.0 ) +pz = geompy.MakeVertex( 0.0, 0.0, 100.0 ) +vz = geompy.MakeVector( pO, pz ) -prism1 = geom.MakePrism( face1, pO, pz ) -Id_prism1 = geompy.addToStudy( prism1, "prism1") +prism1 = geompy.MakePrismVecH( face1, vz, 100.0 ) +Id_prism1 = geompy.addToStudy( prism1, "prism1" ) # ---- create two cylinders +pc1 = geompy.MakeVertex( 90.0, 50.0, -40.0 ) +pc2 = geompy.MakeVertex( 170.0, 70.0, -40.0 ) -pc1 = geom.MakePointStruct( 90.0, 50.0, -40.0 ) -pc2 = geom.MakePointStruct( 170.0, 70.0, -40.0 ) -vz = geom.MakeDirection( pz ) radius = 20.0 height = 180.0 -cyl1 = geom.MakeCylinder( pc1, vz, radius, height ) -cyl2 = geom.MakeCylinder( pc2, vz, radius, height ) +cyl1 = geompy.MakeCylinder( pc1, vz, radius, height ) +cyl2 = geompy.MakeCylinder( pc2, vz, radius, height ) Id_Cyl1 = geompy.addToStudy( cyl1, "cyl1" ) Id_Cyl2 = geompy.addToStudy( cyl2, "cyl2" ) -# ---- cut with cyl1 -shape = geom.MakeBoolean( prism1, cyl1, 2 ) +# ---- cut with cyl1 +shape = geompy.MakeBoolean( prism1, cyl1, 2 ) -# ---- fuse with cyl2 -shape1 = geom.MakeBoolean( shape, cyl2, 3 ) +# ---- fuse with cyl2 to obtain the final mechanic piece :) +mechanic = geompy.MakeBoolean( shape, cyl2, 3 ) +Id_mechanic = geompy.addToStudy( mechanic, "mechanic" ) -Id_shape1 = geompy.addToStudy( shape1, "shape1") +# ---- explode on faces +SubFaceL = geompy.SubShapeAllSorted(mechanic, geompy.ShapeType["FACE"]) -#faces = geompy.SubShapeAllSorted( shape1, ShapeTypeFace) -#i = 0 -#for face in faces: -# geompy.addToStudy(face,"face_" + str(i)) -# i = i+1 - # ---- add a face sub shape in study to be meshed different -IdSubFaceList = [] -IdSubFaceList.append(1) -sub_face = geompy.SubShapeSorted( shape1, ShapeTypeFace, IdSubFaceList ) -name = geompy.SubShapeName( sub_face._get_Name(), shape1._get_Name() ) +sub_face1 = SubFaceL[0] +name = geompy.SubShapeName( sub_face1, mechanic ) -Id_SubFace = geompy.addToStudyInFather( shape1, sub_face, name ) +Id_SubFace1 = geompy.addToStudyInFather( mechanic, sub_face1, name ) # ---- add a face sub shape in study to be meshed different -IdSubFaceL = [] -IdSubFaceL.append(2) -sub_face2 = geompy.SubShapeSorted( shape1, ShapeTypeFace, IdSubFaceL ) -name = geompy.SubShapeName( sub_face2._get_Name(), shape1._get_Name() ) +sub_face2 = SubFaceL[4] +name = geompy.SubShapeName( sub_face2, mechanic ) -Id_SubFace2 = geompy.addToStudyInFather( shape1, sub_face2, name ) +Id_SubFace2 = geompy.addToStudyInFather( mechanic, sub_face2, name ) # ---- add a face sub shape in study to be meshed different -IdSubFaceL = [] -IdSubFaceL.append(3) -sub_face3 = geompy.SubShapeSorted( shape1, ShapeTypeFace, IdSubFaceL ) -name = geompy.SubShapeName( sub_face3._get_Name(), shape1._get_Name() ) +sub_face3 = SubFaceL[5] +name = geompy.SubShapeName( sub_face3, mechanic ) -Id_SubFace3 = geompy.addToStudyInFather( shape1, sub_face3, name ) +Id_SubFace3 = geompy.addToStudyInFather( mechanic, sub_face3, name ) # ---- add a face sub shape in study to be meshed different -IdSubFaceL = [] -IdSubFaceL.append(6) -sub_face4 = geompy.SubShapeSorted( shape1, ShapeTypeFace, IdSubFaceL ) -name = geompy.SubShapeName( sub_face4._get_Name(), shape1._get_Name() ) - -Id_SubFace4 = geompy.addToStudyInFather( shape1, sub_face4, name ) +sub_face4 = SubFaceL[10] +name = geompy.SubShapeName( sub_face4, mechanic ) +Id_SubFace4 = geompy.addToStudyInFather( mechanic, sub_face4, name ) # ---------------------------- SMESH -------------------------------------- -# ------------------------------ Length Hypothesis +# ---- launch SMESH, init a Mesh with shape 'mechanic' -print "-------------------------- create Hypothesis" -print "-------------------------- LocalLength" -hyp1 = smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so") -hyp1.SetLength( 100.0 ) -print hyp1.GetName() -print hyp1.GetId() -print hyp1.GetLength() +smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") -idlength = salome.ObjectToID(hyp1) -smeshgui.SetName(idlength, "Local_Length_100"); +# -- Init -- +shape_mesh = salome.IDToObject( Id_mechanic ) +smesh.SetCurrentStudy(salome.myStudy) + +mesh = smesh.CreateMesh(shape_mesh) + +smeshgui = salome.ImportComponentGUI("SMESH") +smeshgui.Init(salome.myStudyId) + +idmesh = salome.ObjectToID(mesh) +smeshgui.SetName( idmesh, "Mesh_mechanic" ) print "-------------------------- NumberOfSegments" -hyp2 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") -hyp2.SetNumberOfSegments( 10 ) -print hyp2.GetName() -print hyp2.GetId() -print hyp2.GetNumberOfSegments() +numberOfSegment = 10 + +hypNbSeg = smesh.CreateHypothesis( "NumberOfSegments", "libStdMeshersEngine.so" ) +hypNbSeg.SetNumberOfSegments( numberOfSegment ) +print hypNbSeg.GetName() +print hypNbSeg.GetId() +print hypNbSeg.GetNumberOfSegments() -idseg = salome.ObjectToID(hyp2) -smeshgui.SetName(idseg, "NumberOfSegments_12"); +smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10") print "-------------------------- MaxElementArea" -hyp3 = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" ) -hyp3.SetMaxElementArea( 25 ) -print hyp3.GetName() -print hyp3.GetId() -print hyp3.GetMaxElementArea() +maxElementArea = 25 -idarea1 = salome.ObjectToID(hyp3) -smeshgui.SetName(idarea1, "MaxElementArea_20"); +hypArea25 = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" ) +hypArea25.SetMaxElementArea( maxElementArea ) +print hypArea25.GetName() +print hypArea25.GetId() +print hypArea25.GetMaxElementArea() + +smeshgui.SetName(salome.ObjectToID(hypArea25), "MaxElementArea_25") print "-------------------------- MaxElementArea" -hyp4 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so") -hyp4.SetMaxElementArea( 35 ) -print hyp4.GetName() -print hyp4.GetId() -print hyp4.GetMaxElementArea() +maxElementArea = 35 -idarea2 = salome.ObjectToID(hyp4) -smeshgui.SetName(idarea2, "MaxElementArea_30"); +hypArea35 = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" ) +hypArea35.SetMaxElementArea( maxElementArea ) +print hypArea35.GetName() +print hypArea35.GetId() +print hypArea35.GetMaxElementArea() +smeshgui.SetName(salome.ObjectToID(hypArea35), "MaxElementArea_35") print "-------------------------- Regular_1D" -alg1 = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so") -listHyp =alg1.GetCompatibleHypothesis() +algoReg1D = smesh.CreateHypothesis( "Regular_1D", "libStdMeshersEngine.so" ) +listHyp = algoReg1D.GetCompatibleHypothesis() for hyp in listHyp: print hyp -print alg1.GetName() -print alg1.GetId() +print algoReg1D.GetName() +print algoReg1D.GetId() -idreg1d = salome.ObjectToID(alg1) -smeshgui.SetName( idreg1d, "Regular_1D" ); +smeshgui.SetName(salome.ObjectToID(algoReg1D), "Regular_1D") print "-------------------------- MEFISTO_2D" -alg2 = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so") -listHyp = alg2.GetCompatibleHypothesis() +algoMef = smesh.CreateHypothesis( "MEFISTO_2D", "libStdMeshersEngine.so" ) +listHyp = algoMef.GetCompatibleHypothesis() for hyp in listHyp: print hyp -print alg2.GetName() -print alg2.GetId() +print algoMef.GetName() +print algoMef.GetId() -idmef = salome.ObjectToID(alg2) -smeshgui.SetName( idmef, "MEFISTO_2D" ); +smeshgui.SetName(salome.ObjectToID(algoMef), "MEFISTO_2D") print "-------------------------- SMESH_Quadrangle_2D" -alg3 = smesh.CreateHypothesis( "Quadrangle_2D", "libStdMeshersEngine.so" ) -listHyp = alg3.GetCompatibleHypothesis() +algoQuad = smesh.CreateHypothesis( "Quadrangle_2D", "libStdMeshersEngine.so" ) +listHyp = algoQuad.GetCompatibleHypothesis() for hyp in listHyp: print hyp -print alg3.GetName() -print alg3.GetId() - -idqad2 = salome.ObjectToID(alg3) -smeshgui.SetName( idqad2, "SMESH_Quadrangle_2D" ); - +print algoQuad.GetName() +print algoQuad.GetId() -print "-------------------------- add hypothesis to main shape1" +smeshgui.SetName(salome.ObjectToID(algoQuad), "SMESH_Quadrangle_2D") -shape_mesh = salome.IDToObject( Id_shape1 ) +print "-------------------------- add hypothesis to main shape" -mesh = smesh.CreateMesh(shape_mesh) - -idmesh = salome.ObjectToID(mesh) -smeshgui.SetName( idmesh, "Mesh_mechanic" ); +mesh.AddHypothesis( shape_mesh, hypNbSeg ) # nb segments +mesh.AddHypothesis( shape_mesh, hypArea25 ) # max area -mesh.AddHypothesis( shape_mesh, alg1 ) # Regular 1D/wire discretisation -mesh.AddHypothesis( shape_mesh, alg2 ) # MEFISTO 2D +mesh.AddHypothesis( shape_mesh, algoReg1D ) # Regular 1D/wire discretisation +mesh.AddHypothesis( shape_mesh, algoMef ) # MEFISTO 2D -ret = mesh.AddHypothesis( shape_mesh, hyp2 ) # nb segments -ret = mesh.AddHypothesis( shape_mesh, hyp3 ) # max area +print "-------------------------- add hypothesis and algorithm to sub face 1" -print "--------Add hypothesis and algorith to sub face" +submesh = mesh.GetSubMesh(sub_face1, "SubMeshFace1") -#sub_face = salome.IDToObject( Id_SubFace ) -submesh = mesh.GetSubMesh(sub_face, "SubMeshFace") +mesh.AddHypothesis( sub_face1, algoQuad ) # Quadrangle 2D +mesh.AddHypothesis( sub_face1, hypArea35 ) # max area -mesh.AddHypothesis( sub_face, alg3 ) # Quadrangle 2D -mesh.AddHypothesis( sub_face, hyp4 ) # max area +print "-------------------------- add hypothesis and algorithm to sub face 2" -print "--------Add hypothesis and algorith to sub face 2" +submesh = mesh.GetSubMesh(sub_face2, "SubMeshFace2") -#sub_face2 = salome.IDToObject( Id_SubFace2 ) -submesh = mesh.GetSubMesh(sub_face2, "SubMeshFace2") +mesh.AddHypothesis( sub_face2, algoQuad ) # Quadrangle 2D +mesh.AddHypothesis( sub_face2, hypArea35 ) # max area -mesh.AddHypothesis( sub_face2, alg3 ) # Quadrangle 2D -ret = mesh.AddHypothesis( sub_face2, hyp4 ) # max area +print "-------------------------- add hypothesis and algorith to sub face 3" -print "--------Add hypothesis and algorith to sub face 3" +submesh = mesh.GetSubMesh(sub_face3, "SubMeshFace3") -#sub_face3 = salome.IDToObject( Id_SubFace3 ) -submesh = mesh.GetSubMesh(sub_face3, "SubMeshFace3") +mesh.AddHypothesis( sub_face3, algoQuad ) # Quadrangle 2D +mesh.AddHypothesis( sub_face3, hypArea35 ) # max area -mesh.AddHypothesis( sub_face3, alg3 ) # Quadrangle 2D -ret = mesh.AddHypothesis( sub_face3, hyp4 ) # max area +print "-------------------------- add hypothesis and algorith to sub face 4" -print "--------Add hypothesis and algorith to sub face 4" +submesh = mesh.GetSubMesh(sub_face4, "SubMeshFace4") -#sub_face4 = salome.IDToObject( Id_SubFace4 ) -submesh = mesh.GetSubMesh(sub_face4, "SubMeshFace4") +mesh.AddHypothesis( sub_face4, algoQuad ) # Quadrangle 2D +mesh.AddHypothesis( sub_face4, hypArea35 ) # max area -mesh.AddHypothesis( sub_face4, alg3 ) # Quadrangle 2D -ret = mesh.AddHypothesis( sub_face4, hyp4 ) # max area +print "-------------------------- compute the mesh of the mechanic piece" -smesh.Compute(mesh,shape_mesh) +smesh.Compute(mesh, shape_mesh) print "Information about the Mesh_mechanic:" -print "Number of nodes : ", mesh.NbNodes() -print "Number of edges : ", mesh.NbEdges() -print "Number of faces : ", mesh.NbFaces() -print "Number of triangles : ", mesh.NbTriangles() -print "Number of quadrangles: ", mesh.NbQuadrangles() - -salome.sg.updateObjBrowser(1); +print "Number of nodes : ", mesh.NbNodes() +print "Number of edges : ", mesh.NbEdges() +print "Number of faces : ", mesh.NbFaces() +print "Number of triangles : ", mesh.NbTriangles() +print "Number of quadrangles : ", mesh.NbQuadrangles() +print "Number of volumes : ", mesh.NbVolumes() +print "Number of tetrahedrons: ", mesh.NbTetras() + +salome.sg.updateObjBrowser(1) diff --git a/src/SMESH_SWIG/SMESH_mechanic_editor.py b/src/SMESH_SWIG/SMESH_mechanic_editor.py new file mode 100644 index 000000000..596786ed9 --- /dev/null +++ b/src/SMESH_SWIG/SMESH_mechanic_editor.py @@ -0,0 +1,308 @@ +# 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : SMESH_withHole.py +# Author : Lucien PIGNOLONI +# Module : SMESH +# $Header$ + +#------------------------------------------------------------------------- + +import salome +import geompy + +import StdMeshers + +import SMESH + +# ---------------------------- GEOM -------------------------------------- + +# ---- define contigous arcs and segment to define a closed wire +p1 = geompy.MakeVertex( 100.0, 0.0, 0.0 ) +p2 = geompy.MakeVertex( 50.0, 50.0, 0.0 ) +p3 = geompy.MakeVertex( 100.0, 100.0, 0.0 ) +arc1 = geompy.MakeArc( p1, p2, p3 ) + +p4 = geompy.MakeVertex( 170.0, 100.0, 0.0 ) +seg1 = geompy.MakeVector( p3, p4 ) + +p5 = geompy.MakeVertex( 200.0, 70.0, 0.0 ) +p6 = geompy.MakeVertex( 170.0, 40.0, 0.0 ) +arc2 = geompy.MakeArc( p4, p5, p6 ) + +p7 = geompy.MakeVertex( 120.0, 30.0, 0.0 ) +arc3 = geompy.MakeArc( p6, p7, p1 ) + +# ---- define a closed wire with arcs and segment +List1 = [] +List1.append( arc1 ) +List1.append( seg1 ) +List1.append( arc2 ) +List1.append( arc3 ) + +wire1 = geompy.MakeWire( List1 ) +Id_wire1 = geompy.addToStudy( wire1, "wire1" ) + +# ---- define a planar face with wire +WantPlanarFace = 1 #True +face1 = geompy.MakeFace( wire1, WantPlanarFace ) +Id_face1 = geompy.addToStudy( face1, "face1" ) + +# ---- create a shape by extrusion +pO = geompy.MakeVertex( 0.0, 0.0, 0.0 ) +pz = geompy.MakeVertex( 0.0, 0.0, 100.0 ) +vz = geompy.MakeVector( pO, pz ) + +prism1 = geompy.MakePrismVecH( face1, vz, 100.0 ) +Id_prism1 = geompy.addToStudy( prism1, "prism1" ) + +# ---- create two cylinders +pc1 = geompy.MakeVertex( 90.0, 50.0, -40.0 ) +pc2 = geompy.MakeVertex( 170.0, 70.0, -40.0 ) + +radius = 20.0 +height = 180.0 +cyl1 = geompy.MakeCylinder( pc1, vz, radius, height ) +cyl2 = geompy.MakeCylinder( pc2, vz, radius, height ) + +Id_Cyl1 = geompy.addToStudy( cyl1, "cyl1" ) +Id_Cyl2 = geompy.addToStudy( cyl2, "cyl2" ) + +# ---- cut with cyl1 +shape = geompy.MakeBoolean( prism1, cyl1, 2 ) + +# ---- fuse with cyl2 to obtain the final mechanic piece :) +mechanic = geompy.MakeBoolean( shape, cyl2, 3 ) +Id_mechanic = geompy.addToStudy( mechanic, "mechanic" ) + +# ---- explode on faces +SubFaceL = geompy.SubShapeAllSorted(mechanic, geompy.ShapeType["FACE"]) + +# ---- add a face sub shape in study to be meshed different +sub_face1 = SubFaceL[0] +name = geompy.SubShapeName( sub_face1, mechanic ) + +Id_SubFace1 = geompy.addToStudyInFather( mechanic, sub_face1, name ) + +# ---- add a face sub shape in study to be meshed different +sub_face2 = SubFaceL[4] +name = geompy.SubShapeName( sub_face2, mechanic ) + +Id_SubFace2 = geompy.addToStudyInFather( mechanic, sub_face2, name ) + +# ---- add a face sub shape in study to be meshed different +sub_face3 = SubFaceL[5] +name = geompy.SubShapeName( sub_face3, mechanic ) + +Id_SubFace3 = geompy.addToStudyInFather( mechanic, sub_face3, name ) + +# ---- add a face sub shape in study to be meshed different +sub_face4 = SubFaceL[10] +name = geompy.SubShapeName( sub_face4, mechanic ) + +Id_SubFace4 = geompy.addToStudyInFather( mechanic, sub_face4, name ) + +# ---------------------------- SMESH -------------------------------------- + +# ---- launch SMESH, init a Mesh with shape 'mechanic' + +smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") + +# -- Init -- +shape_mesh = salome.IDToObject( Id_mechanic ) +smesh.SetCurrentStudy(salome.myStudy) + +mesh = smesh.CreateMesh(shape_mesh) + +smeshgui = salome.ImportComponentGUI("SMESH") +smeshgui.Init(salome.myStudyId) + +idmesh = salome.ObjectToID(mesh) +smeshgui.SetName( idmesh, "Mesh_mechanic" ) + +print "-------------------------- NumberOfSegments" + +numberOfSegment = 10 + +hypNbSeg = smesh.CreateHypothesis( "NumberOfSegments", "libStdMeshersEngine.so" ) +hypNbSeg.SetNumberOfSegments( numberOfSegment ) +print hypNbSeg.GetName() +print hypNbSeg.GetId() +print hypNbSeg.GetNumberOfSegments() + +smeshgui.SetName(salome.ObjectToID(hypNbSeg), "NumberOfSegments_10") + +print "-------------------------- MaxElementArea" + +maxElementArea = 25 + +hypArea25 = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" ) +hypArea25.SetMaxElementArea( maxElementArea ) +print hypArea25.GetName() +print hypArea25.GetId() +print hypArea25.GetMaxElementArea() + +smeshgui.SetName(salome.ObjectToID(hypArea25), "MaxElementArea_25") + +print "-------------------------- MaxElementArea" + +maxElementArea = 35 + +hypArea35 = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" ) +hypArea35.SetMaxElementArea( maxElementArea ) +print hypArea35.GetName() +print hypArea35.GetId() +print hypArea35.GetMaxElementArea() + +smeshgui.SetName(salome.ObjectToID(hypArea35), "MaxElementArea_35") + +print "-------------------------- Regular_1D" + +algoReg1D = smesh.CreateHypothesis( "Regular_1D", "libStdMeshersEngine.so" ) +listHyp = algoReg1D.GetCompatibleHypothesis() +for hyp in listHyp: + print hyp +print algoReg1D.GetName() +print algoReg1D.GetId() + +smeshgui.SetName(salome.ObjectToID(algoReg1D), "Regular_1D") + +print "-------------------------- MEFISTO_2D" + +algoMef = smesh.CreateHypothesis( "MEFISTO_2D", "libStdMeshersEngine.so" ) +listHyp = algoMef.GetCompatibleHypothesis() +for hyp in listHyp: + print hyp +print algoMef.GetName() +print algoMef.GetId() + +smeshgui.SetName(salome.ObjectToID(algoMef), "MEFISTO_2D") + +print "-------------------------- SMESH_Quadrangle_2D" + +algoQuad = smesh.CreateHypothesis( "Quadrangle_2D", "libStdMeshersEngine.so" ) +listHyp = algoQuad.GetCompatibleHypothesis() +for hyp in listHyp: + print hyp +print algoQuad.GetName() +print algoQuad.GetId() + +smeshgui.SetName(salome.ObjectToID(algoQuad), "SMESH_Quadrangle_2D") + +print "-------------------------- add hypothesis to main shape" + +mesh.AddHypothesis( shape_mesh, hypNbSeg ) # nb segments +mesh.AddHypothesis( shape_mesh, hypArea25 ) # max area + +mesh.AddHypothesis( shape_mesh, algoReg1D ) # Regular 1D/wire discretisation +mesh.AddHypothesis( shape_mesh, algoMef ) # MEFISTO 2D + +print "-------------------------- add hypothesis and algorithm to sub face 1" + +submesh = mesh.GetSubMesh(sub_face1, "SubMeshFace1") + +mesh.AddHypothesis( sub_face1, algoQuad ) # Quadrangle 2D +mesh.AddHypothesis( sub_face1, hypArea35 ) # max area + +print "-------------------------- add hypothesis and algorithm to sub face 2" + +submesh = mesh.GetSubMesh(sub_face2, "SubMeshFace2") + +mesh.AddHypothesis( sub_face2, algoQuad ) # Quadrangle 2D +mesh.AddHypothesis( sub_face2, hypArea35 ) # max area + +print "-------------------------- add hypothesis and algorith to sub face 3" + +submesh = mesh.GetSubMesh(sub_face3, "SubMeshFace3") + +mesh.AddHypothesis( sub_face3, algoQuad ) # Quadrangle 2D +mesh.AddHypothesis( sub_face3, hypArea35 ) # max area + +print "-------------------------- add hypothesis and algorith to sub face 4" + +submesh = mesh.GetSubMesh(sub_face4, "SubMeshFace4") + +mesh.AddHypothesis( sub_face4, algoQuad ) # Quadrangle 2D +mesh.AddHypothesis( sub_face4, hypArea35 ) # max area + +print "-------------------------- compute the mesh of the mechanic piece" + +smesh.Compute(mesh, shape_mesh) + +print "Information about the Mesh_mechanic:" +print "Number of nodes : ", mesh.NbNodes() +print "Number of edges : ", mesh.NbEdges() +print "Number of faces : ", mesh.NbFaces() +print "Number of triangles : ", mesh.NbTriangles() +print "Number of quadrangles : ", mesh.NbQuadrangles() +print "Number of volumes : ", mesh.NbVolumes() +print "Number of tetrahedrons: ", mesh.NbTetras() + + +MeshEditor = mesh.GetMeshEditor() + +#1 cutting of quadrangles of the 'SubMeshFace2' submesh +submesh = mesh.GetSubMesh(sub_face2, "SubMeshFace2") +MeshEditor.SplitQuadObject(submesh, 1) + +#2 cutting of triangles of the group +FacesTriToQuad = [2381, 2382, 2383, 2384, 2385, 2386, 2387, 2388, 2389, 2390, 2391, 2392, 2393, 2394, 2395, 2396, 2397, 2398, 2399, 2400, 2401, 2402, 2403, 2404, 2405, 2406, 2407, 2408, 2409, 2410, 2411, 2412, 2413, 2414, 2415, 2416, 2417, 2418, 2419, 2420, 2421, 2422] +GroupTriToQuad = mesh.CreateGroup(SMESH.FACE,"Group of faces (quad)") +GroupTriToQuad.Add(FacesTriToQuad) +MeshEditor.TriToQuadObject(GroupTriToQuad, None , 1.57) + +#3 extrusion of the group +point = SMESH.PointStruct(0, 0, 5) +vector = SMESH.DirStruct(point) +MeshEditor.ExtrusionSweepObject(GroupTriToQuad, vector, 5) + +#4 mirror object +MeshEditor.MirrorObject(mesh, SMESH.AxisStruct(0, 0, 0, 0, 0, 0), SMESH.SMESH_MeshEditor.POINT, 0) + +#5 mesh translation +point = SMESH.PointStruct(10, 10, 10) +vector = SMESH.DirStruct(point) +MeshEditor.TranslateObject(mesh, vector, 0) + +#6 mesh rotation +axisXYZ = SMESH.AxisStruct(0, 0, 0, 10, 10, 10) +angle180 = 180*3.141/180 +MeshEditor.RotateObject(mesh, axisXYZ, angle180, 0) + +#7 group smoothing +FacesSmooth = [864, 933, 941, 950, 1005, 1013] +GroupSmooth = mesh.CreateGroup(SMESH.FACE,"Group of faces (smooth)") +GroupSmooth.Add(FacesSmooth) +MeshEditor.SmoothObject(GroupSmooth, [], 20, 2, SMESH.SMESH_MeshEditor.CENTROIDAL_SMOOTH) + +#8 rotation sweep object +FacesRotate = [492, 493, 502, 503] +GroupRotate = mesh.CreateGroup(SMESH.FACE,"Group of faces (rotate)") +GroupRotate.Add(FacesRotate) +angle45 = 45*3.141/180 +axisXYZ = SMESH.AxisStruct(-38.3128, -73.3658, -133.321, -13.3402, -13.3265, 6.66632) +MeshEditor.RotationSweepObject(GroupRotate, axisXYZ, angle45, 4, 1e-5) + +#9 reorientation of the whole mesh +submesh = mesh.GetSubMesh(sub_face1, "SubMeshFace1") +MeshEditor.ReorientObject(submesh) + +salome.sg.updateObjBrowser(1) diff --git a/src/SMESH_SWIG/SMESH_mechanic_tetra.py b/src/SMESH_SWIG/SMESH_mechanic_tetra.py index 689614891..eee3f87d8 100644 --- a/src/SMESH_SWIG/SMESH_mechanic_tetra.py +++ b/src/SMESH_SWIG/SMESH_mechanic_tetra.py @@ -1,21 +1,21 @@ # 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org # # # @@ -27,93 +27,83 @@ import salome import geompy -import StdMeshers -import NETGENPlugin - -geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") +geom = geompy.geom smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") +smesh.SetCurrentStudy(salome.myStudy) smeshgui = salome.ImportComponentGUI("SMESH") -smeshgui.Init(salome.myStudyId); +smeshgui.Init(salome.myStudyId) + +import StdMeshers +import NETGENPlugin # ---------------------------- GEOM -------------------------------------- -ShapeTypeCompSolid = 1 -ShapeTypeSolid = 2 -ShapeTypeShell = 3 -ShapeTypeFace = 4 -ShapeTypeWire = 5 -ShapeTypeEdge = 6 -ShapeTypeVertex = 7 # ---- define contigous arcs and segment to define a closed wire +p1 = geompy.MakeVertex( 100.0, 0.0, 0.0 ) +p2 = geompy.MakeVertex( 50.0, 50.0, 0.0 ) +p3 = geompy.MakeVertex( 100.0, 100.0, 0.0 ) +arc1 = geompy.MakeArc( p1, p2, p3 ) -p1 = geom.MakePointStruct( 100.0, 0.0, 0.0 ) -p2 = geom.MakePointStruct( 50.0, 50.0, 0.0 ) -p3 = geom.MakePointStruct( 100.0, 100.0, 0.0 ) -arc1 = geom.MakeArc( p1, p2, p3 ) +p4 = geompy.MakeVertex( 170.0, 100.0, 0.0 ) +seg1 = geompy.MakeVector( p3, p4 ) -p4 = geom.MakePointStruct( 170.0, 100.0, 0.0 ) -seg1 = geom.MakeVector( p3, p4 ) +p5 = geompy.MakeVertex( 200.0, 70.0, 0.0 ) +p6 = geompy.MakeVertex( 170.0, 40.0, 0.0 ) +arc2 = geompy.MakeArc( p4, p5, p6 ) -p5 = geom.MakePointStruct( 200.0, 70.0, 0.0 ) -p6 = geom.MakePointStruct( 170.0, 40.0, 0.0 ) -arc2 = geom.MakeArc( p4, p5, p6 ) - -p7 = geom.MakePointStruct( 120.0, 30.0, 0.0 ) -arc3 = geom.MakeArc( p6, p7, p1 ) +p7 = geompy.MakeVertex( 120.0, 30.0, 0.0 ) +arc3 = geompy.MakeArc( p6, p7, p1 ) # ---- define a closed wire with arcs and segment - List1 = [] List1.append( arc1 ) List1.append( seg1 ) List1.append( arc2 ) List1.append( arc3 ) -ListIOR1 = [] -for S in List1 : - ListIOR1.append( S._get_Name() ) -wire1 = geom.MakeWire( ListIOR1 ) +wire1 = geompy.MakeWire( List1 ) +Id_wire1 = geompy.addToStudy( wire1, "wire1" ) # ---- define a planar face with wire - WantPlanarFace = 1 #True -face1 = geom.MakeFace( wire1, WantPlanarFace ) +face1 = geompy.MakeFace( wire1, WantPlanarFace ) +Id_face1 = geompy.addToStudy( face1, "face1" ) # ---- create a shape by extrusion +pO = geompy.MakeVertex( 0.0, 0.0, 0.0 ) +pz = geompy.MakeVertex( 0.0, 0.0, 100.0 ) +vz = geompy.MakeVector( pO, pz ) -pO = geom.MakePointStruct( 0.0, 0.0, 0.0 ) -pz = geom.MakePointStruct( 0.0, 0.0, 100.0 ) - -prism1 = geom.MakePrism( face1, pO, pz ) +prism1 = geompy.MakePrismVecH( face1, vz, 100.0 ) +Id_prism1 = geompy.addToStudy( prism1, "prism1") # ---- create two cylinders -pc1 = geom.MakePointStruct( 90.0, 50.0, -40.0 ) -pc2 = geom.MakePointStruct( 170.0, 70.0, -40.0 ) -vz = geom.MakeDirection( pz ) +pc1 = geompy.MakeVertex( 90.0, 50.0, -40.0 ) +pc2 = geompy.MakeVertex( 170.0, 70.0, -40.0 ) radius = 20.0 height = 180.0 -cyl1 = geom.MakeCylinder( pc1, vz, radius, height ) -cyl2 = geom.MakeCylinder( pc2, vz, radius, height ) +cyl1 = geompy.MakeCylinder( pc1, vz, radius, height ) +cyl2 = geompy.MakeCylinder( pc2, vz, radius, height ) -# ---- cut with cyl1 +Id_Cyl1 = geompy.addToStudy( cyl1, "cyl1" ) +Id_Cyl2 = geompy.addToStudy( cyl2, "cyl2" ) -shape = geom.MakeBoolean( prism1, cyl1, 2 ) +# ---- cut with cyl1 +shape = geompy.MakeBoolean( prism1, cyl1, 2 ) # ---- fuse with cyl2 to obtain the final mechanic piece :) - -mechanic = geom.MakeBoolean( shape, cyl2, 3 ) - -idMechanic = geompy.addToStudy( mechanic, "mechanic") +mechanic = geompy.MakeBoolean( shape, cyl2, 3 ) +Id_mechanic = geompy.addToStudy( mechanic, "mechanic" ) # ---- Analysis of the geometry print "Analysis of the geometry mechanic :" -subShellList=geompy.SubShapeAll(mechanic,ShapeTypeShell) -subFaceList=geompy.SubShapeAll(mechanic,ShapeTypeFace) -subEdgeList=geompy.SubShapeAll(mechanic,ShapeTypeEdge) +subShellList = geompy.SubShapeAll(mechanic,geompy.ShapeType["SHELL"]) +subFaceList = geompy.SubShapeAll(mechanic,geompy.ShapeType["FACE"]) +subEdgeList = geompy.SubShapeAll(mechanic,geompy.ShapeType["EDGE"]) print "number of Shells in mechanic : ",len(subShellList) print "number of Faces in mechanic : ",len(subFaceList) @@ -126,7 +116,7 @@ print "-------------------------- NumberOfSegments" numberOfSegment = 10 hypNbSeg = smesh.CreateHypothesis( "NumberOfSegments", "libStdMeshersEngine.so" ) -hypNbSeg.SetNumberOfSegments(numberOfSegment) +hypNbSeg.SetNumberOfSegments( numberOfSegment ) print hypNbSeg.GetName() print hypNbSeg.GetId() print hypNbSeg.GetNumberOfSegments() @@ -138,7 +128,7 @@ print "-------------------------- MaxElementArea" maxElementArea = 20 hypArea = smesh.CreateHypothesis( "MaxElementArea", "libStdMeshersEngine.so" ) -hypArea.SetMaxElementArea(maxElementArea) +hypArea.SetMaxElementArea( maxElementArea ) print hypArea.GetName() print hypArea.GetId() print hypArea.GetMaxElementArea() @@ -150,7 +140,7 @@ print "-------------------------- MaxElementVolume" maxElementVolume = 20 hypVolume = smesh.CreateHypothesis( "MaxElementVolume", "libStdMeshersEngine.so" ) -hypVolume.SetMaxElementVolume(maxElementVolume) +hypVolume.SetMaxElementVolume( maxElementVolume ) print hypVolume.GetName() print hypVolume.GetId() print hypVolume.GetMaxElementVolume() @@ -166,7 +156,7 @@ for hyp in listHyp: print algoReg1D.GetName() print algoReg1D.GetId() -smeshgui.SetName(salome.ObjectToID(algoReg1D), "Regular_1D" ) +smeshgui.SetName(salome.ObjectToID(algoReg1D), "Regular_1D") print "-------------------------- MEFISTO_2D" @@ -177,7 +167,7 @@ for hyp in listHyp: print algoMef.GetName() print algoMef.GetId() -smeshgui.SetName(salome.ObjectToID(algoMef), "MEFISTO_2D" ) +smeshgui.SetName(salome.ObjectToID(algoMef), "MEFISTO_2D") print "-------------------------- NETGEN_3D" @@ -188,33 +178,35 @@ for hyp in listHyp: print algoNg.GetName() print algoNg.GetId() -smeshgui.SetName(salome.ObjectToID(algoNg), "NETGEN_3D" ) +smeshgui.SetName(salome.ObjectToID(algoNg), "NETGEN_3D") print "-------------------------- add hypothesis to main mechanic" -shape_mesh = salome.IDToObject( idMechanic ) +shape_mesh = salome.IDToObject( Id_mechanic ) mesh = smesh.CreateMesh(shape_mesh) -smeshgui.SetName(salome.ObjectToID(mesh), "Mesh_mechanic_tetra" ); -mesh.AddHypothesis( shape_mesh, algoReg1D ) # Regular 1D/wire discretisation -mesh.AddHypothesis( shape_mesh, algoMef ) # MEFISTO 2D -mesh.AddHypothesis( shape_mesh, algoNg ) # NETGEN 3D +idmesh = salome.ObjectToID(mesh) +smeshgui.SetName( idmesh, "Mesh_mechanic_tetra" ) mesh.AddHypothesis( shape_mesh, hypNbSeg ) # nb segments mesh.AddHypothesis( shape_mesh, hypArea ) # max area -mesh.AddHypothesis( shape_mesh, hypVolume ) # max volume +mesh.AddHypothesis( shape_mesh, hypVolume ) # max volume + +mesh.AddHypothesis( shape_mesh, algoReg1D ) # Regular 1D/wire discretisation +mesh.AddHypothesis( shape_mesh, algoMef ) # MEFISTO 2D +mesh.AddHypothesis( shape_mesh, algoNg ) # NETGEN 3D print "-------------------------- compute the mesh of the mechanic piece" smesh.Compute(mesh,shape_mesh) print "Information about the Mesh_mechanic_tetra:" -print "Number of nodes : ", mesh.NbNodes() -print "Number of edges : ", mesh.NbEdges() -print "Number of faces : ", mesh.NbFaces() -print "Number of triangles : ", mesh.NbTriangles() -print "Number of volumes: ", mesh.NbVolumes() +print "Number of nodes : ", mesh.NbNodes() +print "Number of edges : ", mesh.NbEdges() +print "Number of faces : ", mesh.NbFaces() +print "Number of triangles : ", mesh.NbTriangles() +print "Number of quadrangles: ", mesh.NbQuadrangles() +print "Number of volumes : ", mesh.NbVolumes() print "Number of tetrahedrons: ", mesh.NbTetras() -salome.sg.updateObjBrowser(1); - +salome.sg.updateObjBrowser(1) diff --git a/src/SMESH_SWIG/SMESH_test0.py b/src/SMESH_SWIG/SMESH_test0.py index ce717fdde..a7a5282a5 100644 --- a/src/SMESH_SWIG/SMESH_test0.py +++ b/src/SMESH_SWIG/SMESH_test0.py @@ -22,54 +22,42 @@ # File : SMESH_test0.py # Module : SMESH -import SMESH -import smeshpy import salome -from salome import sg -import math -#import SMESH_BasicHypothesis_idl - import geompy - -geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") -myBuilder = salome.myStudy.NewBuilder() +from geompy import geom from geompy import gg -ShapeTypeCompSolid = 1 -ShapeTypeSolid = 2 -ShapeTypeShell = 3 -ShapeTypeFace = 4 -ShapeTypeWire = 5 -ShapeTypeEdge = 6 -ShapeTypeVertex = 7 +import SMESH + +myBuilder = salome.myStudy.NewBuilder() # ---- define a box box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) -idbox = geompy.addToStudy(box,"box") +idbox = geompy.addToStudy(box, "box") # ---- add first face of box in study -subShapeList=geompy.SubShapeAll(box,ShapeTypeFace) -face=subShapeList[0] -name = geompy.SubShapeName( face._get_Name(), box._get_Name() ) +subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) +face = subShapeList[0] +name = geompy.SubShapeName(face, box) print name -idface=geompy.addToStudyInFather(box,face,name) +idface = geompy.addToStudyInFather(box, face, name) # ---- add shell from box in study -subShellList=geompy.SubShapeAll(box,ShapeTypeShell) +subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"]) shell = subShellList[0] -name = geompy.SubShapeName( shell._get_Name(), box._get_Name() ) +name = geompy.SubShapeName(shell, box) print name -idshell=geompy.addToStudyInFather(box,shell,name) +idshell = geompy.addToStudyInFather(box, shell, name) # ---- add first edge of face in study -edgeList = geompy.SubShapeAll(face,ShapeTypeEdge) -edge=edgeList[0]; -name = geompy.SubShapeName( edge._get_Name(), face._get_Name() ) +edgeList = geompy.SubShapeAll(face, geompy.ShapeType["EDGE"]) +edge = edgeList[0] +name = geompy.SubShapeName(edge, face) print name -idedge=geompy.addToStudyInFather(face,edge,name) +idedge = geompy.addToStudyInFather(face, edge, name) -sg.updateObjBrowser(1); +salome.sg.updateObjBrowser(1) diff --git a/src/SMESH_SWIG/SMESH_test1.py b/src/SMESH_SWIG/SMESH_test1.py index a16b63d5a..c0b04299a 100644 --- a/src/SMESH_SWIG/SMESH_test1.py +++ b/src/SMESH_SWIG/SMESH_test1.py @@ -27,58 +27,46 @@ import geompy import StdMeshers -geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") - -geom.GetCurrentStudy(salome.myStudy._get_StudyId()) smesh.SetCurrentStudy(salome.myStudy) -ShapeTypeCompSolid = 1 -ShapeTypeSolid = 2 -ShapeTypeShell = 3 -ShapeTypeFace = 4 -ShapeTypeWire = 5 -ShapeTypeEdge = 6 -ShapeTypeVertex = 7 - # ---- define a box box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) -idbox = geompy.addToStudy(box,"box") +idbox = geompy.addToStudy(box, "box") # ---- add first face of box in study -subShapeList=geompy.SubShapeAll(box,ShapeTypeFace) -face=subShapeList[0] -name = geompy.SubShapeName( face._get_Name(), box._get_Name() ) +subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) +face = subShapeList[0] +name = geompy.SubShapeName(face, box) print name -idface=geompy.addToStudyInFather(box,face,name) +idface = geompy.addToStudyInFather(box, face, name) # ---- add shell from box in study -subShellList=geompy.SubShapeAll(box,ShapeTypeShell) +subShellList = geompy.SubShapeAll(box, geompy.ShapeType["SHELL"]) shell = subShellList[0] -name = geompy.SubShapeName( shell._get_Name(), box._get_Name() ) +name = geompy.SubShapeName(shell, box) print name -idshell=geompy.addToStudyInFather(box,shell,name) +idshell = geompy.addToStudyInFather(box, shell, name) # ---- add first edge of face in study -edgeList = geompy.SubShapeAll(face,ShapeTypeEdge) -edge=edgeList[0]; -name = geompy.SubShapeName( edge._get_Name(), face._get_Name() ) +edgeList = geompy.SubShapeAll(face, geompy.ShapeType["EDGE"]) +edge = edgeList[0] +name = geompy.SubShapeName(edge, face) print name -idedge=geompy.addToStudyInFather(face,edge,name) +idedge = geompy.addToStudyInFather(face, edge, name) # ---- launch SMESH -smeshgui = salome.ImportComponentGUI("SMESH") -smeshgui.Init(salome.myStudyId); -# ---- create Hypothesis +smeshgui = salome.ImportComponentGUI("SMESH") +smeshgui.Init(salome.myStudyId) print "-------------------------- create Hypothesis" -print "-------------------------- LocalLength" +print "-------------------------- LocalLength" hypLen1 = smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so") hypLen1.SetLength(100) print hypLen1.GetName() @@ -120,7 +108,7 @@ smeshgui.SetName(idarea2, "MaxElementArea_500"); print "-------------------------- Regular_1D" algoReg = smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so") -listHyp=algoReg.GetCompatibleHypothesis() +listHyp = algoReg.GetCompatibleHypothesis() for hyp in listHyp: print hyp print algoReg.GetName() @@ -131,7 +119,7 @@ smeshgui.SetName(idreg, "Regular_1D"); print "-------------------------- MEFISTO_2D" algoMef = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so") -listHyp=algoMef.GetCompatibleHypothesis() +listHyp = algoMef.GetCompatibleHypothesis() for hyp in listHyp: print hyp print algoMef.GetName() @@ -142,13 +130,11 @@ smeshgui.SetName(idmef, "MEFISTO_2D"); # ---- Init a Mesh with the box -box=salome.IDToObject(idbox) -mesh=smesh.CreateMesh(box) - +box = salome.IDToObject(idbox) +mesh = smesh.CreateMesh(box) idmesh = salome.ObjectToID(mesh) smeshgui.SetName(idmesh, "Meshbox"); -# ---- add hypothesis to box print "-------------------------- add hypothesis to box" mesh.AddHypothesis(box,algoReg) mesh.AddHypothesis(box,hypNbSeg1) @@ -158,14 +144,14 @@ mesh.AddHypothesis(box,hypArea1) # ---- add hypothesis to edge print "-------------------------- add hypothesis to edge" -edge=salome.IDToObject(idedge) +edge = salome.IDToObject(idedge) submesh = mesh.GetSubMesh(edge, "SubMeshEdge") -mesh.AddHypothesis(edge , algoReg) +mesh.AddHypothesis(edge, algoReg) mesh.AddHypothesis(edge, hypLen1) print "-------------------------- add hypothesis to face" face = salome.IDToObject(idface) -submesh =mesh.GetSubMesh(face, "SubMeshFace") -mesh.AddHypothesis(face,hypArea2) +submesh = mesh.GetSubMesh(face, "SubMeshFace") +mesh.AddHypothesis(face, hypArea2) salome.sg.updateObjBrowser(1); diff --git a/src/SMESH_SWIG/SMESH_test2.py b/src/SMESH_SWIG/SMESH_test2.py index 1c58f73da..b552a1490 100644 --- a/src/SMESH_SWIG/SMESH_test2.py +++ b/src/SMESH_SWIG/SMESH_test2.py @@ -27,13 +27,12 @@ from SMESH_test1 import * # ---- compute box print "-------------------------- compute box" -ret=smesh.Compute(mesh,box) +ret = smesh.Compute(mesh,box) print ret -log=mesh.GetLog(0); # no erase trace +log = mesh.GetLog(0); # no erase trace for linelog in log: print linelog - salome.sg.updateObjBrowser(1); # ---- compute edge diff --git a/src/SMESH_SWIG/SMESH_test3.py b/src/SMESH_SWIG/SMESH_test3.py index 65d7129e6..e10501858 100644 --- a/src/SMESH_SWIG/SMESH_test3.py +++ b/src/SMESH_SWIG/SMESH_test3.py @@ -22,77 +22,61 @@ # File : SMESH_test3.py # Module : SMESH -import smeshpy -import salome -from salome import sg +#import salome import math -#import SMESH_BasicHypothesis_idl - import geompy -geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") -myBuilder = salome.myStudy.NewBuilder() -from geompy import gg +pi = math.pi -ShapeTypeCompSolid = 1 -ShapeTypeSolid = 2 -ShapeTypeShell = 3 -ShapeTypeFace = 4 -ShapeTypeWire = 5 -ShapeTypeEdge = 6 -ShapeTypeVertex = 7 +# --------------------------------------------- +xa = math.sin(pi/12) +ya = 0 +za = math.cos(pi/12) -pi=math.pi +xb = 0 +yb = math.sin(pi/18) +zb = math.cos(pi/18) -# --------------------------------------------- -xa=math.sin(pi/12) -ya=0 -za=math.cos(pi/12) - -xb=0 -yb=math.sin(pi/18) -zb=math.cos(pi/18) - -xc=math.cos(-pi/18) -yc=0 -zc=math.sin(-pi/18) - -rc1=150 -hc1=300 -rc2=150 -rc3=150 -rc4=300 -# --------------------------------------------- -point_0 = geom.MakePointStruct(0, 0, 0) -point_z = geom.MakePointStruct(0, 0, 1) +xc = math.cos(-pi/18) +yc = 0 +zc = math.sin(-pi/18) + +rc1 = 150 +rc2 = 150 +rc3 = 150 +rc4 = 300 -point_a = geom.MakePointStruct(xa, ya, za) -point_b = geom.MakePointStruct(xb, yb, zb) -point_c = geom.MakePointStruct(xc, yc, zc) +hc1 = 300 +hc2 = 2*hc1 +hc3 = 2*hc1 +hc4 = 2*hc1 -dir_z = geom.MakeDirection(point_z) -axe_z = geom.MakeAxisStruct(0, 0, 0, 0, 0, 1) +# --------------------------------------------- +point_0 = geompy.MakeVertex(0, 0, 0) +point_z = geompy.MakeVertex(0, 0, 1) -dir_a = geom.MakeDirection(point_a) -axe_a = geom.MakeAxisStruct(0, 0, 0, xa, ya, za) +point_a = geompy.MakeVertex(xa, ya, za) +point_b = geompy.MakeVertex(xb, yb, zb) +point_c = geompy.MakeVertex(xc, yc, zc) -dir_b = geom.MakeDirection(point_b) -axe_b = geom.MakeAxisStruct(0, 0, 0, xb, yb, zb) +dir_z = geompy.MakeVector(point_0, point_z) +dir_a = geompy.MakeVector(point_0, point_a) +dir_b = geompy.MakeVector(point_0, point_b) +dir_c = geompy.MakeVector(point_0, point_c) -dir_c = geom.MakeDirection(point_c) -axe_c = geom.MakeAxisStruct(0, 0, 0, xc, yc, zc) +axe_z = dir_z +axe_a = dir_a +axe_b = dir_b +axe_c = dir_c cyl_1 = geompy.MakeCylinder(point_0, dir_z, rc1, hc1) -hc2=2*hc1 cyl_t = geompy.MakeCylinder(point_0, dir_a, rc2, hc2) cyl_a = geompy.MakeTranslation(cyl_t, 1.2*rc1, 0.1*rc1, -0.5*hc1) -hc3=2*hc1 cyl_t = geompy.MakeCylinder(point_0, dir_b, rc3, hc3) cyl_b = geompy.MakeTranslation(cyl_t, -1.2*rc1, -0.1*rc1, -0.5*hc1) -hc4=2*hc1 cyl_t = geompy.MakeCylinder(point_0, dir_c, rc4, hc4) cyl_t = geompy.MakeRotation(cyl_t, axe_c, pi/2) cyl_c = geompy.MakeTranslation(cyl_t, -hc1, 0, 0) diff --git a/src/SMESH_SWIG/SMESH_test4.py b/src/SMESH_SWIG/SMESH_test4.py index 3a48db694..09271b6f1 100755 --- a/src/SMESH_SWIG/SMESH_test4.py +++ b/src/SMESH_SWIG/SMESH_test4.py @@ -1,31 +1,18 @@ import salome -from geompy import gg import geompy import SMESH - import StdMeshers -ShapeTypeCompSolid = 1 -ShapeTypeSolid = 2 -ShapeTypeShell = 3 -ShapeTypeFace = 4 -ShapeTypeWire = 5 -ShapeTypeEdge = 6 -ShapeTypeVertex = 7 - -geom = salome.lcc.FindOrLoadComponent("FactoryServer", "GEOM") smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") - -geom.GetCurrentStudy(salome.myStudy._get_StudyId()) smesh.SetCurrentStudy(salome.myStudy) box = geompy.MakeBox(0., 0., 0., 100., 200., 300.) -idbox = geompy.addToStudy(box,"box") +idbox = geompy.addToStudy(box, "box") -subShapeList = geompy.SubShapeAll(box,ShapeTypeFace) +subShapeList = geompy.SubShapeAll(box, geompy.ShapeType["FACE"]) face = subShapeList[0] -name = geompy.SubShapeName( face._get_Name(), box._get_Name() ) -idface = geompy.addToStudyInFather(box,face,name) +name = geompy.SubShapeName(face, box) +idface = geompy.addToStudyInFather(box, face, name) box = salome.IDToObject(idbox) face = salome.IDToObject(idface) diff --git a/src/SMESH_SWIG/SMESH_test5.py b/src/SMESH_SWIG/SMESH_test5.py new file mode 100644 index 000000000..7259b6e35 --- /dev/null +++ b/src/SMESH_SWIG/SMESH_test5.py @@ -0,0 +1,79 @@ +# 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +# +# +# +# File : SMESH_test1.py +# Module : SMESH + +import salome +import SMESH +import SALOMEDS +import CORBA +import os +import os.path + +def SetSObjName(theSObj,theName) : + ok, anAttr = theSObj.FindAttribute("AttributeName") + if ok: + aName = anAttr._narrow(SALOMEDS.AttributeName) + #print aName.__dict__ + aName.SetValue(theName) + +def ConvertMED2UNV(thePath,theFile) : + anInitFileName = thePath + theFile + aMeshes,aResult = smesh.CreateMeshesFromMED(anInitFileName) + print aResult, aMeshes + + for iMesh in range(len(aMeshes)) : + aMesh = aMeshes[iMesh] + anSObj = salome.ObjectToSObject(aMesh) + print anSObj.GetName(), + aFileName = anInitFileName + aFileName = os.path.basename(aFileName) + SetSObjName(anSObj,aFileName) + print anSObj.GetName() + + aFileName = thePath + theFile + "." + str(iMesh) + ".unv" + aMesh.ExportUNV(aFileName) + aMesh = smesh.CreateMeshesFromUNV(aFileName) + anSObj = salome.ObjectToSObject(aMesh) + print anSObj.GetName(), + os.remove(aFileName) + aFileName = os.path.basename(aFileName) + SetSObjName(anSObj,aFileName) + print anSObj.GetName() + +smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") +smesh.SetCurrentStudy(salome.myStudy) + +aPath = os.getenv('KERNEL_ROOT_DIR') + '/examples/' +aListDir = os.listdir(aPath) +print aListDir + +for iFile in range(len(aListDir)) : + aFileName = aListDir[iFile] + aName,anExt = os.path.splitext(aFileName) + if anExt == ".med" : + aFileName = os.path.basename(aFileName) + print aFileName + ConvertMED2UNV(aPath,aFileName) + #break + +salome.sg.updateObjBrowser(1) diff --git a/src/SMESH_SWIG/batchmode_mefisto.py b/src/SMESH_SWIG/batchmode_mefisto.py index 6fa30717e..203b1602e 100644 --- a/src/SMESH_SWIG/batchmode_mefisto.py +++ b/src/SMESH_SWIG/batchmode_mefisto.py @@ -4,17 +4,11 @@ import re import batchmode_salome import batchmode_geompy import batchmode_smesh +import StdMeshers -geom = batchmode_geompy.geom smesh = batchmode_smesh.smesh - -geom.GetCurrentStudy(batchmode_salome.myStudyId) smesh.SetCurrentStudy(batchmode_salome.myStudy) -ShapeType = batchmode_smesh.ShapeType - -import StdMeshers - def CreateMesh (theFileName, area, len = None, nbseg = None): if not(os.path.isfile(theFileName)) or re.search("\.brep$", theFileName) is None : @@ -31,49 +25,44 @@ def CreateMesh (theFileName, area, len = None, nbseg = None): # ---- Import shape from BREP file and add it to the study - shape_mesh = geom.ImportBREP(theFileName) - Id_shape = batchmode_geompy.addToStudy( shape_mesh, "shape_mesh") - + shape_mesh = batchmode_geompy.Import(theFileName, "BREP") + Id_shape = batchmode_geompy.addToStudy(shape_mesh, "shape_mesh") # ---- SMESH - # ---- create Hypothesis - print "-------------------------- create Hypothesis" if (len is not None): print "-------------------------- LocalLength" hypLength1 = smesh.CreateHypothesis("LocalLength", "libStdMeshersEngine.so") hypLength1.SetLength(len) - print "Hypothesis type: ", hypLength1.GetName() - print "Hypothesis ID: ", hypLength1.GetId() + print "Hypothesis type : ", hypLength1.GetName() + print "Hypothesis ID : ", hypLength1.GetId() print "Hypothesis Value: ", hypLength1.GetLength() if (nbseg is not None): print "-------------------------- NumberOfSegments" hypNbSeg1 = smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") hypNbSeg1.SetNumberOfSegments(nbseg) - print "Hypothesis type: ", hypNbSeg1.GetName() - print "Hypothesis ID: ", hypNbSeg1.GetId() + print "Hypothesis type : ", hypNbSeg1.GetName() + print "Hypothesis ID : ", hypNbSeg1.GetId() print "Hypothesis Value: ", hypNbSeg1.GetNumberOfSegments() - if (area == "LengthFromEdges"): print "-------------------------- LengthFromEdges" hypLengthFromEdges = smesh.CreateHypothesis("LengthFromEdges", "libStdMeshersEngine.so") hypLengthFromEdges.SetMode(1) - print "Hypothesis type: ", hypLengthFromEdges.GetName() - print "Hypothesis ID: ", hypLengthFromEdges.GetId() + print "Hypothesis type : ", hypLengthFromEdges.GetName() + print "Hypothesis ID : ", hypLengthFromEdges.GetId() print "LengthFromEdges Mode: ", hypLengthFromEdges.GetMode() else: print "-------------------------- MaxElementArea" hypArea1 = smesh.CreateHypothesis("MaxElementArea", "libStdMeshersEngine.so") hypArea1.SetMaxElementArea(area) - print "Hypothesis type: ", hypArea1.GetName() - print "Hypothesis ID: ", hypArea1.GetId() + print "Hypothesis type : ", hypArea1.GetName() + print "Hypothesis ID : ", hypArea1.GetId() print "Hypothesis Value: ", hypArea1.GetMaxElementArea() - print "-------------------------- Regular_1D" @@ -84,18 +73,17 @@ def CreateMesh (theFileName, area, len = None, nbseg = None): print hyp print "Algo name: ", algoReg.GetName() - print "Algo ID: ", algoReg.GetId() + print "Algo ID : ", algoReg.GetId() print "-------------------------- MEFISTO_2D" algoMef = smesh.CreateHypothesis("MEFISTO_2D", "libStdMeshersEngine.so") - listHyp=algoMef.GetCompatibleHypothesis() + listHyp = algoMef.GetCompatibleHypothesis() for hyp in listHyp: print hyp print "Algo name: ", algoMef.GetName() - print "Algo ID: ", algoMef.GetId() - + print "Algo ID : ", algoMef.GetId() # ---- add hypothesis to shape @@ -108,16 +96,16 @@ def CreateMesh (theFileName, area, len = None, nbseg = None): print ret if (nbseg is not None): - ret=mesh.AddHypothesis(shape_mesh, hypNbSeg1) + ret = mesh.AddHypothesis(shape_mesh, hypNbSeg1) print "Add Number Of Segements algo .... ", print ret if (len is not None): - ret=mesh.AddHypothesis(shape_mesh,hypLength1) + ret = mesh.AddHypothesis(shape_mesh,hypLength1) print "Add Local Length algo .... ", print ret - ret=mesh.AddHypothesis(shape_mesh, algoMef) + ret = mesh.AddHypothesis(shape_mesh, algoMef) print "Add MEFISTO_2D algo....", print ret @@ -126,25 +114,23 @@ def CreateMesh (theFileName, area, len = None, nbseg = None): print "Add Length From Edges algo .... ", print ret else: - ret=mesh.AddHypothesis(shape_mesh, hypArea1) + ret = mesh.AddHypothesis(shape_mesh, hypArea1) print "Add Max Triangle Area algo .... ", print ret - # ---- compute mesh - print "-------------------------- compute mesh" - ret=smesh.Compute(mesh,shape_mesh) + ret = smesh.Compute(mesh,shape_mesh) print "Compute Mesh .... ", print ret - log=mesh.GetLog(0); # no erase trace + log = mesh.GetLog(0); # no erase trace #for linelog in log: # print linelog print "------------ INFORMATION ABOUT MESH ------------" - print "Number of nodes: ", mesh.NbNodes() - print "Number of edges: ", mesh.NbEdges() - print "Number of faces: ", mesh.NbFaces() + print "Number of nodes : ", mesh.NbNodes() + print "Number of edges : ", mesh.NbEdges() + print "Number of faces : ", mesh.NbFaces() print "Number of triangles: ", mesh.NbTriangles() return mesh diff --git a/src/SMESH_SWIG/batchmode_smesh.py b/src/SMESH_SWIG/batchmode_smesh.py index 899dc59af..4964c8b0c 100644 --- a/src/SMESH_SWIG/batchmode_smesh.py +++ b/src/SMESH_SWIG/batchmode_smesh.py @@ -8,6 +8,7 @@ # $Header$ from batchmode_salome import * +from batchmode_geompy import ShapeType import SMESH #-------------------------------------------------------------------------- @@ -19,46 +20,34 @@ myStudyBuilder = myStudy.NewBuilder() if myStudyBuilder is None: raise RuntimeError, " Null myStudyBuilder" -father = myStudy.FindComponent("MESH") +father = myStudy.FindComponent("SMESH") if father is None: - father = myStudyBuilder.NewComponent("MESH") - FName = myStudyBuilder.FindOrCreateAttribute(father, "AttributeName"); - Comp = modulecatalog.GetComponent( "SMESH" ) - FName.SetValue( Comp._get_componentusername() ) - aPixmap = myStudyBuilder.FindOrCreateAttribute(father, "AttributePixMap"); - aPixmap.SetPixMap( "ICON_OBJBROWSER_Mesh" ); + father = myStudyBuilder.NewComponent("SMESH") + FName = myStudyBuilder.FindOrCreateAttribute(father, "AttributeName") + Comp = modulecatalog.GetComponent("SMESH") + FName.SetValue(Comp._get_componentusername()) + aPixmap = myStudyBuilder.FindOrCreateAttribute(father, "AttributePixMap") + aPixmap.SetPixMap("ICON_OBJBROWSER_Mesh") myStudyBuilder.DefineComponentInstance(father,smesh) mySComponentMesh = father._narrow(SALOMEDS.SComponent) -Tag_HypothesisRoot = 1; -Tag_AlgorithmsRoot = 2; +Tag_HypothesisRoot = 1 +Tag_AlgorithmsRoot = 2 -Tag_RefOnShape = 1; -Tag_RefOnAppliedHypothesis = 2; -Tag_RefOnAppliedAlgorithms = 3; +Tag_RefOnShape = 1 +Tag_RefOnAppliedHypothesis = 2 +Tag_RefOnAppliedAlgorithms = 3 -Tag_SubMeshOnVertex = 4; -Tag_SubMeshOnEdge = 5; -Tag_SubMeshOnFace = 6; -Tag_SubMeshOnSolid = 7; -Tag_SubMeshOnCompound = 8; +Tag_SubMeshOnVertex = 4 +Tag_SubMeshOnEdge = 5 +Tag_SubMeshOnFace = 6 +Tag_SubMeshOnSolid = 7 +Tag_SubMeshOnCompound = 8 Tag = {"HypothesisRoot":1,"AlgorithmsRoot":2,"RefOnShape":1,"RefOnAppliedHypothesis":2,"RefOnAppliedAlgorithms":3,"SubMeshOnVertex":4,"SubMeshOnEdge":5,"SubMeshOnFace":6,"SubMeshOnSolid":7,"SubMeshOnCompound":8} -# -- enumeration -- -ShapeTypeCompSolid = 1 -ShapeTypeSolid = 2 -ShapeTypeShell = 3 -ShapeTypeFace = 4 -ShapeTypeWire = 5 -ShapeTypeEdge = 6 -ShapeTypeVertex = 7 - -# -- enumeration ShapeType as a dictionary -- -ShapeType = {"CompSolid":1, "Solid":2, "Shell":3, "Face":4, "Wire":5, "Edge":6, "Vertex":7} - #------------------------------------------------------------ def Init(): pass @@ -78,17 +67,17 @@ def AddNewMesh(IOR): aPixmap = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributePixMap") aPixmap.SetPixMap( "mesh_tree_hypo.png" ) aSelAttr = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributeSelectable") - aSelAttr.SetSelectable(0); + aSelAttr.SetSelectable(0) res, AlgorithmsRoot = mySComponentMesh.FindSubObject (Tag_AlgorithmsRoot) if AlgorithmsRoot is None or res == 0: AlgorithmsRoot = myStudyBuilder.NewObjectToTag (mySComponentMesh, Tag_AlgorithmsRoot) aName = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributeName") - aName.SetValue("Algorithms"); - aPixmap = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributePixMap"); - aPixmap.SetPixMap( "mesh_tree_algo.png" ); - aSelAttr = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributeSelectable"); - aSelAttr.SetSelectable(0); + aName.SetValue("Algorithms") + aPixmap = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributePixMap") + aPixmap.SetPixMap( "mesh_tree_algo.png" ) + aSelAttr = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributeSelectable") + aSelAttr.SetSelectable(0) HypothesisRoot = HypothesisRoot._narrow(SALOMEDS.SObject) newMesh = myStudyBuilder.NewObject(mySComponentMesh) @@ -109,22 +98,22 @@ def AddNewHypothesis(IOR): res, HypothesisRoot = mySComponentMesh.FindSubObject (Tag_HypothesisRoot) if HypothesisRoot is None or res == 0: HypothesisRoot = myStudyBuilder.NewObjectToTag (mySComponentMesh, Tag_HypothesisRoot) - aName = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributeName"); - aName.SetValue("Hypotheses"); - aSelAttr = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributeSelectable"); - aSelAttr.SetSelectable(0); - aPixmap = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributePixMap"); - aPixmap.SetPixMap( "mesh_tree_hypo.png" ); + aName = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributeName") + aName.SetValue("Hypotheses") + aSelAttr = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributeSelectable") + aSelAttr.SetSelectable(0) + aPixmap = myStudyBuilder.FindOrCreateAttribute(HypothesisRoot, "AttributePixMap") + aPixmap.SetPixMap( "mesh_tree_hypo.png" ) # Add New Hypothesis newHypo = myStudyBuilder.NewObject(HypothesisRoot) aPixmap = myStudyBuilder.FindOrCreateAttribute(newHypo, "AttributePixMap") H = orb.string_to_object(IOR) - aType = H.GetName(); - aPixmap.SetPixMap( "mesh_tree_hypo.png_" + aType ); - anIOR = myStudyBuilder.FindOrCreateAttribute(newHypo, "AttributeIOR"); - anIOR.SetValue(IOR); - return newHypo.GetID(); + aType = H.GetName() + aPixmap.SetPixMap( "mesh_tree_hypo.png_" + aType ) + anIOR = myStudyBuilder.FindOrCreateAttribute(newHypo, "AttributeIOR") + anIOR.SetValue(IOR) + return newHypo.GetID() #------------------------------------------------------------ def AddNewAlgorithms(IOR): @@ -138,73 +127,73 @@ def AddNewAlgorithms(IOR): if AlgorithmsRoot is None or res == 0: AlgorithmsRoot = myStudyBuilde.NewObjectToTag (mySComponentMesh, Tag_AlgorithmsRoot) aName = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributeName") - aName.SetValue("Algorithms"); + aName.SetValue("Algorithms") aSelAttr = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributeSelectable") - aSelAttr.SetSelectable(0); - aPixmap = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributePixMap"); - aPixmap.SetPixMap( "mesh_tree_algo.png" ); + aSelAttr.SetSelectable(0) + aPixmap = myStudyBuilder.FindOrCreateAttribute(AlgorithmsRoot, "AttributePixMap") + aPixmap.SetPixMap( "mesh_tree_algo.png" ) # Add New Algorithms newHypo = myStudyBuilder.NewObject(AlgorithmsRoot) - aPixmap = myStudyBuilder.FindOrCreateAttribute(newHypo, "AttributePixMap"); - aPixmap = anAttr._narrow(SALOMEDS.AttributePixMap); + aPixmap = myStudyBuilder.FindOrCreateAttribute(newHypo, "AttributePixMap") + aPixmap = anAttr._narrow(SALOMEDS.AttributePixMap) H = orb.string_to_object(IOR) aType = H.GetName(); #QString in fact - aPixmap.SetPixMap( "mesh_tree_algo.png_" + aType ); - anIOR = myStudyBuilder.FindOrCreateAttribute(newHypo, "AttributeIOR"); - anIOR.SetValue(IOR); - return newHypo.GetID(); + aPixmap.SetPixMap( "mesh_tree_algo.png_" + aType ) + anIOR = myStudyBuilder.FindOrCreateAttribute(newHypo, "AttributeIOR") + anIOR.SetValue(IOR) + return newHypo.GetID() #------------------------------------------------------------ def SetShape(ShapeEntry, MeshEntry): SO_MorSM = myStudy.FindObjectID( MeshEntry ) - SO_GeomShape = myStudy.FindObjectID( ShapeEntry ); + SO_GeomShape = myStudy.FindObjectID( ShapeEntry ) if SO_MorSM is not None and SO_GeomShape is not None : # VSR: added temporarily - shape reference is published automatically by the engine - res, Ref = SO_MorSM.FindSubObject( Tag_RefOnShape ); + res, Ref = SO_MorSM.FindSubObject( Tag_RefOnShape ) if res == 1 : - return; + return # VSR ###################################################################### - SO = myStudyBuilder.NewObjectToTag (SO_MorSM, Tag_RefOnShape); - myStudyBuilder.Addreference (SO,SO_GeomShape); - + SO = myStudyBuilder.NewObjectToTag (SO_MorSM, Tag_RefOnShape) + myStudyBuilder.Addreference (SO,SO_GeomShape) + #------------------------------------------------------------ def SetHypothesis(Mesh_Or_SubMesh_Entry, Hypothesis_Entry): - SO_MorSM = myStudy.FindObjectID( Mesh_Or_SubMesh_Entry ); - SO_Hypothesis = myStudy.FindObjectID( Hypothesis_Entry ); + SO_MorSM = myStudy.FindObjectID( Mesh_Or_SubMesh_Entry ) + SO_Hypothesis = myStudy.FindObjectID( Hypothesis_Entry ) if SO_MorSM is not None and SO_Hypothesis is not None : #Find or Create Applied Hypothesis root res, AHR = SO_MorSM.FindSubObject (Tag_RefOnAppliedHypothesis) if AHR is None or res == 0: - AHR = myStudyBuilder.NewObjectToTag (SO_MorSM, Tag_RefOnAppliedHypothesis); - aName = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributeName"); + AHR = myStudyBuilder.NewObjectToTag (SO_MorSM, Tag_RefOnAppliedHypothesis) + aName = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributeName") # The same name as in SMESH_Mesh_i::AddHypothesis() ################## - aName.SetValue("Applied hypotheses"); + aName.SetValue("Applied hypotheses") - aSelAttr = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributeSelectable"); - aSelAttr.SetSelectable(0); - aPixmap = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributePixMap"); - aPixmap.SetPixMap( "mesh_tree_hypo.png" ); + aSelAttr = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributeSelectable") + aSelAttr.SetSelectable(0) + aPixmap = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributePixMap") + aPixmap.SetPixMap( "mesh_tree_hypo.png" ) # VSR: added temporarily - reference to applied hypothesis is published automatically by the engine else : - it = myStudy.NewChildIterator(AHR); + it = myStudy.NewChildIterator(AHR) while it.More() : - res, Ref = it.Value().ReferencedObject(); + res, Ref = it.Value().ReferencedObject() if res and Ref is not None and Ref.GetID() == Hypothesis_Entry : - return; - it.Next(); + return + it.Next() # VSR ###################################################################### - SO = myStudyBuilder.NewObject(AHR); - myStudyBuilder.Addreference (SO,SO_Hypothesis); + SO = myStudyBuilder.NewObject(AHR) + myStudyBuilder.Addreference (SO,SO_Hypothesis) #------------------------------------------------------------ def SetAlgorithms(Mesh_Or_SubMesh_Entry, Algorithms_Entry): @@ -212,38 +201,38 @@ def SetAlgorithms(Mesh_Or_SubMesh_Entry, Algorithms_Entry): SO_Algorithms = myStudy.FindObjectID( Algorithms_Entry ) if SO_MorSM != None and SO_Algorithms != None : #Find or Create Applied Algorithms root - res, AHR = SO_MorSM.FindSubObject (Tag_RefOnAppliedAlgorithms); + res, AHR = SO_MorSM.FindSubObject (Tag_RefOnAppliedAlgorithms) if AHR is None or res == 0: - AHR = myStudyBuilder.NewObjectToTag (SO_MorSM, Tag_RefOnAppliedAlgorithms); - aName = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributeName"); + AHR = myStudyBuilder.NewObjectToTag (SO_MorSM, Tag_RefOnAppliedAlgorithms) + aName = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributeName") # The same name as in SMESH_Mesh_i::AddHypothesis() ################## - aName.SetValue("Applied algorithms"); + aName.SetValue("Applied algorithms") - aSelAttr = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributeSelectable"); - aSelAttr.SetSelectable(0); - aPixmap = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributePixMap"); - aPixmap.SetPixMap( "mesh_tree_algo.png" ); + aSelAttr = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributeSelectable") + aSelAttr.SetSelectable(0) + aPixmap = myStudyBuilder.FindOrCreateAttribute(AHR, "AttributePixMap") + aPixmap.SetPixMap( "mesh_tree_algo.png" ) # VSR: added temporarily - reference to applied hypothesis is published automatically by the engine else : - it = myStudy.NewChildIterator(AHR); + it = myStudy.NewChildIterator(AHR) while it.More() : - res, Ref = it.Value().ReferencedObject(); + res, Ref = it.Value().ReferencedObject() if res and Ref is not None and Ref.GetID() == Algorithms_Entry : - return; - it.Next(); + return + it.Next() # VSR ###################################################################### - SO = myStudyBuilder.NewObject(AHR); - myStudyBuilder.Addreference (SO,SO_Algorithms); + SO = myStudyBuilder.NewObject(AHR) + myStudyBuilder.Addreference (SO,SO_Algorithms) #------------------------------------------------------------ def UnSetHypothesis( Applied_Hypothesis_Entry ): - SO_Applied_Hypothesis = myStudy.FindObjectID( Applied_Hypothesis_Entry ); + SO_Applied_Hypothesis = myStudy.FindObjectID( Applied_Hypothesis_Entry ) if SO_Applied_Hypothesis : - myStudyBuilder.RemoveObject(SO_Applied_Hypothesis); + myStudyBuilder.RemoveObject(SO_Applied_Hypothesis) #------------------------------------------------------------ @@ -257,36 +246,36 @@ def AddSubMesh ( SO_Mesh_Entry, SM_IOR, ST): SO_Mesh = myStudy.FindObjectID( SO_Mesh_Entry ) if ( SO_Mesh ) : - if ST == ShapeTypeCompSolid : - Tag_Shape = Tag_SubMeshOnSolid; - Name = "SubMeshes on Solid"; - elif ST == ShapeTypeFace : - Tag_Shape = Tag_SubMeshOnFace; - Name = "SubMeshes on Face"; - elif ST == ShapeTypeEdge : - Tag_Shape = Tag_SubMeshOnEdge; - Name = "SubMeshes on Edge"; - elif ST == ShapeTypeVertex : - Tag_Shape = Tag_SubMeshOnVertex; - Name = "SubMeshes on Vertex"; + if ST == ShapeType["COMPSOLID"] : + Tag_Shape = Tag_SubMeshOnSolid + Name = "SubMeshes on Solid" + elif ST == ShapeType["FACE"] : + Tag_Shape = Tag_SubMeshOnFace + Name = "SubMeshes on Face" + elif ST == ShapeType["EDGE"] : + Tag_Shape = Tag_SubMeshOnEdge + Name = "SubMeshes on Edge" + elif ST == ShapeType["VERTEX"] : + Tag_Shape = Tag_SubMeshOnVertex + Name = "SubMeshes on Vertex" else : - Tag_Shape = Tag_SubMeshOnCompound; - Name = "SubMeshes on Compound"; + Tag_Shape = Tag_SubMeshOnCompound + Name = "SubMeshes on Compound" res, SubmeshesRoot = SO_Mesh.FindSubObject (Tag_Shape) if SubmeshesRoot is None or res == 0: - SubmeshesRoot = myStudyBuilder.NewObjectToTag (SO_Mesh, Tag_Shape); - aName = myStudyBuilder.FindOrCreateAttribute(SubmeshesRoot, "AttributeName"); - aName.SetValue(Name); - aSelAttr = myStudyBuilder.FindOrCreateAttribute(SubmeshesRoot, "AttributeSelectable"); - aSelAttr.SetSelectable(0); + SubmeshesRoot = myStudyBuilder.NewObjectToTag (SO_Mesh, Tag_Shape) + aName = myStudyBuilder.FindOrCreateAttribute(SubmeshesRoot, "AttributeName") + aName.SetValue(Name) + aSelAttr = myStudyBuilder.FindOrCreateAttribute(SubmeshesRoot, "AttributeSelectable") + aSelAttr.SetSelectable(0) - SO = myStudyBuilder.NewObject (SubmeshesRoot); - anIOR = myStudyBuilder.FindOrCreateAttribute(SO, "AttributeIOR"); - anIOR.SetValue(SM_IOR); - return SO.GetID(); - - return None; + SO = myStudyBuilder.NewObject (SubmeshesRoot) + anIOR = myStudyBuilder.FindOrCreateAttribute(SO, "AttributeIOR") + anIOR.SetValue(SM_IOR) + return SO.GetID() + + return None #------------------------------------------------------------ def AddSubMeshOnShape (Mesh_Entry, GeomShape_Entry, SM_IOR, ST) : @@ -295,23 +284,21 @@ def AddSubMeshOnShape (Mesh_Entry, GeomShape_Entry, SM_IOR, ST) : if aSO is not None: return aSO.GetID() # VSR ###################################################################### - SO_GeomShape = myStudy.FindObjectID( GeomShape_Entry ); + SO_GeomShape = myStudy.FindObjectID( GeomShape_Entry ) if SO_GeomShape != None : - SM_Entry = AddSubMesh (Mesh_Entry,SM_IOR,ST); - SO_SM = myStudy.FindObjectID( SM_Entry ); + SM_Entry = AddSubMesh (Mesh_Entry,SM_IOR,ST) + SO_SM = myStudy.FindObjectID( SM_Entry ) if SO_SM != None : - SetShape (GeomShape_Entry, SM_Entry); - return SM_Entry; - - return None; + SetShape (GeomShape_Entry, SM_Entry) + return SM_Entry + + return None #------------------------------------------------------------ def SetName(Entry, Name): - SO = myStudy.FindObjectID( Entry ); + SO = myStudy.FindObjectID( Entry ) if SO != None : - aName = myStudyBuilder.FindOrCreateAttribute(SO, "AttributeName"); - aName.SetValue(Name); - - + aName = myStudyBuilder.FindOrCreateAttribute(SO, "AttributeName") + aName.SetValue(Name) diff --git a/src/SMESH_SWIG/cube2geometry.py b/src/SMESH_SWIG/cube2geometry.py new file mode 100644 index 000000000..3d503dc13 --- /dev/null +++ b/src/SMESH_SWIG/cube2geometry.py @@ -0,0 +1,92 @@ +# CEA/LGLS 2004, Francis KLOSS (OCC) +# ================================== + +# Import +# ------ + +from geompy import * +from meshpy import * + +# Geometry +# ======== + +# Piece +# ----- + +# A small cube centered and put on a great cube + +ox = 0 +oy = 0 +oz = 0 + +arete = 10 + +# Points +# ------ + +blockPoint111 = MakeVertex(ox , oy, oz) +blockPoint211 = MakeVertex(ox+arete, oy, oz) +blockPoint112 = MakeVertex(ox , oy, oz+arete) +blockPoint212 = MakeVertex(ox+arete, oy, oz+arete) + +# Faces +# ----- + +blockFace1 = MakeQuad4Vertices(blockPoint111, blockPoint211, blockPoint212, blockPoint112) + +# Solids +# ------ + +blockSolid11 = MakePrismVecH(blockFace1, MakeVectorDXDYDZ(0, 1, 0), arete) + +# Translations +# ------------ + +blockSolid21 = MakeTranslation(blockSolid11, arete, 0, 0) +blockSolid31 = MakeTranslation(blockSolid21, arete, 0, 0) + +blockSolid12 = MakeTranslation(blockSolid11, 0, 0, arete) +blockSolid22 = MakeTranslation(blockSolid12, arete, 0, 0) +blockSolid32 = MakeTranslation(blockSolid22, arete, 0, 0) + +blockSolid13 = MakeTranslation(blockSolid12, 0, 0, arete) +blockSolid23 = MakeTranslation(blockSolid13, arete, 0, 0) +blockSolid33 = MakeTranslation(blockSolid23, arete, 0, 0) + +blockSolid111 = MakeTranslation(blockSolid22, 0, arete, 0) + +# Compound +# -------- + +c_l = [] +c_l.append(blockSolid11) +c_l.append(blockSolid21) +c_l.append(blockSolid31) +c_l.append(blockSolid12) +c_l.append(blockSolid22) +c_l.append(blockSolid32) +c_l.append(blockSolid13) +c_l.append(blockSolid23) +c_l.append(blockSolid33) +c_l.append(blockSolid111) + +c_cpd = MakeCompound(c_l) +piece = MakeGlueFaces(c_cpd, 1.e-5) + +# Add in study +# ------------ + +piece_id = addToStudy(piece, "Cubes2geometry") + +# Meshing +# ======= + +# Create hexahedrical mesh on piece +# --------------------------------- + +m_hexa=MeshHexa(piece, 4, "Cubes2geometryHexa") + +# Compute +# ------- + +m_hexa.Compute() diff --git a/src/SMESH_SWIG/cube2partition.py b/src/SMESH_SWIG/cube2partition.py new file mode 100644 index 000000000..4d69f555e --- /dev/null +++ b/src/SMESH_SWIG/cube2partition.py @@ -0,0 +1,83 @@ +# CEA/LGLS 2004, Francis KLOSS (OCC) +# ================================== + +# Import +# ------ + +from geompy import * +from meshpy import * + +# Piece +# ----- + +# A small cube centered and put on a great cube + +# Geometry +# -------- + +g_ox = 0 +g_oy = 0 +g_oz = 0 + +g_arete = 10 + +g_trim = 1000 + +# Points +# ------ + +v_arete2 = g_arete*2 +v_arete3 = g_arete*3 + +v_1 = MakeVertex(g_ox , g_oy , g_oz ) +v_2 = MakeVertex(g_ox+v_arete3, g_oy+g_arete , g_oz+v_arete3) + +v_3 = MakeVertex(g_ox+g_arete , g_oy+g_arete , g_oz+g_arete ) +v_4 = MakeVertex(g_ox+v_arete2, g_oy+v_arete2, g_oz+v_arete2) + +# Solids +# ------ + +s_base = MakeBoxTwoPnt(v_1, v_2) +s_haut = MakeBoxTwoPnt(v_3, v_4) + +# Partition +# --------- + +p_dir1 = MakeVectorDXDYDZ(1, 0, 0) +p_dir2 = MakeVectorDXDYDZ(0, 0, 1) + +p_tools = [] +p_tools.append(MakePlane(v_3, p_dir1, g_trim)) +p_tools.append(MakePlane(v_4, p_dir1, g_trim)) +p_tools.append(MakePlane(v_3, p_dir2, g_trim)) +p_tools.append(MakePlane(v_4, p_dir2, g_trim)) + +p_element = MakePartition([s_base], p_tools, [], [], ShapeType["SOLID"]) + +# Compound +# -------- + +c_element = SubShapeAll(p_element, ShapeType["SOLID"]) +c_element.append(s_haut) + +c_cpd = MakeCompound(c_element) +piece = MakeGlueFaces(c_cpd, 1.e-5) + +# Study +# ----- + +piece_id = addToStudy(piece, "Cubes2partition") + +# Meshing +# ======= + +# Create hexahedrical mesh on piece +# --------------------------------- + +m_hexa=MeshHexa(piece, 4, "Cubes2partitionHexa") + +# Compute +# ------- + +m_hexa.Compute() diff --git a/src/SMESH_SWIG/cube2pyGibi.py b/src/SMESH_SWIG/cube2pyGibi.py new file mode 100644 index 000000000..9de2b23b8 --- /dev/null +++ b/src/SMESH_SWIG/cube2pyGibi.py @@ -0,0 +1,295 @@ +# CEA/LGLS 2004, Francis KLOSS (OCC) +# ================================== + +# Import +# ------ + +from geompy import * +from meshpy import * + +# Geometry +# ======== + +# A small cube centered and put on a great cube + +# Points +# ------ + +greatPoint111 = MakeVertex( 0, 0, 0) +greatPoint211 = MakeVertex(10, 0, 0) +greatPoint311 = MakeVertex(20, 0, 0) +greatPoint411 = MakeVertex(30, 0, 0) + +greatPoint121 = MakeVertex( 0, 10, 0) +greatPoint221 = MakeVertex(10, 10, 0) +greatPoint321 = MakeVertex(20, 10, 0) +greatPoint421 = MakeVertex(30, 10, 0) + +greatPoint112 = MakeVertex( 0, 0, 10) +greatPoint212 = MakeVertex(10, 0, 10) +greatPoint312 = MakeVertex(20, 0, 10) +greatPoint412 = MakeVertex(30, 0, 10) + +greatPoint122 = MakeVertex( 0, 10, 10) +greatPoint222 = MakeVertex(10, 10, 10) +greatPoint322 = MakeVertex(20, 10, 10) +greatPoint422 = MakeVertex(30, 10, 10) + +greatPoint113 = MakeVertex( 0, 0, 20) +greatPoint213 = MakeVertex(10, 0, 20) +greatPoint313 = MakeVertex(20, 0, 20) +greatPoint413 = MakeVertex(30, 0, 20) + +greatPoint123 = MakeVertex( 0, 10, 20) +greatPoint223 = MakeVertex(10, 10, 20) +greatPoint323 = MakeVertex(20, 10, 20) +greatPoint423 = MakeVertex(30, 10, 20) + +greatPoint114 = MakeVertex( 0, 0, 30) +greatPoint214 = MakeVertex(10, 0, 30) +greatPoint314 = MakeVertex(20, 0, 30) +greatPoint414 = MakeVertex(30, 0, 30) + +greatPoint124 = MakeVertex( 0, 10, 30) +greatPoint224 = MakeVertex(10, 10, 30) +greatPoint324 = MakeVertex(20, 10, 30) +greatPoint424 = MakeVertex(30, 10, 30) + + +smallPoint111 = greatPoint222 +smallPoint211 = greatPoint322 +smallPoint121 = MakeVertex(10, 20, 10) +smallPoint221 = MakeVertex(20, 20, 10) + +smallPoint112 = greatPoint223 +smallPoint212 = greatPoint323 +smallPoint122 = MakeVertex(10, 20, 20) +smallPoint222 = MakeVertex(20, 20, 20) + +# Edges +# ----- + +smallEdgeX11 = MakeEdge(smallPoint111, smallPoint211) +smallEdgeX21 = MakeEdge(smallPoint121, smallPoint221) +smallEdgeX12 = MakeEdge(smallPoint112, smallPoint212) +smallEdgeX22 = MakeEdge(smallPoint122, smallPoint222) + +smallEdgeY11 = MakeEdge(smallPoint111, smallPoint121) +smallEdgeY21 = MakeEdge(smallPoint211, smallPoint221) +smallEdgeY12 = MakeEdge(smallPoint112, smallPoint122) +smallEdgeY22 = MakeEdge(smallPoint212, smallPoint222) + +smallEdgeZ11 = MakeEdge(smallPoint111, smallPoint112) +smallEdgeZ21 = MakeEdge(smallPoint211, smallPoint212) +smallEdgeZ12 = MakeEdge(smallPoint121, smallPoint122) +smallEdgeZ22 = MakeEdge(smallPoint221, smallPoint222) + + +greatEdgeX111 = MakeEdge(greatPoint111, greatPoint211) +greatEdgeX211 = MakeEdge(greatPoint211, greatPoint311) +greatEdgeX311 = MakeEdge(greatPoint311, greatPoint411) +greatEdgeX121 = MakeEdge(greatPoint121, greatPoint221) +greatEdgeX221 = MakeEdge(greatPoint221, greatPoint321) +greatEdgeX321 = MakeEdge(greatPoint321, greatPoint421) + +greatEdgeX112 = MakeEdge(greatPoint112, greatPoint212) +greatEdgeX212 = MakeEdge(greatPoint212, greatPoint312) +greatEdgeX312 = MakeEdge(greatPoint312, greatPoint412) +greatEdgeX122 = MakeEdge(greatPoint122, greatPoint222) +greatEdgeX222 = smallEdgeX11 +greatEdgeX322 = MakeEdge(greatPoint322, greatPoint422) + +greatEdgeX113 = MakeEdge(greatPoint113, greatPoint213) +greatEdgeX213 = MakeEdge(greatPoint213, greatPoint313) +greatEdgeX313 = MakeEdge(greatPoint313, greatPoint413) +greatEdgeX123 = MakeEdge(greatPoint123, greatPoint223) +greatEdgeX223 = smallEdgeX12 +greatEdgeX323 = MakeEdge(greatPoint323, greatPoint423) + +greatEdgeX114 = MakeEdge(greatPoint114, greatPoint214) +greatEdgeX214 = MakeEdge(greatPoint214, greatPoint314) +greatEdgeX314 = MakeEdge(greatPoint314, greatPoint414) +greatEdgeX124 = MakeEdge(greatPoint124, greatPoint224) +greatEdgeX224 = MakeEdge(greatPoint224, greatPoint324) +greatEdgeX324 = MakeEdge(greatPoint324, greatPoint424) + +greatEdgeY11 = MakeEdge(greatPoint111, greatPoint121) +greatEdgeY21 = MakeEdge(greatPoint211, greatPoint221) +greatEdgeY31 = MakeEdge(greatPoint311, greatPoint321) +greatEdgeY41 = MakeEdge(greatPoint411, greatPoint421) + +greatEdgeY12 = MakeEdge(greatPoint112, greatPoint122) +greatEdgeY22 = MakeEdge(greatPoint212, greatPoint222) +greatEdgeY32 = MakeEdge(greatPoint312, greatPoint322) +greatEdgeY42 = MakeEdge(greatPoint412, greatPoint422) + +greatEdgeY13 = MakeEdge(greatPoint113, greatPoint123) +greatEdgeY23 = MakeEdge(greatPoint213, greatPoint223) +greatEdgeY33 = MakeEdge(greatPoint313, greatPoint323) +greatEdgeY43 = MakeEdge(greatPoint413, greatPoint423) + +greatEdgeY14 = MakeEdge(greatPoint114, greatPoint124) +greatEdgeY24 = MakeEdge(greatPoint214, greatPoint224) +greatEdgeY34 = MakeEdge(greatPoint314, greatPoint324) +greatEdgeY44 = MakeEdge(greatPoint414, greatPoint424) + +greatEdgeZ111 = MakeEdge(greatPoint111, greatPoint112) +greatEdgeZ211 = MakeEdge(greatPoint211, greatPoint212) +greatEdgeZ311 = MakeEdge(greatPoint311, greatPoint312) +greatEdgeZ411 = MakeEdge(greatPoint411, greatPoint412) + +greatEdgeZ121 = MakeEdge(greatPoint121, greatPoint122) +greatEdgeZ221 = MakeEdge(greatPoint221, greatPoint222) +greatEdgeZ321 = MakeEdge(greatPoint321, greatPoint322) +greatEdgeZ421 = MakeEdge(greatPoint421, greatPoint422) + +greatEdgeZ112 = MakeEdge(greatPoint112, greatPoint113) +greatEdgeZ212 = MakeEdge(greatPoint212, greatPoint213) +greatEdgeZ312 = MakeEdge(greatPoint312, greatPoint313) +greatEdgeZ412 = MakeEdge(greatPoint412, greatPoint413) + +greatEdgeZ122 = MakeEdge(greatPoint122, greatPoint123) +greatEdgeZ222 = smallEdgeZ11 +greatEdgeZ322 = smallEdgeZ21 +greatEdgeZ422 = MakeEdge(greatPoint422, greatPoint423) + +greatEdgeZ113 = MakeEdge(greatPoint113, greatPoint114) +greatEdgeZ213 = MakeEdge(greatPoint213, greatPoint214) +greatEdgeZ313 = MakeEdge(greatPoint313, greatPoint314) +greatEdgeZ413 = MakeEdge(greatPoint413, greatPoint414) + +greatEdgeZ123 = MakeEdge(greatPoint123, greatPoint124) +greatEdgeZ223 = MakeEdge(greatPoint223, greatPoint224) +greatEdgeZ323 = MakeEdge(greatPoint323, greatPoint324) +greatEdgeZ423 = MakeEdge(greatPoint423, greatPoint424) + +# Faces +# ----- + +smallFaceX1 = MakeQuad(smallEdgeY11, smallEdgeZ11, smallEdgeY12, smallEdgeZ12) +smallFaceX2 = MakeQuad(smallEdgeY21, smallEdgeZ21, smallEdgeY22, smallEdgeZ22) +smallFaceY1 = MakeQuad(smallEdgeX11, smallEdgeZ11, smallEdgeX12, smallEdgeZ21) +smallFaceY2 = MakeQuad(smallEdgeX21, smallEdgeZ12, smallEdgeX22, smallEdgeZ22) +smallFaceZ1 = MakeQuad(smallEdgeX11, smallEdgeY11, smallEdgeX21, smallEdgeY21) +smallFaceZ2 = MakeQuad(smallEdgeX12, smallEdgeY12, smallEdgeX22, smallEdgeY22) + + +greatFaceX11 = MakeQuad(greatEdgeY11, greatEdgeZ111, greatEdgeY12, greatEdgeZ121) +greatFaceX21 = MakeQuad(greatEdgeY21, greatEdgeZ211, greatEdgeY22, greatEdgeZ221) +greatFaceX31 = MakeQuad(greatEdgeY31, greatEdgeZ311, greatEdgeY32, greatEdgeZ321) +greatFaceX41 = MakeQuad(greatEdgeY41, greatEdgeZ411, greatEdgeY42, greatEdgeZ421) + +greatFaceX12 = MakeQuad(greatEdgeY12, greatEdgeZ112, greatEdgeY13, greatEdgeZ122) +greatFaceX22 = MakeQuad(greatEdgeY22, greatEdgeZ212, greatEdgeY23, greatEdgeZ222) +greatFaceX32 = MakeQuad(greatEdgeY32, greatEdgeZ312, greatEdgeY33, greatEdgeZ322) +greatFaceX42 = MakeQuad(greatEdgeY42, greatEdgeZ412, greatEdgeY43, greatEdgeZ422) + +greatFaceX13 = MakeQuad(greatEdgeY13, greatEdgeZ113, greatEdgeY14, greatEdgeZ123) +greatFaceX23 = MakeQuad(greatEdgeY23, greatEdgeZ213, greatEdgeY24, greatEdgeZ223) +greatFaceX33 = MakeQuad(greatEdgeY33, greatEdgeZ313, greatEdgeY34, greatEdgeZ323) +greatFaceX43 = MakeQuad(greatEdgeY43, greatEdgeZ413, greatEdgeY44, greatEdgeZ423) + +greatFaceY111 = MakeQuad(greatEdgeX111, greatEdgeZ111, greatEdgeX112, greatEdgeZ211) +greatFaceY211 = MakeQuad(greatEdgeX211, greatEdgeZ211, greatEdgeX212, greatEdgeZ311) +greatFaceY311 = MakeQuad(greatEdgeX311, greatEdgeZ311, greatEdgeX312, greatEdgeZ411) +greatFaceY121 = MakeQuad(greatEdgeX121, greatEdgeZ121, greatEdgeX122, greatEdgeZ221) +greatFaceY221 = MakeQuad(greatEdgeX221, greatEdgeZ221, greatEdgeX222, greatEdgeZ321) +greatFaceY321 = MakeQuad(greatEdgeX321, greatEdgeZ321, greatEdgeX322, greatEdgeZ421) + +greatFaceY112 = MakeQuad(greatEdgeX112, greatEdgeZ112, greatEdgeX113, greatEdgeZ212) +greatFaceY212 = MakeQuad(greatEdgeX212, greatEdgeZ212, greatEdgeX213, greatEdgeZ312) +greatFaceY312 = MakeQuad(greatEdgeX312, greatEdgeZ312, greatEdgeX313, greatEdgeZ412) +greatFaceY122 = MakeQuad(greatEdgeX122, greatEdgeZ122, greatEdgeX123, greatEdgeZ222) +greatFaceY222 = smallFaceY1 +greatFaceY322 = MakeQuad(greatEdgeX322, greatEdgeZ322, greatEdgeX323, greatEdgeZ422) + +greatFaceY113 = MakeQuad(greatEdgeX113, greatEdgeZ113, greatEdgeX114, greatEdgeZ213) +greatFaceY213 = MakeQuad(greatEdgeX213, greatEdgeZ213, greatEdgeX214, greatEdgeZ313) +greatFaceY313 = MakeQuad(greatEdgeX313, greatEdgeZ313, greatEdgeX314, greatEdgeZ413) +greatFaceY123 = MakeQuad(greatEdgeX123, greatEdgeZ123, greatEdgeX124, greatEdgeZ223) +greatFaceY223 = MakeQuad(greatEdgeX223, greatEdgeZ223, greatEdgeX224, greatEdgeZ323) +greatFaceY323 = MakeQuad(greatEdgeX323, greatEdgeZ323, greatEdgeX324, greatEdgeZ423) + +greatFaceZ11 = MakeQuad(greatEdgeX111, greatEdgeY11, greatEdgeX121, greatEdgeY21) +greatFaceZ21 = MakeQuad(greatEdgeX211, greatEdgeY21, greatEdgeX221, greatEdgeY31) +greatFaceZ31 = MakeQuad(greatEdgeX311, greatEdgeY31, greatEdgeX321, greatEdgeY41) + +greatFaceZ12 = MakeQuad(greatEdgeX112, greatEdgeY12, greatEdgeX122, greatEdgeY22) +greatFaceZ22 = MakeQuad(greatEdgeX212, greatEdgeY22, greatEdgeX222, greatEdgeY32) +greatFaceZ32 = MakeQuad(greatEdgeX312, greatEdgeY32, greatEdgeX322, greatEdgeY42) + +greatFaceZ13 = MakeQuad(greatEdgeX113, greatEdgeY13, greatEdgeX123, greatEdgeY23) +greatFaceZ23 = MakeQuad(greatEdgeX213, greatEdgeY23, greatEdgeX223, greatEdgeY33) +greatFaceZ33 = MakeQuad(greatEdgeX313, greatEdgeY33, greatEdgeX323, greatEdgeY43) + +greatFaceZ14 = MakeQuad(greatEdgeX114, greatEdgeY14, greatEdgeX124, greatEdgeY24) +greatFaceZ24 = MakeQuad(greatEdgeX214, greatEdgeY24, greatEdgeX224, greatEdgeY34) +greatFaceZ34 = MakeQuad(greatEdgeX314, greatEdgeY34, greatEdgeX324, greatEdgeY44) + +# Solids +# ------ + +smallBlock = MakeHexa(smallFaceX1, smallFaceX2, smallFaceY1, smallFaceY2, smallFaceZ1, smallFaceZ2) + +greatBlock11 = MakeHexa(greatFaceX11, greatFaceX21, greatFaceY111, greatFaceY121, greatFaceZ11, greatFaceZ12) +greatBlock21 = MakeHexa(greatFaceX21, greatFaceX31, greatFaceY211, greatFaceY221, greatFaceZ21, greatFaceZ22) +greatBlock31 = MakeHexa(greatFaceX31, greatFaceX41, greatFaceY311, greatFaceY321, greatFaceZ31, greatFaceZ32) + +greatBlock12 = MakeHexa(greatFaceX12, greatFaceX22, greatFaceY112, greatFaceY122, greatFaceZ12, greatFaceZ13) +greatBlock22 = MakeHexa(greatFaceX22, greatFaceX32, greatFaceY212, greatFaceY222, greatFaceZ22, greatFaceZ23) +greatBlock32 = MakeHexa(greatFaceX32, greatFaceX42, greatFaceY312, greatFaceY322, greatFaceZ32, greatFaceZ33) + +greatBlock13 = MakeHexa(greatFaceX13, greatFaceX23, greatFaceY113, greatFaceY123, greatFaceZ13, greatFaceZ14) +greatBlock23 = MakeHexa(greatFaceX23, greatFaceX33, greatFaceY213, greatFaceY223, greatFaceZ23, greatFaceZ24) +greatBlock33 = MakeHexa(greatFaceX33, greatFaceX43, greatFaceY313, greatFaceY323, greatFaceZ33, greatFaceZ34) + +# Compound +# -------- + +c_l = [] +c_l.append(smallBlock) +c_l.append(greatBlock11) +c_l.append(greatBlock21) +c_l.append(greatBlock31) +c_l.append(greatBlock12) +c_l.append(greatBlock22) +c_l.append(greatBlock32) +c_l.append(greatBlock13) +c_l.append(greatBlock23) +c_l.append(greatBlock33) + +c_cpd = MakeCompound(c_l) +piece = MakeGlueFaces(c_cpd, 1.e-5) + +# Add in study +# ------------ + +piece_id = addToStudy(piece, "Cubes2pyGibi") + +# Meshing +# ======= + +# Create hexahedrical mesh on piece +# --------------------------------- + +m_hexa=MeshHexa(piece, 4, "Cubes2pyGibiHexa") + +# Get edges +# --------- + +e_edges = SubShapeAllSorted(piece, ShapeType["EDGE"]) + +# Create local hypothesis +# ----------------------- + +m_local=3 + +m_i=10 +while m_i<18: + m_hexa.local(e_edges[m_i], m_local) + m_i=m_i+1 + +# Compute +# ------- + +m_hexa.Compute() diff --git a/src/SMESH_SWIG/cyl2complementary.py b/src/SMESH_SWIG/cyl2complementary.py new file mode 100644 index 000000000..c5a7f9afc --- /dev/null +++ b/src/SMESH_SWIG/cyl2complementary.py @@ -0,0 +1,100 @@ +# CEA/LGLS 2004, Francis KLOSS (OCC) +# ================================== + +# Import +# ------ + +from geompy import * +from meshpy import * + +# Piece +# ----- + +# Create the hexahedrical block geometry of a holed parallelepipede. +# The hole has a T form composed by 2 cylinders with different radius, and their axis are normal. +# This piece is meshed in hexahedrical. + +gx = 0 +gy = 0 +gz = 0 + +g_dx = 250 +g_dy = 200 +g_dz = 150 + +g_rayonGrand = 70 +g_rayonPetit = 50 + +g_trim = 1000 + +# Geometry +# ======== + +# The parallelepipede +# ------------------- + +p_boite = MakeBox(gx-g_dx, gy-g_dy, gz-g_dz, gx+g_dx, gy+g_dy, gz+g_dz) + +# The great cylinder +# ------------------ + +g_base = MakeVertex(gx-g_dx, gy, gz) +g_dir = MakeVectorDXDYDZ(1, 0, 0) +g_cyl = MakeCylinder(g_base, g_dir, g_rayonGrand, g_dx*2) + +# The first hole +# -------------- + +b_boite = MakeCut(p_boite , g_cyl) + +# Partitioning +# ------------ + +p_base = MakeVertex(gx, gy, gz) + +p_tools = [] + +p_tools.append(MakePlane(p_base, MakeVectorDXDYDZ(0, 1 , 0 ), g_trim)) +p_tools.append(MakePlane(p_base, MakeVectorDXDYDZ(0, g_dz, g_dy), g_trim)) +p_tools.append(MakePlane(p_base, MakeVectorDXDYDZ(0, -g_dz, g_dy), g_trim)) + +p_tools.append(MakePlane(MakeVertex(gx-g_rayonPetit, gy, gz), g_dir, g_trim)) +p_tools.append(MakePlane(MakeVertex(gx+g_rayonPetit, gy, gz), g_dir, g_trim)) + +p_piece = MakePartition([b_boite], p_tools, [], [], ShapeType["SOLID"]) + +# The small cylinder +# ------------------ + +c_cyl = MakeCylinder(p_base, MakeVectorDXDYDZ(0, 0, 1), g_rayonPetit, g_dz) + +# The second hole +# --------------- + +d_element = SubShapeAllSorted(p_piece, ShapeType["SOLID"]) + +d_element[ 8] = MakeCut(d_element[ 8], c_cyl) +d_element[10] = MakeCut(d_element[10], c_cyl) + +# Compound +# -------- + +piece = MakeCompound(d_element) + +# Add piece in study +# ------------------ + +piece_id = addToStudy(piece, "BoxHoled2Cylinders") + +# Meshing +# ======= + +# Mesh with hexahedrons +# --------------------- + +m_hexa=MeshHexa(piece, 4, "BoxHoled2CylindersHexa") + +# Compute mesh +# ------------ + +m_hexa.Compute() diff --git a/src/SMESH_SWIG/cyl2geometry.py b/src/SMESH_SWIG/cyl2geometry.py new file mode 100644 index 000000000..9e27f79ec --- /dev/null +++ b/src/SMESH_SWIG/cyl2geometry.py @@ -0,0 +1,170 @@ +# CEA/LGLS 2004, Francis KLOSS (OCC) +# ================================== + +# Import +# ------ + +from geompy import * +from meshpy import * + +# Piece +# ----- + +# Creer la geometrie en bloc hexahedrique d'une piece en forme de T composee de 2 cylindres de diametre different dont les axes se coupent orthogonalement, +# puis mailler en hexahedrique. + +cx = 0 +cy = 0 +cz = 0 + +g_rayon = 100.0 +g_hauteur = 500 + +p_rayon = 50.0 +p_hauteur = 500 + +g_trim = 1000 + +# Geometrie +# ========= + +cpd = [] + +# Gros cylindre +# ------------- + +g_base = MakeVertex(cx, cy, cz) +g_dir = MakeVectorDXDYDZ(0, 0, 1) +t_hauteur = p_rayon+10.0 + +g_cyl = MakeCylinder(g_base, g_dir, g_rayon, g_hauteur) + +g_coupe = MakeVectorDXDYDZ(1, 0, 0) + +g_tools = [] +g_tools.append(MakePlane(MakeVertex(cx+t_hauteur, cy, cz), g_coupe, g_trim)) +g_tools.append(MakePlane(MakeVertex(cx-t_hauteur, cy, cz), g_coupe, g_trim)) + +g_partie = MakePartition([g_cyl], g_tools, [], [], ShapeType["SOLID"]) +g_bas, g_centre, g_haut = SubShapeAllSorted(g_partie, ShapeType["SOLID"]) + +# Partie basse du gros cylindre +# ----------------------------- + +b_hauteur = 10 +b_base = 20 + +b_boite = MakeBox(cx-t_hauteur, cy-b_base, cz, cx-t_hauteur-b_hauteur, cy+b_base, cz+g_hauteur) +cpd.append(b_boite) + +b_cyl = MakeCut(g_bas, b_boite) + +b_tools = [] +b_tools.append(MakePlane(MakeVertex(cx-t_hauteur-b_hauteur, cy+b_base, cz), MakeVectorDXDYDZ( 1, 1, 0), g_trim)) +b_tools.append(MakePlane(MakeVertex(cx-t_hauteur-b_hauteur, cy-b_base, cz), MakeVectorDXDYDZ(-1, 1, 0), g_trim)) + +b_partie = MakePartition([b_cyl], b_tools, [], [], ShapeType["SOLID"]) +b_element = SubShapeAll(b_partie, ShapeType["SOLID"]) +cpd = cpd + b_element + +# Partie haute du gros cylindre +# ----------------------------- + +h_plan = MakePlane(g_base, g_coupe, g_trim) + +cpd.append(MakeMirrorByPlane(b_boite, h_plan)) + +for h in b_element: + h_symetrie = MakeMirrorByPlane(h, h_plan) + cpd.append(h_symetrie) + +# Petit cylindre +# -------------- + +z_arete = p_rayon/2 +x_arete = z_arete*t_hauteur*2/g_hauteur + +px = cx-x_arete +py = cy-1.5*g_rayon +pz = cz+g_hauteur/2 + +p_base = MakeVertex(cx, py, pz) +p_dir = MakeVectorDXDYDZ(0, 1, 0) +p_cyl = MakeCylinder(p_base, p_dir, p_rayon, p_hauteur) + +p_boite = MakeBox(px, py, pz-z_arete, cx+x_arete, py+p_hauteur, pz+z_arete) + +# Partie interieure du petit cylindre +# ----------------------------------- + +i_cyl = MakeCommon(p_cyl, g_cyl) +i_tuyau = MakeCut(i_cyl, p_boite) +i_boite = MakeCommon(p_boite, g_cyl) + +# Partie exterieure du petit cylindre +# ----------------------------------- + +e_cyl0 = MakeCut(p_cyl, g_cyl) +e_cyl = SubShapeAllSorted(e_cyl0, ShapeType["SOLID"]) + +e_tuyau = MakeCut(e_cyl[1], p_boite) + +e_boite0 = MakeCut(p_boite, g_cyl) +e_boite = SubShapeAllSorted(e_boite0, ShapeType["SOLID"]) + +cpd.append(e_boite[1]) + +# Partie centrale du gros cylindre +# -------------------------------- + +c_cyl = MakeCut(g_centre, p_cyl) + +# Partitionner +# ------------ + +p_tools = [] +p_tools.append(MakePlane(MakeVertex(px, py, pz-z_arete), MakeVectorDXDYDZ(-z_arete, 0, x_arete), g_trim)) +p_tools.append(MakePlane(MakeVertex(px, py, pz+z_arete), MakeVectorDXDYDZ( z_arete, 0, x_arete), g_trim)) + +p_partie = MakePartition([e_tuyau], p_tools, [], [], ShapeType["SOLID"]) +p_element = SubShapeAll(p_partie, ShapeType["SOLID"]) +cpd = cpd + p_element + +q_partie = MakePartition([i_tuyau, c_cyl], p_tools, [], [], ShapeType["SOLID"]) +q_element = SubShapeAll(q_partie, ShapeType["SOLID"]) + +q_element = q_element + [i_boite] + +q_tools = [] +q_tools.append(MakePlane(MakeVertex(cx, cy-b_base, cz), MakeVectorDXDYDZ(0, 1, 0), g_trim)) +q_tools.append(MakePlane(MakeVertex(cx, cy+b_base, cz), MakeVectorDXDYDZ(0, 1, 0), g_trim)) + +r_element = [] +for e in q_element: + r_partie = MakePartition([e], q_tools, [], [], ShapeType["SOLID"]) + r_element = r_element + SubShapeAll(r_partie, ShapeType["SOLID"]) + +cpd = cpd + r_element + +# Compound +# -------- + +piece = MakeCompound(cpd) + +# Ajouter la piece dans l'etude +# ----------------------------- + +piece_id = addToStudy(piece, "T2Cylindres") + +# Maillage +# ======== + +# Mailler des hexahedres +# ---------------------- + +m_hexa=MeshHexa(piece, 4, "T2CylindresHexa") + +# Calculer le maillage +# -------------------- + +m_hexa.Compute() diff --git a/src/SMESH_SWIG/grid17partition.py b/src/SMESH_SWIG/grid17partition.py new file mode 100644 index 000000000..ad7e4b2a4 --- /dev/null +++ b/src/SMESH_SWIG/grid17partition.py @@ -0,0 +1,108 @@ +# CEA/LGLS 2004, Francis KLOSS (OCC) +# ================================== + +# Import +# ------ + +from geompy import * +from meshpy import * + +# Piece +# ----- + +# grid compound of 17 x 17 elements +# an element is compound of 3 cylinders concentriques +# an element is centered in a square of the grid +# prisme the grid + +# Geometry +# -------- + +g_x = 0 +g_y = 0 +g_z = 0 + +g_arete = 50 +g_hauteur = 30 + +g_rayon1 = 20 +g_rayon2 = 30 +g_rayon3 = 40 + +# The real value for CEA, but need 3 days for computing +#g_grid = 17 +g_grid = 3 + +g_trim = 1000 + +# Solids +# ------ + +s_boite = MakeBox(g_x-g_arete, g_y-g_hauteur, g_z-g_arete, g_x+g_arete, g_y+g_hauteur, g_z+g_arete) + +s_pi4 = 3.141592653/4 +s_hauteur = 2*g_hauteur +s_centre = MakeVertex(g_x, g_y-g_hauteur, g_z) +s_dir = MakeVectorDXDYDZ(0, 1, 0) + +s_cyl0 = MakeCylinder(s_centre, s_dir, g_rayon3, s_hauteur) +s_cyl1 = MakeRotation(s_cyl0, s_dir, s_pi4) + +s_blo1 = MakeCut(s_boite, s_cyl1) + +s_cyl0 = MakeCylinder(s_centre, s_dir, g_rayon2, s_hauteur) +s_cyl2 = MakeRotation(s_cyl0, s_dir, s_pi4) + +s_blo2 = MakeCut(s_cyl1, s_cyl2) + +s_cyl0 = MakeCylinder(s_centre, s_dir, g_rayon1, s_hauteur) +s_cyl3 = MakeRotation(s_cyl0, s_dir, s_pi4) + +s_blo3 = MakeCut(s_cyl2, s_cyl3) + +s_arete = g_rayon1/2 + +s_blo4 = MakeBox(g_x-s_arete, g_y-g_hauteur, g_z-s_arete, g_x+s_arete, g_y+g_hauteur, g_z+s_arete) + +s_blo5 = MakeCut(s_cyl3, s_blo4) + +# Partition +# --------- + +p_tools = [] +p_tools.append(MakePlane(s_centre, MakeVectorDXDYDZ( 1, 0, 1), g_trim)) +p_tools.append(MakePlane(s_centre, MakeVectorDXDYDZ(-1, 0, 1), g_trim)) + +p_partie = MakePartition([s_blo1, s_blo2, s_blo3, s_blo5], p_tools, [], [], ShapeType["SOLID"]) + +# Compound +# -------- + +c_cpd = SubShapeAll(p_partie, ShapeType["SOLID"]) +c_cpd.append(s_blo4) + +c_element = MakeCompound(c_cpd) + +# Grid +# ---- + +piece = MakeMultiTranslation2D(c_element, MakeVectorDXDYDZ(1, 0, 0), 2*g_arete, g_grid, + MakeVectorDXDYDZ(0, 0, 1), 2*g_arete, g_grid) + +# Add in study +# ------------ + +piece_id = addToStudy(piece, "Grid17partition") + +# Meshing +# ======= + +# Create hexahedrical mesh on piece +# --------------------------------- + +m_hexa=MeshHexa(piece, 4, "Grid17partitionHexa") + +# Compute +# ------- + +m_hexa.Compute() diff --git a/src/SMESH_SWIG/grid3partition.py b/src/SMESH_SWIG/grid3partition.py new file mode 100644 index 000000000..63e498dca --- /dev/null +++ b/src/SMESH_SWIG/grid3partition.py @@ -0,0 +1,94 @@ +# CEA/LGLS 2004, Francis KLOSS (OCC) +# ================================== + +# Import +# ------ + +from geompy import * +from meshpy import * + +# Piece +# ----- + +# grid compound of 3 x 3 elements +# an element is compound of 3 cylinders concentriques +# an element is centered in a square of the grid +# the smaller cylinder is a hole + +# prisme the grid + +# Geometry +# -------- + +g_x = 0 +g_y = 0 +g_z = 0 + +g_arete = 50 +g_hauteur = 30 + +g_rayon1 = 20 +g_rayon2 = 30 +g_rayon3 = 40 + +g_grid = 3 + +g_trim = 1000 + +# Element +# ------- + +e_boite = MakeBox(g_x-g_arete, g_y-g_hauteur, g_z-g_arete, g_x+g_arete, g_y+g_hauteur, g_z+g_arete) + +e_pi4 = 3.141592653/4 +e_hauteur = 2*g_hauteur +e_centre = MakeVertex(g_x, g_y-g_hauteur, g_z) +e_dir = MakeVectorDXDYDZ(0, 1, 0) + +e_cyl0 = MakeCylinder(e_centre, e_dir, g_rayon3, e_hauteur) +e_cyl1 = MakeRotation(e_cyl0, e_dir, e_pi4) + +e_blo1 = MakeCut(e_boite, e_cyl1) + +e_cyl0 = MakeCylinder(e_centre, e_dir, g_rayon2, e_hauteur) +e_cyl2 = MakeRotation(e_cyl0, e_dir, e_pi4) + +e_blo2 = MakeCut(e_cyl1, e_cyl2) + +e_cyl0 = MakeCylinder(e_centre, e_dir, g_rayon1, e_hauteur) +e_cyl3 = MakeRotation(e_cyl0, e_dir, e_pi4) + +e_blo3 = MakeCut(e_cyl2, e_cyl3) + +# Partition +# --------- + +p_tools = [] +p_tools.append(MakePlane(e_centre, MakeVectorDXDYDZ( 1, 0, 1), g_trim)) +p_tools.append(MakePlane(e_centre, MakeVectorDXDYDZ(-1, 0, 1), g_trim)) + +p_element = MakePartition([e_blo1, e_blo2, e_blo3], p_tools, [], [], ShapeType["SOLID"]) + +# Grid +# ---- + +piece = MakeMultiTranslation2D(p_element, MakeVectorDXDYDZ(1, 0, 0), 2*g_arete, g_grid, + MakeVectorDXDYDZ(0, 0, 1), 2*g_arete, g_grid) + +# Add in study +# ------------ + +piece_id = addToStudy(piece, "Grid3partition") + +# Meshing +# ======= + +# Create hexahedrical mesh on piece +# --------------------------------- + +m_hexa=MeshHexa(piece, 4, "Grid3partitionHexa") + +# Compute +# ------- + +m_hexa.Compute() diff --git a/src/SMESH_SWIG/grid4partition.py b/src/SMESH_SWIG/grid4partition.py new file mode 100644 index 000000000..4019d4bbf --- /dev/null +++ b/src/SMESH_SWIG/grid4partition.py @@ -0,0 +1,72 @@ +# CEA/LGLS 2004, Francis KLOSS (OCC) +# ================================== + +# Import +# ------ + +from geompy import * +from meshpy import * + +# Piece +# ----- + +# grid compound by a square with a cylinder on each vertex + +# Geometry +# -------- + +ox = 0 +oy = 0 +oz = 0 + +arete = 50 +hauteur = 100 +rayon = 10 + +g_trim = 1000 + +# Box +# --- + +piecePoint = MakeVertex(ox, oy, oz) + +pieceBox = MakeBoxTwoPnt(piecePoint, MakeVertex(ox+arete, oy+hauteur, oz+arete)) + +# Cut by cylinders +# ---------------- + +dirUp = MakeVectorDXDYDZ(0, 1, 0) + +pieceCut1 = MakeCut(pieceBox , MakeCylinder(piecePoint , dirUp, rayon, hauteur)) +pieceCut2 = MakeCut(pieceCut1, MakeCylinder(MakeVertex(ox+arete, oy, oz ), dirUp, rayon, hauteur)) +pieceCut3 = MakeCut(pieceCut2, MakeCylinder(MakeVertex(ox , oy, oz+arete), dirUp, rayon, hauteur)) +pieceCut4 = MakeCut(pieceCut3, MakeCylinder(MakeVertex(ox+arete, oy, oz+arete), dirUp, rayon, hauteur)) + +# Compound by make a partition of a solid +# --------------------------------------- + +dir = MakeVectorDXDYDZ(-1, 0, 1) + +tools = [] +tools.append(MakePlane(MakeVertex(ox+rayon, oy, oz ), dir, g_trim)) +tools.append(MakePlane(MakeVertex(ox , oy, oz+rayon), dir, g_trim)) + +piece = MakePartition([pieceCut4], tools, [], [], ShapeType["SOLID"]) + +# Add in study +# ------------ + +piece_id = addToStudy(piece, "Grid4partition") + +# Meshing +# ======= + +# Create hexahedrical mesh on piece +# --------------------------------- + +m_hexa=MeshHexa(piece, 4, "Grid4partitionHexa") + +# Compute +# ------- + +m_hexa.Compute() diff --git a/src/SMESH_SWIG/grid4pyGibi.py b/src/SMESH_SWIG/grid4pyGibi.py new file mode 100644 index 000000000..d77f3b546 --- /dev/null +++ b/src/SMESH_SWIG/grid4pyGibi.py @@ -0,0 +1,114 @@ +# CEA/LGLS 2004, Francis KLOSS (OCC) +# ================================== + +# Import +# ------ + +from geompy import * +from meshpy import * + +import math + +# Piece +# ----- + +# grid compound by a square with a cylinder on each vertex + +# Geometry +# -------- + +ox = 0 +oy = 0 +oz = 0 + +arete = 50 +hauteur = 100 + +rayon = 10 + +demi = rayon/2 +r3 = demi*math.sqrt(3) + +# Points +# ------ + +piecePoint111 = MakeVertex(ox+rayon , oy, oz) +piecePoint211 = MakeVertex(ox+arete-rayon, oy, oz) +piecePoint112 = MakeVertex(ox , oy, oz+rayon) +piecePoint212 = MakeVertex(ox+arete , oy, oz+rayon) +piecePoint113 = MakeVertex(ox , oy, oz+arete-rayon) +piecePoint213 = MakeVertex(ox+arete , oy, oz+arete-rayon) +piecePoint114 = MakeVertex(ox+rayon , oy, oz+arete) +piecePoint214 = MakeVertex(ox+arete-rayon, oy, oz+arete) + +pieceCenter1 = MakeVertex(ox , oy, oz) +pieceCenter2 = MakeVertex(ox+arete , oy, oz) +pieceCenter3 = MakeVertex(ox , oy, oz+arete) +pieceCenter4 = MakeVertex(ox+arete , oy, oz+arete) + +piecePass1 = MakeVertex(ox+demi , oy, oz+r3) +piecePass2 = MakeVertex(ox+arete-demi , oy, oz+r3) +piecePass3 = MakeVertex(ox+arete-demi , oy, oz+arete-r3) +piecePass4 = MakeVertex(ox+demi , oy, oz+arete-r3) + +# Edges +# ----- + +pieceEdgeSquare1 = MakeEdge(piecePoint111, piecePoint211) +pieceEdgeSquare2 = MakeEdge(piecePoint114, piecePoint214) +pieceEdgeSquare3 = MakeEdge(piecePoint112, piecePoint113) +pieceEdgeSquare4 = MakeEdge(piecePoint212, piecePoint213) + +pieceEdgeDiagonal1 = MakeEdge(piecePoint111, piecePoint213) +pieceEdgeDiagonal2 = MakeEdge(piecePoint112, piecePoint214) + +pieceEdgeArc1 = MakeArc(piecePoint111, piecePass1, piecePoint112) +pieceEdgeArc2 = MakeArc(piecePoint211, piecePass2, piecePoint212) +pieceEdgeArc3 = MakeArc(piecePoint213, piecePass3, piecePoint214) +pieceEdgeArc4 = MakeArc(piecePoint113, piecePass4, piecePoint114) + +# Faces +# ----- + +pieceFace1 = MakeQuad(pieceEdgeSquare1, pieceEdgeArc2, pieceEdgeSquare4, pieceEdgeDiagonal1) +pieceFace2 = MakeQuad(pieceEdgeSquare2, pieceEdgeArc4, pieceEdgeSquare3, pieceEdgeDiagonal2) + +pieceFace3 = MakeQuad(pieceEdgeArc1, pieceEdgeDiagonal1, pieceEdgeArc3, pieceEdgeDiagonal2) + +# Solids +# ------ + +pieceVector = MakeVectorDXDYDZ(0, 1, 0) + +pieceSolid1 = MakePrismVecH(pieceFace1, pieceVector, hauteur) +pieceSolid2 = MakePrismVecH(pieceFace2, pieceVector, hauteur) +pieceSolid3 = MakePrismVecH(pieceFace3, pieceVector, hauteur) + +# Compound +# -------- + +c_l = [] +c_l.append(pieceSolid1) +c_l.append(pieceSolid2) +c_l.append(pieceSolid3) + +c_cpd = MakeCompound(c_l) +piece = MakeGlueFaces(c_cpd, 1.e-5) + +# Add in study +# ------------ + +piece_id = addToStudy(piece, "Grid4pyGibi") + +# Meshing +# ======= + +# Create hexahedrical mesh on piece +# --------------------------------- + +m_hexa=MeshHexa(piece, 4, "Grid4pyGibiHexa") + +# Compute +# ------- + +m_hexa.Compute() diff --git a/src/SMESH_SWIG/hole1geometry.py b/src/SMESH_SWIG/hole1geometry.py new file mode 100644 index 000000000..9622dc7df --- /dev/null +++ b/src/SMESH_SWIG/hole1geometry.py @@ -0,0 +1,109 @@ +# CEA/LGLS 2004, Francis KLOSS (OCC) +# ================================== + +# Import +# ------ + +from geompy import * +from meshpy import * + +# Piece +# ----- + +# A holed cube + +# Geometry +# -------- + +ox = 0 +oy = 0 +oz = 0 + +longueur1 = 30 +longueur2 = 70 + +largeur1 = 30 +largeur2 = 50 + +hauteur = 50 + +rayon = 10 + +# Triangular face +# --------------- + +def triangle(p1, p2, p3): + l = [] + l.append(MakeEdge(p1, p2)) + l.append(MakeEdge(p2, p3)) + l.append(MakeEdge(p3, p1)) + w = MakeWire(l) + return MakeFace(w, 1) + +# Points +# ------ + +basePoint111 = MakeVertex(ox-longueur1, oy, oz-largeur1) +basePoint211 = MakeVertex(ox+longueur2, oy, oz-largeur1) +basePoint112 = MakeVertex(ox-longueur1, oy, oz+largeur2) +basePoint212 = MakeVertex(ox+longueur2, oy, oz+largeur2) + +holePoint = MakeVertex(ox, oy, oz) + +# Faces +# ----- + +baseFace1 = triangle(basePoint111, basePoint211, holePoint) +baseFace2 = triangle(basePoint211, basePoint212, holePoint) +baseFace3 = triangle(basePoint212, basePoint112, holePoint) +baseFace4 = triangle(basePoint112, basePoint111, holePoint) + +# Solids +# ------ + +baseVector = MakeVectorDXDYDZ(0, 1, 0) + +baseSolid1 = MakePrismVecH(baseFace1, baseVector, hauteur) +baseSolid2 = MakePrismVecH(baseFace2, baseVector, hauteur) +baseSolid3 = MakePrismVecH(baseFace3, baseVector, hauteur) +baseSolid4 = MakePrismVecH(baseFace4, baseVector, hauteur) + +holeSolid = MakeCylinder(holePoint, baseVector, rayon, hauteur) + +# Boolean operations +# ------------------ + +baseHexa1 = MakeCut(baseSolid1, holeSolid) +baseHexa2 = MakeCut(baseSolid2, holeSolid) +baseHexa3 = MakeCut(baseSolid3, MakeRotation(holeSolid, baseVector, 3.141592653)) +baseHexa4 = MakeCut(baseSolid4, holeSolid) + +# Compound +# -------- + +c_l = [] +c_l.append(baseHexa1) +c_l.append(baseHexa2) +c_l.append(baseHexa3) +c_l.append(baseHexa4) + +c_cpd = MakeCompound(c_l) +piece = MakeGlueFaces(c_cpd, 1.e-5) + +# Add in study +# ------------ + +piece_id = addToStudy(piece, "Hole1geometry") + +# Meshing +# ======= + +# Create hexahedrical mesh on piece +# --------------------------------- + +m_hexa=MeshHexa(piece, 4, "Hole1geometryHexa") + +# Compute +# ------- + +m_hexa.Compute() diff --git a/src/SMESH_SWIG/hole1partition.py b/src/SMESH_SWIG/hole1partition.py new file mode 100644 index 000000000..415046d06 --- /dev/null +++ b/src/SMESH_SWIG/hole1partition.py @@ -0,0 +1,75 @@ +# CEA/LGLS 2004, Francis KLOSS (OCC) +# ================================== + +# Import +# ------ + +from geompy import * +from meshpy import * + +import math + +# Piece +# ----- + +# A holed cube at center for partitioning + +# Geometry +# -------- + +g_x = 0 +g_y = 0 +g_z = 0 + +g_longueur = 50.0 +g_largeur = 40.0 +g_hauteur = 25.0 + +g_rayon = 10 + +g_trim = 1000 + +# Box +# --- + +b_boite = MakeBox(g_x-g_longueur, g_y-g_hauteur, g_z-g_largeur, + g_x+g_longueur, g_y+g_hauteur, g_z+g_largeur) + +# Cylinder +# -------- + +c_axe = MakeVectorDXDYDZ(0, 1, 0) + +c_cyl0 = MakeCylinder(MakeVertex(g_x, g_y-g_hauteur, g_z), c_axe, g_rayon, g_hauteur*2) +c_cyl = MakeRotation(c_cyl0, c_axe, math.atan(g_longueur/g_largeur)) + +c_piece = MakeCut(b_boite, c_cyl) + +# Partition +# --------- + +p_centre = MakeVertex(g_x, g_y, g_z) + +p_tools = [] +p_tools.append(MakePlane(p_centre, MakeVectorDXDYDZ( g_largeur, 0, g_longueur), g_trim)) +p_tools.append(MakePlane(p_centre, MakeVectorDXDYDZ(-g_largeur, 0, g_longueur), g_trim)) + +piece = MakePartition([c_piece], p_tools, [], [], ShapeType["SOLID"]) + +# Add in study +# ------------ + +piece_id = addToStudy(piece, "Hole1partition") + +# Meshing +# ======= + +# Create hexahedrical mesh on piece +# --------------------------------- + +m_hexa=MeshHexa(piece, 4, "Hole1partitionHexa") + +# Compute +# ------- + +m_hexa.Compute() diff --git a/src/SMESH_SWIG/hole1pyGibi.py b/src/SMESH_SWIG/hole1pyGibi.py new file mode 100644 index 000000000..7c2fb60ef --- /dev/null +++ b/src/SMESH_SWIG/hole1pyGibi.py @@ -0,0 +1,116 @@ +# CEA/LGLS 2004, Francis KLOSS (OCC) +# ================================== + +# Import +# ------ + +from geompy import * +from meshpy import * + +import math + +# Piece +# ----- + +# A centered holed cube + +# Geometry +# -------- + +ox = 0 +oy = 0 +oz = 0 + +longueur = 100 +largeur = 80 +hauteur = 50 + +rayon = 10 + +# Points +# ------ + +basePoint111 = MakeVertex(ox , oy, oz) +basePoint211 = MakeVertex(ox+longueur, oy, oz) +basePoint112 = MakeVertex(ox , oy, oz+largeur) +basePoint212 = MakeVertex(ox+longueur, oy, oz+largeur) + +cx = ox+longueur/2 +cy = oy +cz = oz+largeur/2 + +ll = longueur/largeur +ll = ll*ll +dx = rayon/math.sqrt(1+ll) +dz = rayon/math.sqrt(1+1/ll) + +circlePoint1 = MakeVertex(cx-dx, cy, cz-dz) +circlePoint2 = MakeVertex(cx+dx, cy, cz-dz) +circlePoint3 = MakeVertex(cx+dx, cy, cz+dz) +circlePoint4 = MakeVertex(cx-dx, cy, cz+dz) + +# Edges +# ----- + +squareEdge1 = MakeEdge(basePoint111, basePoint211) +squareEdge2 = MakeEdge(basePoint211, basePoint212) +squareEdge3 = MakeEdge(basePoint212, basePoint112) +squareEdge4 = MakeEdge(basePoint112, basePoint111) + +diagEdge1 = MakeEdge(basePoint111, circlePoint1) +diagEdge2 = MakeEdge(basePoint211, circlePoint2) +diagEdge3 = MakeEdge(basePoint212, circlePoint3) +diagEdge4 = MakeEdge(basePoint112, circlePoint4) + +arcEdge1 = MakeArc(circlePoint1, MakeVertex(cx , cy, cz-rayon), circlePoint2) +arcEdge2 = MakeArc(circlePoint2, MakeVertex(cx+rayon, cy, cz ), circlePoint3) +arcEdge3 = MakeArc(circlePoint3, MakeVertex(cx , cy, cz+rayon), circlePoint4) +arcEdge4 = MakeArc(circlePoint4, MakeVertex(cx-rayon, cy, cz ), circlePoint1) + +# Faces +# ----- + +baseFace1 = MakeQuad(squareEdge1, diagEdge2, arcEdge1, diagEdge1) +baseFace2 = MakeQuad(squareEdge2, diagEdge3, arcEdge2, diagEdge2) +baseFace3 = MakeQuad(squareEdge3, diagEdge4, arcEdge3, diagEdge3) +baseFace4 = MakeQuad(squareEdge4, diagEdge1, arcEdge4, diagEdge4) + +# Solids +# ------ + +baseVector = MakeVectorDXDYDZ(0, 1, 0) + +baseSolid1 = MakePrismVecH(baseFace1, baseVector, hauteur) +baseSolid2 = MakePrismVecH(baseFace2, baseVector, hauteur) +baseSolid3 = MakePrismVecH(baseFace3, baseVector, hauteur) +baseSolid4 = MakePrismVecH(baseFace4, baseVector, hauteur) + +# Compound +# -------- + +c_l = [] +c_l.append(baseSolid1) +c_l.append(baseSolid2) +c_l.append(baseSolid3) +c_l.append(baseSolid4) + +c_cpd = MakeCompound(c_l) +piece = MakeGlueFaces(c_cpd, 1.e-5) + +# Add in study +# ------------ + +piece_id = addToStudy(piece, "Hole1pyGibi") + +# Meshing +# ======= + +# Create hexahedrical mesh on piece +# --------------------------------- + +m_hexa=MeshHexa(piece, 4, "Hole1pyGibiHexa") + +# Compute +# ------- + +m_hexa.Compute() diff --git a/src/SMESH_SWIG/hole2pyGibi.py b/src/SMESH_SWIG/hole2pyGibi.py new file mode 100644 index 000000000..3db513c2a --- /dev/null +++ b/src/SMESH_SWIG/hole2pyGibi.py @@ -0,0 +1,113 @@ +# CEA/LGLS 2004, Francis KLOSS (OCC) +# ================================== + +# Import +# ------ + +from geompy import * +from meshpy import * + +# Piece +# ----- + +# A twice holed cube + +# Geometry +# -------- + +ox = 0 +oy = 0 +oz = 0 + +longueur = 200 +largeur = 100 +hauteur = 80 + +cylindre = 50 + +rayon = 20 + +# Points +# ------ + +piecePoint1 = MakeVertex(ox , oy, oz) +piecePoint2 = MakeVertex(ox+longueur, oy, oz) +piecePoint3 = MakeVertex(ox+longueur, oy, oz+largeur) +piecePoint4 = MakeVertex(ox , oy, oz+largeur) + +cz = oz+largeur/2 + +cylPoint1 = MakeVertex(ox+cylindre , oy, cz-rayon) +cylPoint2 = MakeVertex(ox+longueur-cylindre, oy, cz-rayon) +cylPoint3 = MakeVertex(ox+longueur-cylindre, oy, cz+rayon) +cylPoint4 = MakeVertex(ox+cylindre , oy, cz+rayon) + +# Edges +# ----- + +pieceEdge1 = MakeEdge(piecePoint1, piecePoint4) +pieceEdge2 = MakeEdge(piecePoint1, cylPoint1) +pieceEdge3 = MakeEdge(piecePoint4, cylPoint4) + +pieceEdge4 = MakeEdge(piecePoint2, piecePoint3) +pieceEdge5 = MakeEdge(piecePoint2, cylPoint2) +pieceEdge6 = MakeEdge(piecePoint3, cylPoint3) + +pieceEdge7 = MakeEdge(cylPoint1, cylPoint2) +pieceEdge8 = MakeEdge(cylPoint3, cylPoint4) + +cylEdge1 = MakeArc(cylPoint1, MakeVertex(ox+cylindre-rayon , oy, cz), cylPoint4) +cylEdge2 = MakeArc(cylPoint1, MakeVertex(ox+cylindre+rayon , oy, cz), cylPoint4) +cylEdge3 = MakeArc(cylPoint2, MakeVertex(ox+longueur-cylindre-rayon, oy, cz), cylPoint3) +cylEdge4 = MakeArc(cylPoint2, MakeVertex(ox+longueur-cylindre+rayon, oy, cz), cylPoint3) + +# Faces +# ----- + +pieceFace1 = MakeQuad4Vertices(piecePoint1, piecePoint2, cylPoint2 , cylPoint1 ) +pieceFace2 = MakeQuad (pieceEdge1 , pieceEdge2 , cylEdge1 , pieceEdge3) +pieceFace3 = MakeQuad4Vertices(piecePoint3, piecePoint4, cylPoint4 , cylPoint3 ) +pieceFace4 = MakeQuad (pieceEdge4 , pieceEdge5 , cylEdge4 , pieceEdge6) +pieceFace5 = MakeQuad (pieceEdge7 , cylEdge3 , pieceEdge8, cylEdge2 ) + +# Solids +# ------ + +pieceVector = MakeVectorDXDYDZ(0, 1, 0) + +pieceSolid1 = MakePrismVecH(pieceFace1, pieceVector, hauteur) +pieceSolid2 = MakePrismVecH(pieceFace2, pieceVector, hauteur) +pieceSolid3 = MakePrismVecH(pieceFace3, pieceVector, hauteur) +pieceSolid4 = MakePrismVecH(pieceFace4, pieceVector, hauteur) +pieceSolid5 = MakePrismVecH(pieceFace5, pieceVector, hauteur) + +# Compound +# -------- + +c_l = [] +c_l.append(pieceSolid1) +c_l.append(pieceSolid2) +c_l.append(pieceSolid3) +c_l.append(pieceSolid4) +c_l.append(pieceSolid5) + +c_cpd = MakeCompound(c_l) +piece = MakeGlueFaces(c_cpd, 1.e-5) + +# Add in study +# ------------ + +piece_id = addToStudy(piece, "Hole2pyGibi") + +# Meshing +# ======= + +# Create hexahedrical mesh on piece +# --------------------------------- + +m_hexa=MeshHexa(piece, 4, "Hole2pyGibiHexa") + +# Compute +# ------- + +m_hexa.Compute() diff --git a/src/SMESH_SWIG/meshpy.py b/src/SMESH_SWIG/meshpy.py new file mode 100644 index 000000000..757a6fea6 --- /dev/null +++ b/src/SMESH_SWIG/meshpy.py @@ -0,0 +1,101 @@ +# CEA/LGLS 2004, Francis KLOSS (OCC) +# ================================== + +# Import +# ------ + +import geompy + +import salome + +import StdMeshers + +# Variables +# --------- + +smesh = salome.lcc.FindOrLoadComponent("FactoryServer", "SMESH") +smesh.SetCurrentStudy(salome.myStudy) +smeshgui = salome.ImportComponentGUI("SMESH") +smeshgui.Init(salome.myStudyId) + +# Hexahedrical meshing +# +# Examples: cube2pyGibi.py, lines 270-295 +# cube2partition.py, lines 72-83 +# -------------------- + +class MeshHexaImpl: + piece = 0 + name = 0 + mesh = 0 + cpt = 0 + + # Sets algorithm and hypothesis for 1D discretization of the : + # - algorithm "Regular_1D" + # - hypothesis "NumberOfSegments" with number of segments + # -------------------- + + def Mesh1D(self, shape, n): + hyp1D=smesh.CreateHypothesis("Regular_1D", "libStdMeshersEngine.so") + smeshgui.SetName(salome.ObjectToID(hyp1D), self.name+"/WireDiscretisation/"+str(self.cpt)) + self.mesh.AddHypothesis(shape, hyp1D) + + hyp=smesh.CreateHypothesis("NumberOfSegments", "libStdMeshersEngine.so") + hyp.SetNumberOfSegments(n) + smeshgui.SetName(salome.ObjectToID(hyp), self.name+"/Segments_"+str(n)+"/"+str(self.cpt)) + self.mesh.AddHypothesis(shape, hyp) + + self.cpt=self.cpt+1 + + # Constructor + # + # Creates mesh on the shape , + # sets GUI name of this mesh to . + # Sets the following global algorithms and hypotheses: + # - for 1D discretization: + # - algorithm "Regular_1D" + # - hypothesis "NumberOfSegments" with number of segments , + # - for 2D discretization: + # - algorithm "Quadrangle_2D" + # - for 3D discretization: + # - algorithm "Hexa_3D" + # -------------------- + + def __init__(self, piece, n, name): + self.piece = piece + self.name = name + + self.mesh = smesh.CreateMesh(piece) + smeshgui.SetName(salome.ObjectToID(self.mesh), name) + + self.Mesh1D(piece, n) + + hyp2D=smesh.CreateHypothesis("Quadrangle_2D", "libStdMeshersEngine.so") + smeshgui.SetName(salome.ObjectToID(hyp2D), name+"/Quadrangle") + self.mesh.AddHypothesis(piece, hyp2D) + + hyp3D=smesh.CreateHypothesis("Hexa_3D", "libStdMeshersEngine.so") + smeshgui.SetName(salome.ObjectToID(hyp3D), name+"/ijk") + self.mesh.AddHypothesis(piece, hyp3D) + + # Creates sub-mesh of the mesh, created by constructor. + # This sub-mesh will be created on edge . + # Set algorithm and hypothesis for 1D discretization of the : + # - algorithm "Regular_1D" + # - hypothesis "NumberOfSegments" with number of segments + # Note: the will be automatically published in study under the shape, given in constructor. + # -------------------- + + def local(self, edge, n): + geompy.addToStudyInFather(self.piece, edge, geompy.SubShapeName(edge, self.piece)) + submesh = self.mesh.GetSubMesh(edge, self.name+"/SubMeshEdge/"+str(self.cpt)) + self.Mesh1D(edge, n) + + # Computes mesh, created by constructor. + # -------------------- + + def Compute(self): + smesh.Compute(self.mesh, self.piece) + salome.sg.updateObjBrowser(1) + +MeshHexa = MeshHexaImpl diff --git a/src/StdMeshers/Makefile.in b/src/StdMeshers/Makefile.in index b7d66f8d1..92e94c168 100644 --- a/src/StdMeshers/Makefile.in +++ b/src/StdMeshers/Makefile.in @@ -35,9 +35,13 @@ VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl # header files EXPORT_HEADERS = \ - StdMeshers_LengthFromEdges.hxx \ StdMeshers_LocalLength.hxx \ + StdMeshers_StartEndLength.hxx \ + StdMeshers_Arithmetic1D.hxx \ StdMeshers_NumberOfSegments.hxx \ + StdMeshers_Deflection1D.hxx \ + StdMeshers_Propagation.hxx \ + StdMeshers_LengthFromEdges.hxx \ StdMeshers_MaxElementArea.hxx \ StdMeshers_MaxElementVolume.hxx \ StdMeshers_NotConformAllowed.hxx \ @@ -53,11 +57,15 @@ EXPORT_PYSCRIPTS = LIB = libStdMeshers.la LIB_SRC = \ - StdMeshers_LengthFromEdges.cxx \ StdMeshers_LocalLength.cxx \ + StdMeshers_StartEndLength.cxx \ + StdMeshers_Arithmetic1D.cxx \ + StdMeshers_NumberOfSegments.cxx \ + StdMeshers_Deflection1D.cxx \ + StdMeshers_Propagation.cxx \ + StdMeshers_LengthFromEdges.cxx \ StdMeshers_MaxElementArea.cxx \ StdMeshers_MaxElementVolume.cxx \ - StdMeshers_NumberOfSegments.cxx \ StdMeshers_NotConformAllowed.cxx \ StdMeshers_Regular_1D.cxx \ StdMeshers_Quadrangle_2D.cxx \ diff --git a/src/StdMeshers/StdMeshers_Arithmetic1D.cxx b/src/StdMeshers/StdMeshers_Arithmetic1D.cxx new file mode 100644 index 000000000..d07a53608 --- /dev/null +++ b/src/StdMeshers/StdMeshers_Arithmetic1D.cxx @@ -0,0 +1,139 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_Arithmetic1D.cxx +// Author : Damien COQUERET, OCC +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_Arithmetic1D.hxx" + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_Arithmetic1D::StdMeshers_Arithmetic1D(int hypId, int studyId, + SMESH_Gen * gen):SMESH_Hypothesis(hypId, studyId, gen) +{ + _begLength = 1.; + _endLength = 1.; + _name = "Arithmetic1D"; + _param_algo_dim = 1; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_Arithmetic1D::~StdMeshers_Arithmetic1D() +{ +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void StdMeshers_Arithmetic1D::SetLength(double length, bool isStartLength) + throw(SALOME_Exception) +{ + if ( (isStartLength ? _begLength : _endLength) != length ) { + if (length <= 0) + throw SALOME_Exception(LOCALIZED("length must be positive")); + if ( isStartLength ) + _begLength = length; + else + _endLength = length; + + NotifySubMeshesHypothesisModification(); + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +double StdMeshers_Arithmetic1D::GetLength(bool isStartLength) const +{ + return isStartLength ? _begLength : _endLength; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & StdMeshers_Arithmetic1D::SaveTo(ostream & save) +{ + save << _begLength << _endLength; + return save; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & StdMeshers_Arithmetic1D::LoadFrom(istream & load) +{ + bool isOK = true; + isOK = (load >> _begLength); + if (!isOK) + load.clear(ios::badbit | load.rdstate()); + isOK = (load >> _endLength); + if (!isOK) + load.clear(ios::badbit | load.rdstate()); + return load; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & operator <<(ostream & save, StdMeshers_Arithmetic1D & hyp) +{ + return hyp.SaveTo( save ); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & operator >>(istream & load, StdMeshers_Arithmetic1D & hyp) +{ + return hyp.LoadFrom( load ); +} diff --git a/src/StdMeshers/StdMeshers_Arithmetic1D.hxx b/src/StdMeshers/StdMeshers_Arithmetic1D.hxx new file mode 100644 index 000000000..ca49df175 --- /dev/null +++ b/src/StdMeshers/StdMeshers_Arithmetic1D.hxx @@ -0,0 +1,55 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_Arithmetic1D.hxx +// Author : Damien COQUERET, OCC +// Module : SMESH +// $Header$ + +#ifndef _SMESH_ARITHMETIC1D_HXX_ +#define _SMESH_ARITHMETIC1D_HXX_ + +#include "SMESH_Hypothesis.hxx" +#include "Utils_SALOME_Exception.hxx" + +class StdMeshers_Arithmetic1D: + public SMESH_Hypothesis +{ +public: + StdMeshers_Arithmetic1D(int hypId, int studyId, SMESH_Gen* gen); + virtual ~StdMeshers_Arithmetic1D(); + + void SetLength(double length, bool isStartLength) throw(SALOME_Exception); + + double GetLength(bool isStartLength) const; + + virtual ostream & SaveTo(ostream & save); + virtual istream & LoadFrom(istream & load); + friend ostream& operator << (ostream & save, StdMeshers_Arithmetic1D & hyp); + friend istream& operator >> (istream & load, StdMeshers_Arithmetic1D & hyp); + +protected: + double _begLength, _endLength; +}; + +#endif diff --git a/src/StdMeshers/StdMeshers_Deflection1D.cxx b/src/StdMeshers/StdMeshers_Deflection1D.cxx new file mode 100644 index 000000000..f6e54691c --- /dev/null +++ b/src/StdMeshers/StdMeshers_Deflection1D.cxx @@ -0,0 +1,136 @@ +// SMESH StdMeshers_Deflection1D : 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_Deflection1D.cxx +// Module : SMESH +// $Header$ + +using namespace std; + +#include "StdMeshers_Deflection1D.hxx" +#include "utilities.h" + + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_Deflection1D::StdMeshers_Deflection1D(int hypId, + int studyId, + SMESH_Gen * gen) + :SMESH_Hypothesis(hypId, studyId, gen) +{ + _value = 1.; + _name = "Deflection1D"; + _param_algo_dim = 1; // is used by SMESH_Regular_1D +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_Deflection1D::~StdMeshers_Deflection1D() +{ +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void StdMeshers_Deflection1D::SetDeflection(double value) + throw(SALOME_Exception) +{ + if (_value != value) { + if (value <= 0.) + throw SALOME_Exception(LOCALIZED("Value must be positive")); + + NotifySubMeshesHypothesisModification(); + + _value = value; + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +double StdMeshers_Deflection1D::GetDeflection() const +{ + return _value; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & StdMeshers_Deflection1D::SaveTo(ostream & save) +{ + save << _value; + return save; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & StdMeshers_Deflection1D::LoadFrom(istream & load) +{ + bool isOK = (load >> _value); + if (!isOK) + load.clear(ios::badbit | load.rdstate()); + return load; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & operator <<(ostream & save, StdMeshers_Deflection1D & hyp) +{ + return hyp.SaveTo( save ); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & operator >>(istream & load, StdMeshers_Deflection1D & hyp) +{ + return hyp.LoadFrom( load ); +} diff --git a/src/SMESHGUI/SMESHGUI_ComputeScalarValue.h b/src/StdMeshers/StdMeshers_Deflection1D.hxx similarity index 56% rename from src/SMESHGUI/SMESHGUI_ComputeScalarValue.h rename to src/StdMeshers/StdMeshers_Deflection1D.hxx index 865e288dd..1ed43cb7d 100644 --- a/src/SMESHGUI/SMESHGUI_ComputeScalarValue.h +++ b/src/StdMeshers/StdMeshers_Deflection1D.hxx @@ -1,4 +1,4 @@ -// SMESH SMESHGUI : GUI for SMESH component +// SMESH StdMeshers : 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 @@ -21,25 +21,33 @@ // // // -// File : SMESHGUI_ComputeScalarValue.h -// Author : Nicolas REJNERI +// File : StdMeshers_Deflection1D.hxx // Module : SMESH // $Header$ -#ifndef SMESHGUI_CONTROLALGORITHMS_H -#define SMESHGUI_CONTROLALGORITHMS_H +#ifndef _StdMeshers_Deflection1D_HXX_ +#define _StdMeshers_Deflection1D_HXX_ -#include "VTKViewer_Common.h" +#include "SMESH_Hypothesis.hxx" +#include "Utils_SALOME_Exception.hxx" -class SMESHGUI_ComputeScalarValue { +class StdMeshers_Deflection1D:public SMESH_Hypothesis +{ public: - static double LengthEdges(vtkCell* theCell); - static double AreaElements(vtkCell* theCell); - static double Taper(vtkCell* theCell); - static double AspectRatio(vtkCell* theCell); - static double MinimumAngle(vtkCell* theCell); - static double Skew(vtkCell* theCell); - static double Warp(vtkCell* theCell); + StdMeshers_Deflection1D(int hypId, int studyId, SMESH_Gen * gen); + virtual ~ StdMeshers_Deflection1D(); + + void SetDeflection(double value) throw(SALOME_Exception); + + double GetDeflection() const; + + virtual ostream & SaveTo(ostream & save); + virtual istream & LoadFrom(istream & load); + friend ostream & operator <<(ostream & save, StdMeshers_Deflection1D & hyp); + friend istream & operator >>(istream & load, StdMeshers_Deflection1D & hyp); + + protected: + double _value; }; #endif diff --git a/src/StdMeshers/StdMeshers_Hexa_3D.cxx b/src/StdMeshers/StdMeshers_Hexa_3D.cxx index 6c631d0db..580c48ee8 100644 --- a/src/StdMeshers/StdMeshers_Hexa_3D.cxx +++ b/src/StdMeshers/StdMeshers_Hexa_3D.cxx @@ -32,6 +32,7 @@ using namespace std; #include "StdMeshers_Quadrangle_2D.hxx" #include "SMESH_Gen.hxx" #include "SMESH_Mesh.hxx" +#include "SMESH_subMesh.hxx" #include "SMDS_MeshElement.hxx" #include "SMDS_MeshNode.hxx" @@ -49,6 +50,7 @@ using namespace std; #include #include #include +#include #include "utilities.h" #include "Utils_ExceptHandlers.hxx" @@ -94,7 +96,7 @@ bool StdMeshers_Hexa_3D::CheckHypothesis const TopoDS_Shape& aShape, SMESH_Hypothesis::Hypothesis_Status& aStatus) { - MESSAGE("StdMeshers_Hexa_3D::CheckHypothesis"); + //MESSAGE("StdMeshers_Hexa_3D::CheckHypothesis"); bool isOk = true; aStatus = SMESH_Hypothesis::HYP_OK; @@ -104,6 +106,37 @@ bool StdMeshers_Hexa_3D::CheckHypothesis return isOk; } +//======================================================================= +//function : findIJ +//purpose : return i,j of the node +//======================================================================= + +static bool findIJ (const SMDS_MeshNode* node, const FaceQuadStruct * quad, int& I, int& J) +{ + I = J = 0; + const SMDS_FacePosition* fpos = + static_cast(node->GetPosition().get()); + if ( ! fpos ) return false; + gp_Pnt2d uv( fpos->GetUParameter(), fpos->GetVParameter() ); + + double minDist = DBL_MAX; + int nbhoriz = Min(quad->nbPts[0], quad->nbPts[2]); + int nbvertic = Min(quad->nbPts[1], quad->nbPts[3]); + for (int i = 1; i < nbhoriz - 1; i++) { + for (int j = 1; j < nbvertic - 1; j++) { + int ij = j * nbhoriz + i; + gp_Pnt2d uv2( quad->uv_grid[ij].u, quad->uv_grid[ij].v ); + double dist = uv.SquareDistance( uv2 ); + if ( dist < minDist ) { + minDist = dist; + I = i; + J = j; + } + } + } + return true; +} + //============================================================================= /*! * Hexahedron mesh on hexaedron like form @@ -130,7 +163,7 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, // 0. - shape and face mesh verification // 0.1 - shape must be a solid (or a shell) with 6 faces - MESSAGE("---"); + //MESSAGE("---"); vector < SMESH_subMesh * >meshFaces; for (TopExp_Explorer exp(aShape, TopAbs_FACE); exp.More(); exp.Next()) @@ -142,12 +175,12 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, if (meshFaces.size() != 6) { SCRUTE(meshFaces.size()); - ASSERT(0); +// ASSERT(0); return false; } // 0.2 - is each face meshed with Quadrangle_2D? (so, with a wire of 4 edges) - MESSAGE("---"); + //MESSAGE("---"); for (int i = 0; i < 6; i++) { @@ -158,7 +191,7 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, { // *** delete _quads SCRUTE(algoName); - ASSERT(0); +// ASSERT(0); return false; } StdMeshers_Quadrangle_2D *quadAlgo = @@ -173,25 +206,35 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, { // *** delete _quads // *** throw exception - ASSERT(0); +// ASSERT(0); + return false; } + + // 0.2.1 - number of points on the opposite edges must be the same + if (_quads[i]->nbPts[0] != _quads[i]->nbPts[2] || + _quads[i]->nbPts[1] != _quads[i]->nbPts[3]) + { + MESSAGE("different number of points on the opposite edges of face " << i); +// ASSERT(0); + return false; + } } // 1. - identify faces and vertices of the "cube" // 1.1 - ancestor maps vertex->edges in the cube - MESSAGE("---"); + //MESSAGE("---"); TopTools_IndexedDataMapOfShapeListOfShape MS; TopExp::MapShapesAndAncestors(aShape, TopAbs_VERTEX, TopAbs_EDGE, MS); // 1.2 - first face is choosen as face Y=0 of the unit cube - MESSAGE("---"); + //MESSAGE("---"); const TopoDS_Shape & aFace = meshFaces[0]->GetSubShape(); const TopoDS_Face & F = TopoDS::Face(aFace); // 1.3 - identify the 4 vertices of the face Y=0: V000, V100, V101, V001 - MESSAGE("---"); + //MESSAGE("---"); int i = 0; TopoDS_Edge E = _quads[0]->edge[i]; //edge will be Y=0,Z=0 on unit cube @@ -237,7 +280,7 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, // - find edge X=1, Z=0 (ancestor of V100 not in face Y=0) // - find edge X=1, Z=1 (ancestor of V101 not in face Y=0) // - find edge X=0, Z=1 (ancestor of V001 not in face Y=0) - MESSAGE("---"); + //MESSAGE("---"); TopoDS_Edge E_0Y0 = EdgeNotInFace(aMesh, aShape, F, _cube.V000, MS); ASSERT(!E_0Y0.IsNull()); @@ -252,7 +295,7 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, ASSERT(!E_0Y1.IsNull()); // 1.5 - identify the 4 vertices in face Y=1: V010, V110, V111, V011 - MESSAGE("---"); + //MESSAGE("---"); TopExp::Vertices(E_0Y0, VFirst, VLast); if (VFirst.IsSame(_cube.V000)) @@ -279,7 +322,7 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, _cube.V011 = VFirst; // 1.6 - find remaining faces given 4 vertices - MESSAGE("---"); + //MESSAGE("---"); _indY0 = 0; _cube.quad_Y0 = _quads[_indY0]; @@ -304,7 +347,7 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, _cube.V100, _cube.V101, _cube.V110, _cube.V111); _cube.quad_X1 = _quads[_indX1]; - MESSAGE("---"); + //MESSAGE("---"); // 1.7 - get convertion coefs from face 2D normalized to 3D normalized @@ -330,18 +373,26 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, // 1.8 - create a 3D structure for normalized values - MESSAGE("---"); - int nbx = _cube.quad_Y0->nbPts[0]; - int nby = _cube.quad_Y0->nbPts[1]; - int nbz; - if (cx0.a1 != 0) - nbz = _cube.quad_X0->nbPts[1]; - else - nbz = _cube.quad_X0->nbPts[0]; + //MESSAGE("---"); + int nbx = _cube.quad_Z0->nbPts[0]; + if (cz0.a1 == 0.) nbx = _cube.quad_Z0->nbPts[1]; + + int nby = _cube.quad_X0->nbPts[0]; + if (cx0.a1 == 0.) nby = _cube.quad_X0->nbPts[1]; + + int nbz = _cube.quad_Y0->nbPts[0]; + if (cy0.a1 != 0.) nbz = _cube.quad_Y0->nbPts[1]; +// int nbx = _cube.quad_Y0->nbPts[0]; +// int nby = _cube.quad_Y0->nbPts[1]; +// int nbz; +// if (cx0.a1 != 0) +// nbz = _cube.quad_X0->nbPts[1]; +// else +// nbz = _cube.quad_X0->nbPts[0]; //SCRUTE(nbx); //SCRUTE(nby); //SCRUTE(nbz); - int nbxyz = nbx * nby * nbz; + int i1, j1, nbxyz = nbx * nby * nbz; Point3DStruct *np = new Point3DStruct[nbxyz]; // 1.9 - store node indexes of faces @@ -360,12 +411,7 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, while(itf->more()) { const SMDS_MeshNode * node = itf->next(); - const SMDS_FacePosition* fpos = - static_cast(node->GetPosition().get()); - double ri = fpos->GetUParameter(); - double rj = fpos->GetVParameter(); - int i1 = int (ri); - int j1 = int (rj); + findIJ( node, quad, i1, j1 ); int ij1 = j1 * nbdown + i1; quad->uv_grid[ij1].node = node; } @@ -396,12 +442,7 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, while(itf->more()) { const SMDS_MeshNode * node = itf->next(); - const SMDS_FacePosition* fpos = - static_cast(node->GetPosition().get()); - double ri = fpos->GetUParameter(); - double rj = fpos->GetVParameter(); - int i1 = int (ri); - int j1 = int (rj); + findIJ( node, quad, i1, j1 ); int ij1 = j1 * nbdown + i1; quad->uv_grid[ij1].node = node; } @@ -432,12 +473,7 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, while(itf->more()) { const SMDS_MeshNode * node = itf->next(); - const SMDS_FacePosition * fpos = - static_cast(node->GetPosition().get()); - double ri = fpos->GetUParameter(); - double rj = fpos->GetVParameter(); - int i1 = int (ri); - int j1 = int (rj); + findIJ( node, quad, i1, j1 ); int ij1 = j1 * nbdown + i1; quad->uv_grid[ij1].node = node; } @@ -468,12 +504,7 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, while(itf->more()) { const SMDS_MeshNode * node = itf->next(); - const SMDS_FacePosition* fpos = - static_cast(node->GetPosition().get()); - double ri = fpos->GetUParameter(); - double rj = fpos->GetVParameter(); - int i1 = int (ri); - int j1 = int (rj); + findIJ( node, quad, i1, j1 ); int ij1 = j1 * nbdown + i1; quad->uv_grid[ij1].node = node; } @@ -504,12 +535,7 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, while(itf->more()) { const SMDS_MeshNode * node = itf->next(); - const SMDS_FacePosition * fpos = - static_cast(node->GetPosition().get()); - double ri = fpos->GetUParameter(); - double rj = fpos->GetVParameter(); - int i1 = int (ri); - int j1 = int (rj); + findIJ( node, quad, i1, j1 ); int ij1 = j1 * nbdown + i1; quad->uv_grid[ij1].node = node; } @@ -540,12 +566,7 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, while(itf->more()) { const SMDS_MeshNode * node = itf->next(); - const SMDS_FacePosition* fpos = - static_cast(node->GetPosition().get()); - double ri = fpos->GetUParameter(); - double rj = fpos->GetVParameter(); - int i1 = int (ri); - int j1 = int (rj); + findIJ( node, quad, i1, j1 ); int ij1 = j1 * nbdown + i1; quad->uv_grid[ij1].node = node; } @@ -716,7 +737,7 @@ bool StdMeshers_Hexa_3D::Compute(SMESH_Mesh & aMesh, } - MESSAGE("End of StdMeshers_Hexa_3D::Compute()"); + //MESSAGE("End of StdMeshers_Hexa_3D::Compute()"); return true; } @@ -750,7 +771,7 @@ int StdMeshers_Hexa_3D::GetFaceIndex(SMESH_Mesh & aMesh, const TopoDS_Vertex & V1, const TopoDS_Vertex & V2, const TopoDS_Vertex & V3) { - MESSAGE("StdMeshers_Hexa_3D::GetFaceIndex"); + //MESSAGE("StdMeshers_Hexa_3D::GetFaceIndex"); int faceIndex = -1; for (int i = 1; i < 6; i++) { @@ -771,7 +792,7 @@ int StdMeshers_Hexa_3D::GetFaceIndex(SMESH_Mesh & aMesh, } } ASSERT(faceIndex > 0); - SCRUTE(faceIndex); + //SCRUTE(faceIndex); return faceIndex; } @@ -788,13 +809,13 @@ TopoDS_Edge const TopoDS_Vertex & aVertex, const TopTools_IndexedDataMapOfShapeListOfShape & MS) { - MESSAGE("StdMeshers_Hexa_3D::EdgeNotInFace"); + //MESSAGE("StdMeshers_Hexa_3D::EdgeNotInFace"); TopTools_IndexedDataMapOfShapeListOfShape MF; TopExp::MapShapesAndAncestors(aFace, TopAbs_VERTEX, TopAbs_EDGE, MF); const TopTools_ListOfShape & ancestorsInSolid = MS.FindFromKey(aVertex); const TopTools_ListOfShape & ancestorsInFace = MF.FindFromKey(aVertex); - SCRUTE(ancestorsInSolid.Extent()); - SCRUTE(ancestorsInFace.Extent()); +// SCRUTE(ancestorsInSolid.Extent()); +// SCRUTE(ancestorsInFace.Extent()); ASSERT(ancestorsInSolid.Extent() == 6); // 6 (edges doublees) ASSERT(ancestorsInFace.Extent() == 2); @@ -836,7 +857,7 @@ void StdMeshers_Hexa_3D::GetConv2DCoefs(const faceQuadStruct & quad, const TopoDS_Vertex & V1, const TopoDS_Vertex & V2, const TopoDS_Vertex & V3, Conv2DStruct & conv) { - MESSAGE("StdMeshers_Hexa_3D::GetConv2DCoefs"); +// MESSAGE("StdMeshers_Hexa_3D::GetConv2DCoefs"); const TopoDS_Face & F = TopoDS::Face(aShape); TopoDS_Edge E = quad.edge[0]; double f, l; @@ -936,8 +957,8 @@ void StdMeshers_Hexa_3D::GetConv2DCoefs(const faceQuadStruct & quad, b2 = -1; c2 = 1; // 1-y } - MESSAGE("X = " << c1 << "+ " << a1 << "*x + " << b1 << "*y"); - MESSAGE("Y = " << c2 << "+ " << a2 << "*x + " << b2 << "*y"); +// MESSAGE("X = " << c1 << "+ " << a1 << "*x + " << b1 << "*y"); +// MESSAGE("Y = " << c2 << "+ " << a2 << "*x + " << b2 << "*y"); conv.a1 = a1; conv.b1 = b1; conv.c1 = c1; @@ -955,8 +976,8 @@ void StdMeshers_Hexa_3D::GetConv2DCoefs(const faceQuadStruct & quad, conv.jb = int (b2); conv.jc = int (c2 * a2 * a2) * (nbdown - 1) + int (c2 * b2 * b2) * (nbright - 1); - MESSAGE("I " << conv.ia << " " << conv.ib << " " << conv.ic); - MESSAGE("J " << conv.ja << " " << conv.jb << " " << conv.jc); +// MESSAGE("I " << conv.ia << " " << conv.ib << " " << conv.ic); +// MESSAGE("J " << conv.ja << " " << conv.jb << " " << conv.jc); } //============================================================================= diff --git a/src/StdMeshers/StdMeshers_MEFISTO_2D.cxx b/src/StdMeshers/StdMeshers_MEFISTO_2D.cxx index 6229e4c6d..b7da7cbe6 100644 --- a/src/StdMeshers/StdMeshers_MEFISTO_2D.cxx +++ b/src/StdMeshers/StdMeshers_MEFISTO_2D.cxx @@ -31,6 +31,7 @@ using namespace std; #include "StdMeshers_MEFISTO_2D.hxx" #include "SMESH_Gen.hxx" #include "SMESH_Mesh.hxx" +#include "SMESH_subMesh.hxx" #include "StdMeshers_MaxElementArea.hxx" #include "StdMeshers_LengthFromEdges.hxx" @@ -58,9 +59,11 @@ using namespace std; #include #include #include +#include +#include #include -#include +//#include //============================================================================= /*! @@ -158,7 +161,8 @@ bool StdMeshers_MEFISTO_2D::CheckHypothesis isOk = false; if (_maxElementArea > 0) { - _edgeLength = 2 * sqrt(_maxElementArea); // triangles : minorant +// _edgeLength = 2 * sqrt(_maxElementArea); // triangles : minorant + _edgeLength = 2 * sqrt(_maxElementArea/sqrt(3.0)); isOk = true; } else @@ -208,64 +212,57 @@ bool StdMeshers_MEFISTO_2D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aSh Z nutysu = 1; // 1: il existe un fonction areteideale_() // Z nutysu=0; // 0: on utilise aretmx R aretmx = _edgeLength; // longueur max aretes future triangulation - //SCRUTE(aretmx); nblf = NumberOfWires(F); - //SCRUTE(nblf); nudslf = new Z[1 + nblf]; nudslf[0] = 0; int iw = 1; int nbpnt = 0; - const TopoDS_Wire OW1 = BRepTools::OuterWire(F); - nbpnt += NumberOfPoints(aMesh, OW1); + myOuterWire = BRepTools::OuterWire(F); + nbpnt += NumberOfPoints(aMesh, myOuterWire); + if ( nbpnt < 3 ) // ex: a circle with 2 segments + return false; nudslf[iw++] = nbpnt; - //SCRUTE(nbpnt); for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next()) { const TopoDS_Wire & W = TopoDS::Wire(exp.Current()); - if (!OW1.IsSame(W)) + if (!myOuterWire.IsSame(W)) { nbpnt += NumberOfPoints(aMesh, W); nudslf[iw++] = nbpnt; - //SCRUTE(nbpnt); } } + // avoid passing same uv points for a vertex common to 2 wires + TopTools_IndexedDataMapOfShapeListOfShape VWMap; + if ( iw - 1 > 1 ) // nbofWires > 1 + TopExp::MapShapesAndAncestors( F , TopAbs_VERTEX, TopAbs_WIRE, VWMap ); + uvslf = new R2[nudslf[nblf]]; - //SCRUTE(nudslf[nblf]); int m = 0; - map mefistoToDS; // correspondence mefisto index--> points IDNodes - TopoDS_Wire OW = BRepTools::OuterWire(F); - LoadPoints(aMesh, F, OW, uvslf, m, mefistoToDS); - //SCRUTE(m); + double scalex, scaley; + ComputeScaleOnFace(aMesh, F, scalex, scaley); + + map mefistoToDS; // correspondence mefisto index--> points IDNodes + if ( !LoadPoints(aMesh, F, myOuterWire, uvslf, m, + mefistoToDS, scalex, scaley, VWMap)) + return false; for (TopExp_Explorer exp(F, TopAbs_WIRE); exp.More(); exp.Next()) { const TopoDS_Wire & W = TopoDS::Wire(exp.Current()); - if (!OW.IsSame(W)) + if (!myOuterWire.IsSame(W)) { - LoadPoints(aMesh, F, W, uvslf, m, mefistoToDS); - //SCRUTE(m); + if (! LoadPoints(aMesh, F, W, uvslf, m, + mefistoToDS, scalex, scaley, VWMap )) + return false; } } -// SCRUTE(nudslf[nblf]); -// for (int i=0; i<=nblf; i++) -// { -// MESSAGE(" -+- " <= 1.e-3 + const double minSin = 1.e-3; + if ( dot > 0 && 1 - dot * dot / ( sqMod1 * sqMod2 ) < minSin * minSin ) { + MESSAGE(" ___ FIX UV ____" << uv0.x << " " << uv0.y); + v1.SetCoord( -v1.Y(), v1.X() ); + double delta = sqrt( sqMod1 ) * minSin; + if ( v1.X() < 0 ) + uv0.x -= delta; + else + uv0.x += delta; + if ( v1.Y() < 0 ) + uv0.y -= delta; + else + uv0.y += delta; +// MESSAGE(" -> " << uv0.x << " " << uv0.y << " "); +// MESSAGE("v1( " << v1.X() << " " << v1.Y() << " ) " << +// "v2( " << v2.X() << " " << v2.Y() << " ) "); +// MESSAGE("SIN: " << sqrt(1 - dot * dot / (sqMod1 * sqMod2))); +// v1.SetCoord( uv0.x - uv1.x, uv0.y - uv1.y ); +// v2.SetCoord( uv2.x - uv1.x, uv2.y - uv1.y ); +// gp_XY v3( uv2.x - uv0.x, uv2.y - uv0.y ); +// sqMod1 = v1.SquareModulus(); +// sqMod2 = v2.SquareModulus(); +// dot = v1*v2; +// double sin = sqrt(1 - dot * dot / (sqMod1 * sqMod2)); +// MESSAGE("NEW SIN: " << sin); + return true; + } + return false; +} + +//======================================================================= +//function : fixCommonVertexUV +//purpose : +//======================================================================= + +static bool fixCommonVertexUV (gp_Pnt2d & theUV, + const TopoDS_Vertex& theV, + const TopoDS_Wire& theW, + const TopoDS_Wire& theOW, + const TopoDS_Face& theF, + const TopTools_IndexedDataMapOfShapeListOfShape & theVWMap, + SMESH_Mesh & theMesh) +{ + if( theW.IsSame( theOW ) || + !theVWMap.Contains( theV )) return false; + + // check if there is another wire sharing theV + const TopTools_ListOfShape& WList = theVWMap.FindFromKey( theV ); + TopTools_ListIteratorOfListOfShape aWIt; + for ( aWIt.Initialize( WList ); aWIt.More(); aWIt.Next() ) + if ( !theW.IsSame( aWIt.Value() )) + break; + if ( !aWIt.More() ) return false; + + TopTools_ListOfShape EList; + list< double > UList; + + // find edges of theW sharing theV + // and find 2d normal to them at theV + gp_Vec2d N(0.,0.); + TopoDS_Iterator itE( theW ); + for ( ; itE.More(); itE.Next() ) + { + const TopoDS_Edge& E = TopoDS::Edge( itE.Value() ); + TopoDS_Iterator itV( E ); + for ( ; itV.More(); itV.Next() ) + { + const TopoDS_Vertex & V = TopoDS::Vertex( itV.Value() ); + if ( !V.IsSame( theV )) + continue; + EList.Append( E ); + Standard_Real u = BRep_Tool::Parameter( V, E ); + UList.push_back( u ); + double f, l; + Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, theF, f, l); + gp_Vec2d d1; + gp_Pnt2d p; + C2d->D1( u, p, d1 ); + gp_Vec2d n( d1.Y(), -d1.X() ); + if ( E.Orientation() == TopAbs_REVERSED ) + n.Reverse(); + N += n.Normalized(); + } + } + + // define step size by which to move theUV + + gp_Pnt2d nextUV; // uv of next node on edge, most distant of the four + double maxDist = -DBL_MAX; + TopTools_ListIteratorOfListOfShape aEIt (EList); + list< double >::iterator aUIt = UList.begin(); + for ( ; aEIt.More(); aEIt.Next(), aUIt++ ) + { + const TopoDS_Edge& E = TopoDS::Edge( aEIt.Value() ); + double f, l; + Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, theF, f, l); + + double umin = DBL_MAX, umax = -DBL_MAX; + SMDS_NodeIteratorPtr nIt = theMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes(); + if ( !nIt->more() ) // no nodes on edge, only on vertices + { + umin = l; + umax = f; + } + else + { + while ( nIt->more() ) { + const SMDS_MeshNode* node = nIt->next(); + const SMDS_EdgePosition* epos = + static_cast(node->GetPosition().get()); + double u = epos->GetUParameter(); + if ( u < umin ) + umin = u; + if ( u > umax ) + umax = u; + } + } + bool isFirstCommon = ( *aUIt == f ); + gp_Pnt2d uv = C2d->Value( isFirstCommon ? umin : umax ); + double dist = theUV.SquareDistance( uv ); + if ( dist > maxDist ) { + maxDist = dist; + nextUV = uv; + } + } + R2 uv0, uv1, uv2; + uv0.x = theUV.X(); uv0.y = theUV.Y(); + uv1.x = nextUV.X(); uv1.y = nextUV.Y(); + uv2.x = uv0.x; uv2.y = uv0.y; + if ( fixOverlappedLinkUV( uv0, uv1, uv2 )) + { + double step = theUV.Distance( gp_Pnt2d( uv0.x, uv0.y )); + + // move theUV along the normal by the step + + N *= step; + + MESSAGE("--fixCommonVertexUV move(" << theUV.X() << " " << theUV.Y() + << ") by (" << N.X() << " " << N.Y() << ")" + << endl << "--- MAX DIST " << maxDist); + + theUV.SetXY( theUV.XY() + N.XY() ); + + return true; + } + return false; +} + //============================================================================= /*! * */ //============================================================================= -void StdMeshers_MEFISTO_2D::LoadPoints(SMESH_Mesh & aMesh, - const TopoDS_Face & FF, - const TopoDS_Wire & WW, R2 * uvslf, int &m, - map&mefistoToDS) +bool StdMeshers_MEFISTO_2D::LoadPoints(SMESH_Mesh & aMesh, + const TopoDS_Face & FF, + const TopoDS_Wire & WW, + R2 * uvslf, + int & m, + map&mefistoToDS, + double scalex, + double scaley, + const TopTools_IndexedDataMapOfShapeListOfShape& VWMap) { - MESSAGE("StdMeshers_MEFISTO_2D::LoadPoints"); - - SMDS_Mesh * meshDS = aMesh.GetMeshDS(); - - double scalex; - double scaley; - TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD)); - ComputeScaleOnFace(aMesh, F, scalex, scaley); - - TopoDS_Wire W = TopoDS::Wire(WW.Oriented(TopAbs_FORWARD)); - BRepTools_WireExplorer wexp(W, F); - for (wexp.Init(W, F); wexp.More(); wexp.Next()) - { - const TopoDS_Edge & E = wexp.Current(); - - // --- IDNodes of first and last Vertex - - TopoDS_Vertex VFirst, VLast; - TopExp::Vertices(E, VFirst, VLast); // corresponds to f and l - - ASSERT(!VFirst.IsNull()); - SMDS_NodeIteratorPtr lid= - aMesh.GetSubMesh(VFirst)->GetSubMeshDS()->GetNodes(); - const SMDS_MeshNode* idFirst = lid->next(); - - ASSERT(!VLast.IsNull()); - lid=aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes(); - const SMDS_MeshNode* idLast = lid->next(); - - // --- edge internal IDNodes (relies on good order storage, not checked) - - int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); - //SCRUTE(nbPoints); - - double f, l; - Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l); - - SMDS_NodeIteratorPtr ite= aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes(); - - bool isForward = (E.Orientation() == TopAbs_FORWARD); - map params; - - while(ite->more()) - { - const SMDS_MeshNode * node = ite->next(); - const SMDS_EdgePosition* epos = - static_cast(node->GetPosition().get()); - double param = epos->GetUParameter(); - params[param] = node; - } - // --- load 2D values into MEFISTO structure, - // add IDNodes in mefistoToDS map - - if (E.Orientation() == TopAbs_FORWARD) - { - gp_Pnt2d p = C2d->Value(f); // first point = Vertex Forward - uvslf[m].x = scalex * p.X(); - uvslf[m].y = scaley * p.Y(); - mefistoToDS[m + 1] = idFirst; - //MESSAGE(" "<::iterator itp = params.begin(); - for (int i = 1; i <= nbPoints; i++) // nbPoints internal - { - double param = (*itp).first; - gp_Pnt2d p = C2d->Value(param); - uvslf[m].x = scalex * p.X(); - uvslf[m].y = scaley * p.Y(); - mefistoToDS[m + 1] = (*itp).second; -// MESSAGE(" "<Value(l); // last point = Vertex Reversed - uvslf[m].x = scalex * p.X(); - uvslf[m].y = scaley * p.Y(); - mefistoToDS[m + 1] = idLast; -// MESSAGE(" "<::reverse_iterator itp = params.rbegin(); - for (int i = nbPoints; i >= 1; i--) - { - double param = (*itp).first; - gp_Pnt2d p = C2d->Value(param); - uvslf[m].x = scalex * p.X(); - uvslf[m].y = scaley * p.Y(); - mefistoToDS[m + 1] = (*itp).second; -// MESSAGE(" "<GetSubMeshDS()->GetNodes(); + if ( !lid->more() ) { + MESSAGE (" NO NODE BUILT ON VERTEX "); + return false; + } + const SMDS_MeshNode* idFirst = lid->next(); + + ASSERT(!VLast.IsNull()); + lid=aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes(); + if ( !lid->more() ) { + MESSAGE (" NO NODE BUILT ON VERTEX "); + return false; + } + const SMDS_MeshNode* idLast = lid->next(); + + // --- edge internal IDNodes (relies on good order storage, not checked) + + int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); + + double f, l; + Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l); + + SMDS_NodeIteratorPtr ite= aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes(); + + bool isForward = (E.Orientation() == TopAbs_FORWARD); + map params; + + while(ite->more()) + { + const SMDS_MeshNode * node = ite->next(); + const SMDS_EdgePosition* epos = + static_cast(node->GetPosition().get()); + double param = epos->GetUParameter(); + params[param] = node; + } + if ( nbPoints != params.size()) + { + MESSAGE( "BAD NODE ON EDGE POSITIONS" ); + return false; + } + + mFirst = m; + + // --- load 2D values into MEFISTO structure, + // add IDNodes in mefistoToDS map + if (E.Orientation() == TopAbs_FORWARD) + { + gp_Pnt2d p = C2d->Value(f).XY().Multiplied( scale ); // first point = Vertex Forward + if ( fixCommonVertexUV( p, VFirst, W, myOuterWire, F, VWMap, aMesh )) + myNodesOnCommonV.push_back( idFirst ); + uvslf[m].x = p.X(); + uvslf[m].y = p.Y(); + mefistoToDS[m + 1] = idFirst; + //MESSAGE(" "<::iterator itp = params.begin(); + for (int i = 1; i <= nbPoints; i++) // nbPoints internal + { + double param = (*itp).first; + gp_Pnt2d p = C2d->Value(param).XY().Multiplied( scale ); + uvslf[m].x = p.X(); + uvslf[m].y = p.Y(); + mefistoToDS[m + 1] = (*itp).second; + //MESSAGE(" "<Value(l).XY().Multiplied( scale ); // last point = Vertex Reversed + if ( fixCommonVertexUV( p, VLast, W, myOuterWire, F, VWMap, aMesh )) + myNodesOnCommonV.push_back( idLast ); + uvslf[m].x = p.X(); + uvslf[m].y = p.Y(); + mefistoToDS[m + 1] = idLast; + //MESSAGE(" "<::reverse_iterator itp = params.rbegin(); + for (int i = nbPoints; i >= 1; i--) + { + double param = (*itp).first; + gp_Pnt2d p = C2d->Value(param).XY().Multiplied( scale ); + uvslf[m].x = p.X(); + uvslf[m].y = p.Y(); + mefistoToDS[m + 1] = (*itp).second; + //MESSAGE(" "< 0 ) + fixOverlappedLinkUV (uvslf[ mFirst - 1], + uvslf[ mFirst ], + uvslf[ mFirst + 1 ]); + + } // for wexp + + fixOverlappedLinkUV (uvslf[ m - 1], + uvslf[ mInit ], + uvslf[ mInit + 1 ]); + + return true; } //============================================================================= @@ -416,76 +613,91 @@ void StdMeshers_MEFISTO_2D::LoadPoints(SMESH_Mesh & aMesh, */ //============================================================================= -// **** a mettre dans SMESH_Algo ou SMESH_2D_Algo - void StdMeshers_MEFISTO_2D::ComputeScaleOnFace(SMESH_Mesh & aMesh, const TopoDS_Face & aFace, double &scalex, double &scaley) { - //MESSAGE("StdMeshers_MEFISTO_2D::ComputeScaleOnFace"); - TopoDS_Face F = TopoDS::Face(aFace.Oriented(TopAbs_FORWARD)); - TopoDS_Wire W = BRepTools::OuterWire(F); - - BRepTools_WireExplorer wexp(W, F); - - double xmin = 1.e300; // min & max of face 2D parametric coord. - double xmax = -1.e300; - double ymin = 1.e300; - double ymax = -1.e300; - int nbp = 50; - scalex = 1; - scaley = 1; - for (wexp.Init(W, F); wexp.More(); wexp.Next()) - { - const TopoDS_Edge & E = wexp.Current(); - double f, l; - Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l); - for (int i = 0; i <= nbp; i++) - { - double param = f + (double (i) / double (nbp))*(l - f); - gp_Pnt2d p = C2d->Value(param); - if (p.X() < xmin) - xmin = p.X(); - if (p.X() > xmax) - xmax = p.X(); - if (p.Y() < ymin) - ymin = p.Y(); - if (p.Y() > ymax) - ymax = p.Y(); -// MESSAGE(" "<< f<<" "<Value(xmin, ymoy); - gp_Pnt PY0 = S->Value(xmoy, ymin); - for (int i = 1; i <= nbp; i++) - { - double x = xmin + (double (i) / double (nbp))*(xmax - xmin); - gp_Pnt PX = S->Value(x, ymoy); - double y = ymin + (double (i) / double (nbp))*(ymax - ymin); - gp_Pnt PY = S->Value(xmoy, y); - length_x += PX.Distance(PX0); - length_y += PY.Distance(PY0); - PX0.SetCoord(PX.X(), PX.Y(), PX.Z()); - PY0.SetCoord(PY.X(), PY.Y(), PY.Z()); - } -// SCRUTE(length_x); -// SCRUTE(length_y); - scalex = length_x / (xmax - xmin); - scaley = length_y / (ymax - ymin); -// SCRUTE(scalex); -// SCRUTE(scaley); - ASSERT(scalex); - ASSERT(scaley); + //MESSAGE("StdMeshers_MEFISTO_2D::ComputeScaleOnFace"); + TopoDS_Face F = TopoDS::Face(aFace.Oriented(TopAbs_FORWARD)); + TopoDS_Wire W = BRepTools::OuterWire(F); + + double xmin = 1.e300; // min & max of face 2D parametric coord. + double xmax = -1.e300; + double ymin = 1.e300; + double ymax = -1.e300; + int nbp = 23; + scalex = 1; + scaley = 1; + + TopExp_Explorer wexp(W, TopAbs_EDGE); + for ( ; wexp.More(); wexp.Next()) + { + const TopoDS_Edge & E = TopoDS::Edge( wexp.Current() ); + double f, l; + Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l); + if ( C2d.IsNull() ) continue; + double du = (l - f) / double (nbp); + for (int i = 0; i <= nbp; i++) + { + double param = f + double (i) * du; + gp_Pnt2d p = C2d->Value(param); + if (p.X() < xmin) + xmin = p.X(); + if (p.X() > xmax) + xmax = p.X(); + if (p.Y() < ymin) + ymin = p.Y(); + if (p.Y() > ymax) + ymax = p.Y(); + // MESSAGE(" "<< f<<" "<Value(xmin, ymoy); + gp_Pnt PY0 = S->Value(xmoy, ymin); + double dx = xsize / double (nbp); + double dy = ysize / double (nbp); + for (int i = 1; i <= nbp; i++) + { + double x = xmin + double (i) * dx; + gp_Pnt PX = S->Value(x, ymoy); + double y = ymin + double (i) * dy; + gp_Pnt PY = S->Value(xmoy, y); + length_x += PX.Distance(PX0); + length_y += PY.Distance(PY0); + PX0 = PX; + PY0 = PY; + } + scalex = length_x / xsize; + scaley = length_y / ysize; +// SCRUTE(xsize); +// SCRUTE(ysize); + double xyratio = xsize*scalex/(ysize*scaley); + const double maxratio = 1.e2; + //SCRUTE(xyratio); + if (xyratio > maxratio) { + SCRUTE( scaley ); + scaley *= xyratio / maxratio; + SCRUTE( scaley ); + } + else if (xyratio < 1./maxratio) { + SCRUTE( scalex ); + scalex *= 1 / xyratio / maxratio; + SCRUTE( scalex ); + } + ASSERT(scalex); + ASSERT(scaley); } //============================================================================= @@ -495,70 +707,90 @@ void StdMeshers_MEFISTO_2D::ComputeScaleOnFace(SMESH_Mesh & aMesh, //============================================================================= void StdMeshers_MEFISTO_2D::StoreResult(SMESH_Mesh & aMesh, - Z nbst, R2 * uvst, Z nbt, Z * nust, - const TopoDS_Face & F, bool faceIsForward, - map&mefistoToDS) + Z nbst, R2 * uvst, Z nbt, Z * nust, + const TopoDS_Face & F, bool faceIsForward, + map&mefistoToDS, + double scalex, double scaley) { - double scalex; - double scaley; - ComputeScaleOnFace(aMesh, F, scalex, scaley); - - SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); - - Z n, m; - Handle(Geom_Surface) S = BRep_Tool::Surface(F); + SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); + + Z n, m; + Handle(Geom_Surface) S = BRep_Tool::Surface(F); + + for (n = 0; n < nbst; n++) + { + if (mefistoToDS.find(n + 1) == mefistoToDS.end()) + { + double u = uvst[n][0] / scalex; + double v = uvst[n][1] / scaley; + gp_Pnt P = S->Value(u, v); + + SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z()); + meshDS->SetNodeOnFace(node, F); + + //MESSAGE(P.X()<<" "<(node->GetPosition().get()); + fpos->SetUParameter(u); + fpos->SetVParameter(v); + } + } + + m = 0; + int mt = 0; + + //SCRUTE(faceIsForward); + for (n = 1; n <= nbt; n++) + { + int inode1 = nust[m++]; + int inode2 = nust[m++]; + int inode3 = nust[m++]; + + const SMDS_MeshNode *n1, *n2, *n3; + n1 = mefistoToDS[inode1]; + n2 = mefistoToDS[inode2]; + n3 = mefistoToDS[inode3]; + //MESSAGE("-- "<AddFace(n1, n2, n3); + else + elt = meshDS->AddFace(n1, n3, n2); + + meshDS->SetMeshElementOnShape(elt, F); + m++; + } + + // remove bad elements build on vertices shared by wires + + list::iterator itN = myNodesOnCommonV.begin(); + for ( ; itN != myNodesOnCommonV.end(); itN++ ) + { + const SMDS_MeshNode* node = *itN; + SMDS_ElemIteratorPtr invElemIt = node->GetInverseElementIterator(); + while ( invElemIt->more() ) + { + const SMDS_MeshElement* elem = invElemIt->next(); + SMDS_ElemIteratorPtr itN = elem->nodesIterator(); + int nbSame = 0; + while ( itN->more() ) + if ( itN->next() == node) + nbSame++; + if (nbSame > 1) { + MESSAGE( "RM bad element " << elem->GetID()); + meshDS->RemoveElement( elem ); + } + } + } - for (n = 0; n < nbst; n++) - { - double u = uvst[n][0] / scalex; - double v = uvst[n][1] / scaley; - gp_Pnt P = S->Value(u, v); - - if (mefistoToDS.find(n + 1) == mefistoToDS.end()) - { - SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z()); - meshDS->SetNodeOnFace(node, F); - - //MESSAGE(nodeId<<" "<(node->GetPosition().get()); - fpos->SetUParameter(u); - fpos->SetVParameter(v); - } - } - - m = 0; - int mt = 0; - - //SCRUTE(faceIsForward); - for (n = 1; n <= nbt; n++) - { - int inode1 = nust[m++]; - int inode2 = nust[m++]; - int inode3 = nust[m++]; - - const SMDS_MeshNode *n1, *n2, *n3; - n1 = mefistoToDS[inode1]; - n2 = mefistoToDS[inode2]; - n3 = mefistoToDS[inode3]; - //MESSAGE("-- "<AddFace(n1, n2, n3); - else - elt = meshDS->AddFace(n1, n3, n2); - - meshDS->SetMeshElementOnShape(elt, F); - m++; - } } //============================================================================= @@ -570,7 +802,7 @@ void StdMeshers_MEFISTO_2D::StoreResult(SMESH_Mesh & aMesh, double StdMeshers_MEFISTO_2D::ComputeEdgeElementLength(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) { - MESSAGE("StdMeshers_MEFISTO_2D::ComputeEdgeElementLength"); + //MESSAGE("StdMeshers_MEFISTO_2D::ComputeEdgeElementLength"); // **** a mettre dans SMESH_2D_Algo ? const TopoDS_Face & FF = TopoDS::Face(aShape); diff --git a/src/StdMeshers/StdMeshers_MEFISTO_2D.hxx b/src/StdMeshers/StdMeshers_MEFISTO_2D.hxx index 38753d6bd..fac85f07d 100644 --- a/src/StdMeshers/StdMeshers_MEFISTO_2D.hxx +++ b/src/StdMeshers/StdMeshers_MEFISTO_2D.hxx @@ -31,13 +31,19 @@ #define _StdMeshers_MEFISTO_2D_HXX_ #include "SMESH_2D_Algo.hxx" -#include "StdMeshers_MaxElementArea.hxx" -#include "StdMeshers_LengthFromEdges.hxx" -#include "Rn.h" +#include class SMDS_MeshNode; -#include +class TopTools_IndexedDataMapOfShapeListOfShape; +class TopoDS_Face; +class TopoDS_WIre; +class StdMeshers_MaxElementArea; +class StdMeshers_LengthFromEdges; +class SMDS_MeshNode; + +#include #include +#include "Rn.h" class StdMeshers_MEFISTO_2D: public SMESH_2D_Algo @@ -56,12 +62,14 @@ public: double ComputeEdgeElementLength(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape); - void LoadPoints(SMESH_Mesh& aMesh, + bool LoadPoints(SMESH_Mesh& aMesh, const TopoDS_Face& F, const TopoDS_Wire& W, R2* uvslf, int& m, - map& mefistoToDS); + map& mefistoToDS, + double scalex, double scaley, + const TopTools_IndexedDataMapOfShapeListOfShape& VWMap); void ComputeScaleOnFace(SMESH_Mesh& aMesh, const TopoDS_Face& aFace, @@ -71,7 +79,8 @@ public: void StoreResult (SMESH_Mesh& aMesh, Z nbst, R2* uvst, Z nbt, Z* nust, const TopoDS_Face& F, bool faceIsForward, - map& mefistoToDS); + map& mefistoToDS, + double scalex, double scaley); ostream & SaveTo(ostream & save); istream & LoadFrom(istream & load); @@ -79,10 +88,13 @@ public: friend istream & operator >> (istream & load, StdMeshers_MEFISTO_2D & hyp); protected: - double _edgeLength; - double _maxElementArea; - const StdMeshers_MaxElementArea* _hypMaxElementArea; + double _edgeLength; + double _maxElementArea; + const StdMeshers_MaxElementArea* _hypMaxElementArea; const StdMeshers_LengthFromEdges* _hypLengthFromEdges; + + TopoDS_Wire myOuterWire; + std::list myNodesOnCommonV; }; #endif diff --git a/src/StdMeshers/StdMeshers_Propagation.cxx b/src/StdMeshers/StdMeshers_Propagation.cxx new file mode 100644 index 000000000..f314b4c28 --- /dev/null +++ b/src/StdMeshers/StdMeshers_Propagation.cxx @@ -0,0 +1,102 @@ +// SMESH SMESH : implementaion of SMESH idl descriptions +// +// Copyright (C) 2003 CEA +// +// 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.org +// +// +// +// File : StdMeshers_Propagation.cxx +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_Propagation.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * + */ +//============================================================================= +StdMeshers_Propagation::StdMeshers_Propagation (int hypId, int studyId, + SMESH_Gen * gen) + : SMESH_Hypothesis(hypId, studyId, gen) +{ + _name = GetName(); + _param_algo_dim = -2; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +StdMeshers_Propagation::~StdMeshers_Propagation() +{ +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & StdMeshers_Propagation::SaveTo (ostream & save) +{ + return save; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +istream & StdMeshers_Propagation::LoadFrom (istream & load) +{ + return load; +} + +//============================================================================= +/*! + * + */ +//============================================================================= +ostream & operator << (ostream & save, StdMeshers_Propagation & hyp) +{ + return hyp.SaveTo(save); +} + +//============================================================================= +/*! + * + */ +//============================================================================= +istream & operator >> (istream & load, StdMeshers_Propagation & hyp) +{ + return hyp.LoadFrom(load); +} + +//============================================================================= +/*! + * GetName + */ +//============================================================================= +std::string StdMeshers_Propagation::GetName () +{ + return "Propagation"; +} diff --git a/src/StdMeshers/StdMeshers_Propagation.hxx b/src/StdMeshers/StdMeshers_Propagation.hxx new file mode 100644 index 000000000..4ee7c5628 --- /dev/null +++ b/src/StdMeshers/StdMeshers_Propagation.hxx @@ -0,0 +1,47 @@ +// SMESH SMESH : implementaion of SMESH idl descriptions +// +// Copyright (C) 2003 CEA +// +// 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.org +// +// +// +// File : StdMeshers_Propagation.hxx +// Module : SMESH +// $Header$ + +#ifndef _SMESH_PROPAGATION_HXX_ +#define _SMESH_PROPAGATION_HXX_ + +#include "SMESH_Hypothesis.hxx" +#include "Utils_SALOME_Exception.hxx" + +class StdMeshers_Propagation:public SMESH_Hypothesis +{ + public: + StdMeshers_Propagation(int hypId, int studyId, SMESH_Gen * gen); + virtual ~ StdMeshers_Propagation(); + + virtual ostream & SaveTo(ostream & save); + virtual istream & LoadFrom(istream & load); + friend ostream & operator <<(ostream & save, StdMeshers_Propagation & hyp); + friend istream & operator >>(istream & load, StdMeshers_Propagation & hyp); + + static std::string GetName (); +}; + +#endif diff --git a/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx b/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx index 14815906d..da6b6a2e4 100644 --- a/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx +++ b/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx @@ -31,6 +31,7 @@ using namespace std; #include "StdMeshers_Quadrangle_2D.hxx" #include "SMESH_Gen.hxx" #include "SMESH_Mesh.hxx" +#include "SMESH_subMesh.hxx" #include "SMDS_MeshElement.hxx" #include "SMDS_MeshNode.hxx" @@ -40,11 +41,14 @@ using namespace std; #include #include #include + #include #include #include -#include -#include +#include +#include + +#include #include #include @@ -58,13 +62,13 @@ using namespace std; */ //============================================================================= -StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D(int hypId, - int studyId, SMESH_Gen * gen):SMESH_2D_Algo(hypId, studyId, gen) +StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D (int hypId, int studyId, SMESH_Gen* gen) + : SMESH_2D_Algo(hypId, studyId, gen) { - MESSAGE("StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D"); - _name = "Quadrangle_2D"; - // _shapeType = TopAbs_FACE; - _shapeType = (1 << TopAbs_FACE); + MESSAGE("StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D"); + _name = "Quadrangle_2D"; + // _shapeType = TopAbs_FACE; + _shapeType = (1 << TopAbs_FACE); } //============================================================================= @@ -75,7 +79,7 @@ StdMeshers_Quadrangle_2D::StdMeshers_Quadrangle_2D(int hypId, StdMeshers_Quadrangle_2D::~StdMeshers_Quadrangle_2D() { - MESSAGE("StdMeshers_Quadrangle_2D::~StdMeshers_Quadrangle_2D"); + MESSAGE("StdMeshers_Quadrangle_2D::~StdMeshers_Quadrangle_2D"); } //============================================================================= @@ -89,14 +93,14 @@ bool StdMeshers_Quadrangle_2D::CheckHypothesis const TopoDS_Shape& aShape, SMESH_Hypothesis::Hypothesis_Status& aStatus) { - //MESSAGE("StdMeshers_Quadrangle_2D::CheckHypothesis"); + //MESSAGE("StdMeshers_Quadrangle_2D::CheckHypothesis"); - bool isOk = true; - aStatus = SMESH_Hypothesis::HYP_OK; + bool isOk = true; + aStatus = SMESH_Hypothesis::HYP_OK; - // nothing to check + // nothing to check - return isOk; + return isOk; } //============================================================================= @@ -105,71 +109,405 @@ bool StdMeshers_Quadrangle_2D::CheckHypothesis */ //============================================================================= -bool StdMeshers_Quadrangle_2D::Compute(SMESH_Mesh & aMesh, - const TopoDS_Shape & aShape)throw(SALOME_Exception) +bool StdMeshers_Quadrangle_2D::Compute (SMESH_Mesh& aMesh, + const TopoDS_Shape& aShape) throw (SALOME_Exception) { Unexpect aCatch(SalomeException); - //MESSAGE("StdMeshers_Quadrangle_2D::Compute"); - SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); - SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape); - - FaceQuadStruct *quad = CheckAnd2Dcompute(aMesh, aShape); - if (!quad) - return false; - - // --- compute 3D values on points, store points & quadrangles - - int nbdown = quad->nbPts[0]; - int nbright = quad->nbPts[1]; - int nbVertices = nbdown * nbright; - int nbQuad = (nbdown - 1) * (nbright - 1); - //SCRUTE(nbVertices); - //SCRUTE(nbQuad); - - // const TopoDS_Face& FF = TopoDS::Face(aShape); - // bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD); - // TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD)); - const TopoDS_Face & F = TopoDS::Face(aShape); - bool faceIsForward = (F.Orientation() == TopAbs_FORWARD); - Handle(Geom_Surface) S = BRep_Tool::Surface(F); - - for (int i = 1; i < nbdown - 1; i++) - for (int j = 1; j < nbright - 1; j++) // internal points - { - int ij = j * nbdown + i; - double u = quad->uv_grid[ij].u; - double v = quad->uv_grid[ij].v; - gp_Pnt P = S->Value(u, v); - SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z()); - meshDS->SetNodeOnFace(node, F); - quad->uv_grid[ij].node = node; -// Handle (SMDS_FacePosition) fpos -// = new SMDS_FacePosition(theSubMesh->GetId(),i,j); // easier than u,v -// node->SetPosition(fpos); - SMDS_FacePosition* fpos = - dynamic_cast(node->GetPosition().get()); - fpos->SetUParameter(i); - fpos->SetVParameter(j); - } - - // bool isQuadForward = ( faceIsForward == quad->isEdgeForward[0]); - for (int i = 0; i < nbdown - 1; i++) - for (int j = 0; j < nbright - 1; j++) // faces - { - const SMDS_MeshNode *a, *b, *c, *d; - a = quad->uv_grid[j * nbdown + i].node; - b = quad->uv_grid[j * nbdown + i + 1].node; - c = quad->uv_grid[(j + 1) * nbdown + i + 1].node; - d = quad->uv_grid[(j + 1) * nbdown + i].node; - // if (isQuadForward) faceId = meshDS->AddFace(a,b,c,d); - // else faceId = meshDS->AddFace(a,d,c,b); - SMDS_MeshFace * face = meshDS->AddFace(a, b, c, d); - meshDS->SetMeshElementOnShape(face, F); - } - - QuadDelete(quad); - bool isOk = true; - return isOk; + //MESSAGE("StdMeshers_Quadrangle_2D::Compute"); + SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); + aMesh.GetSubMesh(aShape); + + FaceQuadStruct *quad = CheckAnd2Dcompute(aMesh, aShape); + if (!quad) + return false; + + // --- compute 3D values on points, store points & quadrangles + + int nbdown = quad->nbPts[0]; + int nbup = quad->nbPts[2]; +// bool isDownOut = (nbdown > nbup); +// bool isUpOut = (nbdown < nbup); + + int nbright = quad->nbPts[1]; + int nbleft = quad->nbPts[3]; +// bool isRightOut = (nbright > nbleft); +// bool isLeftOut = (nbright < nbleft); + + int nbhoriz = Min(nbdown, nbup); + int nbvertic = Min(nbright, nbleft); + + int nbVertices = nbhoriz * nbvertic; + int nbQuad = (nbhoriz - 1) * (nbvertic - 1); + //SCRUTE(nbVertices); + //SCRUTE(nbQuad); + + // const TopoDS_Face& FF = TopoDS::Face(aShape); + // bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD); + // TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD)); + const TopoDS_Face& F = TopoDS::Face(aShape); + bool faceIsForward = (F.Orientation() == TopAbs_FORWARD); + Handle(Geom_Surface) S = BRep_Tool::Surface(F); + + // internal mesh nodes + int i, j; + for (i = 1; i < nbhoriz - 1; i++) { + for (j = 1; j < nbvertic - 1; j++) { + int ij = j * nbhoriz + i; + double u = quad->uv_grid[ij].u; + double v = quad->uv_grid[ij].v; + gp_Pnt P = S->Value(u, v); + SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z()); + meshDS->SetNodeOnFace(node, F); + quad->uv_grid[ij].node = node; + SMDS_FacePosition* fpos = + dynamic_cast(node->GetPosition().get()); + fpos->SetUParameter(u); + fpos->SetVParameter(v); + } + } + + // mesh faces + + // [2] + // --.--.--.--.--.-- nbvertic + // | | ^ + // | | ^ + // [3] | | ^ j [1] + // | | ^ + // | | ^ + // ---.----.----.--- 0 + // 0 > > > > > > > > nbhoriz + // i + // [0] + + i = 0; + int ilow = 0; + int iup = nbhoriz - 1; + if (quad->isEdgeOut[3]) { ilow++; } else { if (quad->isEdgeOut[1]) iup--; } + + int jlow = 0; + int jup = nbvertic - 1; + if (quad->isEdgeOut[0]) { jlow++; } else { if (quad->isEdgeOut[2]) jup--; } + + // regular quadrangles + // bool isQuadForward = ( faceIsForward == quad->isEdgeForward[0]); + for (i = ilow; i < iup; i++) { + for (j = jlow; j < jup; j++) { + const SMDS_MeshNode *a, *b, *c, *d; + a = quad->uv_grid[j * nbhoriz + i].node; + b = quad->uv_grid[j * nbhoriz + i + 1].node; + c = quad->uv_grid[(j + 1) * nbhoriz + i + 1].node; + d = quad->uv_grid[(j + 1) * nbhoriz + i].node; + // if (isQuadForward) faceId = meshDS->AddFace(a,b,c,d); + // else faceId = meshDS->AddFace(a,d,c,b); + SMDS_MeshFace * face = meshDS->AddFace(a, b, c, d); + meshDS->SetMeshElementOnShape(face, F); + } + } + + UVPtStruct *uv_e0 = quad->uv_edges[0]; + UVPtStruct *uv_e1 = quad->uv_edges[1]; + UVPtStruct *uv_e2 = quad->uv_edges[2]; + UVPtStruct *uv_e3 = quad->uv_edges[3]; + + double eps = Precision::Confusion(); + + // Boundary quadrangles + + if (quad->isEdgeOut[0]) { + // Down edge is out + // + // |___|___|___|___|___|___| + // | | | | | | | + // |___|___|___|___|___|___| + // | | | | | | | + // |___|___|___|___|___|___| __ first row of the regular grid + // . . . . . . . . . __ down edge nodes + // + // >->->->->->->->->->->->-> -- direction of processing + + int g = 0; // number of last processed node in the regular grid + + // number of last node of the down edge to be processed + int stop = nbdown - 1; + // if right edge is out, we will stop at a node, previous to the last one + if (quad->isEdgeOut[1]) stop--; + + // for each node of the down edge find nearest node + // in the first row of the regular grid and link them + for (i = 0; i < stop; i++) { + const SMDS_MeshNode *a, *b, *c, *d; + a = uv_e0[i].node; + b = uv_e0[i + 1].node; + gp_Pnt pb (b->X(), b->Y(), b->Z()); + + // find node c in the regular grid, which will be linked with node b + int near = g; + if (i == stop - 1) { + // right bound reached, link with the rightmost node + near = iup; + c = quad->uv_grid[nbhoriz + iup].node; + } else { + // find in the grid node c, nearest to the b + double mind = RealLast(); + for (int k = g; k <= iup; k++) { + + const SMDS_MeshNode *nk; + if (k < ilow) // this can be, if left edge is out + nk = uv_e3[1].node; // get node from the left edge + else + nk = quad->uv_grid[nbhoriz + k].node; // get one of middle nodes + + gp_Pnt pnk (nk->X(), nk->Y(), nk->Z()); + double dist = pb.Distance(pnk); + if (dist < mind - eps) { + c = nk; + near = k; + mind = dist; + } else { + break; + } + } + } + + if (near == g) { // make triangle + SMDS_MeshFace* face = meshDS->AddFace(a, b, c); + meshDS->SetMeshElementOnShape(face, F); + } else { // make quadrangle + if (near - 1 < ilow) + d = uv_e3[1].node; + else + d = quad->uv_grid[nbhoriz + near - 1].node; + SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d); + meshDS->SetMeshElementOnShape(face, F); + + // if node d is not at position g - make additional triangles + if (near - 1 > g) { + for (int k = near - 1; k > g; k--) { + c = quad->uv_grid[nbhoriz + k].node; + if (k - 1 < ilow) + d = uv_e3[1].node; + else + d = quad->uv_grid[nbhoriz + k - 1].node; + SMDS_MeshFace* face = meshDS->AddFace(a, c, d); + meshDS->SetMeshElementOnShape(face, F); + } + } + g = near; + } + } + } else { + if (quad->isEdgeOut[2]) { + // Up edge is out + // + // <-<-<-<-<-<-<-<-<-<-<-<-< -- direction of processing + // + // . . . . . . . . . __ up edge nodes + // ___ ___ ___ ___ ___ ___ __ first row of the regular grid + // | | | | | | | + // |___|___|___|___|___|___| + // | | | | | | | + // |___|___|___|___|___|___| + // | | | | | | | + + int g = nbhoriz - 1; // last processed node in the regular grid + + int stop = 0; + // if left edge is out, we will stop at a second node + if (quad->isEdgeOut[3]) stop++; + + // for each node of the up edge find nearest node + // in the first row of the regular grid and link them + for (i = nbup - 1; i > stop; i--) { + const SMDS_MeshNode *a, *b, *c, *d; + a = uv_e2[i].node; + b = uv_e2[i - 1].node; + gp_Pnt pb (b->X(), b->Y(), b->Z()); + + // find node c in the grid, which will be linked with node b + int near = g; + if (i == stop + 1) { // left bound reached, link with the leftmost node + c = quad->uv_grid[nbhoriz*(nbvertic - 2) + ilow].node; + near = ilow; + } else { + // find node c in the grid, nearest to the b + double mind = RealLast(); + for (int k = g; k >= ilow; k--) { + const SMDS_MeshNode *nk; + if (k > iup) + nk = uv_e1[nbright - 2].node; + else + nk = quad->uv_grid[nbhoriz*(nbvertic - 2) + k].node; + gp_Pnt pnk (nk->X(), nk->Y(), nk->Z()); + double dist = pb.Distance(pnk); + if (dist < mind - eps) { + c = nk; + near = k; + mind = dist; + } else { + break; + } + } + } + + if (near == g) { // make triangle + SMDS_MeshFace* face = meshDS->AddFace(a, b, c); + meshDS->SetMeshElementOnShape(face, F); + } else { // make quadrangle + if (near + 1 > iup) + d = uv_e1[nbright - 2].node; + else + d = quad->uv_grid[nbhoriz*(nbvertic - 2) + near + 1].node; + SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d); + meshDS->SetMeshElementOnShape(face, F); + + if (near + 1 < g) { // if d not is at g - make additional triangles + for (int k = near + 1; k < g; k++) { + c = quad->uv_grid[nbhoriz*(nbvertic - 2) + k].node; + if (k + 1 > iup) + d = uv_e1[nbright - 2].node; + else + d = quad->uv_grid[nbhoriz*(nbvertic - 2) + k + 1].node; + SMDS_MeshFace* face = meshDS->AddFace(a, c, d); + meshDS->SetMeshElementOnShape(face, F); + } + } + g = near; + } + } + } + } + + // right or left boundary quadrangles + if (quad->isEdgeOut[1]) { +// MESSAGE("right edge is out"); + int g = 0; // last processed node in the grid + int stop = nbright - 1; + if (quad->isEdgeOut[2]) stop--; + for (i = 0; i < stop; i++) { + const SMDS_MeshNode *a, *b, *c, *d; + a = uv_e1[i].node; + b = uv_e1[i + 1].node; + gp_Pnt pb (b->X(), b->Y(), b->Z()); + + // find node c in the grid, nearest to the b + int near = g; + if (i == stop - 1) { // up bondary reached + c = quad->uv_grid[nbhoriz*(jup + 1) - 2].node; + near = jup; + } else { + double mind = RealLast(); + for (int k = g; k <= jup; k++) { + const SMDS_MeshNode *nk; + if (k < jlow) + nk = uv_e0[nbdown - 2].node; + else + nk = quad->uv_grid[nbhoriz*(k + 1) - 2].node; + gp_Pnt pnk (nk->X(), nk->Y(), nk->Z()); + double dist = pb.Distance(pnk); + if (dist < mind - eps) { + c = nk; + near = k; + mind = dist; + } else { + break; + } + } + } + + if (near == g) { // make triangle + SMDS_MeshFace* face = meshDS->AddFace(a, b, c); + meshDS->SetMeshElementOnShape(face, F); + } else { // make quadrangle + if (near - 1 < jlow) + d = uv_e0[nbdown - 2].node; + else + d = quad->uv_grid[nbhoriz*near - 2].node; + SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d); + meshDS->SetMeshElementOnShape(face, F); + + if (near - 1 > g) { // if d not is at g - make additional triangles + for (int k = near - 1; k > g; k--) { + c = quad->uv_grid[nbhoriz*(k + 1) - 2].node; + if (k - 1 < jlow) + d = uv_e0[nbdown - 2].node; + else + d = quad->uv_grid[nbhoriz*k - 2].node; + SMDS_MeshFace* face = meshDS->AddFace(a, c, d); + meshDS->SetMeshElementOnShape(face, F); + } + } + g = near; + } + } + } else { + if (quad->isEdgeOut[3]) { +// MESSAGE("left edge is out"); + int g = nbvertic - 1; // last processed node in the grid + int stop = 0; + if (quad->isEdgeOut[0]) stop++; + for (i = nbleft - 1; i > stop; i--) { + const SMDS_MeshNode *a, *b, *c, *d; + a = uv_e3[i].node; + b = uv_e3[i - 1].node; + gp_Pnt pb (b->X(), b->Y(), b->Z()); + + // find node c in the grid, nearest to the b + int near = g; + if (i == stop + 1) { // down bondary reached + c = quad->uv_grid[nbhoriz*jlow + 1].node; + near = jlow; + } else { + double mind = RealLast(); + for (int k = g; k >= jlow; k--) { + const SMDS_MeshNode *nk; + if (k > jup) + nk = uv_e2[1].node; + else + nk = quad->uv_grid[nbhoriz*k + 1].node; + gp_Pnt pnk (nk->X(), nk->Y(), nk->Z()); + double dist = pb.Distance(pnk); + if (dist < mind - eps) { + c = nk; + near = k; + mind = dist; + } else { + break; + } + } + } + + if (near == g) { // make triangle + SMDS_MeshFace* face = meshDS->AddFace(a, b, c); + meshDS->SetMeshElementOnShape(face, F); + } else { // make quadrangle + if (near + 1 > jup) + d = uv_e2[1].node; + else + d = quad->uv_grid[nbhoriz*(near + 1) + 1].node; + SMDS_MeshFace* face = meshDS->AddFace(a, b, c, d); + meshDS->SetMeshElementOnShape(face, F); + + if (near + 1 < g) { // if d not is at g - make additional triangles + for (int k = near + 1; k < g; k++) { + c = quad->uv_grid[nbhoriz*k + 1].node; + if (k + 1 > jup) + d = uv_e2[1].node; + else + d = quad->uv_grid[nbhoriz*(k + 1) + 1].node; + SMDS_MeshFace* face = meshDS->AddFace(a, c, d); + meshDS->SetMeshElementOnShape(face, F); + } + } + g = near; + } + } + } + } + + QuadDelete(quad); + bool isOk = true; + return isOk; } //============================================================================= @@ -178,82 +516,80 @@ bool StdMeshers_Quadrangle_2D::Compute(SMESH_Mesh & aMesh, */ //============================================================================= -FaceQuadStruct *StdMeshers_Quadrangle_2D::CheckAnd2Dcompute(SMESH_Mesh & aMesh, - const TopoDS_Shape & aShape)throw(SALOME_Exception) +FaceQuadStruct *StdMeshers_Quadrangle_2D::CheckAnd2Dcompute + (SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) throw(SALOME_Exception) { Unexpect aCatch(SalomeException); - //MESSAGE("StdMeshers_Quadrangle_2D::ComputeWithoutStore"); - - SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape); - - // const TopoDS_Face& FF = TopoDS::Face(aShape); - // bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD); - // TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD)); - const TopoDS_Face & F = TopoDS::Face(aShape); - bool faceIsForward = (F.Orientation() == TopAbs_FORWARD); - - // verify 1 wire only, with 4 edges, same number of points on opposite edges - - if (NumberOfWires(F) != 1) - { - MESSAGE("only 1 wire by face (quadrangles)"); - return 0; - //throw SALOME_Exception(LOCALIZED("only 1 wire by face (quadrangles)")); - } - // const TopoDS_Wire WW = BRepTools::OuterWire(F); - // TopoDS_Wire W = TopoDS::Wire(WW.Oriented(TopAbs_FORWARD)); - const TopoDS_Wire & W = BRepTools::OuterWire(F); - BRepTools_WireExplorer wexp(W, F); - - FaceQuadStruct *quad = new FaceQuadStruct; - for (int i = 0; i < 4; i++) - quad->uv_edges[i] = 0; - quad->uv_grid = 0; - - int nbEdges = 0; - for (wexp.Init(W, F); wexp.More(); wexp.Next()) - { - // const TopoDS_Edge& EE = wexp.Current(); - // TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD)); - const TopoDS_Edge & E = wexp.Current(); - int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); - if (nbEdges < 4) - { - quad->edge[nbEdges] = E; - quad->nbPts[nbEdges] = nb + 2; // internal points + 2 extrema - } - nbEdges++; - } - - if (nbEdges != 4) - { - MESSAGE("face must have 4 edges /quadrangles"); - QuadDelete(quad); - return 0; - //throw SALOME_Exception(LOCALIZED("face must have 4 edges /quadrangles")); - } - - if (quad->nbPts[0] != quad->nbPts[2]) - { - MESSAGE("different point number-opposed edge"); - QuadDelete(quad); - return 0; - //throw SALOME_Exception(LOCALIZED("different point number-opposed edge")); - } - - if (quad->nbPts[1] != quad->nbPts[3]) - { - MESSAGE("different point number-opposed edge"); - QuadDelete(quad); - return 0; - //throw SALOME_Exception(LOCALIZED("different point number-opposed edge")); - } - - // set normalized grid on unit square in parametric domain - - SetNormalizedGrid(aMesh, F, quad); - - return quad; +// MESSAGE("StdMeshers_Quadrangle_2D::CheckAnd2Dcompute"); + + SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape); + + // const TopoDS_Face& FF = TopoDS::Face(aShape); + // bool faceIsForward = (FF.Orientation() == TopAbs_FORWARD); + // TopoDS_Face F = TopoDS::Face(FF.Oriented(TopAbs_FORWARD)); + const TopoDS_Face & F = TopoDS::Face(aShape); + bool faceIsForward = (F.Orientation() == TopAbs_FORWARD); + + // verify 1 wire only, with 4 edges + + if (NumberOfWires(F) != 1) + { + MESSAGE("only 1 wire by face (quadrangles)"); + return 0; + //throw SALOME_Exception(LOCALIZED("only 1 wire by face (quadrangles)")); + } + // const TopoDS_Wire WW = BRepTools::OuterWire(F); + // TopoDS_Wire W = TopoDS::Wire(WW.Oriented(TopAbs_FORWARD)); + const TopoDS_Wire& W = BRepTools::OuterWire(F); + BRepTools_WireExplorer wexp (W, F); + + FaceQuadStruct *quad = new FaceQuadStruct; + for (int i = 0; i < 4; i++) + quad->uv_edges[i] = 0; + quad->uv_grid = 0; + + int nbEdges = 0; + for (wexp.Init(W, F); wexp.More(); wexp.Next()) + { + // const TopoDS_Edge& EE = wexp.Current(); + // TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD)); + const TopoDS_Edge& E = wexp.Current(); + int nb = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); + if (nbEdges < 4) + { + quad->edge[nbEdges] = E; + quad->nbPts[nbEdges] = nb + 2; // internal points + 2 extrema + } + nbEdges++; + } + + if (nbEdges != 4) + { + MESSAGE("face must have 4 edges /quadrangles"); + QuadDelete(quad); + return 0; + //throw SALOME_Exception(LOCALIZED("face must have 4 edges /quadrangles")); + } + +// if (quad->nbPts[0] != quad->nbPts[2]) { +// MESSAGE("different point number-opposed edge"); +// QuadDelete(quad); +// return 0; +// //throw SALOME_Exception(LOCALIZED("different point number-opposed edge")); +// } +// +// if (quad->nbPts[1] != quad->nbPts[3]) { +// MESSAGE("different point number-opposed edge"); +// QuadDelete(quad); +// return 0; +// //throw SALOME_Exception(LOCALIZED("different point number-opposed edge")); +// } + + // set normalized grid on unit square in parametric domain + + SetNormalizedGrid(aMesh, F, quad); + + return quad; } //============================================================================= @@ -262,21 +598,21 @@ FaceQuadStruct *StdMeshers_Quadrangle_2D::CheckAnd2Dcompute(SMESH_Mesh & aMesh, */ //============================================================================= -void StdMeshers_Quadrangle_2D::QuadDelete(FaceQuadStruct * quad) +void StdMeshers_Quadrangle_2D::QuadDelete (FaceQuadStruct * quad) { - //MESSAGE("StdMeshers_Quadrangle_2D::QuadDelete"); - if (quad) - { - for (int i = 0; i < 4; i++) - { - if (quad->uv_edges[i]) - delete[]quad->uv_edges[i]; - quad->edge[i].Nullify(); - } - if (quad->uv_grid) - delete[]quad->uv_grid; - delete quad; - } + //MESSAGE("StdMeshers_Quadrangle_2D::QuadDelete"); + if (quad) + { + for (int i = 0; i < 4; i++) + { + if (quad->uv_edges[i]) + delete [] quad->uv_edges[i]; + quad->edge[i].Nullify(); + } + if (quad->uv_grid) + delete [] quad->uv_grid; + delete quad; + } } //============================================================================= @@ -285,74 +621,75 @@ void StdMeshers_Quadrangle_2D::QuadDelete(FaceQuadStruct * quad) */ //============================================================================= -void StdMeshers_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh & aMesh, - const TopoDS_Shape & aShape, FaceQuadStruct * quad) throw(SALOME_Exception) +void StdMeshers_Quadrangle_2D::SetNormalizedGrid (SMESH_Mesh & aMesh, + const TopoDS_Shape& aShape, + FaceQuadStruct* quad) throw (SALOME_Exception) { Unexpect aCatch(SalomeException); - // Algorithme décrit dans "Génération automatique de maillages" - // P.L. GEORGE, MASSON, § 6.4.1 p. 84-85 - // traitement dans le domaine paramétrique 2d u,v - // transport - projection sur le carré unité - - const TopoDS_Face & F = TopoDS::Face(aShape); - - // 1 --- find orientation of the 4 edges, by test on extrema - - // max min 0 x1 1 - // |<----north-2-------^ a3 -------------> a2 - // | | ^1 1^ - // west-3 east-1 =right | | - // | | ==> | | - // y0 | | y1 | | - // | | |0 0| - // v----south-0--------> a0 -------------> a1 - // min max 0 x0 1 - // =down - // - - Handle(Geom2d_Curve) c2d[4]; - gp_Pnt2d pf[4]; - gp_Pnt2d pl[4]; - for (int i = 0; i < 4; i++) - { - c2d[i] = BRep_Tool::CurveOnSurface(quad->edge[i], - F, quad->first[i], quad->last[i]); - pf[i] = c2d[i]->Value(quad->first[i]); - pl[i] = c2d[i]->Value(quad->last[i]); - quad->isEdgeForward[i] = false; - } - - double eps2d = 1.e-3; // *** utiliser plutot TopExp::CommonVertex, puis - // distances si piece fausse - int i = 0; - if ((pf[1].Distance(pl[0]) < eps2d) || (pl[1].Distance(pl[0]) < eps2d)) - { - quad->isEdgeForward[0] = true; - } - else - { - double tmp = quad->first[0]; - quad->first[0] = quad->last[0]; - quad->last[0] = tmp; - pf[0] = c2d[0]->Value(quad->first[0]); - pl[0] = c2d[0]->Value(quad->last[0]); - } - for (int i = 1; i < 4; i++) - { - quad->isEdgeForward[i] = (pf[i].Distance(pl[i - 1]) < eps2d); - if (!quad->isEdgeForward[i]) - { - double tmp = quad->first[i]; - quad->first[i] = quad->last[i]; - quad->last[i] = tmp; - pf[i] = c2d[i]->Value(quad->first[i]); - pl[i] = c2d[i]->Value(quad->last[i]); - //SCRUTE(pf[i].Distance(pl[i-1])); - ASSERT(pf[i].Distance(pl[i - 1]) < eps2d); - } - } - //SCRUTE(pf[0].Distance(pl[3])); - ASSERT(pf[0].Distance(pl[3]) < eps2d); + // Algorithme décrit dans "Génération automatique de maillages" + // P.L. GEORGE, MASSON, § 6.4.1 p. 84-85 + // traitement dans le domaine paramétrique 2d u,v + // transport - projection sur le carré unité + +// MESSAGE("StdMeshers_Quadrangle_2D::SetNormalizedGrid"); + const TopoDS_Face& F = TopoDS::Face(aShape); + + // 1 --- find orientation of the 4 edges, by test on extrema + + // max min 0 x1 1 + // |<----north-2-------^ a3 -------------> a2 + // | | ^1 1^ + // west-3 east-1 =right | | + // | | ==> | | + // y0 | | y1 | | + // | | |0 0| + // v----south-0--------> a0 -------------> a1 + // min max 0 x0 1 + // =down + // + + Handle(Geom2d_Curve) c2d[4]; + gp_Pnt2d pf[4]; + gp_Pnt2d pl[4]; + for (int i = 0; i < 4; i++) + { + c2d[i] = BRep_Tool::CurveOnSurface(quad->edge[i], F, + quad->first[i], quad->last[i]); + pf[i] = c2d[i]->Value(quad->first[i]); + pl[i] = c2d[i]->Value(quad->last[i]); + quad->isEdgeForward[i] = false; + } + + double eps2d = 1.e-3; // *** utiliser plutot TopExp::CommonVertex, puis + // distances si piece fausse +// int i = 0; + if ((pf[1].Distance(pl[0]) < eps2d) || (pl[1].Distance(pl[0]) < eps2d)) + { + quad->isEdgeForward[0] = true; + } else { + double tmp = quad->first[0]; + quad->first[0] = quad->last[0]; + quad->last[0] = tmp; + pf[0] = c2d[0]->Value(quad->first[0]); + pl[0] = c2d[0]->Value(quad->last[0]); + } + + for (int i = 1; i < 4; i++) + { + quad->isEdgeForward[i] = (pf[i].Distance(pl[i - 1]) < eps2d); + if (!quad->isEdgeForward[i]) + { + double tmp = quad->first[i]; + quad->first[i] = quad->last[i]; + quad->last[i] = tmp; + pf[i] = c2d[i]->Value(quad->first[i]); + pl[i] = c2d[i]->Value(quad->last[i]); + //SCRUTE(pf[i].Distance(pl[i-1])); + ASSERT(pf[i].Distance(pl[i - 1]) < eps2d); + } + } + //SCRUTE(pf[0].Distance(pl[3])); + ASSERT(pf[0].Distance(pl[3]) < eps2d); // for (int i=0; i<4; i++) // { @@ -361,244 +698,380 @@ void StdMeshers_Quadrangle_2D::SetNormalizedGrid(SMESH_Mesh & aMesh, // MESSAGE(" -last "<uv_edges[i] = LoadEdgePoints(aMesh, F, - quad->edge[i], quad->first[i], quad->last[i]); - - // quad->isEdgeForward[i]); - } - for (int i = 2; i < 4; i++) - { - quad->uv_edges[i] = LoadEdgePoints(aMesh, F, - quad->edge[i], quad->last[i], quad->first[i]); - - // !quad->isEdgeForward[i]); - } - - // 3 --- 2D normalized values on unit square [0..1][0..1] - - int nbdown = quad->nbPts[0]; - int nbright = quad->nbPts[1]; - quad->uv_grid = new UVPtStruct[nbright * nbdown]; - - UVPtStruct *uv_grid = quad->uv_grid; - UVPtStruct *uv_e0 = quad->uv_edges[0]; - UVPtStruct *uv_e1 = quad->uv_edges[1]; - UVPtStruct *uv_e2 = quad->uv_edges[2]; - UVPtStruct *uv_e3 = quad->uv_edges[3]; - gp_Pnt2d a0 = pf[0]; - gp_Pnt2d a1 = pf[1]; - gp_Pnt2d a2 = pf[2]; - gp_Pnt2d a3 = pf[3]; - - // nodes Id on edges - - int j = 0; - for (int i = 0; i < nbdown; i++) - { - int ij = j * nbdown + i; - uv_grid[ij].node = uv_e0[i].node; - } - i = nbdown - 1; - for (int j = 0; j < nbright; j++) - { - int ij = j * nbdown + i; - uv_grid[ij].node = uv_e1[j].node; - } - j = nbright - 1; - for (int i = 0; i < nbdown; i++) - { - int ij = j * nbdown + i; - uv_grid[ij].node = uv_e2[i].node; - } - i = 0; - for (int j = 0; j < nbright; j++) - { - int ij = j * nbdown + i; - uv_grid[ij].node = uv_e3[j].node; - } - - // normalized 2d values on grid - - for (int i = 0; i < nbdown; i++) - for (int j = 0; j < nbright; j++) - { - int ij = j * nbdown + i; - // --- droite i cste : x = x0 + y(x1-x0) - double x0 = uv_e0[i].normParam; // bas - sud - double x1 = uv_e2[i].normParam; // haut - nord - // --- droite j cste : y = y0 + x(y1-y0) - double y0 = uv_e3[j].normParam; // gauche-ouest - double y1 = uv_e1[j].normParam; // droite - est - // --- intersection : x=x0+(y0+x(y1-y0))(x1-x0) - double x = (x0 + y0 * (x1 - x0)) / (1 - (y1 - y0) * (x1 - x0)); - double y = y0 + x * (y1 - y0); - uv_grid[ij].x = x; - uv_grid[ij].y = y; - //MESSAGE("-xy-01 "<Value(param_0); - gp_Pnt2d p1 = c2d[1]->Value(param_1); - gp_Pnt2d p2 = c2d[2]->Value(param_2); - gp_Pnt2d p3 = c2d[3]->Value(param_3); - - double u = - (1 - y) * p0.X() + x * p1.X() + y * p2.X() + (1 - x) * p3.X(); - double v = - (1 - y) * p0.Y() + x * p1.Y() + y * p2.Y() + (1 - x) * p3.Y(); - - u -= (1 - x) * (1 - y) * a0.X() + x * (1 - y) * a1.X() + - x * y * a2.X() + (1 - x) * y * a3.X(); - v -= (1 - x) * (1 - y) * a0.Y() + x * (1 - y) * a1.Y() + - x * y * a2.Y() + (1 - x) * y * a3.Y(); - - uv_grid[ij].u = u; - uv_grid[ij].v = v; - - //MESSAGE("-uv- "<uv_edges[i] = LoadEdgePoints(aMesh, F, quad->edge[i], + quad->first[i], quad->last[i]); + if (!quad->uv_edges[i]) loadOk = false; + // quad->isEdgeForward[i]); + } + + for (int i = 2; i < 4; i++) + { + quad->uv_edges[i] = LoadEdgePoints(aMesh, F, quad->edge[i], + quad->last[i], quad->first[i]); + if (!quad->uv_edges[i]) loadOk = false; + // !quad->isEdgeForward[i]); + } + + if (!loadOk) + { +// MESSAGE("StdMeshers_Quadrangle_2D::SetNormalizedGrid - LoadEdgePoints failed"); + QuadDelete( quad ); + quad = 0; + return; + } + // 3 --- 2D normalized values on unit square [0..1][0..1] + +// int nbdown = quad->nbPts[0]; +// int nbright = quad->nbPts[1]; + int nbhoriz = Min(quad->nbPts[0], quad->nbPts[2]); + int nbvertic = Min(quad->nbPts[1], quad->nbPts[3]); +// MESSAGE("nbhoriz, nbvertic = " << nbhoriz << nbvertic); + + quad->isEdgeOut[0] = (quad->nbPts[0] > quad->nbPts[2]); + quad->isEdgeOut[1] = (quad->nbPts[1] > quad->nbPts[3]); + quad->isEdgeOut[2] = (quad->nbPts[2] > quad->nbPts[0]); + quad->isEdgeOut[3] = (quad->nbPts[3] > quad->nbPts[1]); + + quad->uv_grid = new UVPtStruct[nbvertic * nbhoriz]; + + UVPtStruct *uv_grid = quad->uv_grid; + UVPtStruct *uv_e0 = quad->uv_edges[0]; + UVPtStruct *uv_e1 = quad->uv_edges[1]; + UVPtStruct *uv_e2 = quad->uv_edges[2]; + UVPtStruct *uv_e3 = quad->uv_edges[3]; + + // nodes Id on "in" edges + if (! quad->isEdgeOut[0]) { + int j = 0; + for (int i = 0; i < nbhoriz; i++) { // down + int ij = j * nbhoriz + i; + uv_grid[ij].node = uv_e0[i].node; + } + } + if (! quad->isEdgeOut[1]) { + int i = nbhoriz - 1; + for (int j = 0; j < nbvertic; j++) { // right + int ij = j * nbhoriz + i; + uv_grid[ij].node = uv_e1[j].node; + } + } + if (! quad->isEdgeOut[2]) { + int j = nbvertic - 1; + for (int i = 0; i < nbhoriz; i++) { // up + int ij = j * nbhoriz + i; + uv_grid[ij].node = uv_e2[i].node; + } + } + if (! quad->isEdgeOut[3]) { + int i = 0; + for (int j = 0; j < nbvertic; j++) { // left + int ij = j * nbhoriz + i; + uv_grid[ij].node = uv_e3[j].node; + } + } + + // falsificate "out" edges + if (quad->isEdgeOut[0]) // down + uv_e0 = MakeEdgePoints + (aMesh, F, quad->edge[0], quad->first[0], quad->last[0], nbhoriz - 1); + else if (quad->isEdgeOut[2]) // up + uv_e2 = MakeEdgePoints + (aMesh, F, quad->edge[2], quad->last[2], quad->first[2], nbhoriz - 1); + + if (quad->isEdgeOut[1]) // right + uv_e1 = MakeEdgePoints + (aMesh, F, quad->edge[1], quad->first[1], quad->last[1], nbvertic - 1); + else if (quad->isEdgeOut[3]) // left + uv_e3 = MakeEdgePoints + (aMesh, F, quad->edge[3], quad->last[3], quad->first[3], nbvertic - 1); + + // normalized 2d values on grid + for (int i = 0; i < nbhoriz; i++) + { + for (int j = 0; j < nbvertic; j++) + { + int ij = j * nbhoriz + i; + // --- droite i cste : x = x0 + y(x1-x0) + double x0 = uv_e0[i].normParam; // bas - sud + double x1 = uv_e2[i].normParam; // haut - nord + // --- droite j cste : y = y0 + x(y1-y0) + double y0 = uv_e3[j].normParam; // gauche-ouest + double y1 = uv_e1[j].normParam; // droite - est + // --- intersection : x=x0+(y0+x(y1-y0))(x1-x0) + double x = (x0 + y0 * (x1 - x0)) / (1 - (y1 - y0) * (x1 - x0)); + double y = y0 + x * (y1 - y0); + uv_grid[ij].x = x; + uv_grid[ij].y = y; + //MESSAGE("-xy-01 "<Value(param_0); + gp_Pnt2d p1 = c2d[1]->Value(param_1); + gp_Pnt2d p2 = c2d[2]->Value(param_2); + gp_Pnt2d p3 = c2d[3]->Value(param_3); + + double u = (1 - y) * p0.X() + x * p1.X() + y * p2.X() + (1 - x) * p3.X(); + double v = (1 - y) * p0.Y() + x * p1.Y() + y * p2.Y() + (1 - x) * p3.Y(); + + u -= (1 - x) * (1 - y) * a0.X() + x * (1 - y) * a1.X() + + x * y * a2.X() + (1 - x) * y * a3.X(); + v -= (1 - x) * (1 - y) * a0.Y() + x * (1 - y) * a1.Y() + + x * y * a2.Y() + (1 - x) * y * a3.Y(); + + uv_grid[ij].u = u; + uv_grid[ij].v = v; + + //MESSAGE("-uv- "<GetSubMeshDS()->GetNodes(); + if (!lid->more()) + { + MESSAGE ( "NO NODE BUILT ON VERTEX" ); + return 0; + } + const SMDS_MeshNode* idFirst = lid->next(); + + ASSERT(!VLast.IsNull()); + lid = aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes(); + if (!lid->more()) + { + MESSAGE ( "NO NODE BUILT ON VERTEX" ); + return 0; + } + const SMDS_MeshNode* idLast = lid->next(); + + // --- edge internal IDNodes (relies on good order storage, not checked) + + map params; + SMDS_NodeIteratorPtr ite = aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes(); + + while(ite->more()) + { + const SMDS_MeshNode* node = ite->next(); + const SMDS_EdgePosition* epos = + static_cast(node->GetPosition().get()); + double param = epos->GetUParameter(); + params[param] = node; + } + + int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); + if (nbPoints != params.size()) + { + MESSAGE( "BAD NODE ON EDGE POSITIONS" ); + return 0; + } + UVPtStruct* uvslf = new UVPtStruct[nbPoints + 2]; + + double f, l; + Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l); + + bool isForward = (((l - f) * (last - first)) > 0); + double paramin = 0; + double paramax = 0; + if (isForward) + { + paramin = f; + paramax = l; + gp_Pnt2d p = C2d->Value(f); // first point = Vertex Forward + uvslf[0].x = p.X(); + uvslf[0].y = p.Y(); + uvslf[0].param = f; + uvslf[0].node = idFirst; + //MESSAGE("__ f "<::iterator itp = params.begin(); + for (int i = 1; i <= nbPoints; i++) // nbPoints internal + { + double param = (*itp).first; + gp_Pnt2d p = C2d->Value(param); + uvslf[i].x = p.X(); + uvslf[i].y = p.Y(); + uvslf[i].param = param; + uvslf[i].node = (*itp).second; + //MESSAGE("__ "<Value(l); // last point = Vertex Reversed + uvslf[nbPoints + 1].x = p.X(); + uvslf[nbPoints + 1].y = p.Y(); + uvslf[nbPoints + 1].param = l; + uvslf[nbPoints + 1].node = idLast; + //MESSAGE("__ l "<Value(l); // first point = Vertex Reversed + uvslf[0].x = p.X(); + uvslf[0].y = p.Y(); + uvslf[0].param = l; + uvslf[0].node = idLast; + //MESSAGE("__ l "<::reverse_iterator itp = params.rbegin(); + + for (int j = nbPoints; j >= 1; j--) // nbPoints internal + { + double param = (*itp).first; + int i = nbPoints + 1 - j; + gp_Pnt2d p = C2d->Value(param); + uvslf[i].x = p.X(); + uvslf[i].y = p.Y(); + uvslf[i].param = param; + uvslf[i].node = (*itp).second; + //MESSAGE("__ "<Value(f); // last point = Vertex Forward + uvslf[nbPoints + 1].x = p.X(); + uvslf[nbPoints + 1].y = p.Y(); + uvslf[nbPoints + 1].param = f; + uvslf[nbPoints + 1].node = idFirst; + //MESSAGE("__ f "<GetSubMeshDS()->GetNodes(); - const SMDS_MeshNode * idFirst = lid->next(); - - ASSERT(!VLast.IsNull()); - lid=aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes(); - const SMDS_MeshNode * idLast = lid->next(); - - // --- edge internal IDNodes (relies on good order storage, not checked) - - int nbPoints = aMesh.GetSubMesh(E)->GetSubMeshDS()->NbNodes(); - //SCRUTE(nbPoints); - UVPtStruct *uvslf = new UVPtStruct[nbPoints + 2]; - - double f, l; - Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l); - - map params; - SMDS_NodeIteratorPtr ite= aMesh.GetSubMesh(E)->GetSubMeshDS()->GetNodes(); - - while(ite->more()) - { - const SMDS_MeshNode * node = ite->next(); - const SMDS_EdgePosition* epos = - static_cast(node->GetPosition().get()); - double param = epos->GetUParameter(); - params[param] = node; - } - - bool isForward = (((l - f) * (last - first)) > 0); - double paramin = 0; - double paramax = 0; - if (isForward) - { - paramin = f; - paramax = l; - gp_Pnt2d p = C2d->Value(f); // first point = Vertex Forward - uvslf[0].x = p.X(); - uvslf[0].y = p.Y(); - uvslf[0].param = f; - uvslf[0].node = idFirst; - //MESSAGE("__ f "<::iterator itp = params.begin(); - for (int i = 1; i <= nbPoints; i++) // nbPoints internal - { - double param = (*itp).first; - gp_Pnt2d p = C2d->Value(param); - uvslf[i].x = p.X(); - uvslf[i].y = p.Y(); - uvslf[i].param = param; - uvslf[i].node = (*itp).second; - //MESSAGE("__ "<Value(l); // last point = Vertex Reversed - uvslf[nbPoints + 1].x = p.X(); - uvslf[nbPoints + 1].y = p.Y(); - uvslf[nbPoints + 1].param = l; - uvslf[nbPoints + 1].node = idLast; - //MESSAGE("__ l "<Value(l); // first point = Vertex Reversed - uvslf[0].x = p.X(); - uvslf[0].y = p.Y(); - uvslf[0].param = l; - uvslf[0].node = idLast; - //MESSAGE("__ l "<::reverse_iterator itp = params.rbegin(); - for (int j = nbPoints; j >= 1; j--) // nbPoints internal - { - double param = (*itp).first; - int i = nbPoints + 1 - j; - gp_Pnt2d p = C2d->Value(param); - uvslf[i].x = p.X(); - uvslf[i].y = p.Y(); - uvslf[i].param = param; - uvslf[i].node = (*itp).second; - //MESSAGE("__ "<Value(f); // last point = Vertex Forward - uvslf[nbPoints + 1].x = p.X(); - uvslf[nbPoints + 1].y = p.Y(); - uvslf[nbPoints + 1].param = f; - uvslf[nbPoints + 1].node = idFirst; - //MESSAGE("__ f "< params; + + // --- edge internal points + double fi, li; + Handle(Geom_Curve) Curve = BRep_Tool::Curve(E, fi, li); + if (!Curve.IsNull()) { + try { + GeomAdaptor_Curve C3d (Curve); + double length = EdgeLength(E); + double eltSize = length / nb_segm; + GCPnts_UniformAbscissa Discret (C3d, eltSize, fi, li); + if (!Discret.IsDone()) return false; + int NbPoints = Discret.NbPoints(); + for (int i = 1; i <= NbPoints; i++) { + double param = Discret.Parameter(i); + params.push_back(param); + } + } + catch (Standard_Failure) { + return 0; + } + } + else + { + // Edge is a degenerated Edge + BRep_Tool::Range(E, fi, li); + double du = (li - fi) / nb_segm; + for (int i = 1; i <= nb_segm + 1; i++) + { + double param = fi + (i - 1) * du; + params.push_back(param); + } + } + + double f, l; + Handle(Geom2d_Curve) C2d = BRep_Tool::CurveOnSurface(E, F, f, l); + ASSERT(f != l); + + bool isForward = (((l - f) * (last - first)) > 0); + if (isForward) { + list::iterator itU = params.begin(); + for (int i = 0; i <= nb_segm; i++) // nbPoints internal + { + double param = *itU; + gp_Pnt2d p = C2d->Value(param); + uvslf[i].x = p.X(); + uvslf[i].y = p.Y(); + uvslf[i].param = param; + uvslf[i].normParam = (param - f) / (l - f); + itU++; + } + } else { + list::reverse_iterator itU = params.rbegin(); + for (int j = nb_segm; j >= 0; j--) // nbPoints internal + { + double param = *itU; + int i = nb_segm - j; + gp_Pnt2d p = C2d->Value(param); + uvslf[i].x = p.X(); + uvslf[i].y = p.Y(); + uvslf[i].param = param; + uvslf[i].normParam = (param - l) / (f - l); + itU++; + } + } + + return uvslf; } + //============================================================================= /*! * diff --git a/src/StdMeshers/StdMeshers_Quadrangle_2D.hxx b/src/StdMeshers/StdMeshers_Quadrangle_2D.hxx index afa3882f2..1ecad92d5 100644 --- a/src/StdMeshers/StdMeshers_Quadrangle_2D.hxx +++ b/src/StdMeshers/StdMeshers_Quadrangle_2D.hxx @@ -34,6 +34,8 @@ #include "SMESH_Mesh.hxx" #include "Utils_SALOME_Exception.hxx" +class SMDS_MeshNode; + typedef struct uvPtStruct { double param; @@ -42,7 +44,7 @@ typedef struct uvPtStruct double v; double x; // 2d parameter, normalized [0,1] double y; - const SMDS_MeshNode * node; + const SMDS_MeshNode * node; } UVPtStruct; typedef struct faceQuadStruct @@ -52,6 +54,7 @@ typedef struct faceQuadStruct double first[4]; double last[4]; bool isEdgeForward[4]; + bool isEdgeOut[4]; // true, if an edge has more nodes, than the opposite UVPtStruct* uv_edges[4]; UVPtStruct* uv_grid; } FaceQuadStruct; @@ -90,13 +93,12 @@ protected: throw (SALOME_Exception); UVPtStruct* LoadEdgePoints(SMESH_Mesh& aMesh, - const TopoDS_Face& F, - const TopoDS_Edge& E, - double first, - double last); -// bool isForward); + const TopoDS_Face& F, const TopoDS_Edge& E, + double first, double last); -// FaceQuadStruct _quadDesc; + UVPtStruct* MakeEdgePoints(SMESH_Mesh& aMesh, + const TopoDS_Face& F, const TopoDS_Edge& E, + double first, double last, int nb_segm); }; #endif diff --git a/src/StdMeshers/StdMeshers_Regular_1D.cxx b/src/StdMeshers/StdMeshers_Regular_1D.cxx index aa069ff8c..6a6f92a79 100644 --- a/src/StdMeshers/StdMeshers_Regular_1D.cxx +++ b/src/StdMeshers/StdMeshers_Regular_1D.cxx @@ -1,23 +1,23 @@ // 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // @@ -35,26 +35,40 @@ using namespace std; #include "StdMeshers_LocalLength.hxx" #include "StdMeshers_NumberOfSegments.hxx" +#include "StdMeshers_Arithmetic1D.hxx" +#include "StdMeshers_StartEndLength.hxx" +#include "StdMeshers_Deflection1D.hxx" +#include "StdMeshers_Propagation.hxx" #include "SMDS_MeshElement.hxx" #include "SMDS_MeshNode.hxx" #include "SMDS_EdgePosition.hxx" +#include "SMESH_subMesh.hxx" #include "utilities.h" +#include +#include + #include #include +#include +#include + #include -#include #include #include +#include + +#include +#include #include -#include +//#include //============================================================================= /*! - * + * */ //============================================================================= @@ -63,20 +77,18 @@ StdMeshers_Regular_1D::StdMeshers_Regular_1D(int hypId, int studyId, { MESSAGE("StdMeshers_Regular_1D::StdMeshers_Regular_1D"); _name = "Regular_1D"; - // _shapeType = TopAbs_EDGE; _shapeType = (1 << TopAbs_EDGE); + _compatibleHypothesis.push_back("LocalLength"); _compatibleHypothesis.push_back("NumberOfSegments"); - - _localLength = 0; - _numberOfSegments = 0; - _hypLocalLength = NULL; - _hypNumberOfSegments = NULL; + _compatibleHypothesis.push_back("StartEndLength"); + _compatibleHypothesis.push_back("Deflection1D"); + _compatibleHypothesis.push_back("Arithmetic1D"); } //============================================================================= /*! - * + * */ //============================================================================= @@ -86,7 +98,7 @@ StdMeshers_Regular_1D::~StdMeshers_Regular_1D() //============================================================================= /*! - * + * */ //============================================================================= @@ -95,200 +107,499 @@ bool StdMeshers_Regular_1D::CheckHypothesis const TopoDS_Shape& aShape, SMESH_Hypothesis::Hypothesis_Status& aStatus) { - //MESSAGE("StdMeshers_Regular_1D::CheckHypothesis"); - - list ::const_iterator itl; - const SMESHDS_Hypothesis *theHyp; + _hypType = NONE; + + const list &hyps = GetUsedHypothesis(aMesh, aShape); + if (hyps.size() == 0) + { + aStatus = SMESH_Hypothesis::HYP_MISSING; + return false; // can't work without a hypothesis + } + + // use only the first hypothesis + const SMESHDS_Hypothesis *theHyp = hyps.front(); + + string hypName = theHyp->GetName(); + + if (hypName == "LocalLength") + { + const StdMeshers_LocalLength * hyp = + dynamic_cast (theHyp); + ASSERT(hyp); + _value[ BEG_LENGTH_IND ] = _value[ END_LENGTH_IND ] = hyp->GetLength(); + ASSERT( _value[ BEG_LENGTH_IND ] > 0 ); + _hypType = LOCAL_LENGTH; + aStatus = SMESH_Hypothesis::HYP_OK; + } + + else if (hypName == "NumberOfSegments") + { + const StdMeshers_NumberOfSegments * hyp = + dynamic_cast (theHyp); + ASSERT(hyp); + _value[ NB_SEGMENTS_IND ] = hyp->GetNumberOfSegments(); + _value[ SCALE_FACTOR_IND ] = hyp->GetScaleFactor(); + ASSERT( _value[ NB_SEGMENTS_IND ] > 0 ); + _hypType = NB_SEGMENTS; + aStatus = SMESH_Hypothesis::HYP_OK; + } + + else if (hypName == "Arithmetic1D") + { + const StdMeshers_Arithmetic1D * hyp = + dynamic_cast (theHyp); + ASSERT(hyp); + _value[ BEG_LENGTH_IND ] = hyp->GetLength( true ); + _value[ END_LENGTH_IND ] = hyp->GetLength( false ); + ASSERT( _value[ BEG_LENGTH_IND ] > 0 && _value[ END_LENGTH_IND ] > 0 ); + _hypType = ARITHMETIC_1D; + aStatus = SMESH_Hypothesis::HYP_OK; + } + + else if (hypName == "StartEndLength") + { + const StdMeshers_StartEndLength * hyp = + dynamic_cast (theHyp); + ASSERT(hyp); + _value[ BEG_LENGTH_IND ] = hyp->GetLength( true ); + _value[ END_LENGTH_IND ] = hyp->GetLength( false ); + ASSERT( _value[ BEG_LENGTH_IND ] > 0 && _value[ END_LENGTH_IND ] > 0 ); + _hypType = BEG_END_LENGTH; + aStatus = SMESH_Hypothesis::HYP_OK; + } + + else if (hypName == "Deflection1D") + { + const StdMeshers_Deflection1D * hyp = + dynamic_cast (theHyp); + ASSERT(hyp); + _value[ DEFLECTION_IND ] = hyp->GetDeflection(); + ASSERT( _value[ DEFLECTION_IND ] > 0 ); + _hypType = DEFLECTION; + aStatus = SMESH_Hypothesis::HYP_OK; + } + else + aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE; + + return ( _hypType != NONE ); +} - const list &hyps = GetUsedHypothesis(aMesh, aShape); - int nbHyp = hyps.size(); - if (!nbHyp) +//============================================================================= +/*! + * + */ +//============================================================================= +bool StdMeshers_Regular_1D::computeInternalParameters(const TopoDS_Edge& theEdge, + list & theParams) const +{ + theParams.clear(); + + double f, l; + Handle(Geom_Curve) Curve = BRep_Tool::Curve(theEdge, f, l); + GeomAdaptor_Curve C3d(Curve); + + double length = EdgeLength(theEdge); + //SCRUTE(length); + + switch( _hypType ) + { + case LOCAL_LENGTH: + case NB_SEGMENTS: { + + double eltSize = 1; + if ( _hypType == LOCAL_LENGTH ) + { + double nbseg = ceil(length / _value[ BEG_LENGTH_IND ]); // integer sup + if (nbseg <= 0) + nbseg = 1; // degenerated edge + eltSize = length / nbseg; + } + else + { + double epsilon = 0.001; + if (fabs(_value[ SCALE_FACTOR_IND ] - 1.0) > epsilon) + { + double alpha = + pow( _value[ SCALE_FACTOR_IND ], 1.0 / (_value[ NB_SEGMENTS_IND ] - 1)); + double factor = + length / (1 - pow( alpha,_value[ NB_SEGMENTS_IND ])); + + int i, NbPoints = (int) _value[ NB_SEGMENTS_IND ]; + for ( i = 2; i < NbPoints; i++ ) { - aStatus = SMESH_Hypothesis::HYP_MISSING; - return false; // can't work with no hypothesis + double param = factor * (1 - pow(alpha, i - 1)); + theParams.push_back( param ); } - - itl = hyps.begin(); - theHyp = (*itl); // use only the first hypothesis - - string hypName = theHyp->GetName(); - int hypId = theHyp->GetID(); - //SCRUTE(hypName); - - bool isOk = false; - - if (hypName == "LocalLength") - { - _hypLocalLength = dynamic_cast (theHyp); - ASSERT(_hypLocalLength); - _localLength = _hypLocalLength->GetLength(); - _numberOfSegments = 0; - isOk = true; - aStatus = SMESH_Hypothesis::HYP_OK; - } - - else if (hypName == "NumberOfSegments") - { - _hypNumberOfSegments = - dynamic_cast (theHyp); - ASSERT(_hypNumberOfSegments); - _numberOfSegments = _hypNumberOfSegments->GetNumberOfSegments(); - _scaleFactor = _hypNumberOfSegments->GetScaleFactor(); - _localLength = 0; - isOk = true; - aStatus = SMESH_Hypothesis::HYP_OK; - } - else - aStatus = SMESH_Hypothesis::HYP_INCOMPATIBLE; - - //SCRUTE(_localLength); - //SCRUTE(_numberOfSegments); - - return isOk; + return true; + } + else + { + eltSize = length / _value[ NB_SEGMENTS_IND ]; + } + } + + GCPnts_UniformAbscissa Discret(C3d, eltSize, f, l); + if ( !Discret.IsDone() ) + return false; + + int NbPoints = Discret.NbPoints(); + for ( int i = 2; i < NbPoints; i++ ) + { + double param = Discret.Parameter(i); + theParams.push_back( param ); + } + return true; + } + + case BEG_END_LENGTH: { + + // geometric progression: SUM(n) = ( a1 - an * q ) / ( 1 - q ) = length + + double a1 = _value[ BEG_LENGTH_IND ]; + double an = _value[ END_LENGTH_IND ]; + double q = ( length - a1 ) / ( length - an ); + + double U1 = Min ( f, l ); + double Un = Max ( f, l ); + double param = U1; + double eltSize = a1; + while ( 1 ) { + // computes a point on a curve at the distance + // from the point of parameter . + GCPnts_AbscissaPoint Discret( C3d, eltSize, param ); + if ( !Discret.IsDone() ) break; + param = Discret.Parameter(); + if ( param < Un ) + theParams.push_back( param ); + else + break; + eltSize *= q; + } + if ( a1 + an < length ) { + // compensate error + double Ln = GCPnts_AbscissaPoint::Length( C3d, theParams.back(), Un ); + double dLn = an - Ln; + if ( dLn < 0.5 * an ) + dLn = -dLn; + else { + theParams.pop_back(); + Ln = GCPnts_AbscissaPoint::Length( C3d, theParams.back(), Un ); + dLn = an - Ln; + if ( dLn < 0.5 * an ) + dLn = -dLn; + } + double dUn = dLn * ( Un - U1 ) / length; +// SCRUTE( Ln ); +// SCRUTE( dLn ); +// SCRUTE( dUn ); + list::reverse_iterator itU = theParams.rbegin(); + int i, n = theParams.size(); + for ( i = 1 ; i < n; itU++, i++ ) { + (*itU) += dUn; + dUn /= q; + } + } + + return true; + } + + case DEFLECTION: { + + GCPnts_UniformDeflection Discret(C3d, _value[ DEFLECTION_IND ], true); + if ( !Discret.IsDone() ) + return false; + + int NbPoints = Discret.NbPoints(); + for ( int i = 2; i < NbPoints; i++ ) + { + double param = Discret.Parameter(i); + theParams.push_back( param ); + } + return true; + + } + + case ARITHMETIC_1D: { + // arithmetic progression: SUM(n) = ( an - a1 + q ) * ( a1 + an ) / ( 2 * q ) = length + + double a1 = _value[ BEG_LENGTH_IND ]; + double an = _value[ END_LENGTH_IND ]; + + double nd = (2 * length) / (an + a1) - 1; + int n = int(nd); + if(n != nd) + n++; + + double q = ((2 * length) / (n + 1) - 2 * a1) / n; + double U1 = Min ( f, l ); + double Un = Max ( f, l ); + double param = U1; + double eltSize = a1; + + double L=0; + while ( 1 ) { + L+=eltSize; + // computes a point on a curve at the distance + // from the point of parameter . + GCPnts_AbscissaPoint Discret( C3d, eltSize, param ); + if ( !Discret.IsDone() ) break; + param = Discret.Parameter(); + if ( fabs(param - Un) > Precision::Confusion() && param < Un) { + theParams.push_back( param ); + } + else + break; + eltSize += q; + } + + return true; + } + + default:; + } + + return false; } //============================================================================= /*! - * + * */ //============================================================================= bool StdMeshers_Regular_1D::Compute(SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) { - MESSAGE("StdMeshers_Regular_1D::Compute"); - - SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); - SMESH_subMesh *theSubMesh = aMesh.GetSubMesh(aShape); - - const TopoDS_Edge & EE = TopoDS::Edge(aShape); - TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD)); - - double f, l; - Handle(Geom_Curve) Curve = BRep_Tool::Curve(E, f, l); - - TopoDS_Vertex VFirst, VLast; - TopExp::Vertices(E, VFirst, VLast); // Vfirst corresponds to f and Vlast to l - - double length = EdgeLength(E); - //SCRUTE(length); - - double eltSize = 1; -// if (_localLength > 0) eltSize = _localLength; - if (_localLength > 0) - { - double nbseg = ceil(length / _localLength); // integer sup - if (nbseg <= 0) - nbseg = 1; // degenerated edge - eltSize = length / nbseg; - } - else - { - ASSERT(_numberOfSegments > 0); - eltSize = length / _numberOfSegments; - } - - ASSERT(!VFirst.IsNull()); - SMDS_NodeIteratorPtr lid= aMesh.GetSubMesh(VFirst)->GetSubMeshDS()->GetNodes(); - const SMDS_MeshNode * idFirst = lid->next(); - - ASSERT(!VLast.IsNull()); - lid=aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes(); - const SMDS_MeshNode * idLast = lid->next(); - - if (!Curve.IsNull()) - { - GeomAdaptor_Curve C3d(Curve); - GCPnts_UniformAbscissa Discret(C3d, eltSize, f, l); - int NbPoints = Discret.NbPoints(); - //MESSAGE("nb points on edge : "< 1) - { - double epsilon = 0.001; - if (fabs(_scaleFactor - 1.0) > epsilon) - { - double alpha = - pow(_scaleFactor, 1.0 / (_numberOfSegments - 1)); - double d = - length * (1 - pow(alpha, i - 1)) / (1 - pow(alpha, - _numberOfSegments)); - param = d; - } - } - - gp_Pnt P = Curve->Value(param); - - //Add the Node in the DataStructure - //MESSAGE("point "<AddNode(P.X(), P.Y(), P.Z()); - meshDS->SetNodeOnEdge(node, E); - - // **** edgePosition associe au point = param. - SMDS_EdgePosition* epos = - dynamic_cast(node->GetPosition().get()); - epos->SetUParameter(param); - - SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node); - meshDS->SetMeshElementOnShape(edge, E); - idPrev = node; - } - SMDS_MeshEdge* edge = meshDS->AddEdge(idPrev, idLast); - meshDS->SetMeshElementOnShape(edge, E); - } - else - { -// MESSAGE ("Edge Degeneree non traitee --- arret"); -// ASSERT(0); - if (BRep_Tool::Degenerated(E)) - { - // Edge is a degenerated Edge : We put n = 5 points on the edge. - int NbPoints = 5; - BRep_Tool::Range(E, f, l); - double du = (l - f) / (NbPoints - 1); - MESSAGE("************* Degenerated edge! *****************"); - - TopoDS_Vertex V1, V2; - TopExp::Vertices(E, V1, V2); - gp_Pnt P = BRep_Tool::Pnt(V1); - - const SMDS_MeshNode * idPrev = idFirst; - for (int i = 2; i < NbPoints; i++) - { - double param = f + (i - 1) * du; - SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z()); - meshDS->SetNodeOnEdge(node, E); - -// Handle (SMDS_EdgePosition) epos -// = new SMDS_EdgePosition(theSubMesh->GetId(),param); -// node->SetPosition(epos); - SMDS_EdgePosition* epos = - dynamic_cast(node->GetPosition().get()); - epos->SetUParameter(param); - - SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node); - meshDS->SetMeshElementOnShape(edge, E); - idPrev = node; - } - SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, idLast); - meshDS->SetMeshElementOnShape(edge, E); - } - else - ASSERT(0); - } - return true; + MESSAGE("StdMeshers_Regular_1D::Compute"); + + if ( _hypType == NONE ) + return false; + + SMESHDS_Mesh * meshDS = aMesh.GetMeshDS(); + aMesh.GetSubMesh(aShape); + + const TopoDS_Edge & EE = TopoDS::Edge(aShape); + TopoDS_Edge E = TopoDS::Edge(EE.Oriented(TopAbs_FORWARD)); + + double f, l; + Handle(Geom_Curve) Curve = BRep_Tool::Curve(E, f, l); + + TopoDS_Vertex VFirst, VLast; + TopExp::Vertices(E, VFirst, VLast); // Vfirst corresponds to f and Vlast to l + + ASSERT(!VFirst.IsNull()); + SMDS_NodeIteratorPtr lid= aMesh.GetSubMesh(VFirst)->GetSubMeshDS()->GetNodes(); + if (!lid->more()) + { + MESSAGE (" NO NODE BUILT ON VERTEX "); + return false; + } + const SMDS_MeshNode * idFirst = lid->next(); + + ASSERT(!VLast.IsNull()); + lid=aMesh.GetSubMesh(VLast)->GetSubMeshDS()->GetNodes(); + if (!lid->more()) + { + MESSAGE (" NO NODE BUILT ON VERTEX "); + return false; + } + const SMDS_MeshNode * idLast = lid->next(); + + if (!Curve.IsNull()) + { + list< double > params; + try { + if ( ! computeInternalParameters( E, params )) + return false; + } + catch ( Standard_Failure ) { + return false; + } + + // edge extrema (indexes : 1 & NbPoints) already in SMDS (TopoDS_Vertex) + // only internal nodes receive an edge position with param on curve + + const SMDS_MeshNode * idPrev = idFirst; + + for (list::iterator itU = params.begin(); itU != params.end(); itU++) + { + double param = *itU; + gp_Pnt P = Curve->Value(param); + + //Add the Node in the DataStructure + SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z()); + meshDS->SetNodeOnEdge(node, E); + + // **** edgePosition associe au point = param. + SMDS_EdgePosition* epos = + dynamic_cast(node->GetPosition().get()); + epos->SetUParameter(param); + + SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node); + meshDS->SetMeshElementOnShape(edge, E); + idPrev = node; + } + SMDS_MeshEdge* edge = meshDS->AddEdge(idPrev, idLast); + meshDS->SetMeshElementOnShape(edge, E); + } + else + { + // Edge is a degenerated Edge : We put n = 5 points on the edge. + int NbPoints = 5; + BRep_Tool::Range(E, f, l); + double du = (l - f) / (NbPoints - 1); + //MESSAGE("************* Degenerated edge! *****************"); + + TopoDS_Vertex V1, V2; + TopExp::Vertices(E, V1, V2); + gp_Pnt P = BRep_Tool::Pnt(V1); + + const SMDS_MeshNode * idPrev = idFirst; + for (int i = 2; i < NbPoints; i++) + { + double param = f + (i - 1) * du; + SMDS_MeshNode * node = meshDS->AddNode(P.X(), P.Y(), P.Z()); + meshDS->SetNodeOnEdge(node, E); + + SMDS_EdgePosition* epos = + dynamic_cast(node->GetPosition().get()); + epos->SetUParameter(param); + + SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, node); + meshDS->SetMeshElementOnShape(edge, E); + idPrev = node; + } + SMDS_MeshEdge * edge = meshDS->AddEdge(idPrev, idLast); + meshDS->SetMeshElementOnShape(edge, E); + } + return true; +} + +//============================================================================= +/*! + * GetUsedHypothesis + */ +//============================================================================= + +const list & StdMeshers_Regular_1D::GetUsedHypothesis + (SMESH_Mesh & aMesh, const TopoDS_Shape & aShape) +{ + _usedHypList.clear(); + _usedHypList = GetAppliedHypothesis(aMesh, aShape); // copy + int nbHyp = _usedHypList.size(); + + // try to find being propagated hypothesis + string propName = StdMeshers_Propagation::GetName(); + if (nbHyp == 0) { + // Get all opposite edges + TopTools_ListOfShape anOppositeEdges; + TopoDS_Shape mainShape = aMesh.GetMeshDS()->ShapeToMesh(); + GetOppositeEdges(mainShape, aShape, anOppositeEdges); + TopTools_ListIteratorOfListOfShape oppIt (anOppositeEdges); + for (; oppIt.More(); oppIt.Next()) { + const TopoDS_Shape& oppE = oppIt.Value(); + + // Find Propagation hypothesis on the opposite edge + if (IsPropagated(aMesh, oppE)) { + + // Get hypothesis, used by the opposite edge + _usedHypList = SMESH_Algo::GetUsedHypothesis(aMesh, oppE); + nbHyp = _usedHypList.size(); + if (nbHyp == 1) + break; + } + } + } + + // try to find relevant 1D hypothesis on ancestors + if (nbHyp == 0) { + TopTools_ListIteratorOfListOfShape ancIt (aMesh.GetAncestors(aShape)); + for (; ancIt.More(); ancIt.Next()) { + const TopoDS_Shape& ancestor = ancIt.Value(); + _usedHypList = GetAppliedHypothesis(aMesh, ancestor); // copy + nbHyp = _usedHypList.size(); + if (nbHyp == 1) + break; + } + } + + if (nbHyp > 1) + _usedHypList.clear(); //only one compatible hypothesis allowed + return _usedHypList; +} + +//============================================================================= +/*! + * Is Propagation hypothesis assigned to theShape or its ancestors + */ +//============================================================================= +Standard_Boolean StdMeshers_Regular_1D::IsPropagated (SMESH_Mesh & theMesh, + const TopoDS_Shape & theShape) +{ + const SMESHDS_Mesh * meshDS = theMesh.GetMeshDS(); + + // try to find Propagation hypothesis on theShape + const list & listHyp = meshDS->GetHypothesis(theShape); + + list::const_iterator it = listHyp.begin(); + for (; it != listHyp.end(); it++) { + const SMESHDS_Hypothesis *anHyp = *it; + if (anHyp->GetName() == StdMeshers_Propagation::GetName()) + return Standard_True; + } + + // try to find Propagation hypothesis on ancestors + TopTools_ListIteratorOfListOfShape ancIt (theMesh.GetAncestors(theShape)); + for (; ancIt.More(); ancIt.Next()) { + const TopoDS_Shape& ancestor = ancIt.Value(); + const list & listAncHyp = meshDS->GetHypothesis(ancestor); + + list::const_iterator itAnc = listAncHyp.begin(); + for (; itAnc != listAncHyp.end(); itAnc++) { + const SMESHDS_Hypothesis *anHyp = *itAnc; + if (anHyp->GetName() == StdMeshers_Propagation::GetName()) + return Standard_True; + } + } + + return Standard_False; +} + +//============================================================================= +/*! + * GetOppositeEdges() - get all edges of theShape, + * laying on any quadrangle face in front of theEdge + */ +//============================================================================= +void StdMeshers_Regular_1D::GetOppositeEdges (const TopoDS_Shape& theShape, + const TopoDS_Shape& theEdge, + TopTools_ListOfShape& theOppositeEdges) const +{ + TopExp_Explorer aWires (theShape, TopAbs_WIRE); + for (; aWires.More(); aWires.Next()) { + const TopoDS_Shape& aWire = aWires.Current(); + BRepTools_WireExplorer aWE (TopoDS::Wire(aWire)); + Standard_Integer nb = 1, found = 0; + TopTools_Array1OfShape anEdges (1,4); + for (; aWE.More(); aWE.Next(), nb++) { + if (nb > 4) { + found = 0; + break; + } + anEdges(nb) = aWE.Current(); + if (anEdges(nb).IsSame(theEdge)) + found = nb; + } + if (nb == 5 && found > 0) { + Standard_Integer opp = found + 2; + if (opp > 4) opp -= 4; + theOppositeEdges.Append(anEdges(opp)); + } + } } //============================================================================= /*! - * + * */ //============================================================================= @@ -299,7 +610,7 @@ ostream & StdMeshers_Regular_1D::SaveTo(ostream & save) //============================================================================= /*! - * + * */ //============================================================================= @@ -310,7 +621,7 @@ istream & StdMeshers_Regular_1D::LoadFrom(istream & load) //============================================================================= /*! - * + * */ //============================================================================= @@ -321,7 +632,7 @@ ostream & operator <<(ostream & save, StdMeshers_Regular_1D & hyp) //============================================================================= /*! - * + * */ //============================================================================= diff --git a/src/StdMeshers/StdMeshers_Regular_1D.hxx b/src/StdMeshers/StdMeshers_Regular_1D.hxx index a68549268..b038a91d2 100644 --- a/src/StdMeshers/StdMeshers_Regular_1D.hxx +++ b/src/StdMeshers/StdMeshers_Regular_1D.hxx @@ -32,8 +32,10 @@ #include "SMESH_1D_Algo.hxx" -class StdMeshers_LocalLength; -class StdMeshers_NumberOfSegments; +#include +#include + +class TopoDS_Edge; class StdMeshers_Regular_1D: public SMESH_1D_Algo @@ -49,17 +51,40 @@ public: virtual bool Compute(SMESH_Mesh& aMesh, const TopoDS_Shape& aShape); + virtual const std::list & + GetUsedHypothesis (SMESH_Mesh & aMesh, const TopoDS_Shape & aShape); + ostream & SaveTo(ostream & save); istream & LoadFrom(istream & load); friend ostream & operator << (ostream & save, StdMeshers_Regular_1D & hyp); friend istream & operator >> (istream & load, StdMeshers_Regular_1D & hyp); protected: - double _localLength; - int _numberOfSegments; - double _scaleFactor; - const StdMeshers_LocalLength* _hypLocalLength; - const StdMeshers_NumberOfSegments* _hypNumberOfSegments; + + Standard_Boolean IsPropagated (SMESH_Mesh & theMesh, + const TopoDS_Shape & theShape); + + void GetOppositeEdges (const TopoDS_Shape& theShape, + const TopoDS_Shape& theEdge, + TopTools_ListOfShape& theOppositeEdges) const; + + bool computeInternalParameters (const TopoDS_Edge& theEdge, + std::list< double > & theParameters ) const; + + enum HypothesisType { LOCAL_LENGTH, NB_SEGMENTS, BEG_END_LENGTH, DEFLECTION, ARITHMETIC_1D, NONE }; + + enum ValueIndex { + NB_SEGMENTS_IND = 0, + SCALE_FACTOR_IND = 1, + BEG_LENGTH_IND = 0, + END_LENGTH_IND = 1, + DEFLECTION_IND = 0 + }; + + HypothesisType _hypType; + + double _value[2]; + }; #endif diff --git a/src/StdMeshers/StdMeshers_StartEndLength.cxx b/src/StdMeshers/StdMeshers_StartEndLength.cxx new file mode 100644 index 000000000..6f9d40559 --- /dev/null +++ b/src/StdMeshers/StdMeshers_StartEndLength.cxx @@ -0,0 +1,143 @@ +// SMESH StdMeshers_StartEndLength : 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_StartEndLength.cxx +// Module : SMESH +// $Header$ + +using namespace std; + +#include "StdMeshers_StartEndLength.hxx" +#include "utilities.h" + + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_StartEndLength::StdMeshers_StartEndLength(int hypId, + int studyId, + SMESH_Gen * gen) + :SMESH_Hypothesis(hypId, studyId, gen) +{ + _begLength = 1.; + _endLength = 1.; + _name = "StartEndLength"; + _param_algo_dim = 1; // is used by SMESH_Regular_1D +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +StdMeshers_StartEndLength::~StdMeshers_StartEndLength() +{ +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +void StdMeshers_StartEndLength::SetLength(double length, bool isStartLength) + throw(SALOME_Exception) +{ + if ( (isStartLength ? _begLength : _endLength) != length ) { + if (length <= 0) + throw SALOME_Exception(LOCALIZED("length must be positive")); + if ( isStartLength ) + _begLength = length; + else + _endLength = length; + + NotifySubMeshesHypothesisModification(); + } +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +double StdMeshers_StartEndLength::GetLength(bool isStartLength) const +{ + return isStartLength ? _begLength : _endLength; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & StdMeshers_StartEndLength::SaveTo(ostream & save) +{ + save << _begLength << _endLength; + return save; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & StdMeshers_StartEndLength::LoadFrom(istream & load) +{ + bool isOK = true; + isOK = (load >> _begLength); + if (!isOK) + load.clear(ios::badbit | load.rdstate()); + isOK = (load >> _endLength); + if (!isOK) + load.clear(ios::badbit | load.rdstate()); + return load; +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +ostream & operator <<(ostream & save, StdMeshers_StartEndLength & hyp) +{ + return hyp.SaveTo( save ); +} + +//============================================================================= +/*! + * + */ +//============================================================================= + +istream & operator >>(istream & load, StdMeshers_StartEndLength & hyp) +{ + return hyp.LoadFrom( load ); +} diff --git a/src/StdMeshers/StdMeshers_StartEndLength.hxx b/src/StdMeshers/StdMeshers_StartEndLength.hxx new file mode 100644 index 000000000..05bd2e0bb --- /dev/null +++ b/src/StdMeshers/StdMeshers_StartEndLength.hxx @@ -0,0 +1,53 @@ +// SMESH StdMeshers : 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_StartEndLength.hxx +// Module : SMESH +// $Header$ + +#ifndef _STDMESHERS_STARTENDLENGTH_HXX_ +#define _STDMESHERS_STARTENDLENGTH_HXX_ + +#include "SMESH_Hypothesis.hxx" +#include "Utils_SALOME_Exception.hxx" + +class StdMeshers_StartEndLength:public SMESH_Hypothesis +{ + public: + StdMeshers_StartEndLength(int hypId, int studyId, SMESH_Gen * gen); + virtual ~ StdMeshers_StartEndLength(); + + void SetLength(double length, bool isStartLength) throw(SALOME_Exception); + + double GetLength(bool isStartLength) const; + + virtual ostream & SaveTo(ostream & save); + virtual istream & LoadFrom(istream & load); + friend ostream & operator <<(ostream & save, StdMeshers_StartEndLength & hyp); + friend istream & operator >>(istream & load, StdMeshers_StartEndLength & hyp); + + protected: + double _begLength, _endLength; +}; + +#endif diff --git a/src/StdMeshersGUI/Makefile.in b/src/StdMeshersGUI/Makefile.in index 8c924a23f..86eb49764 100644 --- a/src/StdMeshersGUI/Makefile.in +++ b/src/StdMeshersGUI/Makefile.in @@ -42,26 +42,24 @@ VPATH=.:@srcdir@:@top_srcdir@/idl:$(top_builddir)/idl:${KERNEL_ROOT_DIR}/idl/sal LIB = libStdMeshersGUI.la LIB_SRC = \ StdMeshersGUI.cxx \ - StdMeshersGUI_LocalLengthDlg.cxx \ - StdMeshersGUI_NbSegmentsDlg.cxx \ - StdMeshersGUI_MaxElementAreaDlg.cxx \ - StdMeshersGUI_MaxElementVolumeDlg.cxx + StdMeshersGUI_CreateHypothesisDlg.cxx \ + StdMeshersGUI_CreateStdHypothesisDlg.cxx \ + StdMeshersGUI_Parameters.cxx LIB_MOC = \ - StdMeshersGUI_LocalLengthDlg.h \ - StdMeshersGUI_NbSegmentsDlg.h \ - StdMeshersGUI_MaxElementAreaDlg.h \ - StdMeshersGUI_MaxElementVolumeDlg.h + StdMeshersGUI_CreateHypothesisDlg.h \ + StdMeshersGUI_CreateStdHypothesisDlg.h + +EXPORT_HEADERS = StdMeshersGUI_CreateHypothesisDlg.h LIB_CLIENT_IDL = \ SALOME_Exception.idl \ - SMESH_Gen.idl \ - SMESH_Mesh.idl \ - SMESH_Group.idl \ - SMESH_Filter.idl \ SMESH_Hypothesis.idl \ - SMESH_BasicHypothesis.idl \ - MED.idl + SMESH_BasicHypothesis.idl + +## pb in dependencies search +LIB_CLIENT_IDL += \ + SALOME_GenericObj.idl LIB_SERVER_IDL = @@ -73,6 +71,6 @@ CPPFLAGS += $(QT_INCLUDES) $(VTK_INCLUDES) $(OGL_INCLUDES) $(OCC_INCLUDES) $(PYT CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome -I${GEOM_ROOT_DIR}/include/salome #$(OCC_CXXFLAGS) -LDFLAGS += -lSMESHGUI $(OCC_KERNEL_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome -L${GEOM_ROOT_DIR}/lib/salome +LDFLAGS += -lSMESHGUI -lVTKViewer -lSalomeGUI -lSMESHObject -lSMESHFiltersSelection $(OCC_KERNEL_LIBS) -lTKBO -L${KERNEL_ROOT_DIR}/lib/salome -L${GEOM_ROOT_DIR}/lib/salome @CONCLUDE@ diff --git a/src/StdMeshersGUI/StdMeshersGUI.cxx b/src/StdMeshersGUI/StdMeshersGUI.cxx index e272665f8..8682545d6 100644 --- a/src/StdMeshersGUI/StdMeshersGUI.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI.cxx @@ -25,24 +25,27 @@ // Module : SMESH // $Header$ -using namespace std; - -#include +#include "SALOMEconfig.h" #include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) #include "SMESHGUI.h" +#include "SMESHGUI_Utils.h" #include "SMESHGUI_Hypotheses.h" +#include "SMESHGUI_HypothesesUtils.h" -#include "StdMeshersGUI_LocalLengthDlg.h" -#include "StdMeshersGUI_NbSegmentsDlg.h" -#include "StdMeshersGUI_MaxElementAreaDlg.h" -#include "StdMeshersGUI_MaxElementVolumeDlg.h" +#include "SMESHGUI_aParameterDlg.h" +#include "StdMeshersGUI_Parameters.h" +#include "StdMeshersGUI_CreateStdHypothesisDlg.h" #include "QAD_Desktop.h" #include "QAD_ResourceMgr.h" #include +#include "utilities.h" + +using namespace std; + //============================================================================= /*! class HypothesisCreator * @@ -79,7 +82,7 @@ void StdMeshersGUI_HypothesisCreator::CreateHypothesis // Get default name for hypothesis/algorithm creation char* sHypType = (char*)myHypType.latin1(); - HypothesisData* aHypData = mySMESHGUI->GetHypothesisData(sHypType); + HypothesisData* aHypData = SMESH::GetHypothesisData(sHypType); QString aHypName; if (aHypData) aHypName = aHypData->Label; @@ -89,24 +92,16 @@ void StdMeshersGUI_HypothesisCreator::CreateHypothesis // Create hypothesis/algorithm if (isAlgo) { - mySMESHGUI->CreateHypothesis(myHypType, aHypName, isAlgo); + SMESH::CreateHypothesis(myHypType, aHypName, isAlgo); } else { + if ( StdMeshersGUI_Parameters::HasParameters( myHypType )) // Show Dialog for hypothesis creation - if (myHypType == "LocalLength") - StdMeshersGUI_LocalLengthDlg *aDlg = new StdMeshersGUI_LocalLengthDlg(myHypType, parent, ""); - else if (myHypType == "NumberOfSegments") - StdMeshersGUI_NbSegmentsDlg *aDlg = new StdMeshersGUI_NbSegmentsDlg(myHypType, parent, ""); - else if (myHypType == "MaxElementArea") - StdMeshersGUI_MaxElementAreaDlg *aDlg = new StdMeshersGUI_MaxElementAreaDlg(myHypType, parent, ""); - else if (myHypType == "MaxElementVolume") - StdMeshersGUI_MaxElementVolumeDlg *aDlg = new StdMeshersGUI_MaxElementVolumeDlg(myHypType, parent, ""); - else if (myHypType == "LengthFromEdges") - mySMESHGUI->CreateHypothesis(myHypType, aHypName, isAlgo); // without GUI - else if (myHypType == "NotConformAllowed") - mySMESHGUI->CreateHypothesis(myHypType, aHypName, isAlgo); // without GUI - else ; + StdMeshersGUI_CreateStdHypothesisDlg *aDlg = + new StdMeshersGUI_CreateStdHypothesisDlg(myHypType, parent, ""); + else + SMESH::CreateHypothesis(myHypType, aHypName, isAlgo); // without GUI } } @@ -120,93 +115,30 @@ void StdMeshersGUI_HypothesisCreator::EditHypothesis { MESSAGE("StdMeshersGUI_HypothesisCreator::EditHypothesis"); - Standard_Boolean res = Standard_True; SALOMEDS::Study::ListOfSObject_var listSOmesh = - mySMESHGUI->GetMeshesUsingAlgoOrHypothesis(theHyp); - QString Name = theHyp->GetName(); - if (Name.compare("LocalLength") == 0) - { - StdMeshers::StdMeshers_LocalLength_var LL = - StdMeshers::StdMeshers_LocalLength::_narrow(theHyp); - double beforeLength = LL->GetLength() ; - double Length = mySMESHGUI->Parameter(res, - beforeLength, - QObject::tr("SMESH_LOCAL_LENGTH_HYPOTHESIS"), - QObject::tr("SMESH_VALUE"), - 1.0E-5, 1E6, 6); - if (res && Length != beforeLength) - { - LL->SetLength(Length); - for (int i=0; ilength(); i++) - { - mySMESHGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i], false); - } - } - } - else if (Name.compare("NumberOfSegments") == 0) - { - StdMeshers::StdMeshers_NumberOfSegments_var NOS = - StdMeshers::StdMeshers_NumberOfSegments::_narrow(theHyp); - int beforeNbSeg = NOS->GetNumberOfSegments() ; - int NbSeg = mySMESHGUI->Parameter(res, - beforeNbSeg, - QObject::tr("SMESH_NB_SEGMENTS_HYPOTHESIS"), - QObject::tr("SMESH_VALUE"), - 1, 1000000); - if (res && NbSeg != beforeNbSeg) - { - NOS->SetNumberOfSegments(NbSeg); - for (int i=0; ilength(); i++) - { - SALOMEDS::SObject_var SO = listSOmesh[i] ; - mySMESHGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i], false); - } - } - } - else if (Name.compare("MaxElementArea") == 0) - { - StdMeshers::StdMeshers_MaxElementArea_var MEA = - StdMeshers::StdMeshers_MaxElementArea::_narrow(theHyp); - double beforeMaxArea = MEA->GetMaxElementArea(); - double MaxArea = mySMESHGUI->Parameter(res, - beforeMaxArea, - QObject::tr("SMESH_MAX_ELEMENT_AREA_HYPOTHESIS"), - QObject::tr("SMESH_VALUE"), - 1.0E-5, 1E6, 6); - if (res && MaxArea != beforeMaxArea) - { - MEA->SetMaxElementArea(MaxArea); - for (int i=0; ilength(); i++) - { - mySMESHGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i], false); - } - } - } - else if (Name.compare("MaxElementVolume") == 0) - { - StdMeshers::StdMeshers_MaxElementVolume_var MEV = - StdMeshers::StdMeshers_MaxElementVolume::_narrow(theHyp); - double beforeMaxVolume = MEV->GetMaxElementVolume() ; - double MaxVolume = mySMESHGUI->Parameter(res, - beforeMaxVolume, - QObject::tr("SMESH_MAX_ELEMENT_VOLUME_HYPOTHESIS"), - QObject::tr("SMESH_VALUE"), - 1.0E-5, 1E6, 6); - if (res && MaxVolume != beforeMaxVolume) - { - MEV->SetMaxElementVolume(MaxVolume); - for (int i=0; ilength(); i++) - { - mySMESHGUI->GetStudyAPI().ModifiedMesh(listSOmesh[i], false); - } - } + SMESH::GetMeshesUsingAlgoOrHypothesis(theHyp); + + list paramList; + StdMeshersGUI_Parameters::GetParameters( theHyp, paramList ); + + bool modified = false; + if ( SMESHGUI_aParameterDlg::Parameters( paramList, QObject::tr("SMESH_VALUE")) ) + modified = StdMeshersGUI_Parameters::SetParameters( theHyp, paramList ); + + if ( modified ) { + //set new Attribute Comment for hypothesis which parameters were modified + QString aParams = ""; + StdMeshersGUI_Parameters::GetParameters( theHyp, paramList, aParams ); + SALOMEDS::SObject_var SHyp = SMESH::FindSObject(theHyp); + if (!SHyp->_is_nil()) + if (!aParams.isEmpty()) { + SMESH::SetValue(SHyp, aParams); + //mySMESHGUI->GetActiveStudy()->updateObjBrowser(true); + } + + for (int i=0; ilength(); i++) + SMESH::ModifiedMesh(listSOmesh[i], false); } -// else if (Name.compare("Regular_1D") == 0) -// {} -// else if (Name.compare("MEFISTO_2D") == 0) -// {} - else - {} } //============================================================================= diff --git a/src/StdMeshersGUI/StdMeshersGUI_CreateHypothesisDlg.cxx b/src/StdMeshersGUI/StdMeshersGUI_CreateHypothesisDlg.cxx new file mode 100644 index 000000000..90c3632f5 --- /dev/null +++ b/src/StdMeshersGUI/StdMeshersGUI_CreateHypothesisDlg.cxx @@ -0,0 +1,343 @@ +// SMESH StdMeshersGUI : GUI for StdMeshers plugin +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshersGUI_CreateHypothesisDlg.cxx +// Moved here from SMESHGUI_CreateHypothesisDlg.cxx +// Author : Nicolas REJNERI +// Module : SMESH +// $Header$ + +#include "StdMeshersGUI_CreateHypothesisDlg.h" +#include "StdMeshersGUI_Parameters.h" +#include "SMESHGUI.h" +#include "SMESHGUI_SpinBox.h" +#include "SMESHGUI_Hypotheses.h" +#include "SMESHGUI_HypothesesUtils.h" +#include "SMESHGUI_Utils.h" + +#include "QAD_Application.h" +#include "QAD_Desktop.h" +#include "utilities.h" + +#include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "QAD_MessageBox.h" +#include "QAD_WaitCursor.h" + +// QT Includes +#include +#include +#include +#include +#include +#include +#include + +using namespace std; + +//================================================================================= +// class : StdMeshersGUI_CreateHypothesisDlg() +// purpose : Constructs a StdMeshersGUI_CreateHypothesisDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +StdMeshersGUI_CreateHypothesisDlg::StdMeshersGUI_CreateHypothesisDlg (const QString& hypType, + QWidget* parent, + const char* name, + bool modal, + WFlags /*fl*/) + : QDialog (parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose), myHypType( hypType ) +{ +} + +//======================================================================= +//function : CreateDlgLayout +//purpose : +//======================================================================= + +void StdMeshersGUI_CreateHypothesisDlg::CreateDlgLayout(const QString & theCaption, + const QPixmap & theHypIcon, + const QString & theHypTypeName) +{ + setCaption( theCaption ); + + setSizeGripEnabled( TRUE ); + QGridLayout* StdMeshersGUI_CreateHypothesisDlgLayout = new QGridLayout( this ); + StdMeshersGUI_CreateHypothesisDlgLayout->setSpacing( 6 ); + StdMeshersGUI_CreateHypothesisDlgLayout->setMargin( 11 ); + + /***************************************************************/ + iconLabel = new QLabel( this ); + iconLabel->setPixmap( theHypIcon ); + iconLabel->setScaledContents( false ); + iconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); + typeLabel = new QLabel( this ); + typeLabel->setText( theHypTypeName ); + StdMeshersGUI_CreateHypothesisDlgLayout->addWidget( iconLabel, 0, 0 ); + StdMeshersGUI_CreateHypothesisDlgLayout->addWidget( typeLabel, 0, 1 ); + + /***************************************************************/ + GroupC1 = new QGroupBox( this, "GroupC1" ); + GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) ); + GroupC1->setColumnLayout(0, Qt::Vertical ); + GroupC1->layout()->setSpacing( 0 ); + GroupC1->layout()->setMargin( 0 ); + QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() ); + GroupC1Layout->setAlignment( Qt::AlignTop ); + GroupC1Layout->setSpacing( 6 ); + GroupC1Layout->setMargin( 11 ); + + TextLabel_NameHypothesis = new QLabel( GroupC1, "TextLabel_NameHypothesis" ); + TextLabel_NameHypothesis->setText( tr( "SMESH_NAME" ) ); + GroupC1Layout->addWidget( TextLabel_NameHypothesis, 0, 0 ); + + LineEdit_NameHypothesis = new QLineEdit( GroupC1, "LineEdit_NameHypothesis" ); + GroupC1Layout->addWidget( LineEdit_NameHypothesis, 0, 1 ); + + myParamList.clear(); + GetParameters( myHypType, myParamList ); + ASSERT( !myParamList.empty() ); + + /* Spin boxes with labels */ + list::iterator paramIt = myParamList.begin(); + for ( int row = 1; paramIt != myParamList.end(); paramIt++ , row++ ) + { + SMESHGUI_aParameterPtr param = (*paramIt); + QLabel * label = new QLabel( GroupC1, "TextLabel" ); + GroupC1Layout->addWidget( label, row, 0 ); + label->setText( param->Label() ); + QWidget* aSpinWidget; + switch ( param->GetType() ) { + case SMESHGUI_aParameter::DOUBLE: { + SMESHGUI_SpinBox* spin = new SMESHGUI_SpinBox( GroupC1 ); + aSpinWidget = spin; + spin->setPrecision( 12 ); + break; + } + case SMESHGUI_aParameter::INT: { + QSpinBox* spin = new QSpinBox( GroupC1 ); + aSpinWidget = spin; + break; + } + default:; + } + GroupC1Layout->addWidget( aSpinWidget, row, 1 ); + aSpinWidget->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Minimum ) ); + aSpinWidget->setMinimumSize( 150, 0 ); + param->InitializeWidget( aSpinWidget ); + mySpinList.push_back( aSpinWidget ); + } + + StdMeshersGUI_CreateHypothesisDlgLayout->addMultiCellWidget(GroupC1 , 1, 1, 0, 1 ); + + /***************************************************************/ + GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + buttonOk = new QPushButton( GroupButtons, "buttonOk" ); + buttonOk->setText( tr( "SMESH_BUT_OK" ) ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + buttonApply = new QPushButton( GroupButtons, "buttonApply" ); + buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); + buttonApply->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); + QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); + GroupButtonsLayout->addItem( spacer, 0, 2 ); + buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); + buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); + StdMeshersGUI_CreateHypothesisDlgLayout->addMultiCellWidget( GroupButtons, 2, 2, 0, 1 ); + + /***************************************************************/ + Init() ; +} + + +//================================================================================= +// function : ~StdMeshersGUI_CreateHypothesisDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +StdMeshersGUI_CreateHypothesisDlg::~StdMeshersGUI_CreateHypothesisDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void StdMeshersGUI_CreateHypothesisDlg::Init() +{ + mySMESHGUI = SMESHGUI::GetSMESHGUI() ; + + char* sHypType = const_cast(myHypType.latin1()); + HypothesisData* aHypData = SMESH::GetHypothesisData(sHypType); + LineEdit_NameHypothesis->setText( aHypData ? aHypData->Label : QString("") ); + + mySMESHGUI->SetActiveDialogBox( (QDialog*)this ); + + /* signals and slots connections */ + connect( buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()) ); + connect( buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()) ) ; + connect( buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()) ); + + connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; + connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; + + /* Move widget on the botton right corner of main widget */ + int x, y ; + mySMESHGUI->DefineDlgPosition( this, x, y ) ; + this->move( x, y ) ; + this->show() ; /* displays Dialog */ +} + + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void StdMeshersGUI_CreateHypothesisDlg::ClickOnOk() +{ + if ( ClickOnApply() ) + ClickOnCancel() ; +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool StdMeshersGUI_CreateHypothesisDlg::ClickOnApply() +{ + if ( !mySMESHGUI || mySMESHGUI->ActiveStudyLocked() ) + return false; + + QString myHypName = LineEdit_NameHypothesis->text().stripWhiteSpace(); + if ( myHypName.isEmpty() ) { + QAD_MessageBox::warn1 (this, tr( "SMESH_WRN_WARNING" ), + tr( "SMESH_WRN_EMPTY_NAME" ), tr( "SMESH_BUT_OK" ) ); + return false; + } + + QAD_WaitCursor wc; + + try { + SMESH::SMESH_Hypothesis_var Hyp = SMESH::SMESH_Hypothesis::_narrow + ( SMESH::CreateHypothesis (myHypType, + myHypName, + false )); // isAlgorithm + + list::iterator paramIt = myParamList.begin(); + list::iterator widgetIt = mySpinList.begin(); + for ( ; + paramIt != myParamList.end() && widgetIt != mySpinList.end(); + paramIt++ , widgetIt++ ) + (*paramIt)->TakeValue( *widgetIt ); + + SetParameters( Hyp, myParamList ); + + //set new Attribute Comment for hypothesis which parameters were set + QString aParams = ""; + StdMeshersGUI_Parameters::GetParameters( Hyp.in(), myParamList, aParams ); + SALOMEDS::SObject_var SHyp = SMESH::FindSObject(Hyp.in()); + if (!SHyp->_is_nil()) + if (!aParams.isEmpty()) { + SMESH::SetValue(SHyp, aParams); + mySMESHGUI->GetActiveStudy()->updateObjBrowser(true); + } + } + catch (const SALOME::SALOME_Exception& S_ex) { + wc.stop(); + QtCatchCorbaException(S_ex); + return false; + } + return true; +} + +//================================================================================= +// function : ClickOnCancel() +// purpose : +//================================================================================= +void StdMeshersGUI_CreateHypothesisDlg::ClickOnCancel() +{ + close(); +} + +//================================================================================= +// function : DeactivateActiveDialog() +// purpose : +//================================================================================= +void StdMeshersGUI_CreateHypothesisDlg::DeactivateActiveDialog() +{ +// iconLabel->setEnabled(false) ; +// typeLabel->setEnabled(false) ; +// GroupC1->setEnabled(false) ; +// GroupButtons->setEnabled(false) ; + setEnabled(false); +} + + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void StdMeshersGUI_CreateHypothesisDlg::ActivateThisDialog() +{ + if (! isEnabled() ) { + mySMESHGUI->EmitSignalDeactivateDialog() ; +// iconLabel->setEnabled(true) ; +// typeLabel->setEnabled(true) ; +// GroupC1->setEnabled(true) ; +// GroupButtons->setEnabled(true) ; + setEnabled(true) ; + } +} + + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void StdMeshersGUI_CreateHypothesisDlg::enterEvent(QEvent* e) +{ + ActivateThisDialog() ; +} + + +//================================================================================= +// function : closeEvent() +// purpose : +//================================================================================= +void StdMeshersGUI_CreateHypothesisDlg::closeEvent( QCloseEvent* e ) +{ + mySMESHGUI->ResetState(); + QDialog::closeEvent( e ); +} diff --git a/src/StdMeshersGUI/StdMeshersGUI_LocalLengthDlg.h b/src/StdMeshersGUI/StdMeshersGUI_CreateHypothesisDlg.h similarity index 65% rename from src/StdMeshersGUI/StdMeshersGUI_LocalLengthDlg.h rename to src/StdMeshersGUI/StdMeshersGUI_CreateHypothesisDlg.h index 8b3dda580..3a086e3a2 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_LocalLengthDlg.h +++ b/src/StdMeshersGUI/StdMeshersGUI_CreateHypothesisDlg.h @@ -21,18 +21,21 @@ // // // -// File : StdMeshersGUI_LocalLengthDlg.h -// Moved here from SMESHGUI_LocalLengthDlg.h -// Author : Nicolas REJNERI +// File : StdMeshersGUI_CreateHypothesisDlg.h // Module : SMESH // $Header$ -#ifndef DIALOGBOX_LOCAL_LENGTH_H -#define DIALOGBOX_LOCAL_LENGTH_H +#ifndef DIALOGBOX_CreateHypothesisDlg_H +#define DIALOGBOX_CreateHypothesisDlg_H // QT Includes #include +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESHGUI_aParameter.h" + class QGroupBox; class QLabel; class QLineEdit; @@ -41,20 +44,32 @@ class SMESHGUI; class SMESHGUI_SpinBox; //================================================================================= -// class : StdMeshersGUI_LocalLengthDlg +// class : StdMeshersGUI_CreateHypothesisDlg // purpose : //================================================================================= -class StdMeshersGUI_LocalLengthDlg : public QDialog +class StdMeshersGUI_CreateHypothesisDlg : public QDialog { Q_OBJECT public: - StdMeshersGUI_LocalLengthDlg (const QString& hypType, - QWidget* parent = 0, - const char* name = 0, - bool modal = FALSE, - WFlags fl = 0); - ~StdMeshersGUI_LocalLengthDlg (); + StdMeshersGUI_CreateHypothesisDlg (const QString& hypType, + QWidget* parent = 0, + const char* name = 0, + bool modal = FALSE, + WFlags fl = 0); + ~StdMeshersGUI_CreateHypothesisDlg (); + +protected: + + void CreateDlgLayout(const QString & caption, + const QPixmap & hypIcon, + const QString & hypTypeName); + + virtual void GetParameters(const QString & hypType, + std::list & params) = 0; + + virtual bool SetParameters(SMESH::SMESH_Hypothesis_ptr theHyp, + const std::list & params) = 0; private: @@ -65,13 +80,15 @@ private: SMESHGUI* mySMESHGUI ; QString myHypType ; + std::list mySpinList; + std::list myParamList; + QLabel* iconLabel; QLabel* typeLabel; QGroupBox* GroupC1; QLabel* TextLabel_NameHypothesis ; QLineEdit* LineEdit_NameHypothesis ; QLabel* TextLabel_Length ; - SMESHGUI_SpinBox* SpinBox_Length ; QGroupBox* GroupButtons; QPushButton* buttonOk; QPushButton* buttonApply; diff --git a/src/StdMeshersGUI/StdMeshersGUI_CreateStdHypothesisDlg.cxx b/src/StdMeshersGUI/StdMeshersGUI_CreateStdHypothesisDlg.cxx new file mode 100644 index 000000000..32aa02df3 --- /dev/null +++ b/src/StdMeshersGUI/StdMeshersGUI_CreateStdHypothesisDlg.cxx @@ -0,0 +1,109 @@ +// SMESH StdMeshersGUI : GUI for StdMeshers plugin +// +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshersGUI_CreateStdHypothesisDlg.cxx +// Moved here from SMESHGUI_CreateStdHypothesisDlg.cxx +// Author : Nicolas REJNERI +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshersGUI_CreateStdHypothesisDlg.h" +#include "StdMeshersGUI_Parameters.h" +#include "SMESHGUI.h" +#include "SMESHGUI_Hypotheses.h" + +#include "utilities.h" + +#include "SALOMEGUI_QtCatchCorbaException.hxx" +#include "QAD_MessageBox.h" +#include "QAD_WaitCursor.h" +#include "QAD_Desktop.h" + +//================================================================================= +// class : StdMeshersGUI_CreateStdHypothesisDlg() +// purpose : +//================================================================================= +StdMeshersGUI_CreateStdHypothesisDlg::StdMeshersGUI_CreateStdHypothesisDlg (const QString& hypType, + QWidget* parent, + const char* name, + bool modal, + WFlags fl) + : StdMeshersGUI_CreateHypothesisDlg (hypType, parent, name, modal, fl) +{ + QString hypTypeStr; + if (hypType.compare("LocalLength") == 0) + hypTypeStr = "LOCAL_LENGTH"; + else if (hypType.compare("NumberOfSegments") == 0) + hypTypeStr = "NB_SEGMENTS"; + else if (hypType.compare("MaxElementArea") == 0) + hypTypeStr = "MAX_ELEMENT_AREA"; + else if (hypType.compare("MaxElementVolume") == 0) + hypTypeStr = "MAX_ELEMENT_VOLUME"; + else if (hypType.compare("StartEndLength") == 0) + hypTypeStr = "START_END_LENGTH"; + else if (hypType.compare("Deflection1D") == 0) + hypTypeStr = "DEFLECTION1D"; + else if (hypType.compare("Arithmetic1D") == 0) + hypTypeStr = "ARITHMETIC_1D"; + else + return; + + QString caption( tr ( QString( "SMESH_%1_TITLE" ).arg( hypTypeStr ))); + QString hypTypeName( tr ( QString( "SMESH_%1_HYPOTHESIS" ).arg( hypTypeStr ))); + QString hypIconName( tr ( QString( "ICON_DLG_%1" ).arg( hypTypeStr ))); + + CreateDlgLayout(caption, + QAD_Desktop::getResourceManager()->loadPixmap( "SMESH", hypIconName ), + hypTypeName); +} + +//================================================================================= +// function : ~StdMeshersGUI_CreateStdHypothesisDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +StdMeshersGUI_CreateStdHypothesisDlg::~StdMeshersGUI_CreateStdHypothesisDlg() +{ + // no need to delete child widgets, Qt does it all for us +} +//================================================================================= +// function : FillParameters() +// purpose : +//================================================================================= +void StdMeshersGUI_CreateStdHypothesisDlg::GetParameters + (const QString & hypType, + std::list & params) +{ + StdMeshersGUI_Parameters::GetParameters( hypType, params ); +} + +//================================================================================= +// function : SetParameters() +// purpose : +//================================================================================= +bool StdMeshersGUI_CreateStdHypothesisDlg::SetParameters + (SMESH::SMESH_Hypothesis_ptr theHyp, const list & params) +{ + StdMeshersGUI_Parameters::SetParameters( theHyp, params ); + return true; +} diff --git a/src/SMESH_I/SMESH_topo.cxx b/src/StdMeshersGUI/StdMeshersGUI_CreateStdHypothesisDlg.h similarity index 51% rename from src/SMESH_I/SMESH_topo.cxx rename to src/StdMeshersGUI/StdMeshersGUI_CreateStdHypothesisDlg.h index 463d999d9..027c88acb 100644 --- a/src/SMESH_I/SMESH_topo.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_CreateStdHypothesisDlg.h @@ -1,4 +1,4 @@ -// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses +// SMESH SMESHGUI : GUI for SMESH component // // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -21,39 +21,39 @@ // // // -// File : SMESH_topo.cxx -// Author : Paul RASCLE, EDF +// File : StdMeshersGUI_CreateStdHypothesisDlg.h +// Moved here from SMESHGUI_CreateStdHypothesisDlg.h +// Author : Nicolas REJNERI // Module : SMESH // $Header$ -using namespace std; -using namespace std; -#include "SMESH_topo.hxx" -#include "utilities.h" +#ifndef DIALOGBOX_CreateStdHypothesisDlg_H +#define DIALOGBOX_CreateStdHypothesisDlg_H -SMESH_topo::SMESH_topo() -{ - MESSAGE("SMESH_topo()"); -} +#include "StdMeshersGUI_CreateHypothesisDlg.h" -SMESH_topo::~SMESH_topo() -{ - MESSAGE("~SMESH_topo()"); -} +//================================================================================= +// class : StdMeshersGUI_CreateStdHypothesisDlg +// purpose : +//================================================================================= +class StdMeshersGUI_CreateStdHypothesisDlg : public StdMeshersGUI_CreateHypothesisDlg +{ + Q_OBJECT -//============================================================================= -/*! - * Static method, gives a unique local id for a given CORBA reference of - * a shape, within the SALOME session (multi studies). - * Internal geom id or stringified CORBA reference could be used here. - * GEOM Id is more efficient (shorter string). - */ -//============================================================================= + public: + StdMeshersGUI_CreateStdHypothesisDlg (const QString& hypType, + QWidget* parent = 0, + const char* name = 0, + bool modal = FALSE, + WFlags fl = 0); + ~StdMeshersGUI_CreateStdHypothesisDlg (); -string SMESH_topo::GetShapeLocalId(GEOM::GEOM_Shape_ptr aShape) -{ - string str = aShape->ShapeId(); //geomId - MESSAGE(str); - return str; -} + private: + virtual void GetParameters(const QString & hypType, + std::list & params); + + virtual bool SetParameters(SMESH::SMESH_Hypothesis_ptr theHyp, + const std::list & params); +}; +#endif diff --git a/src/StdMeshersGUI/StdMeshersGUI_LocalLengthDlg.cxx b/src/StdMeshersGUI/StdMeshersGUI_LocalLengthDlg.cxx deleted file mode 100644 index 076e10698..000000000 --- a/src/StdMeshersGUI/StdMeshersGUI_LocalLengthDlg.cxx +++ /dev/null @@ -1,296 +0,0 @@ -// SMESH StdMeshersGUI : GUI for StdMeshers plugin -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : StdMeshersGUI_LocalLengthDlg.cxx -// Moved here from SMESHGUI_LocalLengthDlg.cxx -// Author : Nicolas REJNERI -// Module : SMESH -// $Header$ - -using namespace std; -#include "StdMeshersGUI_LocalLengthDlg.h" -#include "SMESHGUI.h" -#include "SMESHGUI_SpinBox.h" - -#include -#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) - -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "utilities.h" - -#include "SALOMEGUI_QtCatchCorbaException.hxx" -#include "QAD_MessageBox.h" -#include "QAD_WaitCursor.h" - -// QT Includes -#include -#include -#include -#include -#include -#include - -//================================================================================= -// class : StdMeshersGUI_LocalLengthDlg() -// purpose : Constructs a StdMeshersGUI_LocalLengthDlg which is a child of 'parent', with the -// name 'name' and widget flags set to 'f'. -// The dialog will by default be modeless, unless you set 'modal' to -// TRUE to construct a modal dialog. -//================================================================================= -StdMeshersGUI_LocalLengthDlg::StdMeshersGUI_LocalLengthDlg (const QString& hypType, - QWidget* parent, - const char* name, - bool modal, - WFlags fl) - : QDialog (parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose), - myHypType(hypType) -{ - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_LOCAL_LENGTH"))); - - if ( !name ) - setName( "StdMeshersGUI_LocalLengthDlg" ); - setCaption( tr( "SMESH_LOCAL_LENGTH_TITLE" ) ); - setSizeGripEnabled( TRUE ); - QGridLayout* StdMeshersGUI_LocalLengthDlgLayout = new QGridLayout( this ); - StdMeshersGUI_LocalLengthDlgLayout->setSpacing( 6 ); - StdMeshersGUI_LocalLengthDlgLayout->setMargin( 11 ); - - /***************************************************************/ - iconLabel = new QLabel( this ); - iconLabel->setPixmap( image0 ); - iconLabel->setScaledContents( false ); - iconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); - typeLabel = new QLabel( this ); - typeLabel->setText( tr( "SMESH_LOCAL_LENGTH_HYPOTHESIS" ) ); - StdMeshersGUI_LocalLengthDlgLayout->addWidget( iconLabel, 0, 0 ); - StdMeshersGUI_LocalLengthDlgLayout->addWidget( typeLabel, 0, 1 ); - - /***************************************************************/ - GroupC1 = new QGroupBox( this, "GroupC1" ); - GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) ); - GroupC1->setColumnLayout(0, Qt::Vertical ); - GroupC1->layout()->setSpacing( 0 ); - GroupC1->layout()->setMargin( 0 ); - QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() ); - GroupC1Layout->setAlignment( Qt::AlignTop ); - GroupC1Layout->setSpacing( 6 ); - GroupC1Layout->setMargin( 11 ); - - TextLabel_NameHypothesis = new QLabel( GroupC1, "TextLabel_NameHypothesis" ); - TextLabel_NameHypothesis->setText( tr( "SMESH_NAME" ) ); - GroupC1Layout->addWidget( TextLabel_NameHypothesis, 0, 0 ); - - LineEdit_NameHypothesis = new QLineEdit( GroupC1, "LineEdit_NameHypothesis" ); - GroupC1Layout->addWidget( LineEdit_NameHypothesis, 0, 1 ); - - TextLabel_Length = new QLabel(GroupC1 , "TextLabel_Length" ); - TextLabel_Length->setText( tr( "SMESH_LENGTH" ) ); - GroupC1Layout->addWidget( TextLabel_Length, 1, 0 ); - - SpinBox_Length = new SMESHGUI_SpinBox( GroupC1, "SpinBox_Length" ); - GroupC1Layout->addWidget( SpinBox_Length, 1, 1 ); - - StdMeshersGUI_LocalLengthDlgLayout->addMultiCellWidget(GroupC1 , 1, 1, 0, 1 ); - - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer, 0, 2 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - StdMeshersGUI_LocalLengthDlgLayout->addMultiCellWidget( GroupButtons, 2, 2, 0, 1 ); - - /***************************************************************/ - Init() ; -} - - -//================================================================================= -// function : ~StdMeshersGUI_LocalLengthDlg() -// purpose : Destroys the object and frees any allocated resources -//================================================================================= -StdMeshersGUI_LocalLengthDlg::~StdMeshersGUI_LocalLengthDlg() -{ - // no need to delete child widgets, Qt does it all for us -} - - -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void StdMeshersGUI_LocalLengthDlg::Init() -{ - /* min, max, step and decimals for spin boxes */ - SpinBox_Length->RangeStepAndValidator( 0.001, 999.999, 1.0, 3 ) ; - SpinBox_Length->SetValue( 1.0 ) ; - - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - - char* sHypType = (char*)myHypType.latin1(); - HypothesisData* aHypData = mySMESHGUI->GetHypothesisData(sHypType); - //_CS_PhB ambiguous overload LineEdit_NameHypothesis->setText( aHypData ? aHypData->Label : "" ); - if (aHypData!=0) - { - LineEdit_NameHypothesis->setText(aHypData->Label); - } - else - { - LineEdit_NameHypothesis->setText(""); - } - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; - - /* signals and slots connections */ - connect( buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()) ); - connect( buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()) ) ; - connect( buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()) ); - - connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - - /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ -} - - -//================================================================================= -// function : ClickOnOk() -// purpose : -//================================================================================= -void StdMeshersGUI_LocalLengthDlg::ClickOnOk() -{ - if ( this->ClickOnApply() ) - this->ClickOnCancel() ; -} - -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -bool StdMeshersGUI_LocalLengthDlg::ClickOnApply() -{ - QString myHypName = LineEdit_NameHypothesis->text().stripWhiteSpace(); - if ( myHypName.isEmpty() ) { - QAD_MessageBox::warn1( this, tr( "SMESH_WRN_WARNING" ), tr( "SMESH_WRN_EMPTY_NAME" ), tr( "SMESH_BUT_OK" ) ); - return false; - } - - double myLength = SpinBox_Length->GetValue(); - - QAD_WaitCursor wc; - try { - SMESH::SMESH_Hypothesis_var Hyp = SMESH::SMESH_Hypothesis::_narrow - (mySMESHGUI->CreateHypothesis(myHypType, - myHypName, - false)); // isAlgorithm - StdMeshers::StdMeshers_LocalLength_var LL = - StdMeshers::StdMeshers_LocalLength::_narrow(Hyp); - if (!LL->_is_nil()) - LL->SetLength(myLength); - } - catch (const SALOME::SALOME_Exception& S_ex) { - wc.stop(); - QtCatchCorbaException(S_ex); - return false; - } - return true; -} - - -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void StdMeshersGUI_LocalLengthDlg::ClickOnCancel() -{ - close(); -} - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void StdMeshersGUI_LocalLengthDlg::DeactivateActiveDialog() -{ - iconLabel->setEnabled(false) ; - typeLabel->setEnabled(false) ; - GroupC1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; -} - - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void StdMeshersGUI_LocalLengthDlg::ActivateThisDialog() -{ - mySMESHGUI->EmitSignalDeactivateDialog() ; - iconLabel->setEnabled(true) ; - typeLabel->setEnabled(true) ; - GroupC1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; -} - - -//================================================================================= -// function : enterEvent() -// purpose : -//================================================================================= -void StdMeshersGUI_LocalLengthDlg::enterEvent(QEvent* e) -{ - ActivateThisDialog() ; -} - - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void StdMeshersGUI_LocalLengthDlg::closeEvent( QCloseEvent* e ) -{ - mySMESHGUI->ResetState(); - QDialog::closeEvent( e ); -} diff --git a/src/StdMeshersGUI/StdMeshersGUI_MaxElementAreaDlg.cxx b/src/StdMeshersGUI/StdMeshersGUI_MaxElementAreaDlg.cxx deleted file mode 100644 index 6e975b160..000000000 --- a/src/StdMeshersGUI/StdMeshersGUI_MaxElementAreaDlg.cxx +++ /dev/null @@ -1,299 +0,0 @@ -// SMESH SMESHGUI : GUI for SMESH component -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : StdMeshersGUI_MaxElementAreaDlg.cxx -// Moved here from SMESHGUI_MaxElementAreaDlg.cxx -// Author : Nicolas REJNERI -// Module : SMESH -// $Header$ - -using namespace std; -#include "StdMeshersGUI_MaxElementAreaDlg.h" -#include "SMESHGUI.h" -#include "SMESHGUI_SpinBox.h" - -#include -#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) - -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "utilities.h" - -#include "SALOMEGUI_QtCatchCorbaException.hxx" -#include "QAD_MessageBox.h" -#include "QAD_WaitCursor.h" - -// QT Includes -#include -#include -#include -#include -#include -#include - -//================================================================================= -// class : StdMeshersGUI_MaxElementAreaDlg() -// purpose : Constructs a StdMeshersGUI_MaxElementAreaDlg which is a child of 'parent', with the -// name 'name' and widget flags set to 'f'. -// The dialog will by default be modeless, unless you set 'modal' to -// TRUE to construct a modal dialog. -//================================================================================= -StdMeshersGUI_MaxElementAreaDlg::StdMeshersGUI_MaxElementAreaDlg (const QString& hypType, - QWidget* parent, - const char* name, - bool modal, - WFlags fl) - : QDialog (parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose), - myHypType(hypType) -{ - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_MAX_ELEMENT_AREA"))); - - if ( !name ) - setName( "StdMeshersGUI_MaxElementAreaDlg" ); - setCaption( tr( "SMESH_MAX_ELEMENT_AREA_TITLE" ) ); - setSizeGripEnabled( TRUE ); - QGridLayout* StdMeshersGUI_MaxElementAreaDlgLayout = new QGridLayout( this ); - StdMeshersGUI_MaxElementAreaDlgLayout->setSpacing( 6 ); - StdMeshersGUI_MaxElementAreaDlgLayout->setMargin( 11 ); - - /***************************************************************/ - iconLabel = new QLabel( this ); - iconLabel->setPixmap( image0 ); - iconLabel->setScaledContents( false ); - iconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); - typeLabel = new QLabel( this ); - typeLabel->setText( tr( "SMESH_MAX_ELEMENT_AREA_HYPOTHESIS" ) ); - StdMeshersGUI_MaxElementAreaDlgLayout->addWidget( iconLabel, 0, 0 ); - StdMeshersGUI_MaxElementAreaDlgLayout->addWidget( typeLabel, 0, 1 ); - - /***************************************************************/ - GroupC1 = new QGroupBox( this, "GroupC1" ); - GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) ); - GroupC1->setColumnLayout(0, Qt::Vertical ); - GroupC1->layout()->setSpacing( 0 ); - GroupC1->layout()->setMargin( 0 ); - QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() ); - GroupC1Layout->setAlignment( Qt::AlignTop ); - GroupC1Layout->setSpacing( 6 ); - GroupC1Layout->setMargin( 11 ); - - TextLabel_NameHypothesis = new QLabel( GroupC1, "TextLabel_NameHypothesis" ); - TextLabel_NameHypothesis->setText( tr( "SMESH_NAME" ) ); - GroupC1Layout->addWidget( TextLabel_NameHypothesis, 0, 0 ); - - LineEdit_NameHypothesis = new QLineEdit( GroupC1, "LineEdit_NameHypothesis" ); - GroupC1Layout->addWidget( LineEdit_NameHypothesis, 0, 1 ); - - TextLabel_MaxElementArea = new QLabel(GroupC1 , "TextLabel_MaxElementArea" ); - TextLabel_MaxElementArea->setText( tr( "SMESH_MAX_ELEMENT_AREA" ) ); - GroupC1Layout->addWidget( TextLabel_MaxElementArea, 1, 0 ); - - SpinBox_MaxElementArea = new SMESHGUI_SpinBox( GroupC1, "SpinBox_MaxElementArea" ) ; - GroupC1Layout->addWidget( SpinBox_MaxElementArea, 1, 1 ); - - StdMeshersGUI_MaxElementAreaDlgLayout->addMultiCellWidget(GroupC1 , 1, 1, 0, 1); - - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer, 0, 2 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - StdMeshersGUI_MaxElementAreaDlgLayout->addMultiCellWidget( GroupButtons, 2, 2, 0, 1 ); - - /***************************************************************/ - Init() ; -} - - -//================================================================================= -// function : ~StdMeshersGUI_MaxElementAreaDlg() -// purpose : Destroys the object and frees any allocated resources -//================================================================================= -StdMeshersGUI_MaxElementAreaDlg::~StdMeshersGUI_MaxElementAreaDlg() -{ - // no need to delete child widgets, Qt does it all for us -} - - -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void StdMeshersGUI_MaxElementAreaDlg::Init() -{ - /* min, max, step and decimals for spin boxes */ - SpinBox_MaxElementArea->setPrecision( 10 ); - SpinBox_MaxElementArea->RangeStepAndValidator( 0.001, 999999.999, 1.0, 3 ) ; - SpinBox_MaxElementArea->SetValue( 1.0 ) ; /* is myMaxElementArea */ - - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - - char* sHypType = (char*)myHypType.latin1(); - HypothesisData* aHypData = mySMESHGUI->GetHypothesisData(sHypType); - //CS_PhB ambiguous overload LineEdit_NameHypothesis->setText( aHypData ? aHypData->Label : "" ); - if (aHypData!=0) - { - LineEdit_NameHypothesis->setText(aHypData->Label); - } - else - { - LineEdit_NameHypothesis->setText(""); - } - - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; - - /* signals and slots connections */ - connect( buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()) ); - connect( buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()) ) ; - connect( buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()) ); - - connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - - /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ -} - - -//================================================================================= -// function : ClickOnOk() -// purpose : -//================================================================================= -void StdMeshersGUI_MaxElementAreaDlg::ClickOnOk() -{ - if ( this->ClickOnApply() ) - this->ClickOnCancel() ; -} - -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -bool StdMeshersGUI_MaxElementAreaDlg::ClickOnApply() -{ - QString myHypName = LineEdit_NameHypothesis->text().stripWhiteSpace(); - if ( myHypName.isEmpty() ) { - QAD_MessageBox::warn1( this, tr( "SMESH_WRN_WARNING" ), tr( "SMESH_WRN_EMPTY_NAME" ), tr( "SMESH_BUT_OK" ) ); - return false; - } - - double myMaxElementArea = SpinBox_MaxElementArea->GetValue(); - - QAD_WaitCursor wc; - try { - SMESH::SMESH_Hypothesis_var Hyp = SMESH::SMESH_Hypothesis::_narrow - (mySMESHGUI->CreateHypothesis(myHypType, - myHypName, - false)); // isAlgorithm - StdMeshers::StdMeshers_MaxElementArea_var MaxElArea = - StdMeshers::StdMeshers_MaxElementArea::_narrow(Hyp); - if (!MaxElArea->_is_nil()) - MaxElArea->SetMaxElementArea(myMaxElementArea); - } - catch (const SALOME::SALOME_Exception& S_ex) { - wc.stop(); - QtCatchCorbaException(S_ex); - return false; - } - return true; -} - - -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void StdMeshersGUI_MaxElementAreaDlg::ClickOnCancel() -{ - close(); -} - - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void StdMeshersGUI_MaxElementAreaDlg::DeactivateActiveDialog() -{ - iconLabel->setEnabled(false) ; - typeLabel->setEnabled(false) ; - GroupC1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; -} - - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void StdMeshersGUI_MaxElementAreaDlg::ActivateThisDialog() -{ - mySMESHGUI->EmitSignalDeactivateDialog() ; - iconLabel->setEnabled(true) ; - typeLabel->setEnabled(true) ; - GroupC1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; -} - - -//================================================================================= -// function : enterEvent() -// purpose : -//================================================================================= -void StdMeshersGUI_MaxElementAreaDlg::enterEvent(QEvent* e) -{ - ActivateThisDialog() ; -} - - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void StdMeshersGUI_MaxElementAreaDlg::closeEvent( QCloseEvent* e ) -{ - mySMESHGUI->ResetState(); - QDialog::closeEvent( e ); -} diff --git a/src/StdMeshersGUI/StdMeshersGUI_MaxElementAreaDlg.h b/src/StdMeshersGUI/StdMeshersGUI_MaxElementAreaDlg.h deleted file mode 100644 index e95f3cb08..000000000 --- a/src/StdMeshersGUI/StdMeshersGUI_MaxElementAreaDlg.h +++ /dev/null @@ -1,89 +0,0 @@ -// SMESH SMESHGUI : GUI for SMESH component -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : StdMeshersGUI_MaxElementAreaDlg.h -// Moved here from SMESHGUI_MaxElementAreaDlg.h -// Author : Nicolas REJNERI -// Module : SMESH -// $Header$ - -#ifndef DIALOGBOX_MAX_ELEMENT_AREA_H -#define DIALOGBOX_MAX_ELEMENT_AREA_H - -// QT Includes -#include - -class QGroupBox; -class QLabel; -class QLineEdit; -class QPushButton; -class SMESHGUI; -class SMESHGUI_SpinBox; - -//================================================================================= -// class : StdMeshersGUI_MaxElementAreaDlg -// purpose : -//================================================================================= -class StdMeshersGUI_MaxElementAreaDlg : public QDialog -{ - Q_OBJECT - -public: - StdMeshersGUI_MaxElementAreaDlg (const QString& hypType, - QWidget* parent = 0, - const char* name = 0, - bool modal = FALSE, - WFlags fl = 0 ); - ~StdMeshersGUI_MaxElementAreaDlg (); - -private: - - void Init() ; - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; - - SMESHGUI* mySMESHGUI ; - QString myHypType ; - - QLabel* iconLabel; - QLabel* typeLabel; - QGroupBox* GroupC1; - QLabel* TextLabel_NameHypothesis ; - QLineEdit* LineEdit_NameHypothesis ; - QLabel* TextLabel_MaxElementArea ; - SMESHGUI_SpinBox* SpinBox_MaxElementArea ; - QGroupBox* GroupButtons; - QPushButton* buttonApply; - QPushButton* buttonOk; - QPushButton* buttonCancel; - -private slots: - - void ClickOnOk(); - void ClickOnCancel(); - bool ClickOnApply(); - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; -}; - -#endif // DIALOGBOX_MAX_ELEMENT_AREA_H diff --git a/src/StdMeshersGUI/StdMeshersGUI_MaxElementVolumeDlg.cxx b/src/StdMeshersGUI/StdMeshersGUI_MaxElementVolumeDlg.cxx deleted file mode 100644 index ca5ddcc61..000000000 --- a/src/StdMeshersGUI/StdMeshersGUI_MaxElementVolumeDlg.cxx +++ /dev/null @@ -1,298 +0,0 @@ -// SMESH SMESHGUI : GUI for SMESH component -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : StdMeshersGUI_MaxElementVolumeDlg.cxx -// Moved here from SMESHGUI_MaxElementVolumeDlg.cxx -// Author : Nicolas REJNERI -// Module : SMESH -// $Header$ - -using namespace std; -#include "StdMeshersGUI_MaxElementVolumeDlg.h" -#include "SMESHGUI.h" -#include "SMESHGUI_SpinBox.h" - -#include -#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) - -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "utilities.h" - -#include "SALOMEGUI_QtCatchCorbaException.hxx" -#include "QAD_MessageBox.h" -#include "QAD_WaitCursor.h" - -// QT Includes -#include -#include -#include -#include -#include -#include - -//================================================================================= -// class : StdMeshersGUI_MaxElementVolumeDlg() -// purpose : Constructs a StdMeshersGUI_MaxElementVolumeDlg which is a child of 'parent', with the -// name 'name' and widget flags set to 'f'. -// The dialog will by default be modeless, unless you set 'modal' to -// TRUE to construct a modal dialog. -//================================================================================= -StdMeshersGUI_MaxElementVolumeDlg::StdMeshersGUI_MaxElementVolumeDlg (const QString& hypType, - QWidget* parent, - const char* name, - bool modal, WFlags fl) - : QDialog (parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose), - myHypType(hypType) -{ - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_MAX_ELEMENT_VOLUME"))); - - if ( !name ) - setName( "StdMeshersGUI_MaxElementVolumeDlg" ); - setCaption( tr( "SMESH_MAX_ELEMENT_VOLUME_TITLE" ) ); - setSizeGripEnabled( TRUE ); - QGridLayout* StdMeshersGUI_MaxElementVolumeDlgLayout = new QGridLayout( this ); - StdMeshersGUI_MaxElementVolumeDlgLayout->setSpacing( 6 ); - StdMeshersGUI_MaxElementVolumeDlgLayout->setMargin( 11 ); - - /***************************************************************/ - iconLabel = new QLabel( this ); - iconLabel->setPixmap( image0 ); - iconLabel->setScaledContents( false ); - iconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); - typeLabel = new QLabel( this ); - typeLabel->setText( tr( "SMESH_MAX_ELEMENT_VOLUME_HYPOTHESIS" ) ); - StdMeshersGUI_MaxElementVolumeDlgLayout->addWidget( iconLabel, 0, 0 ); - StdMeshersGUI_MaxElementVolumeDlgLayout->addWidget( typeLabel, 0, 1 ); - - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer, 0, 2 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - StdMeshersGUI_MaxElementVolumeDlgLayout->addMultiCellWidget( GroupButtons, 2, 2, 0, 1 ); - - /***************************************************************/ - GroupC1 = new QGroupBox( this, "GroupC1" ); - GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) ); - GroupC1->setColumnLayout(0, Qt::Vertical ); - GroupC1->layout()->setSpacing( 0 ); - GroupC1->layout()->setMargin( 0 ); - QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() ); - GroupC1Layout->setAlignment( Qt::AlignTop ); - GroupC1Layout->setSpacing( 6 ); - GroupC1Layout->setMargin( 11 ); - - TextLabel_NameHypothesis = new QLabel( GroupC1, "TextLabel_NameHypothesis" ); - TextLabel_NameHypothesis->setText( tr( "SMESH_NAME" ) ); - GroupC1Layout->addWidget( TextLabel_NameHypothesis, 0, 0 ); - - LineEdit_NameHypothesis = new QLineEdit( GroupC1, "LineEdit_NameHypothesis" ); - GroupC1Layout->addWidget( LineEdit_NameHypothesis, 0, 1 ); - - TextLabel_MaxElementVolume = new QLabel(GroupC1 , "TextLabel_MaxElementVolume" ); - TextLabel_MaxElementVolume->setText( tr( "SMESH_MAX_ELEMENT_VOLUME" ) ); - GroupC1Layout->addWidget( TextLabel_MaxElementVolume, 1, 0 ); - - SpinBox_MaxElementVolume = new SMESHGUI_SpinBox( GroupC1, "SpinBox_MaxElementVolume" ) ; - GroupC1Layout->addWidget( SpinBox_MaxElementVolume, 1, 1 ); - - StdMeshersGUI_MaxElementVolumeDlgLayout->addMultiCellWidget(GroupC1 , 1, 1, 0, 1 ); - - /***************************************************************/ - Init() ; -} - - -//================================================================================= -// function : ~StdMeshersGUI_MaxElementVolumeDlg() -// purpose : Destroys the object and frees any allocated resources -//================================================================================= -StdMeshersGUI_MaxElementVolumeDlg::~StdMeshersGUI_MaxElementVolumeDlg() -{ - // no need to delete child widgets, Qt does it all for us -} - - -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void StdMeshersGUI_MaxElementVolumeDlg::Init() -{ - /* min, max, step and decimals for spin boxes */ - SpinBox_MaxElementVolume->setPrecision( 10 ); - SpinBox_MaxElementVolume->RangeStepAndValidator( 0.001, 999999.999, 1.0, 3 ) ; - SpinBox_MaxElementVolume->SetValue( 1.0 ) ; /* is myMaxElementVolume */ - - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - - char* sHypType = (char*)myHypType.latin1(); - HypothesisData* aHypData = mySMESHGUI->GetHypothesisData(sHypType); - //_CS_PhB ambiguous overload LineEdit_NameHypothesis->setText( aHypData ? aHypData->Label : "" ); - if (aHypData!=0) - { - LineEdit_NameHypothesis->setText(aHypData->Label); - } - else - { - LineEdit_NameHypothesis->setText(""); - } - - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; - - /* signals and slots connections */ - connect( buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()) ); - connect( buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()) ) ; - connect( buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()) ); - - connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - - /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ -} - - -//================================================================================= -// function : ClickOnOk() -// purpose : -//================================================================================= -void StdMeshersGUI_MaxElementVolumeDlg::ClickOnOk() -{ - if ( this->ClickOnApply() ) - this->ClickOnCancel() ; -} - -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -bool StdMeshersGUI_MaxElementVolumeDlg::ClickOnApply() -{ - QString myHypName = LineEdit_NameHypothesis->text().stripWhiteSpace(); - if ( myHypName.isEmpty() ) { - QAD_MessageBox::warn1( this, tr( "SMESH_WRN_WARNING" ), tr( "SMESH_WRN_EMPTY_NAME" ), tr( "SMESH_BUT_OK" ) ); - return false; - } - - double myMaxElementVolume = SpinBox_MaxElementVolume->GetValue(); - - QAD_WaitCursor wc; - try { - SMESH::SMESH_Hypothesis_var Hyp = SMESH::SMESH_Hypothesis::_narrow - (mySMESHGUI->CreateHypothesis(myHypType, - myHypName, - false)); // isAlgorithm - StdMeshers::StdMeshers_MaxElementVolume_var MaxElVolume = - StdMeshers::StdMeshers_MaxElementVolume::_narrow(Hyp); - if (!MaxElVolume->_is_nil()) - MaxElVolume->SetMaxElementVolume(myMaxElementVolume); - } - catch (const SALOME::SALOME_Exception& S_ex) { - wc.stop(); - QtCatchCorbaException(S_ex); - return false; - } - return true; -} - - -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void StdMeshersGUI_MaxElementVolumeDlg::ClickOnCancel() -{ - close(); -} - - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void StdMeshersGUI_MaxElementVolumeDlg::DeactivateActiveDialog() -{ - iconLabel->setEnabled(false) ; - typeLabel->setEnabled(false) ; - GroupC1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; -} - - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void StdMeshersGUI_MaxElementVolumeDlg::ActivateThisDialog() -{ - mySMESHGUI->EmitSignalDeactivateDialog() ; - iconLabel->setEnabled(true) ; - typeLabel->setEnabled(true) ; - GroupC1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; -} - - -//================================================================================= -// function : enterEvent() -// purpose : -//================================================================================= -void StdMeshersGUI_MaxElementVolumeDlg::enterEvent(QEvent* e) -{ - ActivateThisDialog() ; -} - - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void StdMeshersGUI_MaxElementVolumeDlg::closeEvent( QCloseEvent* e ) -{ - mySMESHGUI->ResetState(); - QDialog::closeEvent( e ); -} diff --git a/src/StdMeshersGUI/StdMeshersGUI_MaxElementVolumeDlg.h b/src/StdMeshersGUI/StdMeshersGUI_MaxElementVolumeDlg.h deleted file mode 100644 index b31215777..000000000 --- a/src/StdMeshersGUI/StdMeshersGUI_MaxElementVolumeDlg.h +++ /dev/null @@ -1,89 +0,0 @@ -// SMESH SMESHGUI : GUI for SMESH component -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : StdMeshersGUI_MaxElementVolumeDlg.h -// Moved here from SMESHGUI_MaxElementVolumeDlg.h -// Author : Nicolas REJNERI -// Module : SMESH -// $Header$ - -#ifndef DIALOGBOX_MAX_ELEMENT_VOLUME_H -#define DIALOGBOX_MAX_ELEMENT_VOLUME_H - -// QT Includes -#include - -class QGroupBox; -class QLabel; -class QLineEdit; -class QPushButton; -class SMESHGUI; -class SMESHGUI_SpinBox; - -//================================================================================= -// class : StdMeshersGUI_MaxElementVolumeDlg -// purpose : -//================================================================================= -class StdMeshersGUI_MaxElementVolumeDlg : public QDialog -{ - Q_OBJECT - -public: - StdMeshersGUI_MaxElementVolumeDlg (const QString& hypType, - QWidget* parent = 0, - const char* name = 0, - bool modal = FALSE, - WFlags fl = 0 ); - ~StdMeshersGUI_MaxElementVolumeDlg (); - -private: - - void Init() ; - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; - - SMESHGUI* mySMESHGUI ; - QString myHypType ; - - QLabel* iconLabel; - QLabel* typeLabel; - QGroupBox* GroupButtons; - QPushButton* buttonApply; - QPushButton* buttonOk; - QPushButton* buttonCancel; - QGroupBox* GroupC1; - QLabel* TextLabel_NameHypothesis ; - QLineEdit* LineEdit_NameHypothesis ; - QLabel* TextLabel_MaxElementVolume ; - SMESHGUI_SpinBox* SpinBox_MaxElementVolume ; - -private slots: - - void ClickOnOk(); - void ClickOnCancel(); - bool ClickOnApply(); - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; -}; - -#endif // DIALOGBOX_MAX_ELEMENT_VOLUME_H diff --git a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsDlg.cxx b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsDlg.cxx deleted file mode 100644 index 32901874f..000000000 --- a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsDlg.cxx +++ /dev/null @@ -1,297 +0,0 @@ -// SMESH SMESHGUI : GUI for SMESH component -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : StdMeshersGUI_NbSegmentsDlg.cxx -// Moved here from SMESHGUI_NbSegmentsDlg.cxx -// Author : Nicolas REJNERI -// Module : SMESH -// $Header$ - -using namespace std; -#include "StdMeshersGUI_NbSegmentsDlg.h" -#include "SMESHGUI.h" - -#include -#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) - -#include "QAD_Application.h" -#include "QAD_Desktop.h" -#include "utilities.h" - -#include "SALOMEGUI_QtCatchCorbaException.hxx" -#include "QAD_MessageBox.h" -#include "QAD_WaitCursor.h" - -// QT Includes -#include -#include -#include -#include -#include -#include -#include - -//================================================================================= -// class : StdMeshersGUI_NbSegmentsDlg() -// purpose : Constructs a StdMeshersGUI_NbSegmentsDlg which is a child of 'parent', with the -// name 'name' and widget flags set to 'f'. -// The dialog will by default be modeless, unless you set 'modal' to -// TRUE to construct a modal dialog. -//================================================================================= -StdMeshersGUI_NbSegmentsDlg::StdMeshersGUI_NbSegmentsDlg (const QString& hypType, - QWidget* parent, - const char* name, - bool modal, - WFlags fl) - : QDialog (parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose), - myHypType(hypType) -{ - QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap( "SMESH",tr("ICON_DLG_NB_SEGMENTS"))); - - if ( !name ) - setName( "StdMeshersGUI_NbSegmentsDlg" ); - setCaption( tr( "SMESH_NB_SEGMENTS_TITLE" ) ); - setSizeGripEnabled( TRUE ); - QGridLayout* StdMeshersGUI_NbSegmentsDlgLayout = new QGridLayout( this ); - StdMeshersGUI_NbSegmentsDlgLayout->setSpacing( 6 ); - StdMeshersGUI_NbSegmentsDlgLayout->setMargin( 11 ); - - /***************************************************************/ - iconLabel = new QLabel( this ); - iconLabel->setPixmap( image0 ); - iconLabel->setScaledContents( false ); - iconLabel->setSizePolicy( QSizePolicy( QSizePolicy::Fixed, QSizePolicy::Fixed ) ); - typeLabel = new QLabel( this ); - typeLabel->setText( tr( "SMESH_NB_SEGMENTS_HYPOTHESIS" ) ); - StdMeshersGUI_NbSegmentsDlgLayout->addWidget( iconLabel, 0, 0 ); - StdMeshersGUI_NbSegmentsDlgLayout->addWidget( typeLabel, 0, 1 ); - - /***************************************************************/ - GroupC1 = new QGroupBox( this, "GroupC1" ); - GroupC1->setTitle( tr( "SMESH_ARGUMENTS" ) ); - GroupC1->setColumnLayout(0, Qt::Vertical ); - GroupC1->layout()->setSpacing( 0 ); - GroupC1->layout()->setMargin( 0 ); - QGridLayout* GroupC1Layout = new QGridLayout( GroupC1->layout() ); - GroupC1Layout->setAlignment( Qt::AlignTop ); - GroupC1Layout->setSpacing( 6 ); - GroupC1Layout->setMargin( 11 ); - - LineEdit_NameHypothesis = new QLineEdit( GroupC1, "LineEdit_NameHypothesis" ); - GroupC1Layout->addWidget( LineEdit_NameHypothesis, 0, 1 ); - - TextLabel_NameHypothesis = new QLabel( GroupC1, "TextLabel_NameHypothesis" ); - TextLabel_NameHypothesis->setText( tr( "SMESH_NAME" ) ); - GroupC1Layout->addWidget( TextLabel_NameHypothesis, 0, 0 ); - - TextLabel_NbSeg = new QLabel(GroupC1 , "TextLabel_NbSeg" ); - TextLabel_NbSeg->setText( tr( "SMESH_SEGMENTS" ) ); - GroupC1Layout->addWidget( TextLabel_NbSeg, 1, 0 ); - - SpinBox_NbSeg = new QSpinBox( GroupC1, "SpinBox_NbSeg" ); - GroupC1Layout->addWidget( SpinBox_NbSeg, 1, 1 ); - - StdMeshersGUI_NbSegmentsDlgLayout->addMultiCellWidget(GroupC1 , 1, 1, 0, 1 ); - - /***************************************************************/ - GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - buttonOk = new QPushButton( GroupButtons, "buttonOk" ); - buttonOk->setText( tr( "SMESH_BUT_OK" ) ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - buttonApply = new QPushButton( GroupButtons, "buttonApply" ); - buttonApply->setText( tr( "SMESH_BUT_APPLY" ) ); - buttonApply->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonApply, 0, 1 ); - QSpacerItem* spacer = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum ); - GroupButtonsLayout->addItem( spacer, 0, 2 ); - buttonCancel = new QPushButton( GroupButtons, "buttonCancel" ); - buttonCancel->setText( tr( "SMESH_BUT_CLOSE" ) ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 3 ); - StdMeshersGUI_NbSegmentsDlgLayout->addMultiCellWidget( GroupButtons, 2, 2, 0, 1 ); - - /***************************************************************/ - Init() ; -} - - -//================================================================================= -// function : ~StdMeshersGUI_NbSegmentsDlg() -// purpose : Destroys the object and frees any allocated resources -//================================================================================= -StdMeshersGUI_NbSegmentsDlg::~StdMeshersGUI_NbSegmentsDlg() -{ - // no need to delete child widgets, Qt does it all for us -} - - -//================================================================================= -// function : Init() -// purpose : -//================================================================================= -void StdMeshersGUI_NbSegmentsDlg::Init() -{ - SpinBox_NbSeg->setMinValue( 1 ); - SpinBox_NbSeg->setMaxValue( 9999 ); - SpinBox_NbSeg->setValue(3) ; /* myNbSeg */ - - mySMESHGUI = SMESHGUI::GetSMESHGUI() ; - - char* sHypType = (char*)myHypType.latin1(); - HypothesisData* aHypData = mySMESHGUI->GetHypothesisData(sHypType); - //_CS_PhB ambiguous overload LineEdit_NameHypothesis->setText( aHypData ? aHypData->Label : "" ); - if (aHypData!=0) - { - LineEdit_NameHypothesis->setText(aHypData->Label); - } - else - { - LineEdit_NameHypothesis->setText(""); - } - - mySMESHGUI->SetActiveDialogBox( (QDialog*)this ) ; - - /* signals and slots connections */ - connect( buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()) ); - connect( buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel()) ) ; - connect( buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()) ); - - connect( mySMESHGUI, SIGNAL ( SignalDeactivateActiveDialog() ), this, SLOT( DeactivateActiveDialog() ) ) ; - connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( ClickOnCancel() ) ) ; - - /* Move widget on the botton right corner of main widget */ - int x, y ; - mySMESHGUI->DefineDlgPosition( this, x, y ) ; - this->move( x, y ) ; - this->show() ; /* displays Dialog */ -} - - -//================================================================================= -// function : ClickOnOk() -// purpose : -//================================================================================= -void StdMeshersGUI_NbSegmentsDlg::ClickOnOk() -{ - if ( this->ClickOnApply() ) - this->ClickOnCancel() ; -} - -//================================================================================= -// function : ClickOnApply() -// purpose : -//================================================================================= -bool StdMeshersGUI_NbSegmentsDlg::ClickOnApply() -{ - QString myHypName = LineEdit_NameHypothesis->text().stripWhiteSpace(); - if ( myHypName.isEmpty() ) { - QAD_MessageBox::warn1( this, tr( "SMESH_WRN_WARNING" ), tr( "SMESH_WRN_EMPTY_NAME" ), tr( "SMESH_BUT_OK" ) ); - return false; - } - - long myNbSeg = SpinBox_NbSeg->value(); - - QAD_WaitCursor wc; - try { - SMESH::SMESH_Hypothesis_var Hyp = SMESH::SMESH_Hypothesis::_narrow - (mySMESHGUI->CreateHypothesis(myHypType, - myHypName, - false)); // isAlgorithm - StdMeshers::StdMeshers_NumberOfSegments_var NbS = - StdMeshers::StdMeshers_NumberOfSegments::_narrow(Hyp); - if (!NbS->_is_nil()) - NbS->SetNumberOfSegments(myNbSeg); - } - catch (const SALOME::SALOME_Exception& S_ex) { - wc.stop(); - QtCatchCorbaException(S_ex); - return false; - } - return true; -} - - -//================================================================================= -// function : ClickOnCancel() -// purpose : -//================================================================================= -void StdMeshersGUI_NbSegmentsDlg::ClickOnCancel() -{ - close(); -} - -//================================================================================= -// function : DeactivateActiveDialog() -// purpose : -//================================================================================= -void StdMeshersGUI_NbSegmentsDlg::DeactivateActiveDialog() -{ - iconLabel->setEnabled(false) ; - typeLabel->setEnabled(false) ; - GroupC1->setEnabled(false) ; - GroupButtons->setEnabled(false) ; -} - - -//================================================================================= -// function : ActivateThisDialog() -// purpose : -//================================================================================= -void StdMeshersGUI_NbSegmentsDlg::ActivateThisDialog() -{ - mySMESHGUI->EmitSignalDeactivateDialog() ; - iconLabel->setEnabled(true) ; - typeLabel->setEnabled(true) ; - GroupC1->setEnabled(true) ; - GroupButtons->setEnabled(true) ; -} - - -//================================================================================= -// function : enterEvent() -// purpose : -//================================================================================= -void StdMeshersGUI_NbSegmentsDlg::enterEvent(QEvent* e) -{ - ActivateThisDialog() ; -} - - -//================================================================================= -// function : closeEvent() -// purpose : -//================================================================================= -void StdMeshersGUI_NbSegmentsDlg::closeEvent( QCloseEvent* e ) -{ - mySMESHGUI->ResetState(); - QDialog::closeEvent( e ); -} diff --git a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsDlg.h b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsDlg.h deleted file mode 100644 index 3594ac960..000000000 --- a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsDlg.h +++ /dev/null @@ -1,89 +0,0 @@ -// SMESH SMESHGUI : GUI for SMESH component -// -// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org -// -// -// -// File : StdMeshersGUI_NbSegmentsDlg.h -// Moved here from SMESHGUI_NbSegmentsDlg.h -// Author : Nicolas REJNERI -// Module : SMESH -// $Header$ - -#ifndef DIALOGBOX_NB_SEGMENTS_H -#define DIALOGBOX_NB_SEGMENTS_H - -// QT Includes -#include - -class QGroupBox; -class QLabel; -class QLineEdit; -class QSpinBox; -class QPushButton; -class SMESHGUI; - -//================================================================================= -// class : StdMeshersGUI_NbSegmentsDlg -// purpose : -//================================================================================= -class StdMeshersGUI_NbSegmentsDlg : public QDialog -{ - Q_OBJECT - -public: - StdMeshersGUI_NbSegmentsDlg (const QString& hypType, - QWidget* parent = 0, - const char* name = 0, - bool modal = FALSE, - WFlags fl = 0); - ~StdMeshersGUI_NbSegmentsDlg (); - -private: - - void Init() ; - void closeEvent( QCloseEvent* e ) ; - void enterEvent ( QEvent * ) ; - - SMESHGUI* mySMESHGUI ; - QString myHypType ; - - QLabel* iconLabel; - QLabel* typeLabel; - QGroupBox* GroupC1; - QLabel* TextLabel_NameHypothesis ; - QLineEdit* LineEdit_NameHypothesis ; - QLabel* TextLabel_NbSeg ; - QSpinBox* SpinBox_NbSeg ; - QGroupBox* GroupButtons; - QPushButton* buttonApply; - QPushButton* buttonOk; - QPushButton* buttonCancel; - -private slots: - - void ClickOnOk(); - void ClickOnCancel(); - bool ClickOnApply(); - void DeactivateActiveDialog() ; - void ActivateThisDialog() ; -}; - -#endif // DIALOGBOX_NB_SEGMENTS_H diff --git a/src/StdMeshersGUI/StdMeshersGUI_Parameters.cxx b/src/StdMeshersGUI/StdMeshersGUI_Parameters.cxx new file mode 100644 index 000000000..caa67da14 --- /dev/null +++ b/src/StdMeshersGUI/StdMeshersGUI_Parameters.cxx @@ -0,0 +1,306 @@ +// SMESH StdMeshersGUI : GUI for standard meshers +// +// Copyright (C) 2003 CEA +// +// 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.org +// +// +// +// File : StdMeshersGUI_Parameters.cxx +// Module : SMESH +// $Header$ + +#include "StdMeshersGUI_Parameters.h" + +#include + +using namespace std; + +//======================================================================= +//function : HasParameters +//purpose : +//======================================================================= + +bool StdMeshersGUI_Parameters::HasParameters (const QString& hypType) +{ + return ((hypType.compare("LocalLength") == 0) || + (hypType.compare("NumberOfSegments") == 0) || + (hypType.compare("MaxElementArea") == 0) || + (hypType.compare("MaxElementVolume") == 0) || + (hypType.compare("StartEndLength") == 0) || + (hypType.compare("Deflection1D") == 0) || + (hypType.compare("Arithmetic1D") == 0)); +} + +//======================================================================= +//function : GetParameters +//purpose : +//======================================================================= + +#define DOUBLE_PARAM(v,l,b,t,s,d) SMESHGUI_aParameterPtr(new SMESHGUI_doubleParameter(v,l,b,t,s,d)) +#define INT_PARAM(v,l,b,t) SMESHGUI_aParameterPtr(new SMESHGUI_intParameter(v,l,b,t)) + +void StdMeshersGUI_Parameters::GetParameters (const QString& hypType, + list & paramList ) +{ + paramList.clear(); + + if (hypType.compare("LocalLength") == 0) + { + paramList.push_back( DOUBLE_PARAM (1.0, + QObject::tr("SMESH_LOCAL_LENGTH_PARAM"), + 0.001, 999.999, 1.0, 3)); + } + else if (hypType.compare("NumberOfSegments") == 0) + { + paramList.push_back ( INT_PARAM (3, + QObject::tr("SMESH_NB_SEGMENTS_PARAM"), + 1, 9999 )); + } + else if (hypType.compare("Arithmetic1D") == 0) + { + paramList.push_back( DOUBLE_PARAM ( 1.0, + QObject::tr("SMESH_START_LENGTH_PARAM"), + 1.0E-5, 1E6, 1, 6)); + paramList.push_back( DOUBLE_PARAM ( 10.0, + QObject::tr("SMESH_END_LENGTH_PARAM"), + 1.0E-5, 1E6, 1, 6)); + } + else if (hypType.compare("MaxElementArea") == 0) + { + paramList.push_back( DOUBLE_PARAM (1.0, + QObject::tr("SMESH_MAX_ELEMENT_AREA_PARAM"), + 0.001, 999999.999, 1.0, 3)); + } + else if (hypType.compare("MaxElementVolume") == 0) + { + paramList.push_back( DOUBLE_PARAM ( 1.0, + QObject::tr("SMESH_MAX_ELEMENT_VOLUME_PARAM"), + 0.001, 999999.999, 1.0, 3)); + } + else if (hypType.compare("StartEndLength") == 0) + { + paramList.push_back( DOUBLE_PARAM ( 1.0, + QObject::tr("SMESH_START_LENGTH_PARAM"), + 1.0E-5, 1E6, 1, 6)); + paramList.push_back( DOUBLE_PARAM ( 10.0, + QObject::tr("SMESH_END_LENGTH_PARAM"), + 1.0E-5, 1E6, 1, 6)); + } + else if (hypType.compare("Deflection1D") == 0) + { + paramList.push_back( DOUBLE_PARAM ( 1.0, + QObject::tr("SMESH_DEFLECTION1D_PARAM"), + 1.0E-5, 1E6, 1, 6)); + } +} + +//======================================================================= +//function : GetParameters +//purpose : +//======================================================================= + +void StdMeshersGUI_Parameters::GetParameters (SMESH::SMESH_Hypothesis_ptr theHyp, + list & paramList ) +{ + paramList.clear(); + + if (theHyp->_is_nil()) return; + + QString hypType = theHyp->GetName(); + + if (hypType.compare("LocalLength") == 0) + { + StdMeshers::StdMeshers_LocalLength_var LL = + StdMeshers::StdMeshers_LocalLength::_narrow(theHyp); + double length = LL->GetLength(); + paramList.push_back( DOUBLE_PARAM (length, + QObject::tr("SMESH_LOCAL_LENGTH_PARAM"), + 0.001, 999.999, 1.0, 3)); + } + else if (hypType.compare("NumberOfSegments") == 0) + { + StdMeshers::StdMeshers_NumberOfSegments_var NOS = + StdMeshers::StdMeshers_NumberOfSegments::_narrow(theHyp); + int NbSeg = NOS->GetNumberOfSegments() ; + paramList.push_back ( INT_PARAM (NbSeg, + QObject::tr("SMESH_NB_SEGMENTS_PARAM"), + 1, 9999 )); + } + else if (hypType.compare("Arithmetic1D") == 0) + { + StdMeshers::StdMeshers_Arithmetic1D_var hyp = + StdMeshers::StdMeshers_Arithmetic1D::_narrow(theHyp); + double begLength = hyp->GetLength( true ) ; + double endLength = hyp->GetLength( false ) ; + paramList.push_back( DOUBLE_PARAM ( begLength, + QObject::tr("SMESH_START_LENGTH_PARAM"), + 1.0E-5, 1E6, 1, 6)); + paramList.push_back( DOUBLE_PARAM ( endLength, + QObject::tr("SMESH_END_LENGTH_PARAM"), + 1.0E-5, 1E6, 1, 6)); + } + else if (hypType.compare("MaxElementArea") == 0) + { + StdMeshers::StdMeshers_MaxElementArea_var MEA = + StdMeshers::StdMeshers_MaxElementArea::_narrow(theHyp); + double MaxArea = MEA->GetMaxElementArea(); + paramList.push_back( DOUBLE_PARAM (MaxArea, + QObject::tr("SMESH_MAX_ELEMENT_AREA_PARAM"), + 0.001, 999999.999, 1.0, 3)); + } + else if (hypType.compare("MaxElementVolume") == 0) + { + StdMeshers::StdMeshers_MaxElementVolume_var MEV = + StdMeshers::StdMeshers_MaxElementVolume::_narrow(theHyp); + double MaxVolume = MEV->GetMaxElementVolume() ; + paramList.push_back( DOUBLE_PARAM ( MaxVolume, + QObject::tr("SMESH_MAX_ELEMENT_VOLUME_PARAM"), + 0.001, 999999.999, 1.0, 3)); + } + else if (hypType.compare("StartEndLength") == 0) + { + StdMeshers::StdMeshers_StartEndLength_var hyp = + StdMeshers::StdMeshers_StartEndLength::_narrow(theHyp); + double begLength = hyp->GetLength( true ) ; + double endLength = hyp->GetLength( false ) ; + paramList.push_back( DOUBLE_PARAM ( begLength, + QObject::tr("SMESH_START_LENGTH_PARAM"), + 1.0E-5, 1E6, 1, 6)); + paramList.push_back( DOUBLE_PARAM ( endLength, + QObject::tr("SMESH_END_LENGTH_PARAM"), + 1.0E-5, 1E6, 1, 6)); + } + else if (hypType.compare("Deflection1D") == 0) + { + StdMeshers::StdMeshers_Deflection1D_var hyp = + StdMeshers::StdMeshers_Deflection1D::_narrow(theHyp); + double value = hyp->GetDeflection() ; + paramList.push_back( DOUBLE_PARAM ( value, + QObject::tr("SMESH_DEFLECTION1D_PARAM"), + 1.0E-5, 1E6, 1, 6)); + } +} + +//======================================================================= +//function : GetParameters +//purpose : +//======================================================================= +void StdMeshersGUI_Parameters::GetParameters (SMESH::SMESH_Hypothesis_ptr hyp, + list & paramList, + QString& params) +{ + params = ""; + list::iterator paramIt = paramList.begin(); + for ( ; paramIt != paramList.end(); paramIt++) { + int aIntValue; + double aDoubleValue; + if (params.compare("")) params += " ; "; + if ((*paramIt)->GetType() == SMESHGUI_aParameter::INT) { + (*paramIt)->GetNewInt(aIntValue); + params += QString::number(aIntValue);; + } + else { + (*paramIt)->GetNewDouble(aDoubleValue); + params += QString::number(aDoubleValue); + } + } +} + +//======================================================================= +//function : SetParameters +//purpose : +//======================================================================= + +bool StdMeshersGUI_Parameters::SetParameters(SMESH::SMESH_Hypothesis_ptr theHyp, + const list & paramList ) +{ + if (theHyp->_is_nil() || paramList.empty()) return false; + + bool modified = false; + + QString hypType = theHyp->GetName(); + + if (hypType.compare("LocalLength") == 0) + { + StdMeshers::StdMeshers_LocalLength_var LL = + StdMeshers::StdMeshers_LocalLength::_narrow(theHyp); + double length = LL->GetLength(); + modified = paramList.front()->GetNewDouble( length ); + LL->SetLength(length); + } + else if (hypType.compare("NumberOfSegments") == 0) + { + StdMeshers::StdMeshers_NumberOfSegments_var NOS = + StdMeshers::StdMeshers_NumberOfSegments::_narrow(theHyp); + int NbSeg = NOS->GetNumberOfSegments(); + modified = paramList.front()->GetNewInt( NbSeg ); + NOS->SetNumberOfSegments(NbSeg); + } + else if (hypType.compare("Arithmetic1D") == 0) + { + if ( paramList.size() != 2 ) + return false; + StdMeshers::StdMeshers_Arithmetic1D_var hyp = + StdMeshers::StdMeshers_Arithmetic1D::_narrow(theHyp); + double begLength = hyp->GetLength( true ) ; + double endLength = hyp->GetLength( false ) ; + modified = paramList.front()->GetNewDouble( begLength ); + modified = paramList.back()->GetNewDouble( endLength ) || modified; + hyp->SetLength( begLength, true ); + hyp->SetLength( endLength, false ); + } + else if (hypType.compare("MaxElementArea") == 0) + { + StdMeshers::StdMeshers_MaxElementArea_var MEA = + StdMeshers::StdMeshers_MaxElementArea::_narrow(theHyp); + double MaxArea = MEA->GetMaxElementArea(); + modified = paramList.front()->GetNewDouble( MaxArea ); + MEA->SetMaxElementArea(MaxArea); + } + else if (hypType.compare("MaxElementVolume") == 0) + { + StdMeshers::StdMeshers_MaxElementVolume_var MEV = + StdMeshers::StdMeshers_MaxElementVolume::_narrow(theHyp); + double MaxVolume = MEV->GetMaxElementVolume() ; + modified = paramList.front()->GetNewDouble( MaxVolume ); + MEV->SetMaxElementVolume(MaxVolume); + } + else if (hypType.compare("StartEndLength") == 0) + { + if ( paramList.size() != 2 ) + return false; + StdMeshers::StdMeshers_StartEndLength_var hyp = + StdMeshers::StdMeshers_StartEndLength::_narrow(theHyp); + double begLength = hyp->GetLength( true ) ; + double endLength = hyp->GetLength( false ) ; + modified = paramList.front()->GetNewDouble( begLength ); + modified = paramList.back()->GetNewDouble( endLength ) || modified; + hyp->SetLength( begLength, true ); + hyp->SetLength( endLength, false ); + } + else if (hypType.compare("Deflection1D") == 0) + { + StdMeshers::StdMeshers_Deflection1D_var hyp = + StdMeshers::StdMeshers_Deflection1D::_narrow(theHyp); + double value = hyp->GetDeflection() ; + modified = paramList.front()->GetNewDouble( value ); + hyp->SetDeflection( value ); + } + return modified ; +} + diff --git a/src/StdMeshersGUI/StdMeshersGUI_Parameters.h b/src/StdMeshersGUI/StdMeshersGUI_Parameters.h new file mode 100644 index 000000000..5ec4c3a71 --- /dev/null +++ b/src/StdMeshersGUI/StdMeshersGUI_Parameters.h @@ -0,0 +1,54 @@ +// SMESH StdMeshersGUI : GUI for standard meshers +// +// Copyright (C) 2003 CEA +// +// 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.org +// +// +// +// File : StdMeshersGUI_Parameters.h +// Module : SMESH +// $Header$ + +#ifndef STDMESHERSGUI_PARAMETERS_H +#define STDMESHERSGUI_PARAMETERS_H + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESHGUI_aParameter.h" + +#include + +class StdMeshersGUI_Parameters +{ + public: + static bool HasParameters (const QString& hypType); + + static void GetParameters (const QString& hypType, + std::list & params ); + + static void GetParameters (SMESH::SMESH_Hypothesis_ptr hyp, + std::list & params ); + static void GetParameters (SMESH::SMESH_Hypothesis_ptr hyp, + std::list & paramList, + QString& params); + + static bool SetParameters(SMESH::SMESH_Hypothesis_ptr hyp, + const std::list & params ); +}; +#endif diff --git a/src/StdMeshersGUI/StdMeshers_icons.po b/src/StdMeshersGUI/StdMeshers_icons.po index c021365cd..64fe98459 100644 --- a/src/StdMeshersGUI/StdMeshers_icons.po +++ b/src/StdMeshersGUI/StdMeshers_icons.po @@ -35,6 +35,22 @@ msgstr "mesh_hypo_area.png" msgid "ICON_DLG_MAX_ELEMENT_VOLUME" msgstr "mesh_hypo_volume.png" +#Hypo Start End Length +msgid "ICON_DLG_START_END_LENGTH" +msgstr "mesh_hypo_length.png" + +#Hypo deflection 1D +msgid "ICON_DLG_DEFLECTION1D" +msgstr "mesh_hypo_length.png" + +#Hypo Geometric 1D +msgid "ICON_DLG_GEOMETRIC_1D" +msgstr "mesh_hypo_length.png" + +#Hypo Arithmetic 1D +msgid "ICON_DLG_ARITHMETIC_1D" +msgstr "mesh_hypo_length.png" + #----------------------------------------------------------- # ObjectBrowser @@ -79,3 +95,19 @@ msgstr "mesh_tree_hypo_length.png" #mesh_tree_hypo_nonconform msgid "ICON_SMESH_TREE_HYPO_NotConformAllowed" msgstr "mesh_tree_hypo_length.png" + +#mesh_tree_hypo_start_end_length +msgid "ICON_SMESH_TREE_HYPO_StartEndLength" +msgstr "mesh_tree_hypo_length.png" + +#mesh_tree_hypo_deflection1d +msgid "ICON_SMESH_TREE_HYPO_Deflection1D" +msgstr "mesh_tree_hypo_length.png" + +#mesh_tree_hypo_Arithmetic1d +msgid "ICON_SMESH_TREE_HYPO_Arithmetic1D" +msgstr "mesh_tree_hypo_length.png" + +#mesh_tree_hypo_propagation +msgid "ICON_SMESH_TREE_HYPO_Propagation" +msgstr "mesh_tree_hypo_length.png" diff --git a/src/StdMeshersGUI/StdMeshers_msg_en.po b/src/StdMeshersGUI/StdMeshers_msg_en.po index cc6173b71..210033e5a 100644 --- a/src/StdMeshersGUI/StdMeshers_msg_en.po +++ b/src/StdMeshersGUI/StdMeshers_msg_en.po @@ -13,7 +13,10 @@ msgstr "" # -------------- Local Length -------------- msgid "SMESH_LOCAL_LENGTH_HYPOTHESIS" -msgstr "Local Length" +msgstr "Average Length" + +msgid "SMESH_LOCAL_LENGTH_PARAM" +msgstr "Length" msgid "SMESH_LOCAL_LENGTH_TITLE" msgstr "Hypothesis Construction" @@ -23,12 +26,15 @@ msgstr "Hypothesis Construction" msgid "SMESH_NB_SEGMENTS_HYPOTHESIS" msgstr "Number of Segments" +msgid "SMESH_NB_SEGMENTS_PARAM" +msgstr "Number of Segments" + msgid "SMESH_NB_SEGMENTS_TITLE" msgstr "Hypothesis Construction" # ----------- Max. Element Area ------------ -msgid "SMESH_MAX_ELEMENT_AREA" +msgid "SMESH_MAX_ELEMENT_AREA_PARAM" msgstr "Max. Area" msgid "SMESH_MAX_ELEMENT_AREA_HYPOTHESIS" @@ -39,7 +45,7 @@ msgstr "Hypothesis Construction" # ---------- Max. Element Volume ----------- -msgid "SMESH_MAX_ELEMENT_VOLUME" +msgid "SMESH_MAX_ELEMENT_VOLUME_PARAM" msgstr "Max. Volume" msgid "SMESH_MAX_ELEMENT_VOLUME_HYPOTHESIS" @@ -47,3 +53,40 @@ msgstr "Max. Element Volume" msgid "SMESH_MAX_ELEMENT_VOLUME_TITLE" msgstr "Hypothesis Construction" + + +# -------------- Start and End Length -------------- + +msgid "SMESH_START_LENGTH_PARAM" +msgstr "Start Length" + +msgid "SMESH_END_LENGTH_PARAM" +msgstr "End Length" + +msgid "SMESH_START_END_LENGTH_HYPOTHESIS" +msgstr "Start and EndLocal Length" + +msgid "SMESH_START_END_LENGTH_TITLE" +msgstr "Hypothesis Construction" + +# -------------- Deflection 1D -------------- + +msgid "SMESH_DEFLECTION1D_HYPOTHESIS" +msgstr "Deflection 1D" + +msgid "SMESH_DEFLECTION1D_PARAM" +msgstr "Deflection" + +msgid "SMESH_DEFLECTION1D_TITLE" +msgstr "Hypothesis Construction" + +# -------------- Arithmetic 1D -------------- + +msgid "SMESH_ARITHMETIC_1D_HYPOTHESIS" +msgstr "Arithmetic 1D" + +msgid "SMESH_ARITHMETIC_1D_PARAM" +msgstr "Arithmetic Reason" + +msgid "SMESH_ARITHMETIC_1D_TITLE" +msgstr "Hypothesis Construction" diff --git a/src/StdMeshers_I/Makefile.in b/src/StdMeshers_I/Makefile.in index 5891f6e80..12f1c6431 100644 --- a/src/StdMeshers_I/Makefile.in +++ b/src/StdMeshers_I/Makefile.in @@ -42,10 +42,14 @@ LIB= libStdMeshersEngine.la LIB_SRC = \ StdMeshers_i.cxx \ StdMeshers_LocalLength_i.cxx \ + StdMeshers_StartEndLength_i.cxx \ + StdMeshers_Arithmetic1D_i.cxx \ + StdMeshers_NumberOfSegments_i.cxx \ + StdMeshers_Deflection1D_i.cxx \ + StdMeshers_Propagation_i.cxx \ StdMeshers_LengthFromEdges_i.cxx \ StdMeshers_MaxElementArea_i.cxx \ StdMeshers_MaxElementVolume_i.cxx \ - StdMeshers_NumberOfSegments_i.cxx \ StdMeshers_NotConformAllowed_i.cxx \ StdMeshers_Regular_1D_i.cxx \ StdMeshers_Quadrangle_2D_i.cxx \ @@ -56,8 +60,9 @@ LIB_SERVER_IDL = SMESH_BasicHypothesis.idl LIB_CLIENT_IDL = \ SALOMEDS.idl SALOME_Exception.idl \ - GEOM_Gen.idl GEOM_Shape.idl MED.idl SALOMEDS_Attributes.idl \ - SMESH_Gen.idl SMESH_Hypothesis.idl SMESH_Group.idl + GEOM_Gen.idl MED.idl SALOMEDS_Attributes.idl \ + SMESH_Gen.idl SMESH_Hypothesis.idl SMESH_Group.idl \ + SALOME_Comm.idl # Executables targets BIN = diff --git a/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.cxx b/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.cxx new file mode 100644 index 000000000..aad7d1e39 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.cxx @@ -0,0 +1,120 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_Arithmetic1D_i.cxx +// Author : Damien COQUERET, OCC +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_Arithmetic1D_i.hxx" +#include "SMESH_Gen.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * StdMeshers_Arithmetic1D_i::StdMeshers_Arithmetic1D_i + * + * Constructor + */ +//============================================================================= + +StdMeshers_Arithmetic1D_i::StdMeshers_Arithmetic1D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ) +{ + MESSAGE( "StdMeshers_Arithmetic1D_i::StdMeshers_Arithmetic1D_i" ); + myBaseImpl = new ::StdMeshers_Arithmetic1D( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} + +//============================================================================= +/*! + * StdMeshers_Arithmetic1D_i::~StdMeshers_Arithmetic1D_i + * + * Destructor + */ +//============================================================================= + +StdMeshers_Arithmetic1D_i::~StdMeshers_Arithmetic1D_i() +{ + MESSAGE( "StdMeshers_Arithmetic1D_i::~StdMeshers_Arithmetic1D_i" ); +} + +//============================================================================= +/*! + * StdMeshers_Arithmetic1D_i::SetLength + * + * Set length + */ +//============================================================================= + +void StdMeshers_Arithmetic1D_i::SetLength(CORBA::Double theLength, + CORBA::Boolean theIsStart ) + throw ( SALOME::SALOME_Exception ) +{ + MESSAGE( "StdMeshers_StartEndLength_i::SetLength" ); + ASSERT( myBaseImpl ); + try { + this->GetImpl()->SetLength( theLength, theIsStart ); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), + SALOME::BAD_PARAM ); + } +} + +//============================================================================= +/*! + * StdMeshers_Arithmetic1D_i::GetLength + * + * Get length + */ +//============================================================================= + +CORBA::Double StdMeshers_Arithmetic1D_i::GetLength( CORBA::Boolean theIsStart) +{ + MESSAGE( "StdMeshers_StartEndLength_i::GetLength" ); + ASSERT( myBaseImpl ); + return this->GetImpl()->GetLength( theIsStart ); +} + +//============================================================================= +/*! + * StdMeshers_Arithmetic1D_i::GetImpl + * + * Get implementation + */ +//============================================================================= + +::StdMeshers_Arithmetic1D* StdMeshers_Arithmetic1D_i::GetImpl() +{ + MESSAGE( "StdMeshers_Arithmetic1D_i::GetImpl" ); + return ( ::StdMeshers_Arithmetic1D* )myBaseImpl; +} + diff --git a/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.hxx b/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.hxx new file mode 100644 index 000000000..9b7c90114 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_Arithmetic1D_i.hxx @@ -0,0 +1,63 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_Arithmetic1D_i.hxx +// Author : Damien COQUERET, OCC +// Module : SMESH +// $Header$ + +#ifndef _SMESH_ARITHMETIC1D_I_HXX_ +#define _SMESH_ARITHMETIC1D_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESH_Hypothesis_i.hxx" +#include "StdMeshers_Arithmetic1D.hxx" + +// ====================================================== +// Arithmetic 1D hypothesis +// ====================================================== +class StdMeshers_Arithmetic1D_i: + public virtual POA_StdMeshers::StdMeshers_Arithmetic1D, + public virtual SMESH_Hypothesis_i +{ +public: + // Constructor + StdMeshers_Arithmetic1D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + // Destructor + virtual ~StdMeshers_Arithmetic1D_i(); + + // Set length + void SetLength( CORBA::Double theLength, CORBA::Boolean theIsStart ) + throw ( SALOME::SALOME_Exception ); + // Get length + CORBA::Double GetLength(CORBA::Boolean theIsStart); + + // Get implementation + ::StdMeshers_Arithmetic1D* GetImpl(); +}; + +#endif diff --git a/src/StdMeshers_I/StdMeshers_Deflection1D_i.cxx b/src/StdMeshers_I/StdMeshers_Deflection1D_i.cxx new file mode 100644 index 000000000..84ef5e96d --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_Deflection1D_i.cxx @@ -0,0 +1,119 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_Deflection1D_i.cxx +// Moved here from SMESH_LocalLength_i.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_Deflection1D_i.hxx" +#include "SMESH_Gen.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * StdMeshers_Deflection1D_i::StdMeshers_Deflection1D_i + * + * Constructor + */ +//============================================================================= + +StdMeshers_Deflection1D_i::StdMeshers_Deflection1D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ) +{ + MESSAGE( "StdMeshers_Deflection1D_i::StdMeshers_Deflection1D_i" ); + myBaseImpl = new ::StdMeshers_Deflection1D( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} + +//============================================================================= +/*! + * StdMeshers_Deflection1D_i::~StdMeshers_Deflection1D_i + * + * Destructor + */ +//============================================================================= + +StdMeshers_Deflection1D_i::~StdMeshers_Deflection1D_i() +{ + MESSAGE( "StdMeshers_Deflection1D_i::~StdMeshers_Deflection1D_i" ); +} + +//============================================================================= +/*! + * StdMeshers_Deflection1D_i::SetDeflection + * + * Set deflection + */ +//============================================================================= + +void StdMeshers_Deflection1D_i::SetDeflection( CORBA::Double theValue ) + throw ( SALOME::SALOME_Exception ) +{ + MESSAGE( "StdMeshers_Deflection1D_i::SetDeflection" ); + ASSERT( myBaseImpl ); + try { + this->GetImpl()->SetDeflection( theValue ); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), + SALOME::BAD_PARAM ); + } +} + +//============================================================================= +/*! + * StdMeshers_Deflection1D_i::GetDeflection + * + * Get deflection + */ +//============================================================================= + +CORBA::Double StdMeshers_Deflection1D_i::GetDeflection() +{ + MESSAGE( "StdMeshers_Deflection1D_i::GetDeflection" ); + ASSERT( myBaseImpl ); + return this->GetImpl()->GetDeflection(); +} + +//============================================================================= +/*! + * StdMeshers_Deflection1D_i::GetImpl + * + * Get implementation + */ +//============================================================================= + +::StdMeshers_Deflection1D* StdMeshers_Deflection1D_i::GetImpl() +{ + MESSAGE( "StdMeshers_Deflection1D_i::GetImpl" ); + return ( ::StdMeshers_Deflection1D* )myBaseImpl; +} diff --git a/src/SMESH_I/SMESH_topo.hxx b/src/StdMeshers_I/StdMeshers_Deflection1D_i.hxx similarity index 51% rename from src/SMESH_I/SMESH_topo.hxx rename to src/StdMeshers_I/StdMeshers_Deflection1D_i.hxx index 5e2bee0d4..dffc2beda 100644 --- a/src/SMESH_I/SMESH_topo.hxx +++ b/src/StdMeshers_I/StdMeshers_Deflection1D_i.hxx @@ -21,60 +21,47 @@ // // // -// File : SMESH_topo.hxx +// File : StdMeshers_Deflection1D_i.hxx +// Moved here from SMESH_LocalLength_i.hxx // Author : Paul RASCLE, EDF // Module : SMESH // $Header$ -#ifndef _SMESH_TOPO_HXX_ -#define _SMESH_TOPO_HXX_ +#ifndef _SMESH_Deflection1D_I_HXX_ +#define _SMESH_Deflection1D_I_HXX_ #include -#include CORBA_CLIENT_HEADER(GEOM_Shape) +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "SMESH_Hypothesis_i.hxx" +#include "StdMeshers_Deflection1D.hxx" -#include -#include +class SMESH_Gen; -static const char* const SMESH_shapeTypeNames[9] = { "0=TopAbs_COMPOUND", - "1=TopAbs_COMPSOLID", - "2=TopAbs_SOLID", - "3=TopAbs_SHELL", - "4=TopAbs_FACE", - "5=TopAbs_WIRE", - "6=TopAbs_EDGE", - "7=TopAbs_VERTEX", - "8=TopAbs_SHAPE" }; - -class SMESH_topo +// ====================================================== +// Local Length hypothesis +// ====================================================== +class StdMeshers_Deflection1D_i: + public virtual POA_StdMeshers::StdMeshers_Deflection1D, + public virtual SMESH_Hypothesis_i { public: + // Constructor + StdMeshers_Deflection1D_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + // Destructor + virtual ~StdMeshers_Deflection1D_i(); - static string GetShapeLocalId(GEOM::GEOM_Shape_ptr aShape); - - SMESH_topo(); - virtual ~SMESH_topo(); - - map _mapIndShapes[9]; - TopTools_IndexedMapOfShape _myShapes[9]; - -protected: - + // Set deflection + void SetDeflection( CORBA::Double theLength ) + throw ( SALOME::SALOME_Exception ); + // Get deflection + CORBA::Double GetDeflection(); + // Get implementation + ::StdMeshers_Deflection1D* GetImpl(); }; #endif + diff --git a/src/StdMeshers_I/StdMeshers_Propagation_i.cxx b/src/StdMeshers_I/StdMeshers_Propagation_i.cxx new file mode 100644 index 000000000..e4ddfcfcd --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_Propagation_i.cxx @@ -0,0 +1,76 @@ +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses +// +// Copyright (C) 2003 CEA +// +// 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.org +// +// +// +// File : StdMeshers_Propagation_i.cxx +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_Propagation_i.hxx" +#include "SMESH_Gen.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * StdMeshers_Propagation_i::StdMeshers_Propagation_i + * + * Constructor + */ +//============================================================================= +StdMeshers_Propagation_i::StdMeshers_Propagation_i (PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ) +{ + MESSAGE( "StdMeshers_Propagation_i::StdMeshers_Propagation_i" ); + myBaseImpl = new ::StdMeshers_Propagation(theGenImpl->GetANewId(), + theStudyId, + theGenImpl); +} + +//============================================================================= +/*! + * StdMeshers_Propagation_i::~StdMeshers_Propagation_i + * + * Destructor + */ +//============================================================================= +StdMeshers_Propagation_i::~StdMeshers_Propagation_i() +{ + MESSAGE( "StdMeshers_Propagation_i::~StdMeshers_Propagation_i" ); +} + +//============================================================================= +/*! + * StdMeshers_Propagation_i::GetImpl + * + * Get implementation + */ +//============================================================================= +::StdMeshers_Propagation* StdMeshers_Propagation_i::GetImpl() +{ + MESSAGE( "StdMeshers_Propagation_i::GetImpl" ); + return ( ::StdMeshers_Propagation* )myBaseImpl; +} diff --git a/src/StdMeshers_I/StdMeshers_Propagation_i.hxx b/src/StdMeshers_I/StdMeshers_Propagation_i.hxx new file mode 100644 index 000000000..6413235ec --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_Propagation_i.hxx @@ -0,0 +1,57 @@ +// SMESH SMESH_I : idl implementation based on 'SMESH' unit's calsses +// +// Copyright (C) 2003 CEA +// +// 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.org +// +// +// +// File : StdMeshers_Propagation_i.hxx +// Module : SMESH +// $Header$ + +#ifndef _SMESH_PROPAGATION_I_HXX_ +#define _SMESH_PROPAGATION_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESH_Hypothesis_i.hxx" +#include "StdMeshers_Propagation.hxx" + +class SMESH_Gen; + +// ====================================================== +// Propagation hypothesis +// ====================================================== +class StdMeshers_Propagation_i: + public virtual POA_StdMeshers::StdMeshers_Propagation, + public virtual SMESH_Hypothesis_i +{ +public: + // Constructor + StdMeshers_Propagation_i (PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl); + // Destructor + virtual ~StdMeshers_Propagation_i(); + + // Get implementation + ::StdMeshers_Propagation* GetImpl(); +}; + +#endif diff --git a/src/StdMeshers_I/StdMeshers_StartEndLength_i.cxx b/src/StdMeshers_I/StdMeshers_StartEndLength_i.cxx new file mode 100644 index 000000000..08ffa4c81 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_StartEndLength_i.cxx @@ -0,0 +1,120 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_StartEndLength_i.cxx +// Moved here from SMESH_LocalLength_i.cxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +using namespace std; +#include "StdMeshers_StartEndLength_i.hxx" +#include "SMESH_Gen.hxx" + +#include "Utils_CorbaException.hxx" +#include "utilities.h" + +//============================================================================= +/*! + * StdMeshers_StartEndLength_i::StdMeshers_StartEndLength_i + * + * Constructor + */ +//============================================================================= + +StdMeshers_StartEndLength_i::StdMeshers_StartEndLength_i( PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ) + : SALOME::GenericObj_i( thePOA ), + SMESH_Hypothesis_i( thePOA ) +{ + MESSAGE( "StdMeshers_StartEndLength_i::StdMeshers_StartEndLength_i" ); + myBaseImpl = new ::StdMeshers_StartEndLength( theGenImpl->GetANewId(), + theStudyId, + theGenImpl ); +} + +//============================================================================= +/*! + * StdMeshers_StartEndLength_i::~StdMeshers_StartEndLength_i + * + * Destructor + */ +//============================================================================= + +StdMeshers_StartEndLength_i::~StdMeshers_StartEndLength_i() +{ + MESSAGE( "StdMeshers_StartEndLength_i::~StdMeshers_StartEndLength_i" ); +} + +//============================================================================= +/*! + * StdMeshers_StartEndLength_i::SetLength + * + * Set length + */ +//============================================================================= + +void StdMeshers_StartEndLength_i::SetLength(CORBA::Double theLength, + CORBA::Boolean theIsStart ) + throw ( SALOME::SALOME_Exception ) +{ + MESSAGE( "StdMeshers_StartEndLength_i::SetLength" ); + ASSERT( myBaseImpl ); + try { + this->GetImpl()->SetLength( theLength, theIsStart ); + } + catch ( SALOME_Exception& S_ex ) { + THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), + SALOME::BAD_PARAM ); + } +} + +//============================================================================= +/*! + * StdMeshers_StartEndLength_i::GetLength + * + * Get length + */ +//============================================================================= + +CORBA::Double StdMeshers_StartEndLength_i::GetLength( CORBA::Boolean theIsStart) +{ + MESSAGE( "StdMeshers_StartEndLength_i::GetLength" ); + ASSERT( myBaseImpl ); + return this->GetImpl()->GetLength( theIsStart ); +} + +//============================================================================= +/*! + * StdMeshers_StartEndLength_i::GetImpl + * + * Get implementation + */ +//============================================================================= + +::StdMeshers_StartEndLength* StdMeshers_StartEndLength_i::GetImpl() +{ + MESSAGE( "StdMeshers_StartEndLength_i::GetImpl" ); + return ( ::StdMeshers_StartEndLength* )myBaseImpl; +} diff --git a/src/StdMeshers_I/StdMeshers_StartEndLength_i.hxx b/src/StdMeshers_I/StdMeshers_StartEndLength_i.hxx new file mode 100644 index 000000000..009032998 --- /dev/null +++ b/src/StdMeshers_I/StdMeshers_StartEndLength_i.hxx @@ -0,0 +1,67 @@ +// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : StdMeshers_StartEndLength_i.hxx +// Moved here from SMESH_LocalLength_i.hxx +// Author : Paul RASCLE, EDF +// Module : SMESH +// $Header$ + +#ifndef _SMESH_StartEndLength_I_HXX_ +#define _SMESH_StartEndLength_I_HXX_ + +#include +#include CORBA_SERVER_HEADER(SMESH_BasicHypothesis) + +#include "SMESH_Hypothesis_i.hxx" +#include "StdMeshers_StartEndLength.hxx" + +class SMESH_Gen; + +// ====================================================== +// Local Length hypothesis +// ====================================================== +class StdMeshers_StartEndLength_i: + public virtual POA_StdMeshers::StdMeshers_StartEndLength, + public virtual SMESH_Hypothesis_i +{ +public: + // Constructor + StdMeshers_StartEndLength_i(PortableServer::POA_ptr thePOA, + int theStudyId, + ::SMESH_Gen* theGenImpl ); + // Destructor + virtual ~StdMeshers_StartEndLength_i(); + + // Set length + void SetLength( CORBA::Double theLength, CORBA::Boolean theIsStart ) + throw ( SALOME::SALOME_Exception ); + // Get length + CORBA::Double GetLength(CORBA::Boolean theIsStart); + + // Get implementation + ::StdMeshers_StartEndLength* GetImpl(); +}; + +#endif + diff --git a/src/StdMeshers_I/StdMeshers_i.cxx b/src/StdMeshers_I/StdMeshers_i.cxx index c24606d6b..f045bbe72 100644 --- a/src/StdMeshers_I/StdMeshers_i.cxx +++ b/src/StdMeshers_I/StdMeshers_i.cxx @@ -31,11 +31,15 @@ using namespace std; #include "utilities.h" #include "StdMeshers_LocalLength_i.hxx" -#include "StdMeshers_LengthFromEdges_i.hxx" -#include "StdMeshers_NotConformAllowed_i.hxx" +#include "StdMeshers_StartEndLength_i.hxx" +#include "StdMeshers_Arithmetic1D_i.hxx" #include "StdMeshers_NumberOfSegments_i.hxx" +#include "StdMeshers_Deflection1D_i.hxx" +#include "StdMeshers_Propagation_i.hxx" +#include "StdMeshers_LengthFromEdges_i.hxx" #include "StdMeshers_MaxElementArea_i.hxx" #include "StdMeshers_MaxElementVolume_i.hxx" +#include "StdMeshers_NotConformAllowed_i.hxx" #include "StdMeshers_Regular_1D_i.hxx" #include "StdMeshers_MEFISTO_2D_i.hxx" @@ -65,10 +69,18 @@ extern "C" aCreator = new HypothesisCreator_i; else if (strcmp(aHypName, "NotConformAllowed") == 0) aCreator = new HypothesisCreator_i; + else if (strcmp(aHypName, "Propagation") == 0) + aCreator = new HypothesisCreator_i; else if (strcmp(aHypName, "MaxElementArea") == 0) aCreator = new HypothesisCreator_i; else if (strcmp(aHypName, "MaxElementVolume") == 0) aCreator = new HypothesisCreator_i; + else if (strcmp(aHypName, "StartEndLength") == 0) + aCreator = new HypothesisCreator_i; + else if (strcmp(aHypName, "Deflection1D") == 0) + aCreator = new HypothesisCreator_i; + else if (strcmp(aHypName, "Arithmetic1D") == 0) + aCreator = new HypothesisCreator_i; // Algorithms else if (strcmp(aHypName, "Regular_1D") == 0) -- 2.39.2