# 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
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)
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)
- \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
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.
<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>.
\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.
\r
The buttons to the right of the list provide the following operations:\r
<ul>\r
-<li>"Add" - opens \ref add_dimension_page "Add Dimension" dialog to define a new fly-out.</li>\r
+<li>"Add" - opens "Add Dimension" dialog to define a new fly-out.</li>\r
<li>"Remove" - removes the selected item from the list.</li>\r
<li>"Show All" / "Hide All" - shows/hides all dimensions existing in the list.</li>\r
</ul>\r
\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
* \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.
* \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
/*!
* \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);
}
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)
{
#include <TCollection_AsciiString.hxx>
+#include <list>
+
namespace GEOM
{
class TPythonDump
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);
};
//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);
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())
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;
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); }
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;
};
#include <Standard_Stream.hxx>
#include <GEOMImpl_IHealingOperations.hxx>
-
#include <GEOM_PythonDump.hxx>
-
#include <GEOMImpl_HealingDriver.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOMImpl_IHealing.hxx>
#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
* 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
// 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 {
//Make a Python command
GEOM::TPythonDump pd(aFunction);
- pd << aNewObject << " = geompy.Sew(" << theObject << ", " << theTolerance;
+ pd << aNewObject << " = geompy.Sew(" << theObjects << ", " << theTolerance;
if (isAllowNonManifold) {
pd << ", true";
* 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
pd << "empty_list";
}
- pd << ") = geompy.GetFreeBoundary(" << theObject << ")";
+ pd << ") = geompy.GetFreeBoundary(" << theObjects << ")";
}
SetErrorCode(OK);
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);
// 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);
* 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;
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();
* 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;
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();
* 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;
// 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;
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);
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);
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:
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
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.
# 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.
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
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")
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")
{
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();
// 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();
/* init variables */
myEditCurrentArgument = GroupPoints->LineEdit1;
- myObject = GEOM::GEOM_Object::_nil();
+ myObjects.clear();
//myGeomGUI->SetState( 0 );
initSelection();
initName();
GroupPoints->LineEdit1->setText( "" );
- myObject = GEOM::GEOM_Object::_nil();
+ myObjects.clear();
initSelection();
{
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 );
}
}
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
GroupPoints->LineEdit1->setText( "" );
- myObject = GEOM::GEOM_Object::_nil();
+ myObjects.clear();
myClosed = -1;
myOpen = -1;
{
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;
}
//=================================================================================
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();
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();
void RepairGUI_SewingDlg::initSelection()
{
TColStd_MapOfInteger aTypes;
+ aTypes.Add( GEOM_FACE );
aTypes.Add( GEOM_SHELL );
aTypes.Add( GEOM_SOLID );
aTypes.Add( GEOM_COMPOUND );
{
Q_OBJECT
-public:
+ public:
RepairGUI_SewingDlg( GeometryGUI*, QWidget* = 0, bool = false );
~RepairGUI_SewingDlg();
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();
};
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 :