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 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 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 \image html repair6.png

View File

@ -3323,6 +3323,14 @@ module GEOM
*/ */
GEOM_Object Sew (in GEOM_Object theObject, in double theTolerance); 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. * \brief Addition of a point to a given edge object.
* \param theObject Shape to be processed. * \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> <source>GEOM_SEWING_TITLE</source>
<translation>Topological sewing</translation> <translation>Topological sewing</translation>
</message> </message>
<message>
<source>GEOM_ALLOW_NON_MANIFOLD</source>
<translation>Allow Non Manifold</translation>
</message>
<message> <message>
<source>GEOM_SHAPE</source> <source>GEOM_SHAPE</source>
<translation>Shape</translation> <translation>Shape</translation>

View File

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

View File

@ -171,7 +171,7 @@ private:
Standard_Boolean CloseContour ( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const; Standard_Boolean CloseContour ( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const;
Standard_Boolean RemoveIntWires( 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 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 AddPointOnEdge( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const;
Standard_Boolean ChangeOrientation( 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; 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, Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObject,
double theTolerance) double theTolerance,
bool isAllowNonManifold)
{ {
// set error code, check parameters // set error code, check parameters
SetErrorCode(KO); 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 ); Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
//Add the function //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; if (aFunction.IsNull()) return NULL;
@ -642,8 +645,15 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObj
} }
//Make a Python command //Make a Python command
GEOM::TPythonDump(aFunction) << aNewObject << " = geompy.Sew(" GEOM::TPythonDump pd(aFunction);
<< theObject << ", " << theTolerance << ")";
pd << aNewObject << " = geompy.Sew(" << theObject << ", " << theTolerance;
if (isAllowNonManifold) {
pd << ", true";
}
pd << ")";
SetErrorCode(OK); SetErrorCode(OK);
return aNewObject; return aNewObject;

View File

@ -71,7 +71,8 @@ class GEOMImpl_IHealingOperations : public GEOM_IOperations {
const Handle(TColStd_HArray1OfInteger)& theWires); const Handle(TColStd_HArray1OfInteger)& theWires);
Standard_EXPORT Handle(GEOM_Object) Sew( Handle(GEOM_Object) theObject, 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, Standard_EXPORT Handle(GEOM_Object) DivideEdge( Handle(GEOM_Object) theObject,
int theIndex, int theIndex,

View File

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

View File

@ -356,7 +356,38 @@ GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::Sew (GEOM::GEOM_Object_ptr theO
// Perform // Perform
Handle(GEOM_Object) aNewObject = 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()) if (!GetOperations()->IsDone() || aNewObject.IsNull())
return aGEOMObject._retn(); 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, GEOM::GEOM_Object_ptr Sew (GEOM::GEOM_Object_ptr theObject,
CORBA::Double theTolerance); 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, GEOM::GEOM_Object_ptr DivideEdge (GEOM::GEOM_Object_ptr theObject,
CORBA::Short theIndex, CORBA::Short theIndex,
CORBA::Double theValue, CORBA::Double theValue,

View File

@ -5912,6 +5912,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
## Sewing of some shapes into single shape. ## Sewing of some shapes into single shape.
# @param ListShape Shapes to be processed. # @param ListShape Shapes to be processed.
# @param theTolerance Required tolerance value. # @param theTolerance Required tolerance value.
# @param AllowNonManifold Flag that allows non-manifold sewing.
# @param theName Object name; when specified, this parameter is used # @param theName Object name; when specified, this parameter is used
# for result publication in the study. Otherwise, if automatic # for result publication in the study. Otherwise, if automatic
# publication is switched on, default value is used for result name. # 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. # @return New GEOM.GEOM_Object, containing processed shape.
# #
# @ref tui_sewing "Example" # @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. Sewing of some shapes into single shape.
Parameters: Parameters:
ListShape Shapes to be processed. ListShape Shapes to be processed.
theTolerance Required tolerance value. theTolerance Required tolerance value.
AllowNonManifold Flag that allows non-manifold sewing.
theName Object name; when specified, this parameter is used theName Object name; when specified, this parameter is used
for result publication in the study. Otherwise, if automatic for result publication in the study. Otherwise, if automatic
publication is switched on, default value is used for result name. 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 # Example: see GEOM_TestHealing.py
comp = self.MakeCompound(ListShape) comp = self.MakeCompound(ListShape)
# note: auto-publishing is done in self.Sew() # note: auto-publishing is done in self.Sew()
anObj = self.Sew(comp, theTolerance, theName) anObj = self.Sew(comp, theTolerance, AllowNonManifold, theName)
return anObj return anObj
## Sewing of the given object. ## Sewing of the given object.
# @param theObject Shape to be processed. # @param theObject Shape to be processed.
# @param theTolerance Required tolerance value. # @param theTolerance Required tolerance value.
# @param AllowNonManifold Flag that allows non-manifold sewing.
# @param theName Object name; when specified, this parameter is used # @param theName Object name; when specified, this parameter is used
# for result publication in the study. Otherwise, if automatic # for result publication in the study. Otherwise, if automatic
# publication is switched on, default value is used for result name. # publication is switched on, default value is used for result name.
# #
# @return New GEOM.GEOM_Object, containing processed shape. # @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. Sewing of the given object.
Parameters: Parameters:
theObject Shape to be processed. theObject Shape to be processed.
theTolerance Required tolerance value. theTolerance Required tolerance value.
AllowNonManifold Flag that allows non-manifold sewing.
theName Object name; when specified, this parameter is used theName Object name; when specified, this parameter is used
for result publication in the study. Otherwise, if automatic for result publication in the study. Otherwise, if automatic
publication is switched on, default value is used for result name. 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 # Example: see MakeSewing() above
theTolerance,Parameters = ParseParameters(theTolerance) theTolerance,Parameters = ParseParameters(theTolerance)
if AllowNonManifold:
anObj = self.HealOp.SewAllowNonManifold(theObject, theTolerance)
else:
anObj = self.HealOp.Sew(theObject, theTolerance) anObj = self.HealOp.Sew(theObject, theTolerance)
RaiseIfFailed("Sew", self.HealOp) RaiseIfFailed("Sew", self.HealOp)
anObj.SetParameters(Parameters) anObj.SetParameters(Parameters)

View File

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

View File

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