0022178: [CEA 798] Sewing: Make option NonManifoldMode available in GEOM

This commit is contained in:
skv 2013-05-24 10:40:50 +00:00
parent 3282e6d3b3
commit ca3e17352a
13 changed files with 102 additions and 19 deletions

View File

@ -8,9 +8,9 @@
\n The \b Result will be a \b GEOM_Object.
\n <b>TUI Command:</b> <em>geompy.MakeSewing(ListOfShape, Precision),</em>
\n <b>TUI Command:</b> <em>geompy.MakeSewing(ListOfShape, Precision, AllowNonManifold=False),</em>
where \em ListOfShape is list of faces or shells to be sewed, \em Precision is a
precision for sewing.
precision for sewing, \em AllowNonManifold flag that allows non-manifold sewing.
\image html repair6.png

View File

@ -3323,6 +3323,14 @@ module GEOM
*/
GEOM_Object Sew (in GEOM_Object theObject, in double theTolerance);
/*!
* Sewing of the given object. Allows non-manifold sewing.
* \param theObject Shape to be processed.
* \param theTolerance Required tolerance value.
* \return New GEOM_Object, containing processed shape.
*/
GEOM_Object SewAllowNonManifold(in GEOM_Object theObject, in double theTolerance);
/*!
* \brief Addition of a point to a given edge object.
* \param theObject Shape to be processed.

View File

@ -1674,6 +1674,10 @@ Please, select face, shell or solid and try again</translation>
<source>GEOM_SEWING_TITLE</source>
<translation>Topological sewing</translation>
</message>
<message>
<source>GEOM_ALLOW_NON_MANIFOLD</source>
<translation>Allow Non Manifold</translation>
</message>
<message>
<source>GEOM_SHAPE</source>
<translation>Shape</translation>

View File

@ -133,7 +133,10 @@ Standard_Integer GEOMImpl_HealingDriver::Execute(TFunction_Logbook& log) const
RemoveHoles(&HI, anOriginalShape, aShape);
break;
case SEWING:
Sew(&HI, anOriginalShape, aShape);
Sew(&HI, anOriginalShape, aShape, false);
break;
case SEWING_NON_MANIFOLD:
Sew(&HI, anOriginalShape, aShape, true);
break;
case DIVIDE_EDGE:
AddPointOnEdge(&HI, anOriginalShape, aShape);
@ -418,12 +421,16 @@ Standard_Boolean GEOMImpl_HealingDriver::RemoveHoles (GEOMImpl_IHealing* theHI,
//=======================================================================
Standard_Boolean GEOMImpl_HealingDriver::Sew (GEOMImpl_IHealing* theHI,
const TopoDS_Shape& theOriginalShape,
TopoDS_Shape& theOutShape) const
TopoDS_Shape& theOutShape,
Standard_Boolean isAllowNonManifold) const
{
Standard_Real aTol = theHI->GetTolerance();
ShHealOper_Sewing aHealer (theOriginalShape, aTol);
// Set non-manifold mode.
aHealer.SetNonManifoldMode(isAllowNonManifold);
Standard_Boolean aResult = aHealer.Perform();
if (aResult)

View File

@ -171,7 +171,7 @@ private:
Standard_Boolean CloseContour ( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const;
Standard_Boolean RemoveIntWires( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const;
Standard_Boolean RemoveHoles ( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const;
Standard_Boolean Sew ( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const;
Standard_Boolean Sew ( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape&, Standard_Boolean ) const;
Standard_Boolean AddPointOnEdge( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const;
Standard_Boolean ChangeOrientation( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const;
void LimitTolerance( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const;

View File

@ -596,7 +596,8 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::FillHoles (Handle(GEOM_Object)
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObject,
double theTolerance)
double theTolerance,
bool isAllowNonManifold)
{
// set error code, check parameters
SetErrorCode(KO);
@ -611,7 +612,9 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObj
Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
//Add the function
aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), SEWING);
int aFunctionType = (isAllowNonManifold ? SEWING_NON_MANIFOLD : SEWING);
aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), aFunctionType);
if (aFunction.IsNull()) return NULL;
@ -642,8 +645,15 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObj
}
//Make a Python command
GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.Sew("
<< theObject << ", " << theTolerance << ")";
GEOM::TPythonDump pd(aFunction);
pd << aNewObject << " = geompy.Sew(" << theObject << ", " << theTolerance;
if (isAllowNonManifold) {
pd << ", true";
}
pd << ")";
SetErrorCode(OK);
return aNewObject;

View File

@ -71,7 +71,8 @@ class GEOMImpl_IHealingOperations : public GEOM_IOperations {
const Handle(TColStd_HArray1OfInteger)& theWires);
Standard_EXPORT Handle(GEOM_Object) Sew( Handle(GEOM_Object) theObject,
double theTolerance );
double theTolerance,
bool isAllowNonManifold);
Standard_EXPORT Handle(GEOM_Object) DivideEdge( Handle(GEOM_Object) theObject,
int theIndex,

View File

@ -302,6 +302,7 @@
#define CHANGE_ORIENTATION 8
#define LIMIT_TOLERANCE 9
#define FUSE_COLLINEAR_EDGES 10
#define SEWING_NON_MANIFOLD 11
#define BASIC_FILLING 1

View File

@ -356,7 +356,38 @@ GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::Sew (GEOM::GEOM_Object_ptr theO
// Perform
Handle(GEOM_Object) aNewObject =
GetOperations()->Sew( anObject, theTolerance );
GetOperations()->Sew( anObject, theTolerance, false );
if (!GetOperations()->IsDone() || aNewObject.IsNull())
return aGEOMObject._retn();
return GetObject(aNewObject);
}
//=============================================================================
/*!
* SewAllowNonManifold
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::SewAllowNonManifold (GEOM::GEOM_Object_ptr theObject,
CORBA::Double theTolerance)
{
GEOM::GEOM_Object_var aGEOMObject;
// Set a not done flag
GetOperations()->SetNotDone();
// Check parameters
if (theTolerance < 0)
return aGEOMObject._retn();
// Get the object itself
Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
if (anObject.IsNull())
return aGEOMObject._retn();
// Perform
Handle(GEOM_Object) aNewObject =
GetOperations()->Sew( anObject, theTolerance, true );
if (!GetOperations()->IsDone() || aNewObject.IsNull())
return aGEOMObject._retn();

View File

@ -75,6 +75,9 @@ class GEOM_I_EXPORT GEOM_IHealingOperations_i :
GEOM::GEOM_Object_ptr Sew (GEOM::GEOM_Object_ptr theObject,
CORBA::Double theTolerance);
GEOM::GEOM_Object_ptr SewAllowNonManifold (GEOM::GEOM_Object_ptr theObject,
CORBA::Double theTolerance);
GEOM::GEOM_Object_ptr DivideEdge (GEOM::GEOM_Object_ptr theObject,
CORBA::Short theIndex,
CORBA::Double theValue,

View File

@ -5912,6 +5912,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
## Sewing of some shapes into single shape.
# @param ListShape Shapes to be processed.
# @param theTolerance Required tolerance value.
# @param AllowNonManifold Flag that allows non-manifold sewing.
# @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.
@ -5919,13 +5920,14 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
# @return New GEOM.GEOM_Object, containing processed shape.
#
# @ref tui_sewing "Example"
def MakeSewing(self, ListShape, theTolerance, theName=None):
def MakeSewing(self, ListShape, theTolerance, AllowNonManifold=False, theName=None):
"""
Sewing of some shapes into single shape.
Parameters:
ListShape Shapes to be processed.
theTolerance Required tolerance value.
AllowNonManifold Flag that allows non-manifold sewing.
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.
@ -5936,24 +5938,26 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
# Example: see GEOM_TestHealing.py
comp = self.MakeCompound(ListShape)
# note: auto-publishing is done in self.Sew()
anObj = self.Sew(comp, theTolerance, theName)
anObj = self.Sew(comp, theTolerance, AllowNonManifold, theName)
return anObj
## Sewing of the given object.
# @param theObject Shape to be processed.
# @param theTolerance Required tolerance value.
# @param AllowNonManifold Flag that allows non-manifold sewing.
# @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 New GEOM.GEOM_Object, containing processed shape.
def Sew(self, theObject, theTolerance, theName=None):
def Sew(self, theObject, theTolerance, AllowNonManifold=False, theName=None):
"""
Sewing of the given object.
Parameters:
theObject Shape to be processed.
theTolerance Required tolerance value.
AllowNonManifold Flag that allows non-manifold sewing.
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.
@ -5963,6 +5967,9 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
"""
# Example: see MakeSewing() above
theTolerance,Parameters = ParseParameters(theTolerance)
if AllowNonManifold:
anObj = self.HealOp.SewAllowNonManifold(theObject, theTolerance)
else:
anObj = self.HealOp.Sew(theObject, theTolerance)
RaiseIfFailed("Sew", self.HealOp)
anObj.SetParameters(Parameters)

View File

@ -76,15 +76,17 @@ RepairGUI_SewingDlg::RepairGUI_SewingDlg( GeometryGUI* theGeometryGUI, QWidget*
QGridLayout* aLay = new QGridLayout( GroupPoints->Box );
aLay->setMargin( 0 ); aLay->setSpacing( 6 );
myAllowNonManifoldChk = new QCheckBox (tr("GEOM_ALLOW_NON_MANIFOLD"), GroupPoints->Box);
myTolEdt = new SalomeApp_DoubleSpinBox( GroupPoints->Box );
initSpinBox( myTolEdt, 0.0, 100.0, DEFAULT_TOLERANCE_VALUE, "len_tol_precision" );
myTolEdt->setValue( DEFAULT_TOLERANCE_VALUE );
QLabel* aLbl1 = new QLabel( tr( "GEOM_TOLERANCE" ), GroupPoints->Box );
myFreeBoundBtn = new QPushButton( tr( "GEOM_DETECT" ) + QString( " [%1]" ).arg( tr( "GEOM_FREE_BOUNDARIES" ) ),
GroupPoints->Box );
aLay->addWidget( aLbl1, 0, 0 );
aLay->addWidget( myTolEdt, 0, 1 );
aLay->addWidget( myFreeBoundBtn, 1, 0, 1, 2 );
aLay->addWidget( myAllowNonManifoldChk, 0, 0 );
aLay->addWidget( aLbl1, 1, 0 );
aLay->addWidget( myTolEdt, 1, 1 );
aLay->addWidget( myFreeBoundBtn, 2, 0, 1, 2 );
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
layout->setMargin( 0 ); layout->setSpacing( 6 );
@ -301,7 +303,14 @@ bool RepairGUI_SewingDlg::execute( ObjectList& objects )
myClosed = -1;
}
else {
GEOM::GEOM_Object_var anObj = anOper->Sew( myObject, myTolEdt->value() );
GEOM::GEOM_Object_var anObj;
if (myAllowNonManifoldChk->isChecked()) {
anObj = anOper->SewAllowNonManifold( myObject, myTolEdt->value() );
} else {
anObj = anOper->Sew( myObject, myTolEdt->value() );
}
aResult = !anObj->_is_nil();
if ( aResult )
{

View File

@ -30,6 +30,7 @@
#include <GEOMBase_Skeleton.h>
class DlgRef_1SelExt;
class QCheckBox;
class SalomeApp_DoubleSpinBox;
class QPushButton;
@ -60,6 +61,7 @@ private:
GEOM::GEOM_Object_var myObject;
DlgRef_1SelExt* GroupPoints;
QCheckBox* myAllowNonManifoldChk;
SalomeApp_DoubleSpinBox* myTolEdt;
QPushButton* myFreeBoundBtn;