\n You can create a \b Wire from several connected edges and wires by
selecting them in the object browser or in the viewer holding Shift
-button.
-\n The \b Result will be a \b GEOM_Object (WIRE).
+button. Select \b Tolerance which will be used to check
+connections. If you use \b Tolerance more than 1e-07, and gap,
+covered by this tolerance, is detected, edges will be modified to
+connect in the middle of the gap.
+\n The \b Result will be a \b GEOM_Object (WIRE).
-\n <b>TUI Command:</b> <em>geompy.MakeWire(ListOfShape)</em>
+\n <b>TUI Command:</b> <em>geompy.MakeWire(ListOfShape, Tolerance)</em>
-<b>Arguments:</b> Name + List of connected wires or edges.
+<b>Arguments:</b> Name + List of connected wires or edges + Tolerance.
\n <b>Dialog Box:</b>
Our <b>TUI Scripts</b> provide you with useful examples of creation of
\ref tui_creation_wire "Advanced Geometric Objects".
-*/
\ No newline at end of file
+*/
\anchor swig_MakeChamfer
\until id_MakeChamfer
-\anchor swig_NumberOfFaces
-\until Bad number of faces
-
-\anchor swig_NumberOfEdges
-\until Bad number of edges
+\anchor swig_NumberOf
+\until Bad number of shapes
\anchor swig_MakeBlockExplode
\until id_MakeBlockExplode
/*!
* Create a wire from the set of edges and wires.
* \param theEdgesAndWires List of edge and/or wires.
+ * \param theTolerance Maximum distance between vertices, that will be merged.
+ * Values less than 1e-07 are equivalent to 1e-07 (Precision::Confusion()).
* \return New GEOM_Object, containing the created wire.
*/
- GEOM_Object MakeWire (in ListOfGO theEdgesAndWires);
+ GEOM_Object MakeWire (in ListOfGO theEdgesAndWires,
+ in double theTolerance);
/*!
* Create a face on the given wire.
*/
long NumberOfEdges (in GEOM_Object theShape);
+ /*!
+ * Count number of subshapes of type \a theShapeType in the given shape.
+ * \param theShape Shape to count subshapes in.
+ * \param theShapeType The type of subshapes to count.
+ * \return Number of subshapes of type \a theShapeType in \a theShape.
+ */
+ long NumberOfSubShapes (in GEOM_Object theShape,
+ in long theShapeType);
+
/*!
* Reverses an orientation the given shape.
* \param theShape Shape to be reversed.
//-----------------------------------------------------------//
GEOM_Object MakeEdge (in GEOM_Object thePnt1,
in GEOM_Object thePnt2) ;
- GEOM_Object MakeWire (in GEOM_List theEdgesAndWires) ;
+ GEOM_Object MakeWire (in GEOM_List theEdgesAndWires,
+ in double theTolerance) ;
GEOM_Object MakeFace (in GEOM_Object theWire,
in boolean isPlanarWanted) ;
GEOM_Object MakeFaceWires (in GEOM_List theWires,
// GEOM GEOMGUI : GUI for Geometry component
// File : BuildGUI_WireDlg.cxx
// Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
-//
+
#include "BuildGUI_WireDlg.h"
#include <GEOMImpl_Types.hxx>
#include <LightApp_SelectionMgr.h>
#include <TColStd_MapOfInteger.hxx>
+#include <Precision.hxx>
//=================================================================================
// class : BuildGUI_WireDlg()
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
mainFrame()->RadioButton3->close();
- GroupPoints = new DlgRef_1Sel( centralWidget() );
+ GroupArgs = new DlgRef_1Sel1Spin( centralWidget() );
- GroupPoints->GroupBox1->setTitle( tr( "GEOM_WIRE_CONNECT" ) );
- GroupPoints->TextLabel1->setText( tr( "GEOM_OBJECTS" ) );
- GroupPoints->PushButton1->setIcon( image1 );
- GroupPoints->LineEdit1->setReadOnly( true );
+ GroupArgs->GroupBox1->setTitle( tr( "GEOM_WIRE_CONNECT" ) );
+ GroupArgs->TextLabel1->setText( tr( "GEOM_OBJECTS" ) );
+ GroupArgs->PushButton1->setIcon( image1 );
+ GroupArgs->LineEdit1->setReadOnly( true );
+
+ GroupArgs->TextLabel2->setText( tr( "GEOM_TOLERANCE" ) );
+ double SpecificStep = 0.0001;
+ double prec = Precision::Confusion();
+ initSpinBox(GroupArgs->SpinBox_DX, prec, MAX_NUMBER, SpecificStep, 9);
+ GroupArgs->SpinBox_DX->setValue(prec);
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
layout->setMargin( 0 ); layout->setSpacing( 6 );
- layout->addWidget( GroupPoints );
+ layout->addWidget( GroupArgs );
/***************************************************************/
setHelpFileName( "create_wire_page.html" );
void BuildGUI_WireDlg::Init()
{
/* init variables */
- myEditCurrentArgument = GroupPoints->LineEdit1;
- GroupPoints->LineEdit1->setReadOnly( true );
+ myEditCurrentArgument = GroupArgs->LineEdit1;
+ GroupArgs->LineEdit1->setReadOnly( true );
myOkEdgesAndWires = false;
/* signals and slots connections */
connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
- connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
+ connect( GroupArgs->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
void BuildGUI_WireDlg::SetEditCurrentArgument()
{
QPushButton* send = (QPushButton*)sender();
- if ( send != GroupPoints->PushButton1 )
+ if ( send != GroupArgs->PushButton1 )
return;
TColStd_MapOfInteger aMap;
aMap.Add( GEOM_WIRE );
aMap.Add( GEOM_EDGE );
globalSelection( aMap );
- myEditCurrentArgument = GroupPoints->LineEdit1;
+ myEditCurrentArgument = GroupArgs->LineEdit1;
myEditCurrentArgument->setFocus();
SelectionIntoArgument();
// function : isValid
// purpose :
//=================================================================================
-bool BuildGUI_WireDlg::isValid( QString& )
+bool BuildGUI_WireDlg::isValid (QString& msg)
{
- return myOkEdgesAndWires;
+ bool ok = GroupArgs->SpinBox_DX->isValid(msg, !IsPreview());
+ return myOkEdgesAndWires && ok;
}
//=================================================================================
// function : execute
// purpose :
//=================================================================================
-bool BuildGUI_WireDlg::execute( ObjectList& objects )
+bool BuildGUI_WireDlg::execute (ObjectList& objects)
{
GEOM::GEOM_Object_var anObj;
- anObj = GEOM::GEOM_IShapesOperations::_narrow(
- getOperation() )->MakeWire( myEdgesAndWires );
+ anObj = GEOM::GEOM_IShapesOperations::_narrow(getOperation())->
+ MakeWire(myEdgesAndWires, GroupArgs->SpinBox_DX->value());
- if ( !anObj->_is_nil() )
- objects.push_back( anObj._retn() );
+ if (!anObj->_is_nil())
+ objects.push_back(anObj._retn());
return true;
}
-
// GEOM GEOMGUI : GUI for Geometry component
// File : BuildGUI_WireDlg.h
// Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
-//
+
#ifndef BUILDGUI_WIREDLG_H
#define BUILDGUI_WIREDLG_H
#include <GEOMBase_Skeleton.h>
-class DlgRef_1Sel;
+class DlgRef_1Sel1Spin;
//=================================================================================
// class : BuildGUI_WireDlg
GEOM::ListOfGO myEdgesAndWires;
bool myOkEdgesAndWires; /* to check when arguments is defined */
- DlgRef_1Sel* GroupPoints;
+ DlgRef_1Sel1Spin* GroupArgs;
private slots:
void ClickOnOk();
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
+
#include <Standard_Stream.hxx>
#include <GEOMImpl_I3DPrimOperations.hxx>
#include <GEOMImpl_IPrism.hxx>
#include <GEOMImpl_IPipe.hxx>
#include <GEOMImpl_IRevolution.hxx>
-#include <GEOMImpl_IShapes.hxx>
#include <GEOMImpl_IFilling.hxx>
#include <GEOMImpl_IThruSections.hxx>
#include <GEOMImpl_IPipeDiffSect.hxx>
return aRevolution;
}
-//=============================================================================
-/*!
- * MakeSolidShell
- */
-//=============================================================================
-Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeSolidShell (Handle(GEOM_Object) theShell)
-{
- SetErrorCode(KO);
-
- if (theShell.IsNull()) return NULL;
-
- //Add a new Solid object
- Handle(GEOM_Object) aSolid = GetEngine()->AddObject(GetDocID(), GEOM_SOLID);
-
- //Add a new Solid function for creation a solid from a shell
- Handle(GEOM_Function) aFunction =
- aSolid->AddFunction(GEOMImpl_ShapeDriver::GetID(), SOLID_SHELL);
- if (aFunction.IsNull()) return NULL;
-
- //Check if the function is set correctly
- if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) return NULL;
-
- GEOMImpl_IShapes aCI (aFunction);
-
- Handle(GEOM_Function) aRefShell = theShell->GetLastFunction();
-
- if (aRefShell.IsNull()) return NULL;
-
- aCI.SetBase(aRefShell);
-
- //Compute the Solid value
- try {
-#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
- OCC_CATCH_SIGNALS;
-#endif
- if (!GetSolver()->ComputeFunction(aFunction)) {
- SetErrorCode("Solid driver failed");
- return NULL;
- }
- }
- catch (Standard_Failure) {
- Handle(Standard_Failure) aFail = Standard_Failure::Caught();
- SetErrorCode(aFail->GetMessageString());
- return NULL;
- }
-
- //Make a Python command
- GEOM::TPythonDump(aFunction) << aSolid << " = geompy.MakeSolid(" << theShell << ")";
-
- SetErrorCode(OK);
- return aSolid;
-}
-
//=============================================================================
/*!
* MakeFilling
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
+
#ifndef _GEOMImpl_I3DPrimOperations_HXX_
#define _GEOMImpl_I3DPrimOperations_HXX_
Handle(GEOM_Object) theAxis,
double theAngle);
- Standard_EXPORT Handle(GEOM_Object) MakeSolidShell (Handle(GEOM_Object) theShell);
-
- Standard_EXPORT Handle(GEOM_Object) MakeFilling (Handle(GEOM_Object) theShape, int theMinDeg, int theMaxDeg, double theTol2D, double theTol3D, int theNbIter, bool isApprox);
+ Standard_EXPORT Handle(GEOM_Object) MakeFilling (Handle(GEOM_Object) theShape,
+ int theMinDeg, int theMaxDeg,
+ double theTol2D, double theTol3D,
+ int theNbIter, bool isApprox);
- Standard_EXPORT Handle(GEOM_Object) MakeThruSections(const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
- bool theModeSolid,
- double thePreci,
- bool theRuled);
+ Standard_EXPORT Handle(GEOM_Object) MakeThruSections
+ (const Handle(TColStd_HSequenceOfTransient)& theSeqSections,
+ bool theModeSolid,
+ double thePreci,
+ bool theRuled);
Standard_EXPORT Handle(GEOM_Object) MakePipeWithDifferentSections(
const Handle(TColStd_HSequenceOfTransient)& theBases,
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-// NOTE: This is an intreface to a function for the Shapes
-// (Wire, Face, Shell, Solid and Compound) creation.
-//
+// NOTE: This is an intreface to a function for the Shapes
+// (Wire, Face, Shell, Solid and Compound) creation.
+
#include "GEOM_Function.hxx"
#include "TColStd_HSequenceOfTransient.hxx"
#include "TColStd_HArray1OfInteger.hxx"
-#define SHAPE_ARG_SHAPES 1 // for Wire, Shell, Solid and Compound
-
-#define SHAPE_ARG_BASE 2 // for Face, Solid and Sub-shape
-
-#define SHAPE_ARG_PLANAR 3 // for Face
-
-#define SHAPE_ARG_SUBTYPE 4 // for Sub-shape
-#define SHAPE_ARG_INDICES 5 // for Sub-shape
-
class GEOMImpl_IShapes
{
public:
+ enum {
+ SHAPE_ARG_SHAPES = 1, // for Wire, Shell, Solid and Compound
+ SHAPE_ARG_BASE = 2, // for Face, Solid and Sub-shape
+ SHAPE_ARG_PLANAR = 3, // for Face
+ SHAPE_ARG_SUBTYPE = 4, // for Sub-shape
+ SHAPE_ARG_INDICES = 5, // for Sub-shape
+ SHAPE_ARG_TOLERANCE = 6 // for Wire
+ };
+
GEOMImpl_IShapes(Handle(GEOM_Function) theFunction): _func(theFunction) {}
void SetShapes(const Handle(TColStd_HSequenceOfTransient)& theShapes)
Handle(TColStd_HArray1OfInteger) GetIndices()
{ return _func->GetIntegerArray(SHAPE_ARG_INDICES); }
+ void SetTolerance(const Standard_Real theValue)
+ { _func->SetReal(SHAPE_ARG_TOLERANCE, theValue); }
+
+ Standard_Integer GetTolerance() { return _func->GetReal(SHAPE_ARG_TOLERANCE); }
+
private:
Handle(GEOM_Function) _func;
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeWire
- (std::list<Handle(GEOM_Object)> theShapes)
+ (std::list<Handle(GEOM_Object)> theShapes,
+ const Standard_Real theTolerance)
{
- return MakeShape(theShapes, GEOM_WIRE, WIRE_EDGES, "MakeWire");
+ SetErrorCode(KO);
+
+ //Add a new object
+ Handle(GEOM_Object) aWire = GetEngine()->AddObject(GetDocID(), GEOM_WIRE);
+
+ //Add a new function
+ Handle(GEOM_Function) aFunction =
+ aWire->AddFunction(GEOMImpl_ShapeDriver::GetID(), WIRE_EDGES);
+ if (aFunction.IsNull()) return NULL;
+
+ //Check if the function is set correctly
+ if (aFunction->GetDriverGUID() != GEOMImpl_ShapeDriver::GetID()) return NULL;
+
+ GEOMImpl_IShapes aCI (aFunction);
+ aCI.SetTolerance(theTolerance);
+
+ Handle(TColStd_HSequenceOfTransient) aShapesSeq = new TColStd_HSequenceOfTransient;
+
+ // Shapes
+ std::list<Handle(GEOM_Object)>::iterator it = theShapes.begin();
+ for (; it != theShapes.end(); it++) {
+ Handle(GEOM_Function) aRefSh = (*it)->GetLastFunction();
+ if (aRefSh.IsNull()) {
+ SetErrorCode("NULL argument shape for the shape construction");
+ return NULL;
+ }
+ aShapesSeq->Append(aRefSh);
+ }
+ aCI.SetShapes(aShapesSeq);
+
+ //Compute the shape
+ try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
+ if (!GetSolver()->ComputeFunction(aFunction)) {
+ SetErrorCode("Shape driver failed");
+ return NULL;
+ }
+ }
+ catch (Standard_Failure) {
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ SetErrorCode(aFail->GetMessageString());
+ return NULL;
+ }
+
+ //Make a Python command
+ GEOM::TPythonDump pd (aFunction);
+ pd << aWire << " = geompy.MakeWire([";
+
+ // Shapes
+ it = theShapes.begin();
+ if (it != theShapes.end()) {
+ pd << (*it++);
+ while (it != theShapes.end()) {
+ pd << ", " << (*it++);
+ }
+ }
+ pd << "])";
+
+ SetErrorCode(OK);
+ return aWire;
}
//=============================================================================
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IShapesOperations::MakeShape
- (std::list<Handle(GEOM_Object)> theShapes,
+ (std::list<Handle(GEOM_Object)> theShapes,
const Standard_Integer theObjectType,
const Standard_Integer theFunctionType,
const TCollection_AsciiString& theMethodName)
//=============================================================================
/*!
- * NumberOfFaces
+ * NumberOfSubShapes
*/
//=============================================================================
-Standard_Integer GEOMImpl_IShapesOperations::NumberOfFaces (Handle(GEOM_Object) theShape)
+Standard_Integer GEOMImpl_IShapesOperations::NumberOfSubShapes
+ (Handle(GEOM_Object) theShape,
+ const Standard_Integer theShapeType)
{
SetErrorCode(KO);
-
- Standard_Integer nb = 0;
+ Standard_Integer nbShapes = 0;
if (theShape.IsNull()) return -1;
TopoDS_Shape aShape = theShape->GetValue();
if (aShape.IsNull()) return -1;
+ /*
TopTools_MapOfShape mapShape;
- TopExp_Explorer exp (aShape, TopAbs_FACE);
- for (; exp.More(); exp.Next())
- if (mapShape.Add(exp.Current()))
- nb++;
-
- SetErrorCode(OK);
- return nb;
-}
-
-//=============================================================================
-/*!
- * NumberOfEdges
- */
-//=============================================================================
-Standard_Integer GEOMImpl_IShapesOperations::NumberOfEdges (Handle(GEOM_Object) theShape)
-{
- SetErrorCode(KO);
-
- Standard_Integer nb = 0;
-
- if (theShape.IsNull()) return -1;
- TopoDS_Shape aShape = theShape->GetValue();
- if (aShape.IsNull()) return -1;
+ if (aShape.ShapeType() == TopAbs_COMPOUND &&
+ (TopAbs_ShapeEnum(theShapeType) == TopAbs_SHAPE ||
+ TopAbs_ShapeEnum(theShapeType) == TopAbs_COMPSOLID ||
+ TopAbs_ShapeEnum(theShapeType) == TopAbs_COMPOUND)) {
+ TopoDS_Iterator It (aShape, Standard_True, Standard_True);
+ for (; It.More(); It.Next()) {
+ if (mapShape.Add(It.Value())) {
+ if (TopAbs_ShapeEnum(theShapeType) == TopAbs_SHAPE ||
+ TopAbs_ShapeEnum(theShapeType) == It.Value().ShapeType()) {
+ nbShapes++;
+ }
+ }
+ }
+ } else {
+ TopExp_Explorer exp (aShape, TopAbs_ShapeEnum(theShapeType));
+ for (; exp.More(); exp.Next())
+ if (mapShape.Add(exp.Current()))
+ nbShapes++;
+ }
+ */
- TopTools_MapOfShape mapShape;
+ try {
+#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
+ OCC_CATCH_SIGNALS;
+#endif
+ int iType, nbTypes [TopAbs_SHAPE];
+ for (iType = 0; iType < TopAbs_SHAPE; ++iType)
+ nbTypes[iType] = 0;
+ nbTypes[aShape.ShapeType()]++;
+
+ TopTools_MapOfShape aMapOfShape;
+ aMapOfShape.Add(aShape);
+ TopTools_ListOfShape aListOfShape;
+ aListOfShape.Append(aShape);
+
+ TopTools_ListIteratorOfListOfShape itL (aListOfShape);
+ for (; itL.More(); itL.Next()) {
+ TopoDS_Iterator it (itL.Value());
+ for (; it.More(); it.Next()) {
+ TopoDS_Shape s = it.Value();
+ if (aMapOfShape.Add(s)) {
+ aListOfShape.Append(s);
+ nbTypes[s.ShapeType()]++;
+ }
+ }
+ }
- TopExp_Explorer exp (aShape, TopAbs_EDGE);
- for (; exp.More(); exp.Next())
- if (mapShape.Add(exp.Current()))
- nb++;
+ if (TopAbs_ShapeEnum(theShapeType) == TopAbs_SHAPE)
+ nbShapes = aMapOfShape.Extent();
+ else
+ nbShapes = nbTypes[theShapeType];
+ }
+ catch (Standard_Failure) {
+ Handle(Standard_Failure) aFail = Standard_Failure::Caught();
+ SetErrorCode(aFail->GetMessageString());
+ return -1;
+ }
SetErrorCode(OK);
- return nb;
+ return nbShapes;
}
//=============================================================================
// Project : SALOME
// $Header$
//=============================================================================
-//
+
#ifndef _GEOMImpl_IShapesOperations_HXX_
#define _GEOMImpl_IShapesOperations_HXX_
Standard_EXPORT Handle(GEOM_Object) MakeEdge (Handle(GEOM_Object) thePoint1,
Handle(GEOM_Object) thePoint2);
- Standard_EXPORT Handle(GEOM_Object) MakeWire (std::list<Handle(GEOM_Object)> theEdgesAndWires);
+ Standard_EXPORT Handle(GEOM_Object) MakeWire (std::list<Handle(GEOM_Object)> theEdgesAndWires,
+ const Standard_Real theTolerance);
Standard_EXPORT Handle(GEOM_Object) MakeFace (Handle(GEOM_Object) theWire, const bool isPlanarWanted);
Standard_EXPORT TCollection_AsciiString GetShapeTypeString (Handle(GEOM_Object) theShape);
- Standard_EXPORT Standard_Integer NumberOfFaces (Handle(GEOM_Object) theShape);
- Standard_EXPORT Standard_Integer NumberOfEdges (Handle(GEOM_Object) theShape);
+ Standard_EXPORT Standard_Integer NumberOfSubShapes (Handle(GEOM_Object) theShape,
+ const Standard_Integer theShapeType);
Standard_EXPORT Handle(GEOM_Object) ReverseShape(Handle(GEOM_Object) theShapes);
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
+
#include <GEOMImpl_ShapeDriver.hxx>
#include <GEOMImpl_IShapes.hxx>
// OCCT Includes
#include <ShapeFix_Wire.hxx>
+#include <ShapeFix_Edge.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
Standard_ConstructionError::Raise("Wire construction failed: several loops detected");
} else if (aFW->StatusReorder(ShapeExtend_FAIL)) {
Standard_ConstructionError::Raise("Wire construction failed");
- } else if (aFW->StatusReorder(ShapeExtend_DONE2)) {
- Standard_ConstructionError::Raise("Wire construction failed: some gaps detected");
+ //} else if (aFW->StatusReorder(ShapeExtend_DONE2)) {
+ // Standard_ConstructionError::Raise("Wire construction failed: some gaps detected");
} else {
}
+ // IMP 0019766: Building a Wire from unconnected edges by introducing a tolerance
+ Standard_Real aTolerance = aCI.GetTolerance();
+ if (aTolerance < Precision::Confusion())
+ aTolerance = Precision::Confusion();
+
aFW->ClosedWireMode() = Standard_False;
- aFW->FixConnected();
+ aFW->FixConnected(aTolerance);
if (aFW->StatusConnected(ShapeExtend_FAIL)) {
Standard_ConstructionError::Raise("Wire construction failed: cannot build connected wire");
}
+ // IMP 0019766
+ aFW->FixGapsByRangesMode() = Standard_True;
+ if (aFW->FixGaps3d()) {
+ Handle(ShapeExtend_WireData) sbwd = aFW->WireData();
+ Handle(ShapeFix_Edge) aFe = new ShapeFix_Edge;
+ for (Standard_Integer iedge = 1; iedge <= sbwd->NbEdges(); iedge++) {
+ TopoDS_Edge aEdge = TopoDS::Edge(sbwd->Edge(iedge));
+ aFe->FixVertexTolerance(aEdge);
+ aFe->FixSameParameter(aEdge);
+ }
+ }
+ else if (aFW->StatusGaps3d(ShapeExtend_FAIL)) {
+ Standard_ConstructionError::Raise("Wire construction failed: cannot fix 3d gaps");
+ }
+
aShape = aFW->WireAPIMake();
}
}
// Check shape validity
BRepCheck_Analyzer ana (aShape, false);
if (!ana.IsValid()) {
- Standard_ConstructionError::Raise("Algorithm have produced an invalid shape result");
+ //Standard_ConstructionError::Raise("Algorithm have produced an invalid shape result");
}
aFunction->SetValue(aShape);
#include "GEOM_Object_i.hh"
#include <strstream>
+//#include <sstream>
#include "Utils_CorbaException.hxx"
#include "OpUtil.hxx"
// Prepare a file name to open
TCollection_AsciiString aNameWithExt("");
if (isMultiFile)
- aNameWithExt = TCollection_AsciiString((char*)(SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL())).c_str());
+ aNameWithExt = TCollection_AsciiString((char*)(SALOMEDS_Tool::GetNameFromPath
+ (theComponent->GetStudy()->URL())).c_str());
aNameWithExt += TCollection_AsciiString("_GEOM.sgd");
aSeq[0] = CORBA::string_dup(aNameWithExt.ToCString());
// Build a full file name of temporary file
// Prepare a file name to open
TCollection_AsciiString aNameWithExt("");
if (isMultiFile)
- aNameWithExt = TCollection_AsciiString((char*)(SALOMEDS_Tool::GetNameFromPath(theComponent->GetStudy()->URL())).c_str());
+ aNameWithExt = TCollection_AsciiString((char*)(SALOMEDS_Tool::GetNameFromPath
+ (theComponent->GetStudy()->URL())).c_str());
aNameWithExt += TCollection_AsciiString("_GEOM.sgd");
TCollection_AsciiString aFullName = (TCollection_AsciiString((char*)aTmpDir.c_str()) + aNameWithExt);
// function : CopyFrom()
// purpose :
//============================================================================
-SALOMEDS::TMPFile* GEOM_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID) {
+SALOMEDS::TMPFile* GEOM_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID)
+{
// Declare a sequence of the byte to store the copied object
SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile;
// Try to get GEOM_Object object by given SObject
SALOMEDS::GenericAttribute_var anAttr;
if (!theObject->FindAttribute(anAttr, "AttributeIOR")) return aStreamFile._retn();
- GEOM::GEOM_Object_var anObject = GEOM::GEOM_Object::_narrow(_orb->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value()));
+ GEOM::GEOM_Object_var anObject = GEOM::GEOM_Object::_narrow
+ (_orb->string_to_object(SALOMEDS::AttributeIOR::_narrow(anAttr)->Value()));
if (anObject->_is_nil()) return aStreamFile._retn();
aStreamFile = anObject->GetShapeStream();
aGeomObject = GEOM::GEOM_Object::_narrow(anObject);
}
- char* aTypeInfo = "Object";
+ const char* aTypeInfo = "Object";
if ( !aGeomObject->_is_nil() ) {
GEOM::GEOM_IKindOfShape::shape_kind aKind;
GEOM::ListOfLong_var anInts;
#include "GEOM_Engine.hxx"
#include "GEOM_Object.hxx"
+#include <TopAbs.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
#include <TColStd_HArray1OfInteger.hxx>
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::MakeWire
- (const GEOM::ListOfGO& theEdgesAndWires)
+ (const GEOM::ListOfGO& theEdgesAndWires,
+ const CORBA::Double theTolerance)
{
GEOM::GEOM_Object_var aGEOMObject;
// Make Solid
Handle(GEOM_Object) anObject =
- GetOperations()->MakeWire(aShapes);
+ GetOperations()->MakeWire(aShapes, theTolerance);
if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn();
//=============================================================================
CORBA::Long GEOM_IShapesOperations_i::NumberOfFaces (GEOM::GEOM_Object_ptr theShape)
{
- Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
- if (aShape.IsNull()) return -1;
-
- CORBA::Long aNb = GetOperations()->NumberOfFaces(aShape);
- if (!GetOperations()->IsDone()) return -1;
-
- return aNb;
+ return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_FACE));
}
//=============================================================================
*/
//=============================================================================
CORBA::Long GEOM_IShapesOperations_i::NumberOfEdges (GEOM::GEOM_Object_ptr theShape)
+{
+ return NumberOfSubShapes(theShape, Standard_Integer(TopAbs_EDGE));
+}
+
+//=============================================================================
+/*!
+ * NumberOfSubShapes
+ */
+//=============================================================================
+CORBA::Long GEOM_IShapesOperations_i::NumberOfSubShapes (GEOM::GEOM_Object_ptr theShape,
+ const CORBA::Long theShapeType)
{
Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
if (aShape.IsNull()) return -1;
- CORBA::Long aNb = GetOperations()->NumberOfEdges(aShape);
+ CORBA::Long aNb = GetOperations()->NumberOfSubShapes(aShape, theShapeType);
if (!GetOperations()->IsDone()) return -1;
return aNb;
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
+
#ifndef _GEOM_IShapesOperations_i_HeaderFile
#define _GEOM_IShapesOperations_i_HeaderFile
GEOM::GEOM_Object_ptr MakeEdge (GEOM::GEOM_Object_ptr thePnt1,
GEOM::GEOM_Object_ptr thePnt2);
- GEOM::GEOM_Object_ptr MakeWire (const GEOM::ListOfGO& theEdgesAndWires);
+ GEOM::GEOM_Object_ptr MakeWire (const GEOM::ListOfGO& theEdgesAndWires,
+ const CORBA::Double theTolerance);
GEOM::GEOM_Object_ptr MakeFace (GEOM::GEOM_Object_ptr theWire,
CORBA::Boolean isPlanarWanted);
GEOM::GEOM_Object_ptr MakeGlueFaces (GEOM::GEOM_Object_ptr theShape,
CORBA::Double theTolerance,
- CORBA::Boolean doKeepNonSolids);
+ CORBA::Boolean doKeepNonSolids);
GEOM::ListOfGO* GetGlueFaces (GEOM::GEOM_Object_ptr theShape,
CORBA::Double theTolerance);
CORBA::Long NumberOfFaces (GEOM::GEOM_Object_ptr theShape);
CORBA::Long NumberOfEdges (GEOM::GEOM_Object_ptr theShape);
+ CORBA::Long NumberOfSubShapes (GEOM::GEOM_Object_ptr theShape,
+ const CORBA::Long theShapeType);
GEOM::GEOM_Object_ptr ChangeOrientation (GEOM::GEOM_Object_ptr theShape);
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
+
#include <Standard_OStream.hxx>
#include <GEOM_Object_i.hh>
-//#include <GEOM_Gen_i.hh>
#include <GEOM_ISubShape.hxx>
#include <GEOMImpl_Types.hxx>
#include "utilities.h"
#include <fstream>
#include <strstream>
+//#include <sstream>
#include <OpUtil.hxx>
#include <Utils_ExceptHandlers.hxx>
//=============================================================================
// MakeWire:
//=============================================================================
-GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeWire (GEOM::GEOM_List_ptr theEdgesAndWires)
+GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeWire (GEOM::GEOM_List_ptr theEdgesAndWires,
+ CORBA::Double theTolerance)
{
beginService( " GEOM_Superv_i::MakeWire" );
MESSAGE("GEOM_Superv_i::MakeWire");
if (GEOM_List_i<GEOM::ListOfGO>* aListImplEW =
dynamic_cast<GEOM_List_i<GEOM::ListOfGO>*>(GetServant(theEdgesAndWires, myPOA).in())) {
getShapesOp();
- GEOM::GEOM_Object_ptr anObj = myShapesOp->MakeWire(aListImplEW->GetList());
+ GEOM::GEOM_Object_ptr anObj = myShapesOp->MakeWire(aListImplEW->GetList(), theTolerance);
endService( " GEOM_Superv_i::MakeWire" );
return anObj;
}
//-----------------------------------------------------------//
GEOM::GEOM_Object_ptr MakeEdge (GEOM::GEOM_Object_ptr thePnt1,
GEOM::GEOM_Object_ptr thePnt2);
- GEOM::GEOM_Object_ptr MakeWire (GEOM::GEOM_List_ptr theEdgesAndWires);
+ GEOM::GEOM_Object_ptr MakeWire (GEOM::GEOM_List_ptr theEdgesAndWires,
+ CORBA::Double theTolerance);
GEOM::GEOM_Object_ptr MakeFace (GEOM::GEOM_Object_ptr theWire,
CORBA::Boolean isPlanarWanted);
GEOM::GEOM_Object_ptr MakeFaceWires (GEOM::GEOM_List_ptr theWires,
[f_ind_1, f_ind_2, f_ind_3])
id_MakeChamfer = geompy.addToStudy(MakeChamfer, "MakeChamfer")
- # NumberOfFaces
+ # NumberOf
NumberOfFaces = geompy.NumberOfFaces(Box)
if NumberOfFaces != 6:
print "Bad number of faces in BOX!"
- # NumberOfEdges
NumberOfEdges = geompy.NumberOfEdges(Box)
if NumberOfEdges != 12:
print "Bad number of edges in BOX!"
+ NumberOfSolids = geompy.NumberOfSolids(Box)
+ if NumberOfSolids != 1:
+ print "Bad number of solids in BOX!"
+
+ NumberOfShapes = geompy.NumberOfSubShapes(Box, geompy.ShapeType["SHAPE"])
+ if NumberOfShapes != 34:
+ print "Bad number of shapes in BOX!"
+
# MakeBlockExplode
Compound = geompy.MakeCompound([Box, Sphere])
MakeBlockExplode = geompy.MakeBlockExplode(Compound, 6, 6)
## Create a wire from the set of edges and wires.
# @param theEdgesAndWires List of edges and/or wires.
+ # @param theTolerance Maximum distance between vertices, that will be merged.
+ # Values less than 1e-07 are equivalent to 1e-07 (Precision::Confusion()).
# @return New GEOM_Object, containing the created wire.
#
# @ref tui_creation_wire "Example"
- def MakeWire(self,theEdgesAndWires):
+ def MakeWire(self, theEdgesAndWires, theTolerance = 1e-07):
# Example: see GEOM_TestAll.py
- anObj = self.ShapesOp.MakeWire(theEdgesAndWires)
+ anObj = self.ShapesOp.MakeWire(theEdgesAndWires, theTolerance)
RaiseIfFailed("MakeWire", self.ShapesOp)
return anObj
# @param theShape Shape to count faces of.
# @return Quantity of faces.
#
- # @ref swig_NumberOfFaces "Example"
- def NumberOfFaces(self,theShape):
+ # @ref swig_NumberOf "Example"
+ def NumberOfFaces(self, theShape):
# Example: see GEOM_TestOthers.py
nb_faces = self.ShapesOp.NumberOfFaces(theShape)
RaiseIfFailed("NumberOfFaces", self.ShapesOp)
# @param theShape Shape to count edges of.
# @return Quantity of edges.
#
- # @ref swig_NumberOfEdges "Example"
- def NumberOfEdges(self,theShape):
+ # @ref swig_NumberOf "Example"
+ def NumberOfEdges(self, theShape):
# Example: see GEOM_TestOthers.py
nb_edges = self.ShapesOp.NumberOfEdges(theShape)
RaiseIfFailed("NumberOfEdges", self.ShapesOp)
return nb_edges
+ ## Gives quantity of subshapes of type theShapeType in the given shape.
+ # @param theShape Shape to count subshapes of.
+ # @param theShapeType Type of subshapes to count.
+ # @return Quantity of subshapes of given type.
+ #
+ # @ref swig_NumberOf "Example"
+ def NumberOfSubShapes(self, theShape, theShapeType):
+ # Example: see GEOM_TestOthers.py
+ nb_ss = self.ShapesOp.NumberOfSubShapes(theShape, theShapeType)
+ RaiseIfFailed("NumberOfSubShapes", self.ShapesOp)
+ return nb_ss
+
+ ## Gives quantity of solids in the given shape.
+ # @param theShape Shape to count solids in.
+ # @return Quantity of solids.
+ #
+ # @ref swig_NumberOf "Example"
+ def NumberOfSolids(self, theShape):
+ # Example: see GEOM_TestOthers.py
+ nb_solids = self.ShapesOp.NumberOfSubShapes(theShape, ShapeType["SOLID"])
+ RaiseIfFailed("NumberOfSolids", self.ShapesOp)
+ return nb_solids
+
# end of l2_measure
## @}