mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-12-24 08:20:35 +05:00
0022179: [CEA 800] Suppress common edges on two continuous faces without using RemoveExtraEdges
This commit is contained in:
parent
e6a58b5819
commit
3282e6d3b3
BIN
doc/salome/gui/GEOM/images/union_faces.png
Normal file
BIN
doc/salome/gui/GEOM/images/union_faces.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 23 KiB |
BIN
doc/salome/gui/GEOM/images/union_faces1.png
Normal file
BIN
doc/salome/gui/GEOM/images/union_faces1.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
BIN
doc/salome/gui/GEOM/images/union_faces2.png
Normal file
BIN
doc/salome/gui/GEOM/images/union_faces2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 21 KiB |
@ -30,6 +30,8 @@ removes seam and degenerated edges from the given shape.</li>
|
||||
<li>\subpage fuse_edges_operation_page "Fuse Collinear Edges within a Wire" -
|
||||
removes selected vertices from a given wire in case if adjacent edges
|
||||
are C1 continuous.</li>
|
||||
<li>\subpage union_faces_operation_page "Union faces" -
|
||||
unites all faces sharing one surface on a given shape.</li>
|
||||
</ul>
|
||||
|
||||
*/
|
||||
|
@ -90,6 +90,9 @@
|
||||
\anchor swig_RemoveExtraEdges
|
||||
\until "freeFacesWithoutExtra"
|
||||
|
||||
\anchor swig_UnionFaces
|
||||
\until "unitedFaces"
|
||||
|
||||
\anchor swig_GetSharedShapes
|
||||
\until "sharedEdge_"
|
||||
|
||||
|
29
doc/salome/gui/GEOM/input/union_faces_operation.doc
Executable file
29
doc/salome/gui/GEOM/input/union_faces_operation.doc
Executable file
@ -0,0 +1,29 @@
|
||||
/*!
|
||||
|
||||
\page union_faces_operation_page Union Faces
|
||||
|
||||
\n To <b>Union Faces</b> in the <b>Main Menu</b> select
|
||||
<b>Repair - > Union Faces</b>.
|
||||
\n This operation unites all faces sharing one surface on a given
|
||||
shape.
|
||||
|
||||
\n <b>TUI Command:</b> <em>geompy.UnionFaces(theShape)</em>,
|
||||
where <em>theShape</em> is a compound or a single solid.
|
||||
\n <b>Arguments:</b> Name + one shape + a flag.
|
||||
\n <b>Advanced option:</b>
|
||||
\ref restore_presentation_parameters_page "Set presentation parameters and sub-shapes from arguments".
|
||||
|
||||
\image html union_faces.png
|
||||
|
||||
\n <b>Example:</b>
|
||||
|
||||
\image html union_faces1.png
|
||||
<center><em>Shape with not united faces</em></center>
|
||||
|
||||
\image html union_faces2.png
|
||||
<center><em>Improved shape</em></center>
|
||||
|
||||
Our <b>TUI Scripts</b> provide you with useful examples of the
|
||||
\ref swig_UnionFaces "Union Faces" functionality usage.
|
||||
|
||||
*/
|
@ -2556,6 +2556,15 @@ module GEOM
|
||||
GEOM_Object RemoveExtraEdges (in GEOM_Object theShape,
|
||||
in long theOptimumNbFaces);
|
||||
|
||||
/*!
|
||||
* \brief Performs union faces of \a theShape.
|
||||
*
|
||||
* Unite faces sharing one surface.
|
||||
* \param theShape The compound or single solid that contains faces to perform union.
|
||||
* \return Improved shape.
|
||||
*/
|
||||
GEOM_Object UnionFaces (in GEOM_Object theShape);
|
||||
|
||||
/*!
|
||||
* \brief Check, if the given shape is a blocks compound.
|
||||
*
|
||||
|
@ -240,6 +240,7 @@ redo.png \
|
||||
undo.png \
|
||||
glue2.png \
|
||||
remove_extra_edges.png \
|
||||
union_faces.png \
|
||||
coordsys.png \
|
||||
translation.png
|
||||
|
||||
|
BIN
resources/union_faces.png
Normal file
BIN
resources/union_faces.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 845 B |
@ -159,6 +159,10 @@
|
||||
<source>ICON_DLG_FUSE_EDGES</source>
|
||||
<translation>fuse_collinear_edges.png</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ICON_DLG_UNION_FACES</source>
|
||||
<translation>union_faces.png</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ICON_DLG_CHECKSHAPE</source>
|
||||
<translation>check.png</translation>
|
||||
@ -1019,6 +1023,10 @@
|
||||
<source>ICO_FUSE_EDGES</source>
|
||||
<translation>fuse_collinear_edges.png</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ICO_UNION_FACES</source>
|
||||
<translation>union_faces.png</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ICO_NORMALE</source>
|
||||
<translation>normale.png</translation>
|
||||
|
@ -4554,6 +4554,30 @@ Please, select face, shell or solid and try again</translation>
|
||||
<source>STB_FUSE_EDGES</source>
|
||||
<translation>Fuse collinear edges within a wire</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>GEOM_UNION_FACES_TITLE</source>
|
||||
<translation>Union faces</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>GEOM_UNION_FACES</source>
|
||||
<translation>Object to unite faces</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>UNION_FACES_NEW_OBJ_NAME</source>
|
||||
<translation>UnionFaces</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_UNION_FACES</source>
|
||||
<translation>Union faces</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>MEN_UNION_FACES</source>
|
||||
<translation>Union Faces</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>STB_UNION_FACES</source>
|
||||
<translation>Union faces</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>TOP_NORMALE</source>
|
||||
<translation>Normal to a face</translation>
|
||||
|
@ -544,6 +544,7 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
|
||||
case GEOMOp::OpLimitTolerance: // MENU REPAIR - LIMIT TOLERANCE
|
||||
case GEOMOp::OpRemoveExtraEdges: // MENU REPAIR - REMOVE EXTRA EDGES
|
||||
case GEOMOp::OpFuseEdges: // MENU REPAIR - FUSE COLLINEAR EDGES
|
||||
case GEOMOp::OpUnionFaces: // MENU REPAIR - UNION FACES
|
||||
libName = "RepairGUI";
|
||||
break;
|
||||
case GEOMOp::OpProperties: // MENU MEASURE - PROPERTIES
|
||||
@ -823,6 +824,7 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
createGeomAction( GEOMOp::OpOrientation, "CHANGE_ORIENTATION" );
|
||||
createGeomAction( GEOMOp::OpRemoveExtraEdges, "REMOVE_EXTRA_EDGES" );
|
||||
createGeomAction( GEOMOp::OpFuseEdges, "FUSE_EDGES" );
|
||||
createGeomAction( GEOMOp::OpUnionFaces, "UNION_FACES" );
|
||||
|
||||
createGeomAction( GEOMOp::OpPointCoordinates, "POINT_COORDS" );
|
||||
createGeomAction( GEOMOp::OpProperties, "BASIC_PROPS" );
|
||||
@ -1053,6 +1055,7 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
createMenu( GEOMOp::OpOrientation, repairId, -1 );
|
||||
createMenu( GEOMOp::OpRemoveExtraEdges, repairId, -1 );
|
||||
createMenu( GEOMOp::OpFuseEdges, repairId, -1 );
|
||||
createMenu( GEOMOp::OpUnionFaces, repairId, -1 );
|
||||
|
||||
int measurId = createMenu( tr( "MEN_MEASURES" ), -1, -1, 10 );
|
||||
createMenu( GEOMOp::OpPointCoordinates, measurId, -1 );
|
||||
|
@ -161,6 +161,7 @@ namespace GEOMOp {
|
||||
OpLimitTolerance = 4012, // MENU REPAIR - LIMIT TOLERANCE
|
||||
OpGlueEdges = 4013, // MENU REPAIR - GLUE EDGES
|
||||
OpFuseEdges = 4014, // MENU REPAIR - FUSE COLLINEAR EDGES
|
||||
OpUnionFaces = 4015, // MENU REPAIR - UNION FACES
|
||||
// MeasureGUI ------------------//--------------------------------
|
||||
OpProperties = 5000, // MENU MEASURES - PROPERTIES
|
||||
OpCenterMass = 5001, // MENU MEASURES - CENTRE OF MASS
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include <ShHealOper_ShapeProcess.hxx>
|
||||
//#include <GEOMAlgo_Gluer.hxx>
|
||||
#include <BlockFix_BlockFixAPI.hxx>
|
||||
#include <BlockFix_UnionFaces.hxx>
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
@ -733,6 +734,18 @@ Standard_Integer GEOMImpl_BlockDriver::Execute(TFunction_Logbook& log) const
|
||||
// Glue faces of the multi-block
|
||||
aShape = GEOMImpl_GlueDriver::GlueFaces(aMulti, aTol, Standard_False);
|
||||
|
||||
} else if (aType == BLOCK_UNION_FACES) {
|
||||
GEOMImpl_IBlockTrsf aCI (aFunction);
|
||||
Handle(GEOM_Function) aRefShape = aCI.GetOriginal();
|
||||
TopoDS_Shape aBlockOrComp = aRefShape->GetValue();
|
||||
if (aBlockOrComp.IsNull()) {
|
||||
Standard_NullObject::Raise("Null Shape given");
|
||||
}
|
||||
|
||||
BlockFix_UnionFaces aFaceUnifier;
|
||||
|
||||
aFaceUnifier.GetOptimumNbFaces() = 0; // To force union faces.
|
||||
aShape = aFaceUnifier.Perform(aBlockOrComp);
|
||||
} else { // unknown function type
|
||||
return 0;
|
||||
}
|
||||
|
@ -2654,6 +2654,58 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::RemoveExtraEdges
|
||||
return aCopy;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* UnionFaces
|
||||
*/
|
||||
//=============================================================================
|
||||
Handle(GEOM_Object) GEOMImpl_IBlocksOperations::UnionFaces
|
||||
(Handle(GEOM_Object) theObject)
|
||||
{
|
||||
SetErrorCode(KO);
|
||||
|
||||
if (theObject.IsNull()) return NULL;
|
||||
|
||||
Handle(GEOM_Function) aLastFunction = theObject->GetLastFunction();
|
||||
if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be fixed
|
||||
|
||||
//Add a new Copy object
|
||||
Handle(GEOM_Object) aCopy = GetEngine()->AddObject(GetDocID(), GEOM_COPY);
|
||||
|
||||
//Add a function
|
||||
Handle(GEOM_Function) aFunction =
|
||||
aCopy->AddFunction(GEOMImpl_BlockDriver::GetID(), BLOCK_UNION_FACES);
|
||||
|
||||
//Check if the function is set correctly
|
||||
if (aFunction->GetDriverGUID() != GEOMImpl_BlockDriver::GetID()) return NULL;
|
||||
|
||||
GEOMImpl_IBlockTrsf aTI (aFunction);
|
||||
aTI.SetOriginal(aLastFunction);
|
||||
|
||||
//Compute the fixed shape
|
||||
try {
|
||||
#if OCC_VERSION_LARGE > 0x06010000
|
||||
OCC_CATCH_SIGNALS;
|
||||
#endif
|
||||
if (!GetSolver()->ComputeFunction(aFunction)) {
|
||||
SetErrorCode("Block driver failed to remove extra edges of the given shape");
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
|
||||
SetErrorCode(aFail->GetMessageString());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//Make a Python command
|
||||
GEOM::TPythonDump(aFunction) << aCopy << " = geompy.UnionFaces("
|
||||
<< theObject << ")";
|
||||
|
||||
SetErrorCode(OK);
|
||||
return aCopy;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* CheckAndImprove
|
||||
|
@ -140,6 +140,8 @@ class GEOMImpl_IBlocksOperations : public GEOM_IOperations {
|
||||
Standard_EXPORT Handle(GEOM_Object) RemoveExtraEdges (Handle(GEOM_Object) theShape,
|
||||
const Standard_Integer theOptimumNbFaces = 6);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) UnionFaces (Handle(GEOM_Object) theShape);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) CheckAndImprove (Handle(GEOM_Object) theCompound);
|
||||
|
||||
Standard_EXPORT static void AddBlocksFrom (const TopoDS_Shape& theShape,
|
||||
|
@ -342,6 +342,7 @@
|
||||
#define BLOCK_COMPOUND_GLUE 8
|
||||
#define BLOCK_REMOVE_EXTRA 9
|
||||
#define BLOCK_COMPOUND_IMPROVE 10
|
||||
#define BLOCK_UNION_FACES 11
|
||||
|
||||
// Marker
|
||||
#define MARKER_CS 1
|
||||
|
@ -801,6 +801,31 @@ GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::RemoveExtraEdges
|
||||
return GetObject(anObject);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* UnionFaces
|
||||
*/
|
||||
//=============================================================================
|
||||
GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::UnionFaces
|
||||
(GEOM::GEOM_Object_ptr theShape)
|
||||
{
|
||||
GEOM::GEOM_Object_var aGEOMObject;
|
||||
|
||||
//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) anObject = GetOperations()->UnionFaces(aShape);
|
||||
if (!GetOperations()->IsDone() || anObject.IsNull())
|
||||
return aGEOMObject._retn();
|
||||
|
||||
return GetObject(anObject);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* CheckAndImprove
|
||||
|
@ -127,6 +127,8 @@ class GEOM_I_EXPORT GEOM_IBlocksOperations_i :
|
||||
GEOM::GEOM_Object_ptr RemoveExtraEdges (GEOM::GEOM_Object_ptr theShape,
|
||||
CORBA::Long theOptimumNbFaces);
|
||||
|
||||
GEOM::GEOM_Object_ptr UnionFaces (GEOM::GEOM_Object_ptr theShape);
|
||||
|
||||
GEOM::GEOM_Object_ptr CheckAndImprove (GEOM::GEOM_Object_ptr theCompound);
|
||||
|
||||
// Extract blocks from blocks compounds
|
||||
|
@ -208,7 +208,7 @@ def TestOtherOperations (geompy, math):
|
||||
geompy.addToStudy(MultiRot1Dt, "MakeMultiRotation1DNbTimes")
|
||||
geompy.addToStudy(MultiRot1Ds, "MakeMultiRotation1DByStep")
|
||||
geompy.addToStudy(MultiRot2Dt, "MakeMultiRotation2DNbTimes")
|
||||
geompy.addToStudy(MultiRot2Ds, "MakeMultiRotation2DByStep")
|
||||
id_MultiRot2D = geompy.addToStudy(MultiRot2Ds, "MakeMultiRotation2DByStep")
|
||||
|
||||
# MakeFilletAll
|
||||
radius_fillet = 10.
|
||||
@ -540,6 +540,11 @@ def TestOtherOperations (geompy, math):
|
||||
|
||||
geompy.addToStudy(freeFacesWithoutExtra, "freeFacesWithoutExtra")
|
||||
|
||||
# UnionFaces
|
||||
unitedFaces = geompy.UnionFaces(freeFaces)
|
||||
|
||||
geompy.addToStudy(unitedFaces, "unitedFaces")
|
||||
|
||||
# GetSharedShapes
|
||||
sharedFaces = geompy.GetSharedShapes(part, freeFaces,
|
||||
geompy.ShapeType["FACE"])
|
||||
|
@ -10740,6 +10740,40 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
|
||||
self._autoPublish(anObj, theName, "removeExtraEdges")
|
||||
return anObj
|
||||
|
||||
## Performs union faces of \a theShape
|
||||
# Unite faces sharing one surface. It means that
|
||||
# these faces must have references to one C++ surface object (handle).
|
||||
# @param theShape The compound or single solid that contains faces
|
||||
# to perform union.
|
||||
# @param theName Object name; when specified, this parameter is used
|
||||
# for result publication in the study. Otherwise, if automatic
|
||||
# publication is switched on, default value is used for result name.
|
||||
#
|
||||
# @return Improved shape.
|
||||
#
|
||||
# @ref swig_UnionFaces "Example"
|
||||
def UnionFaces(self, theShape, theName=None):
|
||||
"""
|
||||
Performs union faces of theShape.
|
||||
Unite faces sharing one surface. It means that
|
||||
these faces must have references to one C++ surface object (handle).
|
||||
|
||||
Parameters:
|
||||
theShape The compound or single solid that contains faces
|
||||
to perform union.
|
||||
theName Object name; when specified, this parameter is used
|
||||
for result publication in the study. Otherwise, if automatic
|
||||
publication is switched on, default value is used for result name.
|
||||
|
||||
Returns:
|
||||
Improved shape.
|
||||
"""
|
||||
# Example: see GEOM_TestOthers.py
|
||||
anObj = self.BlocksOp.UnionFaces(theShape)
|
||||
RaiseIfFailed("UnionFaces", self.BlocksOp)
|
||||
self._autoPublish(anObj, theName, "unionFaces")
|
||||
return anObj
|
||||
|
||||
## Check, if the given shape is a blocks compound.
|
||||
# Fix all detected errors.
|
||||
# \note Single block can be also fixed by this method.
|
||||
|
@ -39,6 +39,7 @@ salomeinclude_HEADERS = \
|
||||
RepairGUI_GlueDlg.h \
|
||||
RepairGUI_LimitToleranceDlg.h \
|
||||
RepairGUI_RemoveExtraEdgesDlg.h \
|
||||
RepairGUI_UnionFacesDlg.h \
|
||||
RepairGUI_FuseEdgesDlg.h
|
||||
|
||||
# Libraries targets
|
||||
@ -59,6 +60,7 @@ dist_libRepairGUI_la_SOURCES = \
|
||||
RepairGUI_GlueDlg.h \
|
||||
RepairGUI_LimitToleranceDlg.h \
|
||||
RepairGUI_RemoveExtraEdgesDlg.h \
|
||||
RepairGUI_UnionFacesDlg.h \
|
||||
RepairGUI_FuseEdgesDlg.h \
|
||||
\
|
||||
RepairGUI.cxx \
|
||||
@ -75,6 +77,7 @@ dist_libRepairGUI_la_SOURCES = \
|
||||
RepairGUI_GlueDlg.cxx \
|
||||
RepairGUI_LimitToleranceDlg.cxx \
|
||||
RepairGUI_RemoveExtraEdgesDlg.cxx \
|
||||
RepairGUI_UnionFacesDlg.cxx \
|
||||
RepairGUI_FuseEdgesDlg.cxx
|
||||
|
||||
MOC_FILES = \
|
||||
@ -91,6 +94,7 @@ MOC_FILES = \
|
||||
RepairGUI_GlueDlg_moc.cxx \
|
||||
RepairGUI_LimitToleranceDlg_moc.cxx \
|
||||
RepairGUI_RemoveExtraEdgesDlg_moc.cxx \
|
||||
RepairGUI_UnionFacesDlg_moc.cxx \
|
||||
RepairGUI_FuseEdgesDlg_moc.cxx
|
||||
|
||||
nodist_libRepairGUI_la_SOURCES = \
|
||||
|
@ -45,6 +45,7 @@
|
||||
#include "RepairGUI_ChangeOrientationDlg.h" // Method CHANGE ORIENTATION
|
||||
#include "RepairGUI_RemoveExtraEdgesDlg.h" // Method REMOVE EXTRA EDGES
|
||||
#include "RepairGUI_FuseEdgesDlg.h" // Method FUSE COLLINEAR EDGES
|
||||
#include "RepairGUI_UnionFacesDlg.h" // Method UNION FACES
|
||||
|
||||
//=======================================================================
|
||||
// function : RepairGUI()
|
||||
@ -92,6 +93,7 @@ bool RepairGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
|
||||
case GEOMOp::OpOrientation: aDlg = new RepairGUI_ChangeOrientationDlg (getGeometryGUI(), parent); break;
|
||||
case GEOMOp::OpRemoveExtraEdges: aDlg = new RepairGUI_RemoveExtraEdgesDlg (getGeometryGUI(), parent); break;
|
||||
case GEOMOp::OpFuseEdges: aDlg = new RepairGUI_FuseEdgesDlg (getGeometryGUI(), parent); break;
|
||||
case GEOMOp::OpUnionFaces: aDlg = new RepairGUI_UnionFacesDlg (getGeometryGUI(), parent); break;
|
||||
default:
|
||||
app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
|
||||
break;
|
||||
|
307
src/RepairGUI/RepairGUI_UnionFacesDlg.cxx
Executable file
307
src/RepairGUI/RepairGUI_UnionFacesDlg.cxx
Executable file
@ -0,0 +1,307 @@
|
||||
// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
// GEOM RepairGUI : GUI for Geometry component
|
||||
// File : RepairGUI_UnionFacesDlg.cxx
|
||||
// Author : Michael Zorin, Open CASCADE S.A.S.
|
||||
//
|
||||
#include "RepairGUI_UnionFacesDlg.h"
|
||||
|
||||
#include <DlgRef.h>
|
||||
#include <GeometryGUI.h>
|
||||
#include <GEOMBase.h>
|
||||
|
||||
#include <SalomeApp_Application.h>
|
||||
#include <LightApp_SelectionMgr.h>
|
||||
#include <SUIT_Session.h>
|
||||
#include <SUIT_ResourceMgr.h>
|
||||
|
||||
#include <GEOMImpl_Types.hxx>
|
||||
|
||||
#include <TColStd_MapOfInteger.hxx>
|
||||
|
||||
//=================================================================================
|
||||
// class : RepairGUI_UnionFacesDlg()
|
||||
// purpose : Constructs a RepairGUI_UnionFacesDlg 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.
|
||||
//=================================================================================
|
||||
RepairGUI_UnionFacesDlg::RepairGUI_UnionFacesDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
|
||||
bool modal )
|
||||
: GEOMBase_Skeleton( theGeometryGUI, parent, modal )
|
||||
{
|
||||
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
|
||||
QPixmap image0( aResMgr->loadPixmap( "GEOM", tr( "ICON_DLG_UNION_FACES" ) ) );
|
||||
QPixmap image1( aResMgr->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
|
||||
|
||||
setWindowTitle( tr( "GEOM_UNION_FACES_TITLE" ) );
|
||||
|
||||
/***************************************************************/
|
||||
mainFrame()->GroupConstructors->setTitle(tr("GEOM_UNION_FACES_TITLE"));
|
||||
mainFrame()->RadioButton1->setIcon( image0 );
|
||||
mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose );
|
||||
mainFrame()->RadioButton2->close();
|
||||
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
|
||||
mainFrame()->RadioButton3->close();
|
||||
|
||||
GroupPoints = new DlgRef_1Sel( centralWidget() );
|
||||
|
||||
GroupPoints->GroupBox1->setTitle( tr( "GEOM_UNION_FACES" ) );
|
||||
GroupPoints->TextLabel1->setText( tr( "GEOM_SELECTED_SHAPE" ) );
|
||||
GroupPoints->PushButton1->setIcon( image1 );
|
||||
GroupPoints->LineEdit1->setReadOnly( true );
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
|
||||
layout->setMargin( 0 ); layout->setSpacing( 6 );
|
||||
layout->addWidget( GroupPoints );
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
setHelpFileName( "union_faces_operation_page.html" );
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// function : ~RepairGUI_UnionFacesDlg()
|
||||
// purpose : Destroys the object and frees any allocated resources
|
||||
//=================================================================================
|
||||
RepairGUI_UnionFacesDlg::~RepairGUI_UnionFacesDlg()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// function : Init()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void RepairGUI_UnionFacesDlg::Init()
|
||||
{
|
||||
/* init variables */
|
||||
myEditCurrentArgument = GroupPoints->LineEdit1;
|
||||
|
||||
myOkObject = false;
|
||||
|
||||
activateSelection();
|
||||
|
||||
mainFrame()->GroupBoxPublish->show();
|
||||
//Hide preview checkbox
|
||||
mainFrame()->CheckBoxPreview->hide();
|
||||
|
||||
/* signals and slots connections */
|
||||
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
|
||||
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
|
||||
|
||||
connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
|
||||
connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
|
||||
|
||||
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
|
||||
this, SLOT( SelectionIntoArgument() ) );
|
||||
|
||||
initName( tr( "UNION_FACES_NEW_OBJ_NAME" ) );
|
||||
resize(100,100);
|
||||
SelectionIntoArgument();
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// function : ClickOnOk()
|
||||
// purpose : Same than click on apply but close this dialog.
|
||||
//=================================================================================
|
||||
void RepairGUI_UnionFacesDlg::ClickOnOk()
|
||||
{
|
||||
setIsApplyAndClose( true );
|
||||
if ( ClickOnApply() )
|
||||
ClickOnCancel();
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : ClickOnApply()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
bool RepairGUI_UnionFacesDlg::ClickOnApply()
|
||||
{
|
||||
if ( !onAccept() )
|
||||
return false;
|
||||
|
||||
initName();
|
||||
|
||||
myEditCurrentArgument->setText( "" );
|
||||
myObject = GEOM::GEOM_Object::_nil();
|
||||
|
||||
myOkObject = false;
|
||||
|
||||
activateSelection();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// function : SelectionIntoArgument()
|
||||
// purpose : Called when selection as changed or other case
|
||||
// : used only by SelectButtonC1A1 (LineEditC1A1)
|
||||
//=================================================================================
|
||||
void RepairGUI_UnionFacesDlg::SelectionIntoArgument()
|
||||
{
|
||||
myEditCurrentArgument->setText( "" );
|
||||
QString aName;
|
||||
|
||||
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
|
||||
SALOME_ListIO aSelList;
|
||||
aSelMgr->selectedObjects(aSelList);
|
||||
|
||||
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
|
||||
if ( aSelList.Extent() != 1 ) {
|
||||
if ( myEditCurrentArgument == GroupPoints->LineEdit1 )
|
||||
myOkObject = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// nbSel == 1
|
||||
GEOM::GEOM_Object_ptr aSelectedObject =
|
||||
GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
|
||||
|
||||
if ( CORBA::is_nil( aSelectedObject ) )
|
||||
return;
|
||||
|
||||
if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
|
||||
myObject = aSelectedObject;
|
||||
myOkObject = true;
|
||||
}
|
||||
|
||||
myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : SetEditCurrentArgument()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void RepairGUI_UnionFacesDlg::SetEditCurrentArgument()
|
||||
{
|
||||
if( sender() == GroupPoints->PushButton1 ) {
|
||||
GroupPoints->LineEdit1->setFocus();
|
||||
myEditCurrentArgument = GroupPoints->LineEdit1;
|
||||
}
|
||||
SelectionIntoArgument();
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// function : LineEditReturnPressed()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void RepairGUI_UnionFacesDlg::LineEditReturnPressed()
|
||||
{
|
||||
if ( sender() == GroupPoints->LineEdit1 ) {
|
||||
myEditCurrentArgument = GroupPoints->LineEdit1;
|
||||
GEOMBase_Skeleton::LineEditReturnPressed();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// function : ActivateThisDialog()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void RepairGUI_UnionFacesDlg::ActivateThisDialog()
|
||||
{
|
||||
GEOMBase_Skeleton::ActivateThisDialog();
|
||||
connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
|
||||
this, SLOT( SelectionIntoArgument() ) );
|
||||
|
||||
activateSelection();
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// function : enterEvent()
|
||||
// purpose : Mouse enter onto the dialog to activate it
|
||||
//=================================================================================
|
||||
void RepairGUI_UnionFacesDlg::enterEvent(QEvent* e)
|
||||
{
|
||||
if ( !mainFrame()->GroupConstructors->isEnabled() )
|
||||
ActivateThisDialog();
|
||||
}
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// function : activateSelection
|
||||
// purpose : activate selection of solids and compounds
|
||||
//=================================================================================
|
||||
void RepairGUI_UnionFacesDlg::activateSelection()
|
||||
{
|
||||
TColStd_MapOfInteger aTypes;
|
||||
aTypes.Add( GEOM_SHELL );
|
||||
aTypes.Add( GEOM_SOLID );
|
||||
aTypes.Add( GEOM_COMPOUND );
|
||||
globalSelection( aTypes );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : createOperation
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
GEOM::GEOM_IOperations_ptr RepairGUI_UnionFacesDlg::createOperation()
|
||||
{
|
||||
return getGeomEngine()->GetIBlocksOperations( getStudyId() );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : isValid
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
bool RepairGUI_UnionFacesDlg::isValid( QString& msg )
|
||||
{
|
||||
return myOkObject;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : execute
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
bool RepairGUI_UnionFacesDlg::execute( ObjectList& objects )
|
||||
{
|
||||
GEOM::GEOM_IBlocksOperations_var anOper = GEOM::GEOM_IBlocksOperations::_narrow(getOperation());
|
||||
GEOM::GEOM_Object_var anObj = anOper->UnionFaces(myObject);
|
||||
|
||||
if (!anObj->_is_nil())
|
||||
objects.push_back(anObj._retn());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : restoreSubShapes
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void RepairGUI_UnionFacesDlg::restoreSubShapes( SALOMEDS::Study_ptr theStudy,
|
||||
SALOMEDS::SObject_ptr theSObject )
|
||||
{
|
||||
if ( mainFrame()->CheckBoxRestoreSS->isChecked() ) {
|
||||
// empty list of arguments means that all arguments should be restored
|
||||
getGeomEngine()->RestoreSubShapesSO( theStudy, theSObject, GEOM::ListOfGO(),
|
||||
/*theFindMethod=*/GEOM::FSM_GetInPlace, // ? GetInPlaceByHistory
|
||||
/*theInheritFirstArg=*/true,
|
||||
mainFrame()->CheckBoxAddPrefix->isChecked() );
|
||||
}
|
||||
}
|
72
src/RepairGUI/RepairGUI_UnionFacesDlg.h
Executable file
72
src/RepairGUI/RepairGUI_UnionFacesDlg.h
Executable file
@ -0,0 +1,72 @@
|
||||
// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
// GEOM GEOMGUI : GUI for Geometry component
|
||||
// File : RepairGUI_UnionFacesDlg.h
|
||||
// Author : Michael ZORIN, Open CASCADE S.A.S.
|
||||
//
|
||||
#ifndef REPAIRGUI_UNIONFACESDLG_H
|
||||
#define REPAIRGUI_UNIONFACESDLG_H
|
||||
|
||||
#include <GEOMBase_Skeleton.h>
|
||||
|
||||
class DlgRef_1Sel;
|
||||
|
||||
//=================================================================================
|
||||
// class : RepairGUI_UnionFacesDlg
|
||||
// purpose : Unites faces of a given shape.
|
||||
//=================================================================================
|
||||
class RepairGUI_UnionFacesDlg : public GEOMBase_Skeleton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
RepairGUI_UnionFacesDlg( GeometryGUI*, QWidget* = 0, bool = false );
|
||||
~RepairGUI_UnionFacesDlg();
|
||||
|
||||
protected:
|
||||
// redefined from GEOMBase_Helper
|
||||
virtual GEOM::GEOM_IOperations_ptr createOperation();
|
||||
virtual bool isValid( QString& );
|
||||
virtual bool execute( ObjectList& );
|
||||
virtual void restoreSubShapes( SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr );
|
||||
|
||||
private:
|
||||
void Init();
|
||||
void enterEvent( QEvent* );
|
||||
void activateSelection();
|
||||
|
||||
private:
|
||||
GEOM::GEOM_Object_var myObject;
|
||||
bool myOkObject;
|
||||
|
||||
DlgRef_1Sel* GroupPoints;
|
||||
|
||||
private slots:
|
||||
void ClickOnOk();
|
||||
bool ClickOnApply();
|
||||
|
||||
void ActivateThisDialog();
|
||||
|
||||
void LineEditReturnPressed();
|
||||
void SelectionIntoArgument();
|
||||
void SetEditCurrentArgument();
|
||||
};
|
||||
|
||||
#endif // REPAIRGUI_UNIONFACESDLG_H
|
Loading…
Reference in New Issue
Block a user