0022745: [EDF] Improvement of Sewing operation

This commit is contained in:
eap 2014-10-09 18:34:57 +04:00 committed by vsr
parent 614060d67a
commit db4ad95d8e
23 changed files with 287 additions and 144 deletions

View File

@ -1,27 +1,26 @@
# Sewing
import salome
import salome, math
salome.salome_init()
import GEOM
from salome.geom import geomBuilder
geompy = geomBuilder.New(salome.myStudy)
import math
gg = salome.ImportComponentGUI("GEOM")
gg = salome.ImportComponentGUI("GEOM")
# create base points
px = geompy.MakeVertex(100., 0., 0.)
py = geompy.MakeVertex(0., 100., 0.)
pz = geompy.MakeVertex(0., 0., 100.)
# create base geometry 2D & 3D
# create base geometry 2D
vector = geompy.MakeVector(px, py)
arc = geompy.MakeArc(py, pz, px)
arc = geompy.MakeArc(py, pz, px)
# create base objects
angle = 45. * math.pi / 180
WantPlanarFace = 1 #True
wire = geompy.MakeWire([vector, arc])
face = geompy.MakeFace(wire, WantPlanarFace)
WantPlanarFace = True
wire = geompy.MakeWire([vector, arc])
face = geompy.MakeFace(wire, WantPlanarFace)
face_rot = geompy.MakeRotation(face, vector, angle)
# make sewing
@ -29,9 +28,9 @@ precision = 0.00001
sewing = geompy.MakeSewing([face, face_rot], precision)
# add objects in the study
id_face = geompy.addToStudy(face, "Face")
id_face = geompy.addToStudy(face, "Face")
id_face_rot = geompy.addToStudy(face_rot, "Face rotation")
id_sewing = geompy.addToStudy(sewing, "Sewing")
id_sewing = geompy.addToStudy(sewing, "Sewing")
# display the results
gg.createAndDisplayGO(id_face)
@ -40,3 +39,12 @@ gg.createAndDisplayGO(id_face_rot)
gg.setDisplayMode(id_face_rot,1)
gg.createAndDisplayGO(id_sewing)
gg.setDisplayMode(id_sewing,1)
# Example 2: make a shell of a multiply translated face
quad = geompy.MakeFaceHW( 10, 20, 1 )
quadCompound = geompy.MakeMultiTranslation1D( quad, geompy.MakeVectorDXDYDZ(1,0,0), 10, 3)
shell = geompy.Sew( quadCompound, 1e-6 )
id_shell = geompy.addToStudy( shell, "3 quads shell")
gg.createAndDisplayGO(id_shell)

BIN
doc/salome/gui/GEOM/images/neo-detect2.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.7 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

BIN
doc/salome/gui/GEOM/images/repair6.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -25,7 +25,7 @@ By <b>Cartesian coordinates</b> , which can be either:
- \b Relative coordinates \b DX, \b DY and \b DZ with respect to the previous applied point,
By <b>Angular coordinates</b>, which include:
- the \b Length of the segment and an \b Angle in the chosen plane (OXY for example) in \b Relative mode. The angle is then relative to a local coordinate system with the last point of the sketch as origin. </li>
- the \b Length of the segment and an \b Angle in the chosen plane (OXY for example) in \b Relative mode. The angle is then relative to a local coordinate system with the last point of the sketch as origin.
\image html 3dsketch_angle_rel.png

View File

@ -103,7 +103,7 @@ Buttons marked with small downward triangles have extended
functionality which can be accessed by locking on them with left
mouse button.
\image tree_tool_bar
\image html tree_tool_bar.png
<b>Dump View</b> - exports an object from the viewer in bmp, png or
jpeg image format.

View File

@ -25,8 +25,8 @@ Our <b>TUI Scripts</b> provide you with useful examples of the use of
<em>To import geometrical objects from a BREP, IGES, STEP or STL file:</em>
\par
From the \b File menu choose <b>Import/<FormatName></b>, where <b><FormatName></b> is a name
of desirable format. In the <b>Import <FormatName></b> dialog box select the file to import
From the \b File menu choose <b>Import/\<FormatName\></b>, where <b>\<FormatName\></b> is a name
of desirable format. In the <b>Import \<FormatName\></b> dialog box select the file to import
and press \b Open. The file will be imported in the module and its contents (geometrical object)
will be displayed in the <b>Object Browser</b>.
@ -63,8 +63,8 @@ file:</em>
\par
Select the object you wish to export, then from the \b File menu choose
<b>Export/<FormatName></b>, where <b><FormatName></b> is a name of desirable format.
In the <b>Export <FormatName></b> dialog box define the name and the location
<b>Export/\<FormatName\></b>, where <b>\<FormatName\></b> is a name of desirable format.
In the <b>Export \<FormatName\></b> dialog box define the name and the location
of the file to export and press \b Save.
The dialog box to export the file can provide additional advanced parameters.

View File

@ -18,7 +18,7 @@ It is possible to show/hide a dimension in the view by checking on/off the box t
The buttons to the right of the list provide the following operations:
<ul>
<li>"Add" - opens \ref add_dimension_page "Add Dimension" dialog to define a new fly-out.</li>
<li>"Add" - opens "Add Dimension" dialog to define a new fly-out.</li>
<li>"Remove" - removes the selected item from the list.</li>
<li>"Show All" / "Hide All" - shows/hides all dimensions existing in the list.</li>
</ul>

View File

@ -2,9 +2,24 @@
\page sewing_operation_page Sewing
\b Sewing operation allows uniting several faces (possibly contained
in a shell, solid or compound) into one shell while geometrically
coincident (within a specified tolerance) edges (or parts of edges) of
different faces are replaced by one edge thus producing a shell of
faces with shared boundaries.<p>
This operation is similar to <b>New Entity - > Build - > Shell</b>
operation, the difference is that with \b Sewing you can specify the
tolerance and can get a non-manifold result. <p>
Possibility to create a non-manifold shell can be used e.g. to create a
shell forming several closed domains and then to create several solids
with shared boundaries from this shell.
\note Geometrically coincident faces (or part of faces) won't be
replaced by one face during \b Sewing.
To produce a \b Sewing operation in the <b>Main Menu</b> select <b>Repair - > Sewing</b>.
The \b Result will be a \b GEOM_Object.
The \b Result will be a \b GEOM_Object (shell).
\image html repair6.png

View File

@ -3680,7 +3680,7 @@ module GEOM
* \param theTolerance Required tolerance value.
* \return New GEOM_Object, containing processed shape.
*/
GEOM_Object Sew (in GEOM_Object theObject, in double theTolerance);
GEOM_Object Sew (in ListOfGO theObjects, in double theTolerance);
/*!
* Sewing of the given object. Allows non-manifold sewing.
@ -3688,7 +3688,7 @@ module GEOM
* \param theTolerance Required tolerance value.
* \return New GEOM_Object, containing processed shape.
*/
GEOM_Object SewAllowNonManifold(in GEOM_Object theObject, in double theTolerance);
GEOM_Object SewAllowNonManifold(in ListOfGO theObjects, in double theTolerance);
/*!
* Rebuild the topology of theCompound of solids by removing
@ -3725,12 +3725,12 @@ module GEOM
/*!
* \brief Get a list of wires (wrapped in GEOM_Object-s),
* that constitute a free boundary of the given shape.
* \param theObject Shape to get free boundary of.
* \param theObject Shapes to get free boundary of.
* \param theClosedWires Output. Closed wires on the free boundary of the given shape.
* \param theOpenWires Output. Open wires on the free boundary of the given shape.
* \return FALSE, if an error(s) occured during the method execution.
*/
boolean GetFreeBoundary (in GEOM_Object theObject,
boolean GetFreeBoundary (in ListOfGO theObjects,
out ListOfGO theClosedWires,
out ListOfGO theOpenWires);

View File

@ -140,6 +140,23 @@ namespace GEOM
}
return *this;
}
Standard_EXPORT TPythonDump&
TPythonDump::operator<< (const std::list<Handle(GEOM_Object)>& theObjects)
{
Standard_Integer aLength = theObjects.size();
if ( aLength > 1 ) {
myStream << "[";
}
std::list<Handle(GEOM_Object)>::const_iterator obj = theObjects.begin();
for ( Standard_Integer i = 1; i <= aLength; i++, ++obj ) {
*this << *obj;
if ( i < aLength ) myStream << ", ";
}
if ( aLength > 1 ) {
myStream << "]";
}
return *this;
}
TPythonDump& TPythonDump::operator<< (const GEOM_BaseObject* theObject)
{

View File

@ -30,6 +30,8 @@
#include <TCollection_AsciiString.hxx>
#include <list>
namespace GEOM
{
class TPythonDump
@ -56,7 +58,8 @@ namespace GEOM
Standard_EXPORT TPythonDump& operator<< (const TCollection_AsciiString theArg);
Standard_EXPORT TPythonDump& operator<< (const TopAbs_ShapeEnum theArg);
Standard_EXPORT TPythonDump& operator<< (const Handle(GEOM_BaseObject)& theObject);
Standard_EXPORT TPythonDump& operator<< (const Handle(TColStd_HSequenceOfTransient)& theObjects);
Standard_EXPORT TPythonDump& operator<< (const Handle(TColStd_HSequenceOfTransient)& objects);
Standard_EXPORT TPythonDump& operator<< (const std::list<Handle(GEOM_Object)>& theObjects);
Standard_EXPORT TPythonDump& operator<< (const GEOM_BaseObject* theObject);
};

View File

@ -425,14 +425,33 @@ Standard_Boolean GEOMImpl_HealingDriver::RemoveHoles (GEOMImpl_IHealing* theHI,
//function : Sew
//purpose :
//=======================================================================
Standard_Boolean GEOMImpl_HealingDriver::Sew (GEOMImpl_IHealing* theHI,
Standard_Boolean GEOMImpl_HealingDriver::Sew (GEOMImpl_IHealing* theHI,
const TopoDS_Shape& theOriginalShape,
TopoDS_Shape& theOutShape,
Standard_Boolean isAllowNonManifold) const
TopoDS_Shape& theOutShape,
Standard_Boolean isAllowNonManifold) const
{
Standard_Real aTol = theHI->GetTolerance();
ShHealOper_Sewing aHealer (theOriginalShape, aTol);
TopoDS_Compound faceCompound;
BRep_Builder builder;
builder.MakeCompound( faceCompound );
TopExp_Explorer faceExp( theOriginalShape, TopAbs_FACE );
for ( ; faceExp.More(); faceExp.Next() )
builder.Add( faceCompound, faceExp.Current() );
Handle(TColStd_HSequenceOfTransient) otherObjs = theHI->GetShapes();
for ( int ind = 1; ind <= otherObjs->Length(); ind++)
{
Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(otherObjs->Value(ind));
TopoDS_Shape aShape = aRefShape->GetValue();
if (aShape.IsNull())
Standard_NullObject::Raise("Null object given");
for ( faceExp.Init( aShape, TopAbs_FACE ); faceExp.More(); faceExp.Next() )
builder.Add( faceCompound, faceExp.Current() );
}
ShHealOper_Sewing aHealer (faceCompound, aTol);
// Set non-manifold mode.
aHealer.SetNonManifoldMode(isAllowNonManifold);
@ -606,7 +625,7 @@ void GEOMImpl_HealingDriver::FuseCollinearEdges (const TopoDS_Shape& theOriginal
removeAll = true;
if (!removeAll) {
for (unsigned int ind = 1; ind <= aVerts->Length(); ind++) {
for ( int ind = 1; ind <= aVerts->Length(); ind++) {
Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aVerts->Value(ind));
TopoDS_Shape aShape_i = aRefShape->GetValue();
if (aShape_i.IsNull())
@ -881,7 +900,7 @@ GetCreationInformation(std::string& theOperationName,
case SEWING:
case SEWING_NON_MANIFOLD:
theOperationName = "SEWING";
AddParam( theParams, "Selected shape", aCI.GetOriginal() );
AddParam( theParams, "Selected shapes", aCI.GetOriginalAndShapes() );
AddParam( theParams, "Allow Non Manifold", ( aType == SEWING_NON_MANIFOLD ));
AddParam( theParams, "Tolerance", aCI.GetTolerance() );
break;

View File

@ -55,7 +55,7 @@ public:
void SetValues( const Handle(TColStd_HArray1OfExtendedString)& arr ) { if ( !arr.IsNull() ) _func->SetStringArray(ARG_SHAPE_PROCESS_VALUES, arr); }
Handle(TColStd_HArray1OfExtendedString) GetValues() { return _func->GetStringArray(ARG_SHAPE_PROCESS_VALUES); }
void SetOriginal( Handle(GEOM_Function)& f ) { _func->SetReference(ARG_ORIGINAL, f); }
void SetOriginal( Handle(GEOM_Function) f ) { _func->SetReference(ARG_ORIGINAL, f); }
Handle(GEOM_Function) GetOriginal() { return _func->GetReference(ARG_ORIGINAL); }
void SetFaces( const Handle(TColStd_HArray1OfInteger)& arr ) { if ( !arr.IsNull() ) _func->SetIntegerArray(ARG_LIST_ARGUMENTS, arr); }
@ -84,6 +84,13 @@ public:
Handle(TColStd_HSequenceOfTransient) GetShapes()
{ return _func->GetReferenceList(ARG_LIST_SHAPES); }
Handle(TColStd_HSequenceOfTransient) GetOriginalAndShapes()
{
Handle(TColStd_HSequenceOfTransient) funs = GetShapes();
if ( funs.IsNull() ) funs = new TColStd_HSequenceOfTransient;
funs->Prepend( GetOriginal() );
return funs;
}
private:
Handle(GEOM_Function) _func;
};

View File

@ -28,9 +28,7 @@
#include <Standard_Stream.hxx>
#include <GEOMImpl_IHealingOperations.hxx>
#include <GEOM_PythonDump.hxx>
#include <GEOMImpl_HealingDriver.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOMImpl_IHealing.hxx>
@ -40,22 +38,20 @@
#include <Basics_OCCTVersion.hxx>
#include "utilities.h"
#include <utilities.h>
#include <OpUtil.hxx>
#include <Utils_ExceptHandlers.hxx>
#include <BRep_Builder.hxx>
#include <ShHealOper_ShapeProcess.hxx>
#include <ShapeAnalysis_FreeBounds.hxx>
#include <TopoDS_Compound.hxx>
#include <TopExp_Explorer.hxx>
#include <TColStd_HArray1OfExtendedString.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
#include <TCollection_AsciiString.hxx>
#include <TDF_Tool.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_SequenceOfShape.hxx>
#include <TopoDS_Compound.hxx>
#include <Standard_Failure.hxx>
#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic : see Lucien PIGNOLONI / OCC
@ -585,27 +581,36 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::FillHoles (Handle(GEOM_Object)
* Sew
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObject,
double theTolerance,
bool isAllowNonManifold)
Handle(GEOM_Object)
GEOMImpl_IHealingOperations::Sew (std::list<Handle(GEOM_Object)>& theObjects,
double theTolerance,
bool isAllowNonManifold)
{
// set error code, check parameters
SetErrorCode(KO);
if (theObject.IsNull())
if (theObjects.empty())
return NULL;
Handle(GEOM_Function) aFunction, aLastFunction = theObject->GetLastFunction();
if (aLastFunction.IsNull()) return NULL; //There is no function which creates an object to be processed
Handle(TColStd_HSequenceOfTransient) objects = new TColStd_HSequenceOfTransient;
std::list<Handle(GEOM_Object)>::iterator it = theObjects.begin();
for (; it != theObjects.end(); it++)
{
Handle(GEOM_Function) aRefSh = (*it)->GetLastFunction();
if (aRefSh.IsNull()) {
SetErrorCode("NULL argument shape");
return NULL;
}
objects->Append(aRefSh);
}
// Add a new object
Handle(GEOM_Object) aNewObject = GetEngine()->AddObject( GetDocID(), GEOM_COPY );
//Add the function
int aFunctionType = (isAllowNonManifold ? SEWING_NON_MANIFOLD : SEWING);
aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), aFunctionType);
Handle(GEOM_Function) aFunction =
aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), aFunctionType);
if (aFunction.IsNull()) return NULL;
//Check if the function is set correctly
@ -614,7 +619,8 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObj
// prepare "data container" class IHealing
GEOMImpl_IHealing HI(aFunction);
HI.SetTolerance( theTolerance );
HI.SetOriginal( aLastFunction );
HI.SetOriginal( theObjects.front()->GetLastFunction() ); objects->Remove(1);
HI.SetShapes( objects );
//Compute the result
try {
@ -634,7 +640,7 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::Sew (Handle(GEOM_Object) theObj
//Make a Python command
GEOM::TPythonDump pd(aFunction);
pd << aNewObject << " = geompy.Sew(" << theObject << ", " << theTolerance;
pd << aNewObject << " = geompy.Sew(" << theObjects << ", " << theTolerance;
if (isAllowNonManifold) {
pd << ", true";
@ -835,19 +841,40 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::FuseCollinearEdgesWithinWire
* GetFreeBoundary
*/
//=============================================================================
bool GEOMImpl_IHealingOperations::GetFreeBoundary (Handle(GEOM_Object) theObject,
bool GEOMImpl_IHealingOperations::GetFreeBoundary (Handle(TColStd_HSequenceOfTransient)& theObjects,
Handle(TColStd_HSequenceOfTransient)& theClosed,
Handle(TColStd_HSequenceOfTransient)& theOpen )
{
// set error code, check parameters
SetErrorCode(KO);
if ( theObject.IsNull() || theClosed.IsNull() || theOpen.IsNull() )
if ( theObjects.IsNull() || theObjects->Length() == 0 ||
theClosed.IsNull() || theOpen.IsNull() )
return false;
TopoDS_Shape aShape = theObject->GetValue();
if ( aShape.IsNull() )
return false;
TopoDS_Shape aShape;
TopTools_SequenceOfShape shapes;
for ( int ind = 1; ind <= theObjects->Length(); ind++)
{
Handle(GEOM_Object) aRefShape = Handle(GEOM_Object)::DownCast( theObjects->Value(ind));
if ( aRefShape.IsNull() )
return false;
aShape = aRefShape->GetValue();
if ( aShape.IsNull() )
return false;
shapes.Append( aShape );
}
if ( shapes.Length() > 1 )
{
TopoDS_Compound compound;
BRep_Builder builder;
builder.MakeCompound( compound );
for ( int i = 1; i <= shapes.Length(); ++i )
builder.Add( compound, shapes( i ) );
aShape = compound;
}
// get free boundary shapes
@ -906,7 +933,7 @@ bool GEOMImpl_IHealingOperations::GetFreeBoundary (Handle(GEOM_Object) theObject
pd << "empty_list";
}
pd << ") = geompy.GetFreeBoundary(" << theObject << ")";
pd << ") = geompy.GetFreeBoundary(" << theObjects << ")";
}
SetErrorCode(OK);

View File

@ -70,9 +70,9 @@ class GEOMImpl_IHealingOperations : public GEOM_IOperations {
Standard_EXPORT Handle(GEOM_Object) FillHoles( Handle(GEOM_Object) theObject,
const Handle(TColStd_HArray1OfInteger)& theWires);
Standard_EXPORT Handle(GEOM_Object) Sew( Handle(GEOM_Object) theObject,
double theTolerance,
bool isAllowNonManifold);
Standard_EXPORT Handle(GEOM_Object) Sew( std::list<Handle(GEOM_Object)> & theObject,
double theTolerance,
bool isAllowNonManifold);
Standard_EXPORT Handle(GEOM_Object) RemoveInternalFaces (Handle(GEOM_Object) theObject);
@ -88,9 +88,9 @@ class GEOMImpl_IHealingOperations : public GEOM_IOperations {
// this function does not use Function-Driver mechanism, it just computes the free
// boundary edges and returns them in the sequence. It is called just for information reasons
// and it's not intended for history/undo/redo/etc..
Standard_EXPORT bool GetFreeBoundary ( Handle(GEOM_Object) theObject,
Handle(TColStd_HSequenceOfTransient)& theOutClosedWires,
Handle(TColStd_HSequenceOfTransient)& theOutOpenWires );
Standard_EXPORT bool GetFreeBoundary ( Handle(TColStd_HSequenceOfTransient)& theObjects,
Handle(TColStd_HSequenceOfTransient)& theOutClosedWires,
Handle(TColStd_HSequenceOfTransient)& theOutOpenWires );
Standard_EXPORT Handle(GEOM_Object) ChangeOrientation( Handle(GEOM_Object) theObject);
Standard_EXPORT Handle(GEOM_Object) ChangeOrientationCopy( Handle(GEOM_Object) theObject);

View File

@ -316,8 +316,8 @@ GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::FillHoles (GEOM::GEOM_Object_pt
* Sew
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::Sew (GEOM::GEOM_Object_ptr theObject,
CORBA::Double theTolerance)
GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::Sew (const GEOM::ListOfGO& theObjects,
CORBA::Double theTolerance)
{
GEOM::GEOM_Object_var aGEOMObject;
@ -328,14 +328,18 @@ GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::Sew (GEOM::GEOM_Object_ptr theO
if (theTolerance < 0)
return aGEOMObject._retn();
// Get the object itself
Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
if (anObject.IsNull())
return aGEOMObject._retn();
//Get the shapes
std::list<Handle(GEOM_Object)> objects;
const int aLen = theObjects.length();
for ( int ind = 0; ind < aLen; ind++)
{
Handle(GEOM_Object) aSh = GetObjectImpl(theObjects[ind]);
if (aSh.IsNull()) return aGEOMObject._retn();
objects.push_back(aSh);
}
// Perform
Handle(GEOM_Object) aNewObject =
GetOperations()->Sew( anObject, theTolerance, false );
Handle(GEOM_Object) aNewObject = GetOperations()->Sew( objects, theTolerance, false );
if (!GetOperations()->IsDone() || aNewObject.IsNull())
return aGEOMObject._retn();
@ -347,8 +351,9 @@ GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::Sew (GEOM::GEOM_Object_ptr theO
* SewAllowNonManifold
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::SewAllowNonManifold (GEOM::GEOM_Object_ptr theObject,
CORBA::Double theTolerance)
GEOM::GEOM_Object_ptr
GEOM_IHealingOperations_i::SewAllowNonManifold (const GEOM::ListOfGO& theObjects,
CORBA::Double theTolerance)
{
GEOM::GEOM_Object_var aGEOMObject;
@ -359,14 +364,18 @@ GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::SewAllowNonManifold (GEOM::GEOM
if (theTolerance < 0)
return aGEOMObject._retn();
// Get the object itself
Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
if (anObject.IsNull())
return aGEOMObject._retn();
//Get the shapes
std::list<Handle(GEOM_Object)> objects;
const int aLen = theObjects.length();
for ( int ind = 0; ind < aLen; ind++)
{
Handle(GEOM_Object) aSh = GetObjectImpl(theObjects[ind]);
if (aSh.IsNull()) return aGEOMObject._retn();
objects.push_back(aSh);
}
// Perform
Handle(GEOM_Object) aNewObject =
GetOperations()->Sew( anObject, theTolerance, true );
Handle(GEOM_Object) aNewObject = GetOperations()->Sew( objects, theTolerance, true );
if (!GetOperations()->IsDone() || aNewObject.IsNull())
return aGEOMObject._retn();
@ -473,9 +482,10 @@ GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::FuseCollinearEdgesWithinWire
* GetFreeBoundary
*/
//=============================================================================
CORBA::Boolean GEOM_IHealingOperations_i::GetFreeBoundary ( GEOM::GEOM_Object_ptr theObject,
GEOM::ListOfGO_out theClosedWires,
GEOM::ListOfGO_out theOpenWires )
CORBA::Boolean
GEOM_IHealingOperations_i::GetFreeBoundary ( const GEOM::ListOfGO & theObjects,
GEOM::ListOfGO_out theClosedWires,
GEOM::ListOfGO_out theOpenWires )
{
theClosedWires = new GEOM::ListOfGO;
theOpenWires = new GEOM::ListOfGO;
@ -483,14 +493,19 @@ CORBA::Boolean GEOM_IHealingOperations_i::GetFreeBoundary ( GEOM::GEOM_Object_pt
// Set a not done flag
GetOperations()->SetNotDone();
// Get the object itself
Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
if (anObject.IsNull())
return false;
// Get the objects
Handle(TColStd_HSequenceOfTransient) anObjects = new TColStd_HSequenceOfTransient();
for ( size_t i = 0; i < theObjects.length(); ++i )
{
Handle(GEOM_Object) anObject = GetObjectImpl(theObjects[i]);
if (anObject.IsNull())
return false;
anObjects->Append( anObject );
}
Handle(TColStd_HSequenceOfTransient) aClosed = new TColStd_HSequenceOfTransient();
Handle(TColStd_HSequenceOfTransient) anOpen = new TColStd_HSequenceOfTransient();
bool res = GetOperations()->GetFreeBoundary( anObject, aClosed, anOpen );
bool res = GetOperations()->GetFreeBoundary( anObjects, aClosed, anOpen );
if ( !GetOperations()->IsDone() || !res )
return false;

View File

@ -69,10 +69,10 @@ class GEOM_I_EXPORT GEOM_IHealingOperations_i :
GEOM::GEOM_Object_ptr FillHoles (GEOM::GEOM_Object_ptr theObject,
const GEOM::short_array& theWires);
GEOM::GEOM_Object_ptr Sew (GEOM::GEOM_Object_ptr theObject,
GEOM::GEOM_Object_ptr Sew (const GEOM::ListOfGO & theObject,
CORBA::Double theTolerance);
GEOM::GEOM_Object_ptr SewAllowNonManifold (GEOM::GEOM_Object_ptr theObject,
GEOM::GEOM_Object_ptr SewAllowNonManifold (const GEOM::ListOfGO & theObject,
CORBA::Double theTolerance);
GEOM::GEOM_Object_ptr RemoveInternalFaces (GEOM::GEOM_Object_ptr theCompound);
@ -85,9 +85,9 @@ class GEOM_I_EXPORT GEOM_IHealingOperations_i :
GEOM::GEOM_Object_ptr FuseCollinearEdgesWithinWire (GEOM::GEOM_Object_ptr theWire,
const GEOM::ListOfGO& theVertices);
CORBA::Boolean GetFreeBoundary(GEOM::GEOM_Object_ptr theObject,
GEOM::ListOfGO_out theClosedWires,
GEOM::ListOfGO_out theOpenWires );
CORBA::Boolean GetFreeBoundary(const GEOM::ListOfGO& theObjects,
GEOM::ListOfGO_out theClosedWires,
GEOM::ListOfGO_out theOpenWires );
GEOM::GEOM_Object_ptr ChangeOrientation (GEOM::GEOM_Object_ptr theObject);
GEOM::GEOM_Object_ptr ChangeOrientationCopy (GEOM::GEOM_Object_ptr theObject);

View File

@ -517,6 +517,14 @@ def EnumToLong(theItem):
if hasattr(theItem, "_v"): ret = theItem._v
return ret
## Pack an argument into a list
def ToList( arg ):
if isinstance( arg, list ):
return arg
if hasattr( arg, "__getitem__" ):
return list( arg )
return [ arg ]
## Information about closed/unclosed state of shell or wire
# @ingroup l1_geomBuilder_auxiliary
class info:
@ -4537,7 +4545,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
New GEOM.GEOM_Object, containing the created shell.
"""
# Example: see GEOM_TestAll.py
anObj = self.ShapesOp.MakeShell(theFacesAndShells)
anObj = self.ShapesOp.MakeShell( ToList( theFacesAndShells ))
RaiseIfFailed("MakeShell", self.ShapesOp)
self._autoPublish(anObj, theName, "shell")
return anObj
@ -6317,7 +6325,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
self._autoPublish(anObj, theName, "suppressFaces")
return anObj
## Sewing of some shapes into single shape.
## Sewing of faces into a single shell.
# @param ListShape Shapes to be processed.
# @param theTolerance Required tolerance value.
# @param AllowNonManifold Flag that allows non-manifold sewing.
@ -6325,12 +6333,12 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
# 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.
# @return New GEOM.GEOM_Object, containing a result shell.
#
# @ref tui_sewing "Example"
def MakeSewing(self, ListShape, theTolerance, AllowNonManifold=False, theName=None):
"""
Sewing of some shapes into single shape.
Sewing of faces into a single shell.
Parameters:
ListShape Shapes to be processed.
@ -6341,30 +6349,29 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
publication is switched on, default value is used for result name.
Returns:
New GEOM.GEOM_Object, containing processed shape.
New GEOM.GEOM_Object, containing containing a result shell.
"""
# Example: see GEOM_TestHealing.py
comp = self.MakeCompound(ListShape)
# note: auto-publishing is done in self.Sew()
anObj = self.Sew(comp, theTolerance, AllowNonManifold, theName)
anObj = self.Sew(ListShape, theTolerance, AllowNonManifold, theName)
return anObj
## Sewing of the given object.
# @param theObject Shape to be processed.
## Sewing of faces into a single shell.
# @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.
#
# @return New GEOM.GEOM_Object, containing processed shape.
# @return New GEOM.GEOM_Object, containing a result shell.
@ManageTransactions("HealOp")
def Sew(self, theObject, theTolerance, AllowNonManifold=False, theName=None):
def Sew(self, ListShape, theTolerance, AllowNonManifold=False, theName=None):
"""
Sewing of the given object.
Sewing of faces into a single shell.
Parameters:
theObject Shape to be processed.
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
@ -6372,17 +6379,18 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
publication is switched on, default value is used for result name.
Returns:
New GEOM.GEOM_Object, containing processed shape.
New GEOM.GEOM_Object, containing a result shell.
"""
# Example: see MakeSewing() above
theTolerance,Parameters = ParseParameters(theTolerance)
if AllowNonManifold:
anObj = self.HealOp.SewAllowNonManifold(theObject, theTolerance)
anObj = self.HealOp.SewAllowNonManifold( ToList( ListShape ), theTolerance)
else:
anObj = self.HealOp.Sew(theObject, theTolerance)
anObj = self.HealOp.Sew( ToList( ListShape ), theTolerance)
# To avoid script failure in case of good argument shape
# (Fix of test cases geom/bugs11/L7,L8)
if self.HealOp.GetErrorCode() == "ShHealOper_NotError_msg":
return theObject
return anObj
RaiseIfFailed("Sew", self.HealOp)
anObj.SetParameters(Parameters)
self._autoPublish(anObj, theName, "sewed")
@ -6707,7 +6715,7 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
theOpenWires: Open wires on the free boundary of the given shape.
"""
# Example: see GEOM_TestHealing.py
anObj = self.HealOp.GetFreeBoundary(theObject)
anObj = self.HealOp.GetFreeBoundary( ToList( theObject ))
RaiseIfFailed("GetFreeBoundary", self.HealOp)
self._autoPublish(anObj[1], theName, "closedWire")
self._autoPublish(anObj[2], theName, "openWire")

View File

@ -261,8 +261,11 @@ bool RepairGUI_FreeBoundDlg::execute (ObjectList& objects)
{
GEOM::ListOfGO_var aClosed, anOpen;
GEOM::ListOfGO_var objList = new GEOM::ListOfGO;
objList->length(1);
objList[0] = myObj;
GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow(getOperation());
bool result = anOper->GetFreeBoundary(myObj, aClosed, anOpen);
bool result = anOper->GetFreeBoundary(objList, aClosed, anOpen);
if (result) {
myNbClosed = aClosed->length();

View File

@ -330,8 +330,11 @@ bool RepairGUI_RemoveHolesDlg::execute (ObjectList& objects)
// highlight them (add to objects), display message dialog
GEOM::ListOfGO_var aClosed, anOpen;
GEOM::ListOfGO_var objList = new GEOM::ListOfGO;
objList->length(1);
objList[0] = myObject;
GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow(getOperation());
aResult = anOper->GetFreeBoundary(myObject, aClosed, anOpen);
aResult = anOper->GetFreeBoundary(objList, aClosed, anOpen);
if (aResult) {
myClosed = aClosed->length();

View File

@ -117,7 +117,7 @@ void RepairGUI_SewingDlg::Init()
/* init variables */
myEditCurrentArgument = GroupPoints->LineEdit1;
myObject = GEOM::GEOM_Object::_nil();
myObjects.clear();
//myGeomGUI->SetState( 0 );
initSelection();
@ -166,7 +166,7 @@ bool RepairGUI_SewingDlg::ClickOnApply()
initName();
GroupPoints->LineEdit1->setText( "" );
myObject = GEOM::GEOM_Object::_nil();
myObjects.clear();
initSelection();
@ -182,17 +182,13 @@ void RepairGUI_SewingDlg::SelectionIntoArgument()
{
erasePreview();
myEditCurrentArgument->setText( "" );
myObject = GEOM::GEOM_Object::_nil();
myObjects.clear();
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
myObjects = getSelected( TopAbs_SHAPE, -1 );
if ( aSelList.Extent() == 1 ) {
Handle(SALOME_InteractiveObject) anIO = aSelList.First();
myObject = GEOMBase::ConvertIOinGEOMObject( anIO );
if ( !CORBA::is_nil( myObject ) )
myEditCurrentArgument->setText( GEOMBase::GetName( myObject ) );
if ( !myObjects.isEmpty() ) {
QString aName = myObjects.count() > 1 ? QString( "%1_objects").arg( myObjects.count() ) : GEOMBase::GetName( myObjects[0].get() );
myEditCurrentArgument->setText( aName );
}
}
@ -235,7 +231,7 @@ void RepairGUI_SewingDlg::ActivateThisDialog()
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
GroupPoints->LineEdit1->setText( "" );
myObject = GEOM::GEOM_Object::_nil();
myObjects.clear();
myClosed = -1;
myOpen = -1;
@ -273,7 +269,7 @@ bool RepairGUI_SewingDlg::isValid( QString& msg )
{
myClosed = -1;
bool ok = myTolEdt->isValid( msg, !IsPreview() );
return !myObject->_is_nil() && ( IsPreview() || myTolEdt->value() > 0. ) && ok;
return !myObjects.isEmpty() && ( IsPreview() || myTolEdt->value() > 0. ) && ok;
}
//=================================================================================
@ -285,10 +281,15 @@ bool RepairGUI_SewingDlg::execute( ObjectList& objects )
bool aResult = false;
GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow( getOperation() );
GEOM::ListOfGO_var objList = new GEOM::ListOfGO;
objList->length( myObjects.count() );
for ( int i = 0; i < myObjects.count(); ++i )
objList[i] = myObjects[i].copy();
if ( IsPreview() ) { // called from onDetect(): detect free boundary edges, highlight them (add to objects), display message dialog
GEOM::ListOfGO_var aClosed, anOpen;
aResult = anOper->GetFreeBoundary( myObject, aClosed, anOpen );
aResult = anOper->GetFreeBoundary( objList, aClosed, anOpen );
if ( aResult ) {
myClosed = aClosed->length();
@ -306,9 +307,9 @@ bool RepairGUI_SewingDlg::execute( ObjectList& objects )
GEOM::GEOM_Object_var anObj;
if (myAllowNonManifoldChk->isChecked()) {
anObj = anOper->SewAllowNonManifold( myObject, myTolEdt->value() );
anObj = anOper->SewAllowNonManifold( objList, myTolEdt->value() );
} else {
anObj = anOper->Sew( myObject, myTolEdt->value() );
anObj = anOper->Sew( objList, myTolEdt->value() );
}
aResult = !anObj->_is_nil();
@ -334,6 +335,7 @@ bool RepairGUI_SewingDlg::execute( ObjectList& objects )
void RepairGUI_SewingDlg::initSelection()
{
TColStd_MapOfInteger aTypes;
aTypes.Add( GEOM_FACE );
aTypes.Add( GEOM_SHELL );
aTypes.Add( GEOM_SOLID );
aTypes.Add( GEOM_COMPOUND );

View File

@ -42,7 +42,7 @@ class RepairGUI_SewingDlg : public GEOMBase_Skeleton
{
Q_OBJECT
public:
public:
RepairGUI_SewingDlg( GeometryGUI*, QWidget* = 0, bool = false );
~RepairGUI_SewingDlg();
@ -51,33 +51,33 @@ protected:
virtual GEOM::GEOM_IOperations_ptr createOperation();
virtual bool isValid( QString& );
virtual bool execute( ObjectList& );
private:
void Init();
void enterEvent( QEvent* );
void initSelection();
private:
GEOM::GEOM_Object_var myObject;
QList<GEOM::GeomObjPtr> myObjects;
DlgRef_1SelExt* GroupPoints;
QCheckBox* myAllowNonManifoldChk;
SalomeApp_DoubleSpinBox* myTolEdt;
QPushButton* myFreeBoundBtn;
int myClosed; // Number of free closed boundaries detected. Calculated in execute(), used in onDetect().
int myOpen; // Number of free open boundaries detected. Calculated in execute(), used in onDetect().
private slots:
void ClickOnOk();
bool ClickOnApply();
void ActivateThisDialog();
void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();
void onDetect();
};

View File

@ -248,15 +248,31 @@ Standard_Boolean ShHealOper_Sewing::getModifications(const TopoDS_Shape& theShap
Standard_Boolean ShHealOper_Sewing::isSewed(const TopoDS_Shape& theShape) const
{
Standard_Integer nbNewShells =0;
Standard_Integer nbOldShells =0;
TopExp_Explorer aExpShells(theShape,TopAbs_SHELL);
for( ; aExpShells.More(); aExpShells.Next())
nbNewShells++;
for( aExpShells.Init(myInitShape,TopAbs_SHELL); aExpShells.More(); aExpShells.Next())
nbOldShells++;
return (nbNewShells != nbOldShells);
// Standard_Integer nbNewShells =0;
// Standard_Integer nbOldShells =0;
// TopExp_Explorer aExpShells(theShape,TopAbs_SHELL);
// for( ; aExpShells.More(); aExpShells.Next())
// nbNewShells++;
// for( aExpShells.Init(myInitShape,TopAbs_SHELL); aExpShells.More(); aExpShells.Next())
// nbOldShells++;
// return (nbNewShells != nbOldShells);
// EAP, 22745: [EDF] Improvement of Sewing operation
// now myInitShape is ALWAYS a compound of faces -> no shells
int nbNew = 0, nbOld = 0;
TopExp_Explorer exp;
for ( exp.Init( theShape, TopAbs_VERTEX ); exp.More(); exp.Next() ) ++nbNew;
for ( exp.Init( myInitShape, TopAbs_VERTEX ); exp.More(); exp.Next() ) ++nbOld;
if ( nbNew != nbOld )
return true;
for ( exp.Init( theShape, TopAbs_EDGE ); exp.More(); exp.Next() ) ++nbNew;
for ( exp.Init( myInitShape, TopAbs_EDGE ); exp.More(); exp.Next() ) ++nbOld;
if ( nbNew != nbOld )
return true;
return false;
}
//=======================================================================
//function : deleteFreeEdges
//purpose :