From: jfa Date: Wed, 15 Aug 2012 10:34:21 +0000 (+0000) Subject: Mantis issue 0021483: EDF 1638 GEOM: Retrieve non blocks solids and faces from a... X-Git-Tag: V6_6_0a1~48 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=8a7faf3ee59656292ab87845df7bf01032f30d26;p=modules%2Fgeom.git Mantis issue 0021483: EDF 1638 GEOM: Retrieve non blocks solids and faces from a shape. --- diff --git a/doc/salome/gui/GEOM/images/measures2.png b/doc/salome/gui/GEOM/images/measures2.png new file mode 100644 index 000000000..21e5218a4 Binary files /dev/null and b/doc/salome/gui/GEOM/images/measures2.png differ diff --git a/doc/salome/gui/GEOM/input/get_non_blocks.doc b/doc/salome/gui/GEOM/input/get_non_blocks.doc new file mode 100644 index 000000000..8df0e324c --- /dev/null +++ b/doc/salome/gui/GEOM/input/get_non_blocks.doc @@ -0,0 +1,23 @@ +/*! + +\page get_non_blocks_page Get Non Blocks + +\image html measures2.png + +Retrieve all non blocks solids and faces from the given shape. +Collect them in two groups: solids and faces separately. + +\n Result: Two or less groups are published in the Object + Browser under the processed object. Reports error if + no bad sub-shapes (solids and faces) have been found. + +\n TUI Command: +geompy.GetNonBlocks(Compound). Returns a tuple of two + GEOM_Objects. The first object is a group of all non block solids + (= not 6 faces, or with 6 faces, but with the presence of + non-quadrangular faces). The second object is a group of all non + quadrangular faces. + +See also a \ref tui_get_non_blocks_page "TUI example". + +*/ diff --git a/doc/salome/gui/GEOM/input/tui_get_non_blocks.doc b/doc/salome/gui/GEOM/input/tui_get_non_blocks.doc new file mode 100644 index 000000000..6f648f9a0 --- /dev/null +++ b/doc/salome/gui/GEOM/input/tui_get_non_blocks.doc @@ -0,0 +1,32 @@ +/*! + +\page tui_get_non_blocks_page Get Non Blocks + +\code +import geompy +import salome + +# create solids +box = geompy.MakeBoxDXDYDZ(100, 100, 100) +cyl = geompy.MakeCylinderRH(100, 200) + +geompy.addToStudy(box, 'box') +geompy.addToStudy(cyl, 'cyl') + +# make a compound +compound = geompy.MakeCompound([box1, box2]) +geompy.addToStudy(compound, 'compound') + +# explore the compound +pair = geompy.GetNonBlocks(compound) + +if pair[0] is not None: + geompy.addToStudyInFather(compound, pair[0], "GrNonBlocks") + pass + +if pair[1] is not None: + geompy.addToStudyInFather(compound, pair[1], "GrNonQuads") + pass +\endcode + +*/ diff --git a/doc/salome/gui/GEOM/input/tui_measurement_tools.doc b/doc/salome/gui/GEOM/input/tui_measurement_tools.doc index 4ce9b4239..583f3de0f 100644 --- a/doc/salome/gui/GEOM/input/tui_measurement_tools.doc +++ b/doc/salome/gui/GEOM/input/tui_measurement_tools.doc @@ -17,6 +17,7 @@
  • \subpage tui_free_faces_page
  • \subpage tui_check_shape_page
  • \subpage tui_check_compound_of_blocks_page
  • +
  • \subpage tui_get_non_blocks_page
  • \subpage tui_check_self_intersections_page
  • diff --git a/doc/salome/gui/GEOM/input/tui_test_spanner.doc b/doc/salome/gui/GEOM/input/tui_test_spanner.doc index 5c9df4651..81b212de6 100644 --- a/doc/salome/gui/GEOM/input/tui_test_spanner.doc +++ b/doc/salome/gui/GEOM/input/tui_test_spanner.doc @@ -35,6 +35,11 @@ \anchor swig_GetOppositeFace \until id_face41 +\until id_glueALL + +\anchor swig_GetNonBlocks +\until Spanner is a + \anchor spanner_continue \until return Spanner diff --git a/doc/salome/gui/GEOM/input/using_measurement_tools.doc b/doc/salome/gui/GEOM/input/using_measurement_tools.doc index 7e18a1ddf..513f6077f 100644 --- a/doc/salome/gui/GEOM/input/using_measurement_tools.doc +++ b/doc/salome/gui/GEOM/input/using_measurement_tools.doc @@ -25,6 +25,7 @@ concerning created or imported geometrical objects :
  • \subpage free_faces_page "Check Free Faces"
  • \subpage check_shape_page "Check Shape"
  • \subpage check_compound_of_blocks_page "Check compound of blocks"
  • +
  • \subpage get_non_blocks_page "Get non blocks"
  • \subpage check_self_intersections_page "Detect Self-intersections"
  • @@ -32,4 +33,4 @@ concerning created or imported geometrical objects : \ref tui_measurement_tools_page "Measurement Tools" with TUI commands. -*/ \ No newline at end of file +*/ diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index f3a41ad16..209ac2bd3 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -2403,6 +2403,17 @@ module GEOM string PrintBCErrors (in GEOM_Object theCompound, in BCErrors theErrors); + /*! + * \brief Retrieve all non blocks solids and faces from a shape. + * + * \param theShape The shape to explore. + * \param theNonQuads Output parameter. Group of all non quadrangular faces. + * + * \return Group of all non block solids (= not 6 faces, or with 6 + * faces, but with the presence of non-quadrangular faces). + */ + GEOM_Object GetNonBlocks (in GEOM_Object theShape, out GEOM_Object theNonQuads); + /*! * \brief Remove all seam and degenerated edges from \a theShape. * diff --git a/resources/Makefile.am b/resources/Makefile.am index d5aab779c..57c92dd2d 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -232,6 +232,7 @@ group_new.png \ group_edit.png \ glue.png \ check_blocks_compound.png \ +get_non_blocks.png \ check_self_intersections.png \ free_faces.png \ propagate.png \ diff --git a/resources/get_non_blocks.png b/resources/get_non_blocks.png new file mode 100644 index 000000000..b13b294f2 Binary files /dev/null and b/resources/get_non_blocks.png differ diff --git a/src/GEOMGUI/GEOM_images.ts b/src/GEOMGUI/GEOM_images.ts index d15ade1d2..d9459fdc2 100644 --- a/src/GEOMGUI/GEOM_images.ts +++ b/src/GEOMGUI/GEOM_images.ts @@ -167,6 +167,10 @@ ICON_DLG_CHECK_COMPOUND_OF_BLOCKS check_blocks_compound.png + + ICON_DLG_GETNONBLOCKS + get_non_blocks.png + ICON_DLG_CHECK_SELF_INTERSECTIONS check_self_intersections.png @@ -739,6 +743,10 @@ ICO_CHECK_COMPOUND check_blocks_compound.png + + ICO_GET_NON_BLOCKS + get_non_blocks.png + ICO_CHECK_SELF_INTERSECTIONS check_self_intersections.png diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index cf4c13db2..4f503aae2 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -357,6 +357,18 @@ Please, select face, shell or solid and try again GEOM_CHECK_BLOCKS_COMPOUND_SUBSHAPES Incriminated Sub-shapes + + GEOM_GETNONBLOCKS_TITLE + Get non-hexahedral solids and non-quadrangular faces + + + GEOM_GETNONBLOCKS + Get non blocks + + + GEOM_NONBLOCKS + NonBlocksGroup + GEOM_CHECK_INFOS Object And Its Topological Information @@ -2310,6 +2322,10 @@ Please, select face, shell or solid and try again MEN_CHECK_COMPOUND Check Compound of Blocks + + MEN_GET_NON_BLOCKS + Get Non Blocks + MEN_CHECK_SELF_INTERSECTIONS Detect Self-intersections @@ -3154,6 +3170,10 @@ Please, select face, shell or solid and try again STB_CHECK_COMPOUND Check compound of blocks + + STB_GET_NON_BLOCKS + Get non blocks + STB_CHECK_SELF_INTERSECTIONS Detect Self-intersections @@ -3762,6 +3782,10 @@ Please, select face, shell or solid and try again TOP_CHECK_COMPOUND Check compound of blocks + + TOP_GET_NON_BLOCKS + Get non blocks + TOP_CHECK_SELF_INTERSECTIONS Detect Self-intersections diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 23694246d..6ae6b95e6 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -549,6 +549,7 @@ void GeometryGUI::OnGUIEvent( int id ) case GEOMOp::OpWhatIs: // MENU MEASURE - WHATIS case GEOMOp::OpCheckShape: // MENU MEASURE - CHECK case GEOMOp::OpCheckCompound: // MENU MEASURE - CHECK COMPOUND OF BLOCKS + case GEOMOp::OpGetNonBlocks: // MENU MEASURE - Get NON BLOCKS case GEOMOp::OpPointCoordinates: // MENU MEASURE - POINT COORDINATES case GEOMOp::OpCheckSelfInters: // MENU MEASURE - CHECK SELF INTERSECTIONS libName = "MeasureGUI"; @@ -829,6 +830,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( GEOMOp::OpWhatIs, "WHAT_IS" ); createGeomAction( GEOMOp::OpCheckShape, "CHECK" ); createGeomAction( GEOMOp::OpCheckCompound, "CHECK_COMPOUND" ); + createGeomAction( GEOMOp::OpGetNonBlocks, "GET_NON_BLOCKS" ); createGeomAction( GEOMOp::OpCheckSelfInters, "CHECK_SELF_INTERSECTIONS" ); #ifdef _DEBUG_ // PAL16821 @@ -1059,6 +1061,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createMenu( GEOMOp::OpWhatIs, measurId, -1 ); createMenu( GEOMOp::OpCheckShape, measurId, -1 ); createMenu( GEOMOp::OpCheckCompound, measurId, -1 ); + createMenu( GEOMOp::OpGetNonBlocks, measurId, -1 ); createMenu( GEOMOp::OpCheckSelfInters, measurId, -1 ); #ifdef _DEBUG_ // PAL16821 @@ -1196,6 +1199,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createTool( GEOMOp::OpWhatIs, measureTbId ); createTool( GEOMOp::OpCheckShape, measureTbId ); createTool( GEOMOp::OpCheckCompound, measureTbId ); + createTool( GEOMOp::OpGetNonBlocks, measureTbId ); createTool( GEOMOp::OpCheckSelfInters, measureTbId ); int picturesTbId = createTool( tr( "TOOL_PICTURES" ) ); diff --git a/src/GEOMGUI/GeometryGUI_Operations.h b/src/GEOMGUI/GeometryGUI_Operations.h index 3d8a41d4e..9cb259b5d 100644 --- a/src/GEOMGUI/GeometryGUI_Operations.h +++ b/src/GEOMGUI/GeometryGUI_Operations.h @@ -24,7 +24,7 @@ namespace GEOMOp { enum { - // ToolsGUI ------------------//-------------------------------- + // ToolsGUI --------------------//-------------------------------- OpImport = 1000, // MENU FILE - IMPORT OpExport = 1001, // MENU FILE - EXPORT OpDelete = 1020, // MENU EDIT - DELETE @@ -57,7 +57,7 @@ namespace GEOMOp { OpEdgeWidth = 1260, // POPUP MENU - LINE WIDTH - EDGE WIDTH OpIsosWidth = 1261, // POPUP MENU - LINE WIDTH - ISOS WIDTH - // DisplayGUI ----------------//-------------------------------- + // DisplayGUI ------------------//-------------------------------- OpSwitchVectors = 2001, // MENU VIEW - DISPLAY MODE - SHOW/HIDE EDGE DIRECTION OpShowAll = 2002, // MENU VIEW - SHOW ALL OpHideAll = 2003, // MENU VIEW - HIDE ALL @@ -74,7 +74,7 @@ namespace GEOMOp { OpTexture = 2204, // POPUP MENU - DISPLAY MODE - TEXTURE OpBringToFront = 2205, // POPUP MENU - BRING TO FRONT OpClsBringToFront = 2206, - // BasicGUI ------------------//-------------------------------- + // BasicGUI --------------------//-------------------------------- OpPoint = 3000, // MENU NEW ENTITY - BASIC - POINT OpLine = 3001, // MENU NEW ENTITY - BASIC - LINE OpCircle = 3002, // MENU NEW ENTITY - BASIC - CIRCLE @@ -85,7 +85,7 @@ namespace GEOMOp { OpCurve = 3007, // MENU NEW ENTITY - BASIC - CURVE OpLCS = 3008, // MENU NEW ENTITY - BASIC - LOCAL COORDINATE SYSTEM OpOriginAndVectors = 3009, // MENU NEW ENTITY - BASIC - ORIGIN AND BASE VECTORS - // PrimitiveGUI --------------//-------------------------------- + // PrimitiveGUI ----------------//-------------------------------- OpBox = 3100, // MENU NEW ENTITY - PRIMITIVES - BOX OpCylinder = 3101, // MENU NEW ENTITY - PRIMITIVES - CYLINDER OpSphere = 3102, // MENU NEW ENTITY - PRIMITIVES - SPHERE @@ -93,12 +93,12 @@ namespace GEOMOp { OpCone = 3104, // MENU NEW ENTITY - PRIMITIVES - CONE OpRectangle = 3105, // MENU NEW ENTITY - PRIMITIVES - FACE OpDisk = 3106, // MENU NEW ENTITY - PRIMITIVES - DISK - // GenerationGUI -------------//-------------------------------- + // GenerationGUI ---------------//-------------------------------- OpPrism = 3200, // MENU NEW ENTITY - GENERATION - EXTRUSION OpRevolution = 3201, // MENU NEW ENTITY - GENERATION - REVOLUTION OpFilling = 3202, // MENU NEW ENTITY - GENERATION - FILLING OpPipe = 3203, // MENU NEW ENTITY - GENERATION - EXTRUSION ALONG PATH - // EntityGUI -----------------//-------------------------------- + // EntityGUI -------------------//-------------------------------- Op2dSketcher = 3300, // MENU NEW ENTITY - SKETCHER Op3dSketcher = 3301, // MENU NEW ENTITY - 3D SKETCHER OpExplode = 3302, // MENU NEW ENTITY - EXPLODE @@ -106,20 +106,19 @@ namespace GEOMOp { OpFeatureDetect = 3303, // MENU NEW ENTITY - FEATURE DETECTION #endif OpPictureImport = 3304, // MENU NEW ENTITY - IMPORT PICTURE IN VIEWER - - // BuildGUI ------------------//-------------------------------- + // BuildGUI --------------------//-------------------------------- OpEdge = 3400, // MENU NEW ENTITY - BUILD - EDGE OpWire = 3401, // MENU NEW ENTITY - BUILD - WIRE OpFace = 3402, // MENU NEW ENTITY - BUILD - FACE OpShell = 3403, // MENU NEW ENTITY - BUILD - SHELL OpSolid = 3404, // MENU NEW ENTITY - BUILD - SOLID OpCompound = 3405, // MENU NEW ENTITY - BUILD - COMPOUND - // BooleanGUI ----------------//-------------------------------- + // BooleanGUI ------------------//-------------------------------- OpFuse = 3500, // MENU OPERATIONS - BOOLEAN - FUSE OpCommon = 3501, // MENU OPERATIONS - BOOLEAN - COMMON OpCut = 3502, // MENU OPERATIONS - BOOLEAN - CUT OpSection = 3503, // MENU OPERATIONS - BOOLEAN - SECTION - // TransformationGUI ---------//-------------------------------- + // TransformationGUI -----------//-------------------------------- OpTranslate = 3600, // MENU OPERATIONS - TRANSFORMATION - TRANSLATION OpRotate = 3601, // MENU OPERATIONS - TRANSFORMATION - ROTATION OpChangeLoc = 3602, // MENU OPERATIONS - TRANSFORMATION - LOCATION @@ -130,7 +129,7 @@ namespace GEOMOp { OpMultiRotate = 3607, // MENU OPERATIONS - TRANSFORMATION - MULTI-ROTATION OpReimport = 3608, // POPUP MENU - RELOAD IMPORTED OpProjection = 3609, // MENU OPERATIONS - TRANSFORMATION - PROJECTION - // OperationGUI + // OperationGUI ----------------//-------------------------------- OpPartition = 3700, // MENU OPERATION - PARTITION OpArchimede = 3701, // MENU OPERATION - ARCHIMEDE OpFillet3d = 3702, // MENU OPERATION - FILLET @@ -142,7 +141,7 @@ namespace GEOMOp { OpSharedShapes = 3708, // MENU OPERATION - GET SHARED SHAPES OpExtrudedBoss = 3709, // MENU OPERATION - ETRUDED BOSS OpExtrudedCut = 3710, // MENU OPERATION - ETRUDED CUT - // RepairGUI -----------------//-------------------------------- + // RepairGUI -------------------//-------------------------------- OpSewing = 4000, // MENU REPAIR - SEWING OpSuppressFaces = 4001, // MENU REPAIR - SUPPRESS FACES OpSuppressHoles = 4002, // MENU REPAIR - SUPPRESS HOLES @@ -158,7 +157,7 @@ namespace GEOMOp { OpLimitTolerance = 4012, // MENU REPAIR - LIMIT TOLERANCE OpGlueEdges = 4013, // MENU REPAIR - GLUE EDGES OpFuseEdges = 4014, // MENU REPAIR - FUSE COLLINEAR EDGES - // MeasureGUI ----------------//-------------------------------- + // MeasureGUI ------------------//-------------------------------- OpProperties = 5000, // MENU MEASURES - PROPERTIES OpCenterMass = 5001, // MENU MEASURES - CENTRE OF MASS OpInertia = 5002, // MENU MEASURES - INERTIA @@ -172,22 +171,23 @@ namespace GEOMOp { OpCheckCompound = 5010, // MENU MEASURES - CHECK COMPOUND OF BLOCKS OpPointCoordinates = 5011, // MENU MEASURES - POINT COORDINATES OpCheckSelfInters = 5012, // MENU MEASURES - CHECK SELF INTERSECTIONS - // GroupGUI ------------------//-------------------------------- + OpGetNonBlocks = 5013, // MENU MEASURES - GET NON BLOCKS + // GroupGUI --------------------//-------------------------------- OpGroupCreate = 6000, // MENU GROUP - CREATE OpGroupEdit = 6001, // MENU GROUP - EDIT OpGroupCreatePopup = 6002, // POPUP MENU - CREATE GROUP - // BlocksGUI -----------------//-------------------------------- + // BlocksGUI -------------------//-------------------------------- OpHexaSolid = 6100, // MENU BLOCKS - HEXAHEDRAL SOLID OpMultiTransform = 6101, // MENU BLOCKS - MULTI-TRANSFORMATION OpQuadFace = 6102, // MENU BLOCKS - QUADRANGLE FACE OpPropagate = 6103, // MENU BLOCKS - PROPAGATE OpExplodeBlock = 6104, // MENU BLOCKS - EXPLODE ON BLOCKS - // AdvancedGUI ---------------//-------------------------------- + // AdvancedGUI -----------------//-------------------------------- OpAdvancedNoOp = 10000, // NO OPERATION (advanced operations base) OpPipeTShape = 10001, // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE -// OpPipeTShapeGroups = 10002, // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS - OpDividedDisk = 10003, // MENU NEW ENTITY - ADVANCED - DIVIDEDDISK - OpDividedCylinder = 10004, // MENU NEW ENTITY - ADVANCED - DIVIDEDCYLINDER + //OpPipeTShapeGroups = 10002, // MENU NEW ENTITY - ADVANCED - PIPE TSHAPE GROUPS + OpDividedDisk = 10003, // MENU NEW ENTITY - ADVANCED - DIVIDEDDISK + OpDividedCylinder = 10004, // MENU NEW ENTITY - ADVANCED - DIVIDEDCYLINDER //@@ insert new functions before this line @@ do not remove this line @@// }; } diff --git a/src/GEOMImpl/GEOMImpl_BlockDriver.cxx b/src/GEOMImpl/GEOMImpl_BlockDriver.cxx index 95c2dbf08..d50d24858 100644 --- a/src/GEOMImpl/GEOMImpl_BlockDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_BlockDriver.cxx @@ -600,7 +600,8 @@ Standard_Integer GEOMImpl_BlockDriver::Execute(TFunction_Logbook& log) const TopTools_ListOfShape BLO; // All blocks from the given compound TopTools_ListOfShape NOT; // Not blocks TopTools_ListOfShape EXT; // Hexahedral solids, having degenerated and/or seam edges - GEOMImpl_IBlocksOperations::AddBlocksFrom(aFixedExtra, BLO, NOT, EXT); + TopTools_ListOfShape NOQ; // All non-quadrangular faces + GEOMImpl_IBlocksOperations::AddBlocksFrom(aFixedExtra, BLO, NOT, EXT, NOQ); if (NOT.Extent() > 0) { MESSAGE("Some non-blocks have been removed"); diff --git a/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx b/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx index 42aaa4260..efb69f42c 100644 --- a/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IBlocksOperations.cxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #ifdef WNT #pragma warning( disable:4786 ) @@ -1735,7 +1734,8 @@ Standard_Boolean GEOMImpl_IBlocksOperations::IsCompoundOfBlocks void GEOMImpl_IBlocksOperations::AddBlocksFrom (const TopoDS_Shape& theShape, TopTools_ListOfShape& BLO, TopTools_ListOfShape& NOT, - TopTools_ListOfShape& EXT) + TopTools_ListOfShape& EXT, + TopTools_ListOfShape& NOQ) { TopAbs_ShapeEnum aType = theShape.ShapeType(); switch (aType) { @@ -1744,7 +1744,7 @@ void GEOMImpl_IBlocksOperations::AddBlocksFrom (const TopoDS_Shape& theShape, { TopoDS_Iterator It (theShape); for (; It.More(); It.Next()) { - AddBlocksFrom(It.Value(), BLO, NOT, EXT); + AddBlocksFrom(It.Value(), BLO, NOT, EXT, NOQ); } } break; @@ -1766,7 +1766,7 @@ void GEOMImpl_IBlocksOperations::AddBlocksFrom (const TopoDS_Shape& theShape, for (; expF.More(); expF.Next()) { if (mapFaces.Add(expF.Current())) { nbFaces++; - if (nbFaces > 6) break; + //0021483//if (nbFaces > 6) break; // get wire TopoDS_Shape aF = expF.Current(); @@ -1774,14 +1774,18 @@ void GEOMImpl_IBlocksOperations::AddBlocksFrom (const TopoDS_Shape& theShape, if (!wires.More()) { // no wire in the face hasNonQuadr = Standard_True; - break; + NOQ.Append(aF);//0021483 + //0021483//break; + continue; } TopoDS_Shape aWire = wires.Current(); wires.Next(); if (wires.More()) { // multiple wires in the face hasNonQuadr = Standard_True; - break; + NOQ.Append(aF);//0021483 + //0021483//break; + continue; } // Check number of edges in the face @@ -1796,6 +1800,7 @@ void GEOMImpl_IBlocksOperations::AddBlocksFrom (const TopoDS_Shape& theShape, } if (nbEdges != 4) { hasNonQuadr = Standard_True; + NOQ.Append(aF);//0021483 } } } @@ -1808,6 +1813,47 @@ void GEOMImpl_IBlocksOperations::AddBlocksFrom (const TopoDS_Shape& theShape, } } break; + case TopAbs_SHELL: //0021483 + case TopAbs_FACE: //0021483 + { + // Count edges in each face + TopTools_MapOfShape mapFaces; + TopExp_Explorer expF (theShape, TopAbs_FACE); + for (; expF.More(); expF.Next()) { + if (mapFaces.Add(expF.Current())) { + // get wire + TopoDS_Shape aF = expF.Current(); + TopExp_Explorer wires (aF, TopAbs_WIRE); + if (!wires.More()) { + // no wire in the face + NOQ.Append(aF);//0021483 + continue; + } + TopoDS_Shape aWire = wires.Current(); + wires.Next(); + if (wires.More()) { + // multiple wires in the face + NOQ.Append(aF);//0021483 + continue; + } + + // Check number of edges in the face + Standard_Integer nbEdges = 0; + TopTools_MapOfShape mapEdges; + TopExp_Explorer expW (aWire, TopAbs_EDGE); + for (; expW.More(); expW.Next()) { + if (mapEdges.Add(expW.Current())) { + nbEdges++; + if (nbEdges > 4) break; + } + } + if (nbEdges != 4) { + NOQ.Append(aF);//0021483 + } + } + } + } + break; default: NOT.Append(theShape); } @@ -2353,7 +2399,8 @@ Standard_Boolean GEOMImpl_IBlocksOperations::CheckCompoundOfBlocks TopTools_ListOfShape NOT; // Not blocks TopTools_ListOfShape EXT; // Hexahedral solids, having degenerated and/or seam edges TopTools_ListOfShape BLO; // All blocks from the given compound - AddBlocksFrom(aBlockOrComp, BLO, NOT, EXT); + TopTools_ListOfShape NOQ; // All non-quadrangular faces + AddBlocksFrom(aBlockOrComp, BLO, NOT, EXT, NOQ); // Report non-blocks if (NOT.Extent() > 0) { @@ -2513,6 +2560,100 @@ Standard_Boolean GEOMImpl_IBlocksOperations::CheckCompoundOfBlocks return isCompOfBlocks; } +//============================================================================= +/*! + * GetNonBlocks + */ +//============================================================================= +Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetNonBlocks + (Handle(GEOM_Object) theShape, + Handle(GEOM_Object)& theNonQuads) +{ + SetErrorCode(KO); + + if (theShape.IsNull()) return NULL; + TopoDS_Shape aShape = theShape->GetValue(); + + // Separate blocks from non-blocks + TopTools_ListOfShape BLO; // All blocks from the given compound + TopTools_ListOfShape NOT; // Not blocks + TopTools_ListOfShape EXT; // Hexahedral solids, having degenerated and/or seam edges + TopTools_ListOfShape NOQ; // All non-quadrangular faces + AddBlocksFrom(aShape, BLO, NOT, EXT, NOQ); + + if (NOT.IsEmpty() && EXT.IsEmpty() && NOQ.IsEmpty()) { + SetErrorCode("NOT_FOUND_ANY"); + return NULL; + } + + // Map sub-shapes and their indices + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aShape, anIndices); + + // Non-blocks + Handle(GEOM_Object) aNonBlocks; + if (NOT.Extent() > 0 || EXT.Extent() > 0) { + Handle(TColStd_HArray1OfInteger) anArray = + new TColStd_HArray1OfInteger (1, NOT.Extent() + EXT.Extent()); + Standard_Integer ii = 1; + TopTools_ListIteratorOfListOfShape it1 (NOT); + for (; it1.More(); it1.Next(), ii++) { + anArray->SetValue(ii, anIndices.FindIndex(it1.Value())); + } + TopTools_ListIteratorOfListOfShape it2 (EXT); + for (; it2.More(); it2.Next(), ii++) { + anArray->SetValue(ii, anIndices.FindIndex(it2.Value())); + } + + aNonBlocks = GetEngine()->AddSubShape(theShape, anArray); + if (aNonBlocks.IsNull()) { + SetErrorCode("Error in algorithm: result found, but cannot be returned."); + return NULL; + } + aNonBlocks->SetType(GEOM_GROUP); + TDF_Label aFreeLabel = aNonBlocks->GetFreeLabel(); + TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)TopAbs_SOLID); + } + + // Non-quadrangles + if (NOQ.Extent() > 0) { + Handle(TColStd_HArray1OfInteger) anArray = + new TColStd_HArray1OfInteger (1, NOQ.Extent()); + Standard_Integer ii = 1; + TopTools_ListIteratorOfListOfShape it1 (NOQ); + for (; it1.More(); it1.Next(), ii++) { + anArray->SetValue(ii, anIndices.FindIndex(it1.Value())); + } + + theNonQuads = GetEngine()->AddSubShape(theShape, anArray); + if (theNonQuads.IsNull()) { + SetErrorCode("Error in algorithm: result found, but cannot be returned."); + return NULL; + } + theNonQuads->SetType(GEOM_GROUP); + TDF_Label aFreeLabel = theNonQuads->GetFreeLabel(); + TDataStd_Integer::Set(aFreeLabel, (Standard_Integer)TopAbs_FACE); + } + + //Make a Python command + Handle(GEOM_Function) aMainShape = theShape->GetLastFunction(); + GEOM::TPythonDump pd (aMainShape, /*append=*/true); + pd << "("; + if (aNonBlocks.IsNull()) + pd << "no_bad_solids"; + else + pd << aNonBlocks; + pd << ", "; + if (theNonQuads.IsNull()) + pd << "no_bad_faces"; + else + pd << theNonQuads; + pd << ") = geompy.GetNonBlocks(" << theShape << ")"; + + SetErrorCode(OK); + return aNonBlocks; +} + //============================================================================= /*! * RemoveExtraEdges diff --git a/src/GEOMImpl/GEOMImpl_IBlocksOperations.hxx b/src/GEOMImpl/GEOMImpl_IBlocksOperations.hxx index f702da402..8a34d5510 100644 --- a/src/GEOMImpl/GEOMImpl_IBlocksOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IBlocksOperations.hxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #ifndef _GEOMImpl_IBlocksOperations_HXX_ #define _GEOMImpl_IBlocksOperations_HXX_ @@ -126,14 +125,17 @@ class GEOMImpl_IBlocksOperations : public GEOM_IOperations { }; Standard_EXPORT Standard_Boolean CheckCompoundOfBlocksOld (Handle(GEOM_Object) theCompound, - std::list& theErrors); + std::list& theErrors); Standard_EXPORT Standard_Boolean CheckCompoundOfBlocks (Handle(GEOM_Object) theCompound, - std::list& theErrors); + std::list& theErrors); - Standard_EXPORT TCollection_AsciiString PrintBCErrors (Handle(GEOM_Object) theCompound, + Standard_EXPORT TCollection_AsciiString PrintBCErrors (Handle(GEOM_Object) theCompound, const std::list& theErrors); + Standard_EXPORT Handle(GEOM_Object) GetNonBlocks (Handle(GEOM_Object) theShape, + Handle(GEOM_Object)& theNonQuads); + Standard_EXPORT Handle(GEOM_Object) RemoveExtraEdges (Handle(GEOM_Object) theShape, const Standard_Integer theOptimumNbFaces = 6); @@ -142,7 +144,8 @@ class GEOMImpl_IBlocksOperations : public GEOM_IOperations { Standard_EXPORT static void AddBlocksFrom (const TopoDS_Shape& theShape, TopTools_ListOfShape& BLO, TopTools_ListOfShape& NOT, - TopTools_ListOfShape& EXT); + TopTools_ListOfShape& EXT, + TopTools_ListOfShape& NOQ); // Extract blocks from blocks compounds Standard_EXPORT Handle(TColStd_HSequenceOfTransient) ExplodeCompoundOfBlocks diff --git a/src/GEOM_I/GEOM_IBlocksOperations_i.cc b/src/GEOM_I/GEOM_IBlocksOperations_i.cc index 0c1917d46..c71432528 100644 --- a/src/GEOM_I/GEOM_IBlocksOperations_i.cc +++ b/src/GEOM_I/GEOM_IBlocksOperations_i.cc @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #include @@ -742,6 +741,39 @@ char* GEOM_IBlocksOperations_i::PrintBCErrors return CORBA::string_dup(aDescr.ToCString()); } +//============================================================================= +/*! + * GetNonBlocks + */ +//============================================================================= +GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetNonBlocks + (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_out theNonQuads) +{ + GEOM::GEOM_Object_var aGEOMObject; + GEOM::GEOM_Object_var aNonQuads; + + theNonQuads = aNonQuads._retn(); + + //Set a not done flag + GetOperations()->SetNotDone(); + + //Get the reference Objects + Handle(GEOM_Object) aShape = GetObjectImpl(theShape); + if (aShape.IsNull()) return aGEOMObject._retn(); + + //Get the result + Handle(GEOM_Object) aFaces; + Handle(GEOM_Object) anObject = GetOperations()->GetNonBlocks(aShape, aFaces); + if (!GetOperations()->IsDone() || anObject.IsNull()) + return aGEOMObject._retn(); + + if (!aFaces.IsNull()) + theNonQuads = GetObject(aFaces); + + return GetObject(anObject); +} + //============================================================================= /*! * RemoveExtraEdges diff --git a/src/GEOM_I/GEOM_IBlocksOperations_i.hh b/src/GEOM_I/GEOM_IBlocksOperations_i.hh index a801a1e7e..6f5765092 100644 --- a/src/GEOM_I/GEOM_IBlocksOperations_i.hh +++ b/src/GEOM_I/GEOM_IBlocksOperations_i.hh @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// #ifndef _GEOM_IBlocksOperations_i_HeaderFile #define _GEOM_IBlocksOperations_i_HeaderFile @@ -121,6 +120,9 @@ class GEOM_I_EXPORT GEOM_IBlocksOperations_i : char* PrintBCErrors (GEOM::GEOM_Object_ptr theCompound, const GEOM::GEOM_IBlocksOperations::BCErrors& theErrors); + GEOM::GEOM_Object_ptr GetNonBlocks (GEOM::GEOM_Object_ptr theShape, + GEOM::GEOM_Object_out theNonQuads); + GEOM::GEOM_Object_ptr RemoveExtraEdges (GEOM::GEOM_Object_ptr theShape, CORBA::Long theOptimumNbFaces); diff --git a/src/GEOM_SWIG/GEOM_Spanner.py b/src/GEOM_SWIG/GEOM_Spanner.py index 05c23aed6..7c17db76a 100644 --- a/src/GEOM_SWIG/GEOM_Spanner.py +++ b/src/GEOM_SWIG/GEOM_Spanner.py @@ -20,18 +20,17 @@ # # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # - # GEOM GEOM_SWIG : binding of C++ implementaion with Python # File : GEOM_Spanner.py # Author : Julia DOROVSKIKH # Module : GEOM -# $Header$ +# # ! Please, if you edit this example file, update also # ! GEOM_SRC/doc/salome/gui/GEOM/input/tui_test_spanner.doc # ! as some sequences of symbols from this example are used during # ! documentation generation to identify certain places of this file -############# MakeSpanner ############# # +############# MakeSpanner ############# def MakeSpanner (geompy, math, isBlocksTest = 0, isMeshTest = 0, smesh = None): ### Variables ### @@ -304,6 +303,11 @@ def MakeSpanner (geompy, math, isBlocksTest = 0, isMeshTest = 0, smesh = None): isCompOfBlocks6 = BlocksOp.CheckCompoundOfBlocks(Spanner) if isCompOfBlocks6 == 0: print "Spanner is not a compound of hexahedral solids" + (NonBlocks, NonQuads) = geompy.GetNonBlocks(Spanner) + if NonBlocks is not None: + geompy.addToStudyInFather(Spanner, NonBlocks, "Group of non-hexahedral solids") + if NonQuads is not None: + geompy.addToStudyInFather(Spanner, NonQuads, "Group of non-quadrangular faces") else: print "Spanner is a compound of hexahedral solids" diff --git a/src/GEOM_SWIG/GEOM_TestOthers.py b/src/GEOM_SWIG/GEOM_TestOthers.py index 8e65788e2..73d91287d 100644 --- a/src/GEOM_SWIG/GEOM_TestOthers.py +++ b/src/GEOM_SWIG/GEOM_TestOthers.py @@ -243,6 +243,11 @@ def TestOtherOperations (geompy, math): IsValid = geompy.CheckCompoundOfBlocks(Compound1) if IsValid == 0: print "The Blocks Compound is NOT VALID" + (NonBlocks, NonQuads) = geompy.GetNonBlocks(Compound1) + if NonBlocks is not None: + geompy.addToStudyInFather(Compound1, NonBlocks, "Group of non-hexahedral solids") + if NonQuads is not None: + geompy.addToStudyInFather(Compound1, NonQuads, "Group of non-quadrangular faces") else: print "The Blocks Compound is VALID" diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index ca34d8893..b7e5a4a92 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -7774,6 +7774,36 @@ class geompyDC(GEOM._objref_GEOM_Gen): print Descr return IsValid + ## Retrieve all non blocks solids and faces from \a theShape. + # @param theShape The shape to explore. + # @return A tuple of two GEOM_Objects. The first object is a group of all + # non block solids (= not 6 faces, or with 6 faces, but with the + # presence of non-quadrangular faces). The second object is a + # group of all non quadrangular faces. + # + # @ref tui_measurement_tools_page "Example 1" + # \n @ref swig_GetNonBlocks "Example 2" + def GetNonBlocks (self, theShape): + """ + Retrieve all non blocks solids and faces from theShape. + + Parameters: + theShape The shape to explore. + + Returns: + A tuple of two GEOM_Objects. The first object is a group of all + non block solids (= not 6 faces, or with 6 faces, but with the + presence of non-quadrangular faces). The second object is a + group of all non quadrangular faces. + + Usage: + (res_sols, res_faces) = geompy.GetNonBlocks(myShape1) + """ + # Example: see GEOM_Spanner.py + aTuple = self.BlocksOp.GetNonBlocks(theShape) + RaiseIfFailed("GetNonBlocks", self.BlocksOp) + return aTuple + ## Remove all seam and degenerated edges from \a theShape. # Unite faces and edges, sharing one surface. It means that # this faces must have references to one C++ surface object (handle). diff --git a/src/MeasureGUI/Makefile.am b/src/MeasureGUI/Makefile.am index 8b0541a9a..55cfcf7a5 100644 --- a/src/MeasureGUI/Makefile.am +++ b/src/MeasureGUI/Makefile.am @@ -40,6 +40,7 @@ salomeinclude_HEADERS = \ MeasureGUI_WhatisDlg.h \ MeasureGUI_CheckShapeDlg.h \ MeasureGUI_CheckCompoundOfBlocksDlg.h \ + MeasureGUI_GetNonBlocksDlg.h \ MeasureGUI_CheckSelfIntersectionsDlg.h \ MeasureGUI_PointDlg.h @@ -61,6 +62,7 @@ dist_libMeasureGUI_la_SOURCES = \ MeasureGUI_WhatisDlg.cxx \ MeasureGUI_CheckShapeDlg.cxx \ MeasureGUI_CheckCompoundOfBlocksDlg.cxx \ + MeasureGUI_GetNonBlocksDlg.cxx \ MeasureGUI_CheckSelfIntersectionsDlg.cxx \ MeasureGUI_PointDlg.cxx @@ -78,6 +80,7 @@ MOC_FILES = \ MeasureGUI_WhatisDlg_moc.cxx \ MeasureGUI_CheckShapeDlg_moc.cxx \ MeasureGUI_CheckCompoundOfBlocksDlg_moc.cxx \ + MeasureGUI_GetNonBlocksDlg_moc.cxx \ MeasureGUI_CheckSelfIntersectionsDlg_moc.cxx \ MeasureGUI_PointDlg_moc.cxx @@ -122,4 +125,3 @@ libMeasureGUI_la_CPPFLAGS = \ libMeasureGUI_la_LDFLAGS = \ $(CAS_LDFLAGS) -lTKGeomBase \ ../GEOMBase/libGEOMBase.la ../DlgRef/libDlgRef.la - diff --git a/src/MeasureGUI/MeasureGUI.cxx b/src/MeasureGUI/MeasureGUI.cxx index e1ddbfcff..f31cf7161 100644 --- a/src/MeasureGUI/MeasureGUI.cxx +++ b/src/MeasureGUI/MeasureGUI.cxx @@ -18,7 +18,6 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -// // GEOM GEOMGUI : GUI for Geometry component // File : MeasureGUI.cxx @@ -42,6 +41,7 @@ #include "MeasureGUI_WhatisDlg.h" // Method WHATIS #include "MeasureGUI_CheckShapeDlg.h" // Method CHECKSHAPE #include "MeasureGUI_CheckCompoundOfBlocksDlg.h" // Method CHECKCOMPOUND +#include "MeasureGUI_GetNonBlocksDlg.h" // Method GET NON BLOCKS #include "MeasureGUI_CheckSelfIntersectionsDlg.h" // Method CHECK SELF INTERSCTIONS #include "MeasureGUI_PointDlg.h" // Method POINTCOORDINATES @@ -110,6 +110,9 @@ bool MeasureGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent ) case GEOMOp::OpCheckCompound: dlg = new MeasureGUI_CheckCompoundOfBlocksDlg( getGeometryGUI(), parent ); break; // CHECKCOMPOUND + case GEOMOp::OpGetNonBlocks: + dlg = new MeasureGUI_GetNonBlocksDlg(getGeometryGUI(), parent); + break; // GET NON BLOCKS case GEOMOp::OpCheckSelfInters: dlg = new MeasureGUI_CheckSelfIntersectionsDlg( getGeometryGUI(), parent ); break; // CHECK SELF INTERSCTIONS diff --git a/src/MeasureGUI/MeasureGUI_CenterMassDlg.cxx b/src/MeasureGUI/MeasureGUI_CenterMassDlg.cxx index 84676e669..df20f449c 100644 --- a/src/MeasureGUI/MeasureGUI_CenterMassDlg.cxx +++ b/src/MeasureGUI/MeasureGUI_CenterMassDlg.cxx @@ -84,7 +84,7 @@ MeasureGUI_CenterMassDlg::MeasureGUI_CenterMassDlg( GeometryGUI* theGeometryGUI, /***************************************************************/ - myHelpFileName = "using_measurement_tools_page.html#center_mass_anchor"; + myHelpFileName = "center_mass_page.html"; /* Initialisation */ Init(); diff --git a/src/MeasureGUI/MeasureGUI_GetNonBlocksDlg.cxx b/src/MeasureGUI/MeasureGUI_GetNonBlocksDlg.cxx new file mode 100644 index 000000000..517f5974f --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_GetNonBlocksDlg.cxx @@ -0,0 +1,277 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com + +// GEOM GEOMGUI : GUI for Geometry component +// File : MeasureGUI_GetNonBlocksDlg.cxx + +#include "MeasureGUI_GetNonBlocksDlg.h" + +#include +#include + +#include + +#include +#include +#include +#include +#include + +//================================================================================= +// class : MeasureGUI_GetNonBlocksDlg() +// purpose : Constructs a MeasureGUI_GetNonBlocksDlg which is a child of 'parent', +// with the name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// true to construct a modal dialog. +//================================================================================= +MeasureGUI_GetNonBlocksDlg::MeasureGUI_GetNonBlocksDlg (GeometryGUI* theGeometryGUI, QWidget* parent) + : GEOMBase_Skeleton(theGeometryGUI, parent, false) +{ + QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_GETNONBLOCKS"))); + QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT"))); + + setWindowTitle(tr("GEOM_GETNONBLOCKS_TITLE")); + + /***************************************************************/ + mainFrame()->GroupConstructors->setTitle(tr("GEOM_GETNONBLOCKS")); + mainFrame()->RadioButton1->setIcon(image0); + mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose); + mainFrame()->RadioButton2->close(); + mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); + mainFrame()->RadioButton3->close(); + + myGrp = new DlgRef_1Sel (centralWidget()); + myGrp->GroupBox1->setTitle(tr("GEOM_GETNONBLOCKS")); + myGrp->TextLabel1->setText(tr("GEOM_OBJECT")); + myGrp->PushButton1->setIcon(image1); + myGrp->LineEdit1->setReadOnly(true); + + QVBoxLayout* layout = new QVBoxLayout(centralWidget()); + layout->setMargin(0); layout->setSpacing(6); + layout->addWidget(myGrp); + + /***************************************************************/ + + myHelpFileName = "get_non_blocks_page.html"; + + /* Initialisation */ + Init(); +} + +//================================================================================= +// function : ~MeasureGUI_GetNonBlocksDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +MeasureGUI_GetNonBlocksDlg::~MeasureGUI_GetNonBlocksDlg() +{ +} + +//================================================================================= +// function : Init() +// purpose : +//================================================================================= +void MeasureGUI_GetNonBlocksDlg::Init() +{ + showOnlyPreviewControl(); + + /* init variables */ + myEditCurrentArgument = myGrp->LineEdit1; + + /* signals and slots connections */ + connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); + connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); + + connect(myGrp->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed())); + connect(myGrp->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + + connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + //initName(tr("GEOM_NONBLOCKS")); + mainFrame()->ResultName->setText(tr("GEOM_NONBLOCKS")); + globalSelection(); + SelectionIntoArgument(); +} + +//================================================================================= +// function : ClickOnOk() +// purpose : +//================================================================================= +void MeasureGUI_GetNonBlocksDlg::ClickOnOk() +{ + if (ClickOnApply()) + ClickOnCancel(); +} + +//================================================================================= +// function : ClickOnApply() +// purpose : +//================================================================================= +bool MeasureGUI_GetNonBlocksDlg::ClickOnApply() +{ + if (!onAccept()) + return false; + + //initName(); + return true; +} + +//================================================================================= +// function : SelectionIntoArgument() +// purpose : Called when selection as changed or other case +//================================================================================= +void MeasureGUI_GetNonBlocksDlg::SelectionIntoArgument() +{ + erasePreview(); + myObj = GEOM::GEOM_Object::_nil(); + + LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr(); + SALOME_ListIO aSelList; + aSelMgr->selectedObjects(aSelList); + + if (aSelList.Extent() != 1) { + processObject(); + return; + } + + GEOM::GEOM_Object_var aSelectedObject = + GEOMBase::ConvertIOinGEOMObject(aSelList.First()); + + if (aSelectedObject->_is_nil()) { + processObject(); + return; + } + + myObj = aSelectedObject; + processObject(); +} + +//================================================================================= +// function : SetEditCurrentArgument() +// purpose : +//================================================================================= +void MeasureGUI_GetNonBlocksDlg::SetEditCurrentArgument() +{ + myGrp->LineEdit1->setFocus(); + myEditCurrentArgument = myGrp->LineEdit1; + SelectionIntoArgument(); +} + +//================================================================================= +// function : LineEditReturnPressed() +// purpose : +//================================================================================= +void MeasureGUI_GetNonBlocksDlg::LineEditReturnPressed() +{ + QLineEdit* send = (QLineEdit*)sender(); + if (send == myGrp->LineEdit1) { + myEditCurrentArgument = myGrp->LineEdit1; + GEOMBase_Skeleton::LineEditReturnPressed(); + } +} + +//================================================================================= +// function : ActivateThisDialog() +// purpose : +//================================================================================= +void MeasureGUI_GetNonBlocksDlg::ActivateThisDialog() +{ + GEOMBase_Skeleton::ActivateThisDialog(); + + connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(), + SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + + globalSelection(); + processPreview(); +} + +//================================================================================= +// function : processObject() +// purpose : Fill dialog fields in accordance with myObj +//================================================================================= +void MeasureGUI_GetNonBlocksDlg::processObject() +{ + if (myObj->_is_nil()) { + erasePreview(); + } + else { + myGrp->LineEdit1->setText(GEOMBase::GetName(myObj)); + + processPreview(); + } +} + +//================================================================================= +// function : enterEvent() +// purpose : +//================================================================================= +void MeasureGUI_GetNonBlocksDlg::enterEvent (QEvent*) +{ + if (!mainFrame()->GroupConstructors->isEnabled()) + ActivateThisDialog(); +} + +//================================================================================= +// function : createOperation +// purpose : +//================================================================================= +GEOM::GEOM_IOperations_ptr MeasureGUI_GetNonBlocksDlg::createOperation() +{ + return getGeomEngine()->GetIBlocksOperations(getStudyId()); +} + +//================================================================================= +// function : isValid +// purpose : +//================================================================================= +bool MeasureGUI_GetNonBlocksDlg::isValid (QString&) +{ + return !myObj->_is_nil(); +} + +//================================================================================= +// function : execute +// purpose : +//================================================================================= +bool MeasureGUI_GetNonBlocksDlg::execute (ObjectList& objects) +{ + GEOM::GEOM_IBlocksOperations_var anOper = GEOM::GEOM_IBlocksOperations::_narrow(getOperation()); + GEOM::GEOM_Object_var aNonQuads; + GEOM::GEOM_Object_var anObj = anOper->GetNonBlocks(myObj, aNonQuads); + //mainFrame()->ResultName->setText(tr("GEOM_NONBLOCKS")); + + if (!anObj->_is_nil()) + objects.push_back(anObj._retn()); + if (!aNonQuads->_is_nil()) + objects.push_back(aNonQuads._retn()); + + return true; +} + +//================================================================ +// Function : getFather +// Purpose : Get father object for object to be added in study +// ( called with addInStudy method ) +//================================================================ +GEOM::GEOM_Object_ptr MeasureGUI_GetNonBlocksDlg::getFather (GEOM::GEOM_Object_ptr) +{ + return myObj; +} diff --git a/src/MeasureGUI/MeasureGUI_GetNonBlocksDlg.h b/src/MeasureGUI/MeasureGUI_GetNonBlocksDlg.h new file mode 100644 index 000000000..438a4ec45 --- /dev/null +++ b/src/MeasureGUI/MeasureGUI_GetNonBlocksDlg.h @@ -0,0 +1,69 @@ +// Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com + +// GEOM GEOMGUI : GUI for Geometry component +// File : MeasureGUI_GetNonBlocksDlg.h + +#ifndef MEASUREGUI_GETNONBLOCKSDLG_H +#define MEASUREGUI_GETNONBLOCKSDLG_H + +#include + +class DlgRef_1Sel; + +//================================================================================= +// class : MeasureGUI_GetNonBlocksDlg +// purpose : +//================================================================================= +class MeasureGUI_GetNonBlocksDlg : public GEOMBase_Skeleton +{ + Q_OBJECT + +public: + MeasureGUI_GetNonBlocksDlg (GeometryGUI*, QWidget*); + ~MeasureGUI_GetNonBlocksDlg(); + +protected: + // redefined from GEOMBase_Helper + virtual GEOM::GEOM_IOperations_ptr createOperation(); + virtual bool isValid (QString&); + virtual bool execute (ObjectList&); + virtual GEOM::GEOM_Object_ptr getFather (GEOM::GEOM_Object_ptr); + +private slots: + void ClickOnOk(); + bool ClickOnApply(); + void ActivateThisDialog(); + void LineEditReturnPressed(); + void SelectionIntoArgument(); + void SetEditCurrentArgument(); + +private: + void Init(); + void enterEvent (QEvent*); + void processObject(); + +private: + GEOM::GEOM_Object_var myObj; + DlgRef_1Sel* myGrp; +}; + +#endif // MEASUREGUI_GETNONBLOCKSDLG_H