IMPs 0020745 (GetVertexNearPoint and GetShapesNearPoint) and 0020851 (LimitTolerance).

This commit is contained in:
jfa 2010-07-14 07:16:07 +00:00
parent 7b43a272be
commit da9569a425
30 changed files with 1275 additions and 142 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

View File

@ -0,0 +1,23 @@
/*!
\page limit_tolerance_operation_page Limit Tolerance
\n To produce a <b>Limit Tolerance</b> operation in the <b>Main
Menu</b> select <b>Repair - > Limit Tolerance</b>.
\n It is possible on all kind of shapes.
\n The \b Result will be a \b GEOM_Object.
\n <b>TUI Command:</b> <em>geompy.LimitTolerance(Shape, Tolerance),</em>
where \em Shape is a shape with presumably incorrect tolerance, \em
Tolerance is a desired value of tolerance.
\image html limit_tolerance_dlg.png
\n <b>Arguments:</b> Name + 1 shape + 1 value (new tolerance).
Our <b>TUI Scripts</b> provide you with useful examples of the use of
\ref tui_limit_tolerance "Repairing Operations".
*/

View File

@ -17,6 +17,8 @@ holes with free boundaries on a selected face.</li>
<li>\subpage sewing_operation_page "Sewing" - sews faces or shells.</li>
<li>\subpage glue_faces_operation_page "Glue faces" - unites
coincident faces within the given tolerance.</li>
<li>\subpage limit_tolerance_operation_page "Limit Tolerance" - tries
to set new tolerance value for the given shape.</li>
<li>\subpage add_point_on_edge_operation_page "Add point on edge" -
splits an edge in two.</li>
<li>\subpage change_orientation_operation_page "Change orientation" -

View File

@ -289,6 +289,31 @@ gg.createAndDisplayGO(id_glue)
gg.setDisplayMode(id_glue,1)
\endcode
\anchor tui_limit_tolerance
<br><h2>Limit Tolerance</h2>
\code
import geompy
gg = salome.ImportComponentGUI("GEOM")
# import initial topology
bad_shape = geompy.ImportBREP("my_bad_shape.brep")
# limit tolerance
tolerance = 1e-07
good_shape = geompy.LimitTolerance(bad_shape, tolerance)
# add objects in the study
id_bad_shape = geompy.addToStudy(bad_shape, "My Bad Shape")
id_good_shape = geompy.addToStudy(good_shape, "My Good Shape")
# display the results
gg.createAndDisplayGO(id_bad_shape)
gg.setDisplayMode(id_bad_shape, 1)
gg.createAndDisplayGO(id_good_shape)
gg.setDisplayMode(id_good_shape, 1)
\endcode
\anchor tui_add_point_on_edge
<br><h2>Add Point on Edge</h2>

View File

@ -99,12 +99,21 @@
\anchor swig_GetPoint
\until blocksComp (-50, -50, -50)
\anchor swig_GetVertexNearPoint
\until near (40, 40, 40)
\anchor swig_GetEdge
\until by two points
\anchor swig_GetEdgeNearPoint
\until edge near point
\anchor swig_GetBlockByParts
\until "b0 image"
\anchor swig_GetShapesNearPoint
\until "faces near point"
\anchor swig_GetShapesOnPlane
\until Face on Plane

View File

@ -1905,6 +1905,15 @@ module GEOM
in double theZ,
in double theEpsilon);
/*!
* Find a vertex of the given shape, which has minimal distance to the given point.
* \param theShape Any shape.
* \param thePoint Point, close to the desired vertex.
* \return New GEOM_Object, containing the found vertex.
*/
GEOM_Object GetVertexNearPoint (in GEOM_Object theShape,
in GEOM_Object thePoint);
/*!
* Get an edge, found in the given shape by two given vertices.
* \param theShape Block or a compound of blocks.
@ -1973,6 +1982,22 @@ module GEOM
GEOM_Object GetFaceByNormale (in GEOM_Object theBlock,
in GEOM_Object theVector);
/*!
* Find all subshapes of type \a theShapeType of the given shape,
* which have minimal distance to the given point.
* \param theShape Any shape.
* \param thePoint Point, close to the desired shape.
* \param theShapeType Defines what kind of subshapes is searched.
* \param theTolerance The tolerance for distances comparison. All shapes
* with distances to the given point in interval
* [minimal_distance, minimal_distance + theTolerance] will be gathered.
* \return New GEOM_Object, containing a group of all found shapes.
*/
GEOM_Object GetShapesNearPoint (in GEOM_Object theShape,
in GEOM_Object thePoint,
in long theShapeType,
in double theTolerance);
/*!
* Extract blocks from blocks compounds
*/
@ -2726,6 +2751,14 @@ module GEOM
GEOM_Object ChangeOrientation (in GEOM_Object theObject);
GEOM_Object ChangeOrientationCopy (in GEOM_Object theObject);
/*!
* Try to limit tolerance of the given object by value \a theTolerance.
* \param theObject Shape to be processed.
* \param theTolerance Required tolerance value.
* \return New GEOM_Object, containing processed shape.
*/
GEOM_Object LimitTolerance (in GEOM_Object theObject, in double theTolerance);
};
/*!

View File

@ -93,6 +93,7 @@ filletface.png \
filling.png \
fuse.png \
geometry.png \
limit_tolerance.png \
line.png \
line2points.png \
line2faces.png \

Binary file not shown.

After

Width:  |  Height:  |  Size: 565 B

View File

@ -269,6 +269,10 @@
<source>ICON_DLG_GLUE_FACES2</source>
<translation>glue2.png</translation>
</message>
<message>
<source>ICON_DLG_LIMIT_TOLERANCE</source>
<translation>limit_tolerance.png</translation>
</message>
<message>
<source>ICON_DLG_INERTIA</source>
<translation>axisinertia.png</translation>
@ -849,6 +853,10 @@
<source>ICO_GLUE_FACES</source>
<translation>glue.png</translation>
</message>
<message>
<source>ICO_LIMIT_TOLERANCE</source>
<translation>limit_tolerance.png</translation>
</message>
<message>
<source>ICO_GROUP_CREATE</source>
<translation>group_new.png</translation>

View File

@ -771,6 +771,10 @@ Please, select face, shell or solid and try again</translation>
<source>GEOM_GLUE_TITLE</source>
<translation>Glue faces</translation>
</message>
<message>
<source>GEOM_LIMIT_TOLERANCE_TITLE</source>
<translation>Limit tolerance</translation>
</message>
<message>
<source>GEOM_HEIGHT</source>
<translation>Height :</translation>
@ -2055,6 +2059,10 @@ Please, select face, shell or solid and try again</translation>
<source>GLUE_NEW_OBJ_NAME</source>
<translation>Glue</translation>
</message>
<message>
<source>LIMIT_TOLERANCE_NEW_OBJ_NAME</source>
<translation>Limit_tolerance</translation>
</message>
<message>
<source>MEN_ALL_SEL_ONLY</source>
<translation>Select All</translation>
@ -2307,6 +2315,10 @@ Please, select face, shell or solid and try again</translation>
<source>MEN_ISOS</source>
<translation>Isos</translation>
</message>
<message>
<source>MEN_LIMIT_TOLERANCE</source>
<translation>Limit tolerance</translation>
</message>
<message>
<source>MEN_LINE</source>
<translation>Line</translation>
@ -2955,6 +2967,10 @@ Please, select face, shell or solid and try again</translation>
<source>STB_LINE</source>
<translation>Create a line</translation>
</message>
<message>
<source>STB_LIMIT_TOLERANCE</source>
<translation>Limit tolerance</translation>
</message>
<message>
<source>STB_LOCAL_CS</source>
<translation>Create a local coordinate system</translation>
@ -3479,6 +3495,10 @@ Please, select face, shell or solid and try again</translation>
<source>TOP_LINE</source>
<translation>Create a line</translation>
</message>
<message>
<source>TOP_LIMIT_TOLERANCE</source>
<translation>Limit tolerance</translation>
</message>
<message>
<source>TOP_LOCAL_CS</source>
<translation>Create a local coordinate system</translation>

View File

@ -19,11 +19,10 @@
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// GEOM GEOMGUI : GUI for Geometry component
// File : GeometryGUI.cxx
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
// GEOM GEOMGUI : GUI for Geometry component
// File : GeometryGUI.cxx
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
//
#include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows
#include "Python.h"
#include "GeometryGUI.h"
@ -476,6 +475,7 @@ void GeometryGUI::OnGUIEvent( int id )
case GEOMOp::OpFreeFaces: // MENU MEASURE - FREE FACES
case GEOMOp::OpOrientation: // MENU REPAIR - CHANGE ORIENTATION
case GEOMOp::OpGlueFaces: // MENU REPAIR - GLUE FACES
case GEOMOp::OpLimitTolerance: // MENU REPAIR - LIMIT TOLERANCE
case GEOMOp::OpRemoveExtraEdges: // MENU REPAIR - REMOVE EXTRA EDGES
libName = "RepairGUI";
break;
@ -706,6 +706,7 @@ void GeometryGUI::initialize( CAM_Application* app )
createGeomAction( GEOMOp::OpSewing, "SEWING" );
createGeomAction( GEOMOp::OpGlueFaces, "GLUE_FACES" );
createGeomAction( GEOMOp::OpLimitTolerance, "LIMIT_TOLERANCE" );
createGeomAction( GEOMOp::OpSuppressFaces, "SUPPRESS_FACES" );
createGeomAction( GEOMOp::OpSuppressHoles, "SUPPERSS_HOLES" );
createGeomAction( GEOMOp::OpShapeProcess, "SHAPE_PROCESS" );
@ -891,6 +892,7 @@ void GeometryGUI::initialize( CAM_Application* app )
createMenu( GEOMOp::OpSuppressHoles, repairId, -1 );
createMenu( GEOMOp::OpSewing, repairId, -1 );
createMenu( GEOMOp::OpGlueFaces, repairId, -1 );
createMenu( GEOMOp::OpLimitTolerance, repairId, -1 );
createMenu( GEOMOp::OpAddPointOnEdge, repairId, -1 );
//createMenu( GEOMOp::OpFreeBoundaries, repairId, -1 );
//createMenu( GEOMOp::OpFreeFaces, repairId, -1 );
@ -1507,21 +1509,21 @@ void GeometryGUI::createPreferences()
const int nbQuantities = 8;
int prec[nbQuantities], ii = 0;
prec[ii++] = addPreference( tr( "GEOM_PREF_length_precision" ), precGroup,
LightApp_Preferences::IntSpin, "Geometry", "length_precision" );
LightApp_Preferences::IntSpin, "Geometry", "length_precision" );
prec[ii++] = addPreference( tr( "GEOM_PREF_angle_precision" ), precGroup,
LightApp_Preferences::IntSpin, "Geometry", "angle_precision" );
LightApp_Preferences::IntSpin, "Geometry", "angle_precision" );
prec[ii++] = addPreference( tr( "GEOM_PREF_len_tol_precision" ), precGroup,
LightApp_Preferences::IntSpin, "Geometry", "len_tol_precision" );
LightApp_Preferences::IntSpin, "Geometry", "len_tol_precision" );
prec[ii++] = addPreference( tr( "GEOM_PREF_ang_tol_precision" ), precGroup,
LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" );
LightApp_Preferences::IntSpin, "Geometry", "ang_tol_precision" );
prec[ii++] = addPreference( tr( "GEOM_PREF_weight_precision" ), precGroup,
LightApp_Preferences::IntSpin, "Geometry", "weight_precision" );
LightApp_Preferences::IntSpin, "Geometry", "weight_precision" );
prec[ii++] = addPreference( tr( "GEOM_PREF_density_precision" ), precGroup,
LightApp_Preferences::IntSpin, "Geometry", "density_precision" );
LightApp_Preferences::IntSpin, "Geometry", "density_precision" );
prec[ii++] = addPreference( tr( "GEOM_PREF_parametric_precision" ), precGroup,
LightApp_Preferences::IntSpin, "Geometry", "parametric_precision" );
LightApp_Preferences::IntSpin, "Geometry", "parametric_precision" );
prec[ii ] = addPreference( tr( "GEOM_PREF_param_tol_precision" ), precGroup,
LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" );
LightApp_Preferences::IntSpin, "Geometry", "param_tol_precision" );
// Set property for precision value for spinboxes
for ( ii = 0; ii < nbQuantities; ii++ ){

View File

@ -16,10 +16,9 @@
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : GeometryGUI_Operations.h
// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
//
#ifndef GEOMETRYGUI_OPERATIONS_H
#define GEOMETRYGUI_OPERATIONS_H
@ -131,6 +130,7 @@ namespace GEOMOp {
OpOrientation = 4009, // MENU REPAIR - CHANGE ORIENTATION
OpGlueFaces = 4010, // MENU REPAIR - GLUE FACES
OpRemoveExtraEdges = 4011, // MENU REPAIR - REMOVE EXTRA EDGES
OpLimitTolerance = 4012, // MENU REPAIR - LIMIT TOLERANCE
// MeasureGUI ----------------//--------------------------------
OpProperties = 5000, // MENU MEASURES - PROPERTIES
OpCenterMass = 5001, // MENU MEASURES - CENTRE OF MASS

View File

@ -18,7 +18,6 @@
// 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>
@ -45,6 +44,12 @@
#include <TopoDS_Iterator.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TColStd_IndexedDataMapOfTransientTransient.hxx>
#include <TNaming_CopyShape.hxx>
#include <ShapeFix_ShapeTolerance.hxx>
#include <ShapeFix_Shape.hxx>
#include <BRepCheck_Analyzer.hxx>
#include <Precision.hxx>
#include <StdFail_NotDone.hxx>
@ -126,6 +131,9 @@ Standard_Integer GEOMImpl_HealingDriver::Execute(TFunction_Logbook& log) const
case CHANGE_ORIENTATION:
ChangeOrientation(&HI, anOriginalShape, aShape);
break;
case LIMIT_TOLERANCE:
LimitTolerance(&HI, anOriginalShape, aShape);
break;
default:
return 0;
}
@ -465,6 +473,36 @@ Standard_Boolean GEOMImpl_HealingDriver::ChangeOrientation (GEOMImpl_IHealing* t
return aResult;
}
//=======================================================================
//function : LimitTolerance
//purpose :
//=======================================================================
void GEOMImpl_HealingDriver::LimitTolerance (GEOMImpl_IHealing* theHI,
const TopoDS_Shape& theOriginalShape,
TopoDS_Shape& theOutShape) const
{
Standard_Real aTol = theHI->GetTolerance();
if (aTol < Precision::Confusion())
aTol = Precision::Confusion();
// 1. Make a copy to prevent the original shape changes.
TopoDS_Shape aShapeCopy;
TColStd_IndexedDataMapOfTransientTransient aMapTShapes;
TNaming_CopyShape::CopyTool(theOriginalShape, aMapTShapes, aShapeCopy);
// 2. Limit tolerance.
ShapeFix_ShapeTolerance aSFT;
aSFT.LimitTolerance(aShapeCopy, aTol, aTol, TopAbs_SHAPE);
// 3. Fix obtained shape.
Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape (aShapeCopy);
aSfs->Perform();
theOutShape = aSfs->Shape();
BRepCheck_Analyzer ana (theOutShape, Standard_True);
if (!ana.IsValid())
StdFail_NotDone::Raise("Non valid shape result");
}
//=======================================================================
//function : GEOMImpl_HealingDriver_Type_

View File

@ -19,10 +19,9 @@
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// File : GEOMImpl_HealingDriver.hxx
// Module : GEOMImpl
//
#ifndef _GEOMImpl_HealingDriver_HeaderFile
#define _GEOMImpl_HealingDriver_HeaderFile
@ -167,7 +166,7 @@ Standard_Boolean RemoveHoles ( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS
Standard_Boolean Sew ( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const;
Standard_Boolean AddPointOnEdge( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const;
Standard_Boolean ChangeOrientation( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const;
void LimitTolerance( GEOMImpl_IHealing*, const TopoDS_Shape&, TopoDS_Shape& ) const;
};

View File

@ -569,6 +569,81 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetPoint
return aResult;
}
//=============================================================================
/*!
* GetVertexNearPoint
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetVertexNearPoint
(Handle(GEOM_Object) theShape,
Handle(GEOM_Object) thePoint)
{
SetErrorCode(KO);
// New Point object
Handle(GEOM_Object) aResult;
// Arguments
if (theShape.IsNull() || thePoint.IsNull()) return NULL;
TopoDS_Shape aBlockOrComp = theShape->GetValue();
TopoDS_Shape aPoint = thePoint->GetValue();
if (aBlockOrComp.IsNull() || aPoint.IsNull()) {
SetErrorCode("Given shape is null");
return NULL;
}
if (aPoint.ShapeType() != TopAbs_VERTEX) {
SetErrorCode("Element for vertex identification is not a vertex");
return NULL;
}
TopoDS_Vertex aVert = TopoDS::Vertex(aPoint);
gp_Pnt aP = BRep_Tool::Pnt(aVert);
// Compute the Vertex value
TopoDS_Shape V;
bool isFound = false;
Standard_Real aDist = RealLast();
TopTools_MapOfShape mapShape;
TopExp_Explorer exp (aBlockOrComp, TopAbs_VERTEX);
for (; exp.More(); exp.Next()) {
if (mapShape.Add(exp.Current())) {
TopoDS_Vertex aVi = TopoDS::Vertex(exp.Current());
gp_Pnt aPi = BRep_Tool::Pnt(aVi);
Standard_Real aDisti = aPi.Distance(aP);
if (aDisti < aDist) {
V = aVi;
aDist = aDisti;
isFound = true;
}
}
}
if (!isFound) {
SetErrorCode("Vertex has not been found");
return NULL;
}
TopTools_IndexedMapOfShape anIndices;
TopExp::MapShapes(aBlockOrComp, anIndices);
Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1,1);
anArray->SetValue(1, anIndices.FindIndex(V));
aResult = GetEngine()->AddSubShape(theShape, anArray);
// The GetPoint() doesn't change object so no new function is required.
Handle(GEOM_Function) aFunction = theShape->GetLastFunction();
// Make a Python command
GEOM::TPythonDump(aFunction, /*append=*/true)
<< aResult << " = geompy.GetVertexNearPoint("
<< theShape << ", " << thePoint << ")";
SetErrorCode(OK);
return aResult;
}
//=============================================================================
/*!
* GetEdge
@ -1458,6 +1533,136 @@ Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetFaceByNormale
return aResult;
}
//=============================================================================
/*!
* GetShapesNearPoint
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IBlocksOperations::GetShapesNearPoint
(Handle(GEOM_Object) theShape,
Handle(GEOM_Object) thePoint,
const Standard_Integer theShapeType,
const Standard_Real theTolerance)
{
SetErrorCode(KO);
// New object
Handle(GEOM_Object) aResult;
// Arguments
if (theShape.IsNull() || thePoint.IsNull()) return NULL;
TopoDS_Shape aBlockOrComp = theShape->GetValue();
if (aBlockOrComp.IsNull()) {
SetErrorCode("Block or compound is null");
return NULL;
}
TopoDS_Shape anArg = thePoint->GetValue();
if (anArg.IsNull()) {
SetErrorCode("Null shape is given as argument");
return NULL;
}
if (anArg.ShapeType() != TopAbs_VERTEX) {
SetErrorCode("Element for face identification is not a vertex");
return NULL;
}
if (theShapeType < TopAbs_SOLID || TopAbs_VERTEX < theShapeType) {
SetErrorCode("Invalid type of result is requested");
return NULL;
}
if (theTolerance < Precision::Confusion()) {
theTolerance == Precision::Confusion();
}
// Compute the result
try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
#endif
TopoDS_Vertex aVert = TopoDS::Vertex(anArg);
TopTools_MapOfShape mapShape;
Standard_Integer nbEdges = 0;
TopExp_Explorer exp (aBlockOrComp, TopAbs_ShapeEnum(theShapeType));
for (; exp.More(); exp.Next()) {
if (mapShape.Add(exp.Current())) {
nbEdges++;
}
}
if (nbEdges == 0) {
SetErrorCode("Given shape contains no subshapes of requested type");
return NULL;
}
// Calculate distances and find min
mapShape.Clear();
Standard_Integer ind = 1;
Standard_Real aMinDist = RealLast();
TopTools_Array1OfShape anEdges (1, nbEdges);
TColStd_Array1OfReal aDistances (1, nbEdges);
for (exp.Init(aBlockOrComp, TopAbs_ShapeEnum(theShapeType)); exp.More(); exp.Next()) {
if (mapShape.Add(exp.Current())) {
TopoDS_Shape anEdge = exp.Current();
anEdges(ind) = anEdge;
BRepExtrema_DistShapeShape aDistTool (aVert, anEdges(ind));
if (!aDistTool.IsDone()) {
SetErrorCode("Can not find a distance from the given point to one of subshapes");
return NULL;
}
aDistances(ind) = aDistTool.Value();
if (aDistances(ind) < aMinDist) {
aMinDist = aDistances(ind);
}
ind++;
}
}
if (aMinDist < RealLast()) {
// Collect subshapes with distance < (aMinDist + theTolerance)
int nbSubShapes = 0;
TopTools_Array1OfShape aNearShapes (1, nbEdges);
for (ind = 1; ind <= nbEdges; ind++) {
if (aDistances(ind) < aMinDist + theTolerance) {
nbSubShapes++;
aNearShapes(nbSubShapes) = anEdges(ind);
}
}
// Add subshape
TopTools_IndexedMapOfShape anIndices;
TopExp::MapShapes(aBlockOrComp, anIndices);
Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger (1, nbSubShapes);
for (ind = 1; ind <= nbSubShapes; ind++) {
anArray->SetValue(ind, anIndices.FindIndex(aNearShapes(ind)));
}
aResult = GetEngine()->AddSubShape(theShape, anArray);
}
}
catch (Standard_Failure) {
Handle(Standard_Failure) aFail = Standard_Failure::Caught();
SetErrorCode(aFail->GetMessageString());
return NULL;
}
if (aResult.IsNull())
return NULL;
Handle(GEOM_Function) aFunction = aResult->GetLastFunction();
//Make a Python command
GEOM::TPythonDump(aFunction)
<< aResult << " = geompy.GetShapesNearPoint(" << theShape << ", " << thePoint
<< ", " << TopAbs_ShapeEnum(theShapeType) << ", " << theTolerance << ")";
SetErrorCode(OK);
return aResult;
}
//=============================================================================
/*!
* IsCompoundOfBlocks

View File

@ -18,7 +18,6 @@
// 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_IBlocksOperations_HXX_
#define _GEOMImpl_IBlocksOperations_HXX_
@ -41,68 +40,76 @@ class GEOMImpl_IBlocksOperations : public GEOM_IOperations {
// Creation of blocks and block faces
Standard_EXPORT Handle(GEOM_Object) MakeQuad (Handle(GEOM_Object) theEdge1,
Handle(GEOM_Object) theEdge2,
Handle(GEOM_Object) theEdge3,
Handle(GEOM_Object) theEdge4);
Handle(GEOM_Object) theEdge2,
Handle(GEOM_Object) theEdge3,
Handle(GEOM_Object) theEdge4);
Standard_EXPORT Handle(GEOM_Object) MakeQuad2Edges (Handle(GEOM_Object) theEdge1,
Handle(GEOM_Object) theEdge2);
Handle(GEOM_Object) theEdge2);
Standard_EXPORT Handle(GEOM_Object) MakeQuad4Vertices (Handle(GEOM_Object) thePoint1,
Handle(GEOM_Object) thePoint2,
Handle(GEOM_Object) thePoint3,
Handle(GEOM_Object) thePoint4);
Handle(GEOM_Object) thePoint2,
Handle(GEOM_Object) thePoint3,
Handle(GEOM_Object) thePoint4);
Standard_EXPORT Handle(GEOM_Object) MakeHexa (Handle(GEOM_Object) theFace1,
Handle(GEOM_Object) theFace2,
Handle(GEOM_Object) theFace3,
Handle(GEOM_Object) theFace4,
Handle(GEOM_Object) theFace5,
Handle(GEOM_Object) theFace6);
Handle(GEOM_Object) theFace2,
Handle(GEOM_Object) theFace3,
Handle(GEOM_Object) theFace4,
Handle(GEOM_Object) theFace5,
Handle(GEOM_Object) theFace6);
Standard_EXPORT Handle(GEOM_Object) MakeHexa2Faces (Handle(GEOM_Object) theFace1,
Handle(GEOM_Object) theFace2);
Handle(GEOM_Object) theFace2);
Standard_EXPORT Handle(GEOM_Object) MakeBlockCompound (Handle(GEOM_Object) theCompound);
// Extract elements of blocks and blocks compounds
Standard_EXPORT Handle(GEOM_Object) GetPoint (Handle(GEOM_Object) theShape,
const Standard_Real theX,
const Standard_Real theY,
const Standard_Real theZ,
const Standard_Real theEpsilon);
const Standard_Real theX,
const Standard_Real theY,
const Standard_Real theZ,
const Standard_Real theEpsilon);
Standard_EXPORT Handle(GEOM_Object) GetVertexNearPoint (Handle(GEOM_Object) theShape,
Handle(GEOM_Object) thePoint);
Standard_EXPORT Handle(GEOM_Object) GetEdge (Handle(GEOM_Object) theShape,
Handle(GEOM_Object) thePoint1,
Handle(GEOM_Object) thePoint2);
Handle(GEOM_Object) thePoint1,
Handle(GEOM_Object) thePoint2);
Standard_EXPORT Handle(GEOM_Object) GetEdgeNearPoint (Handle(GEOM_Object) theBlock,
Handle(GEOM_Object) thePoint);
Handle(GEOM_Object) thePoint);
Standard_EXPORT Handle(GEOM_Object) GetFaceByPoints (Handle(GEOM_Object) theShape,
Handle(GEOM_Object) thePoint1,
Handle(GEOM_Object) thePoint2,
Handle(GEOM_Object) thePoint3,
Handle(GEOM_Object) thePoint4);
Handle(GEOM_Object) thePoint1,
Handle(GEOM_Object) thePoint2,
Handle(GEOM_Object) thePoint3,
Handle(GEOM_Object) thePoint4);
Standard_EXPORT Handle(GEOM_Object) GetFaceByEdges (Handle(GEOM_Object) theShape,
Handle(GEOM_Object) theEdge1,
Handle(GEOM_Object) theEdge2);
Handle(GEOM_Object) theEdge1,
Handle(GEOM_Object) theEdge2);
Standard_EXPORT Handle(GEOM_Object) GetOppositeFace (Handle(GEOM_Object) theBlock,
Handle(GEOM_Object) theFace);
Handle(GEOM_Object) theFace);
Standard_EXPORT Handle(GEOM_Object) GetFaceNearPoint (Handle(GEOM_Object) theBlock,
Handle(GEOM_Object) thePoint);
Handle(GEOM_Object) thePoint);
Standard_EXPORT Handle(GEOM_Object) GetFaceByNormale (Handle(GEOM_Object) theBlock,
Handle(GEOM_Object) theVector);
Handle(GEOM_Object) theVector);
Standard_EXPORT Handle(GEOM_Object) GetShapesNearPoint (Handle(GEOM_Object) theShape,
Handle(GEOM_Object) thePoint,
const Standard_Integer theShapeType,
const Standard_Real theTolerance);
// Check blocks compounds
Standard_EXPORT Standard_Boolean IsCompoundOfBlocks (Handle(GEOM_Object) theCompound,
const Standard_Integer theMinNbFaces,
const Standard_Integer theMaxNbFaces,
Standard_Integer& theNbBlocks);
const Standard_Integer theMinNbFaces,
const Standard_Integer theMaxNbFaces,
Standard_Integer& theNbBlocks);
enum BCErrorType {
NOT_BLOCK,
@ -118,13 +125,13 @@ class GEOMImpl_IBlocksOperations : public GEOM_IOperations {
};
Standard_EXPORT Standard_Boolean CheckCompoundOfBlocksOld (Handle(GEOM_Object) theCompound,
std::list<BCError>& theErrors);
std::list<BCError>& theErrors);
Standard_EXPORT Standard_Boolean CheckCompoundOfBlocks (Handle(GEOM_Object) theCompound,
std::list<BCError>& theErrors);
std::list<BCError>& theErrors);
Standard_EXPORT TCollection_AsciiString PrintBCErrors (Handle(GEOM_Object) theCompound,
const std::list<BCError>& theErrors);
const std::list<BCError>& theErrors);
Standard_EXPORT Handle(GEOM_Object) RemoveExtraEdges (Handle(GEOM_Object) theShape,
const Standard_Integer theOptimumNbFaces = 6);
@ -132,9 +139,9 @@ class GEOMImpl_IBlocksOperations : public GEOM_IOperations {
Standard_EXPORT Handle(GEOM_Object) CheckAndImprove (Handle(GEOM_Object) theCompound);
Standard_EXPORT static void AddBlocksFrom (const TopoDS_Shape& theShape,
TopTools_ListOfShape& BLO,
TopTools_ListOfShape& NOT,
TopTools_ListOfShape& EXT);
TopTools_ListOfShape& BLO,
TopTools_ListOfShape& NOT,
TopTools_ListOfShape& EXT);
// Extract blocks from blocks compounds
Standard_EXPORT Handle(TColStd_HSequenceOfTransient) ExplodeCompoundOfBlocks
@ -143,7 +150,7 @@ class GEOMImpl_IBlocksOperations : public GEOM_IOperations {
const Standard_Integer theMaxNbFaces);
Standard_EXPORT Handle(GEOM_Object) GetBlockNearPoint (Handle(GEOM_Object) theCompound,
Handle(GEOM_Object) thePoint);
Handle(GEOM_Object) thePoint);
Standard_EXPORT Handle(GEOM_Object) GetBlockByParts
(Handle(GEOM_Object) theCompound,
@ -155,17 +162,17 @@ class GEOMImpl_IBlocksOperations : public GEOM_IOperations {
// Operations on blocks with gluing of result
Standard_EXPORT Handle(GEOM_Object) MakeMultiTransformation1D (Handle(GEOM_Object) theBlock,
const Standard_Integer theDirFace1,
const Standard_Integer theDirFace2,
const Standard_Integer theNbTimes);
const Standard_Integer theDirFace1,
const Standard_Integer theDirFace2,
const Standard_Integer theNbTimes);
Standard_EXPORT Handle(GEOM_Object) MakeMultiTransformation2D (Handle(GEOM_Object) theBlock,
const Standard_Integer theDirFace1U,
const Standard_Integer theDirFace2U,
const Standard_Integer theNbTimesU,
const Standard_Integer theDirFace1V,
const Standard_Integer theDirFace2V,
const Standard_Integer theNbTimesV);
const Standard_Integer theDirFace1U,
const Standard_Integer theDirFace2U,
const Standard_Integer theNbTimesU,
const Standard_Integer theDirFace1V,
const Standard_Integer theDirFace2V,
const Standard_Integer theNbTimesV);
// Build groups for Propagation of 1D hypotheses
Standard_EXPORT Handle(TColStd_HSequenceOfTransient) Propagate (Handle(GEOM_Object) theShape);

View File

@ -19,9 +19,8 @@
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// NOTE: This is an intreface to a function for the Healing creation.
//NOTE: This is an intreface to a function for the Healing creation.
//
#include "GEOM_Function.hxx"
#include <TColStd_HArray1OfInteger.hxx>

View File

@ -18,7 +18,6 @@
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
#ifdef WNT
#pragma warning( disable:4786 )
@ -864,7 +863,6 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientation (Handle(GEOM_
return theObject;
}
//=============================================================================
/*!
* ChangeOrientationCopy
@ -921,3 +919,62 @@ Handle(GEOM_Object) GEOMImpl_IHealingOperations::ChangeOrientationCopy (Handle(G
SetErrorCode(OK);
return aNewObject;
}
//=============================================================================
/*!
* LimitTolerance
*/
//=============================================================================
Handle(GEOM_Object) GEOMImpl_IHealingOperations::LimitTolerance (Handle(GEOM_Object) theObject,
double theTolerance)
{
// Set error code, check parameters
SetErrorCode(KO);
if (theObject.IsNull())
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
// Add a new object
Handle(GEOM_Object) aNewObject = GetEngine()->AddObject(GetDocID(), theObject->GetType());
// Add the function
aFunction = aNewObject->AddFunction(GEOMImpl_HealingDriver::GetID(), LIMIT_TOLERANCE);
if (aFunction.IsNull())
return NULL;
// Check if the function is set correctly
if (aFunction->GetDriverGUID() != GEOMImpl_HealingDriver::GetID()) return NULL;
// Prepare "data container" class IHealing
GEOMImpl_IHealing HI (aFunction);
HI.SetOriginal(aLastFunction);
HI.SetTolerance(theTolerance);
// Compute
try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
#endif
if (!GetSolver()->ComputeFunction(aFunction)) {
SetErrorCode("Healing 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) << aNewObject << " = geompy.LimitTolerance("
<< theObject << ", " << theTolerance << ")";
SetErrorCode(OK);
return aNewObject;
}

View File

@ -18,7 +18,6 @@
// 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_IHealingOperations_HXX_
#define _GEOMImpl_IHealingOperations_HXX_
@ -39,9 +38,9 @@ class GEOMImpl_IHealingOperations : public GEOM_IOperations {
// Apply Shape Processing to the selected Object
Standard_EXPORT Handle(GEOM_Object) ShapeProcess( Handle(GEOM_Object) theObject,
const Handle(TColStd_HArray1OfExtendedString)& theOperations,
const Handle(TColStd_HArray1OfExtendedString)& theParams,
const Handle(TColStd_HArray1OfExtendedString)& theValues );
const Handle(TColStd_HArray1OfExtendedString)& theOperations,
const Handle(TColStd_HArray1OfExtendedString)& theParams,
const Handle(TColStd_HArray1OfExtendedString)& theValues );
// Retrieve default Shape Process parameters (from resource file)
Standard_EXPORT void GetShapeProcessParameters( std::list<std::string>& theOperations,
@ -54,7 +53,8 @@ class GEOMImpl_IHealingOperations : public GEOM_IOperations {
std::list<std::string>& theValues );
// returns all parameters that are valid for the given operation (Shape Process operator)
Standard_EXPORT static bool GetParameters( const std::string theOperation, std::list<std::string>& theParams );
Standard_EXPORT static bool GetParameters( const std::string theOperation,
std::list<std::string>& theParams );
Standard_EXPORT Handle(GEOM_Object) SuppressFaces( Handle(GEOM_Object) theObject,
const Handle(TColStd_HArray1OfInteger)& theFaces);
@ -73,9 +73,9 @@ class GEOMImpl_IHealingOperations : public GEOM_IOperations {
double theTolerance );
Standard_EXPORT Handle(GEOM_Object) DivideEdge( Handle(GEOM_Object) theObject,
int theIndex,
double theValue,
bool isByParameter );
int theIndex,
double theValue,
bool isByParameter );
// 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
@ -87,6 +87,9 @@ class GEOMImpl_IHealingOperations : public GEOM_IOperations {
Standard_EXPORT Handle(GEOM_Object) ChangeOrientation( Handle(GEOM_Object) theObject);
Standard_EXPORT Handle(GEOM_Object) ChangeOrientationCopy( Handle(GEOM_Object) theObject);
Standard_EXPORT Handle(GEOM_Object) LimitTolerance( Handle(GEOM_Object) theObject,
double theTolerance );
};
#endif

View File

@ -269,6 +269,7 @@
#define SEWING 6
#define DIVIDE_EDGE 7
#define CHANGE_ORIENTATION 8
#define LIMIT_TOLERANCE 9
#define BASIC_FILLING 1

View File

@ -269,6 +269,34 @@ GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetPoint (GEOM::GEOM_Object_ptr
return GetObject(anObject);
}
//=============================================================================
/*!
* GetVertexNearPoint
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetVertexNearPoint
(GEOM::GEOM_Object_ptr theShape,
GEOM::GEOM_Object_ptr thePoint)
{
GEOM::GEOM_Object_var aGEOMObject;
// Set a not done flag
GetOperations()->SetNotDone();
// Get the reference Objects
Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
// Create the Point
Handle(GEOM_Object) anObject =
GetOperations()->GetVertexNearPoint(aShape, aPoint);
if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn();
return GetObject(anObject);
}
//=============================================================================
/*!
* GetEdge
@ -481,6 +509,37 @@ GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetFaceByNormale (GEOM::GEOM_Obj
return GetObject(anObject);
}
//=============================================================================
/*!
* GetShapesNearPoint
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IBlocksOperations_i::GetShapesNearPoint
(GEOM::GEOM_Object_ptr theShape,
GEOM::GEOM_Object_ptr thePoint,
CORBA::Long theShapeType,
CORBA::Double theTolerance)
{
GEOM::GEOM_Object_var aGEOMObject;
// Set a not done flag
GetOperations()->SetNotDone();
// Get the reference Objects
Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
Handle(GEOM_Object) aPoint = GetObjectImpl(thePoint);
if (aShape.IsNull() || aPoint.IsNull()) return aGEOMObject._retn();
// Create the Shape
Handle(GEOM_Object) anObject =
GetOperations()->GetShapesNearPoint(aShape, aPoint, theShapeType, theTolerance);
if (!GetOperations()->IsDone() || anObject.IsNull())
return aGEOMObject._retn();
return GetObject(anObject);
}
//=============================================================================
/*!
* ExplodeCompoundOfBlocks

View File

@ -75,6 +75,9 @@ class GEOM_I_EXPORT GEOM_IBlocksOperations_i :
CORBA::Double theZ,
CORBA::Double theEpsilon);
GEOM::GEOM_Object_ptr GetVertexNearPoint (GEOM::GEOM_Object_ptr theShape,
GEOM::GEOM_Object_ptr thePoint);
GEOM::GEOM_Object_ptr GetEdge (GEOM::GEOM_Object_ptr theShape,
GEOM::GEOM_Object_ptr thePoint1,
GEOM::GEOM_Object_ptr thePoint2);
@ -101,10 +104,15 @@ class GEOM_I_EXPORT GEOM_IBlocksOperations_i :
GEOM::GEOM_Object_ptr GetFaceByNormale (GEOM::GEOM_Object_ptr theBlock,
GEOM::GEOM_Object_ptr theVector);
GEOM::GEOM_Object_ptr GetShapesNearPoint (GEOM::GEOM_Object_ptr theShape,
GEOM::GEOM_Object_ptr thePoint,
CORBA::Long theShapeType,
CORBA::Double theTolerance);
// Check blocks compound
CORBA::Boolean IsCompoundOfBlocks (GEOM::GEOM_Object_ptr theCompound,
CORBA::Long theMinNbFaces,
CORBA::Long theMaxNbFaces,
CORBA::Long theMinNbFaces,
CORBA::Long theMaxNbFaces,
CORBA::Long& theNbBlocks);
CORBA::Boolean CheckCompoundOfBlocks (GEOM::GEOM_Object_ptr theCompound,

View File

@ -18,7 +18,6 @@
// 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>
@ -493,3 +492,30 @@ GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::ChangeOrientationCopy (GEOM::GE
return GetObject(aNewObject);
}
//=============================================================================
/*!
* LimitTolerance
*/
//=============================================================================
GEOM::GEOM_Object_ptr GEOM_IHealingOperations_i::LimitTolerance (GEOM::GEOM_Object_ptr theObject,
CORBA::Double theTolerance)
{
GEOM::GEOM_Object_var aGEOMObject;
// Set a not done flag
GetOperations()->SetNotDone();
// Get the object itself
Handle(GEOM_Object) anObject = GetObjectImpl(theObject);
if (anObject.IsNull())
return aGEOMObject._retn();
// Perform
Handle(GEOM_Object) aNewObject =
GetOperations()->LimitTolerance(anObject, theTolerance);
if (!GetOperations()->IsDone() || aNewObject.IsNull())
return aGEOMObject._retn();
return GetObject(aNewObject);
}

View File

@ -18,7 +18,7 @@
// 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_IHealingOperations_i_HeaderFile
#define _GEOM_IHealingOperations_i_HeaderFile
@ -41,37 +41,60 @@ class GEOM_I_EXPORT GEOM_IHealingOperations_i :
public virtual GEOM_IOperations_i
{
public:
GEOM_IHealingOperations_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, ::GEOMImpl_IHealingOperations* theImpl);
GEOM_IHealingOperations_i(PortableServer::POA_ptr thePOA,
GEOM::GEOM_Gen_ptr theEngine,
::GEOMImpl_IHealingOperations* theImpl);
~GEOM_IHealingOperations_i();
GEOM::GEOM_Object_ptr ProcessShape(GEOM::GEOM_Object_ptr theObject, const GEOM::string_array& theOperations, const GEOM::string_array& theParams, const GEOM::string_array& theValues);
GEOM::GEOM_Object_ptr ProcessShape(GEOM::GEOM_Object_ptr theObject,
const GEOM::string_array& theOperations,
const GEOM::string_array& theParams,
const GEOM::string_array& theValues);
void GetShapeProcessParameters(GEOM::string_array_out theOperations, GEOM::string_array_out theParams, GEOM::string_array_out theValues);
void GetShapeProcessParameters(GEOM::string_array_out theOperations,
GEOM::string_array_out theParams,
GEOM::string_array_out theValues);
void GetOperatorParameters (const char* theOperator, GEOM::string_array_out theParams, GEOM::string_array_out theValues);
void GetOperatorParameters (const char* theOperator,
GEOM::string_array_out theParams,
GEOM::string_array_out theValues);
GEOM::GEOM_Object_ptr SuppressFaces(GEOM::GEOM_Object_ptr theObject, const GEOM::short_array& theFaces);
GEOM::GEOM_Object_ptr SuppressFaces(GEOM::GEOM_Object_ptr theObject,
const GEOM::short_array& theFaces);
GEOM::GEOM_Object_ptr CloseContour (GEOM::GEOM_Object_ptr theObject, const GEOM::short_array& theWires, CORBA::Boolean isCommonVertex);
GEOM::GEOM_Object_ptr CloseContour (GEOM::GEOM_Object_ptr theObject,
const GEOM::short_array& theWires,
CORBA::Boolean isCommonVertex);
GEOM::GEOM_Object_ptr RemoveIntWires (GEOM::GEOM_Object_ptr theObject, const GEOM::short_array& theWires);
GEOM::GEOM_Object_ptr RemoveIntWires (GEOM::GEOM_Object_ptr theObject,
const GEOM::short_array& theWires);
GEOM::GEOM_Object_ptr FillHoles (GEOM::GEOM_Object_ptr theObject, const GEOM::short_array& theWires);
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, CORBA::Double theTolerance);
GEOM::GEOM_Object_ptr Sew (GEOM::GEOM_Object_ptr theObject,
CORBA::Double theTolerance);
GEOM::GEOM_Object_ptr DivideEdge (GEOM::GEOM_Object_ptr theObject, CORBA::Short theIndex, CORBA::Double theValue, CORBA::Boolean isByParameter);
GEOM::GEOM_Object_ptr DivideEdge (GEOM::GEOM_Object_ptr theObject,
CORBA::Short theIndex,
CORBA::Double theValue,
CORBA::Boolean isByParameter);
CORBA::Boolean GetFreeBoundary(GEOM::GEOM_Object_ptr theObject, GEOM::ListOfGO_out theClosedWires, GEOM::ListOfGO_out theOpenWires );
CORBA::Boolean GetFreeBoundary(GEOM::GEOM_Object_ptr theObject,
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);
GEOM::GEOM_Object_ptr LimitTolerance (GEOM::GEOM_Object_ptr theObject,
CORBA::Double theTolerance);
::GEOMImpl_IHealingOperations* GetOperations() { return (::GEOMImpl_IHealingOperations*)GetImpl(); }
private:
Handle(TColStd_HArray1OfExtendedString) Convert( const GEOM::string_array& );
Handle(TColStd_HArray1OfInteger) Convert( const GEOM::short_array& );
Handle(TColStd_HArray1OfExtendedString) Convert( const GEOM::string_array& );
Handle(TColStd_HArray1OfInteger) Convert( const GEOM::short_array& );
};

View File

@ -500,6 +500,17 @@ def TestOtherOperations (geompy, math):
geompy.addToStudyInFather(blocksComp, pb0_top_1, "point from blocksComp (-50, 50, 50)")
geompy.addToStudyInFather(blocksComp, pb0_bot_1, "point from blocksComp (-50, -50, -50)")
# GetVertexNearPoint(theShape, thePoint)
pb0_top_2_near = geompy.MakeVertex(40, 40, 40)
pb0_top_2 = geompy.GetVertexNearPoint(blocksComp, pb0_top_2_near)
geompy.addToStudyInFather(blocksComp, pb0_top_2, "point from blocksComp near (40, 40, 40)")
# GetEdge(theShape, thePoint1, thePoint2)
edge_top_y50 = geompy.GetEdge(blocksComp, pb0_top_1, pb0_top_2)
geompy.addToStudyInFather(blocksComp, edge_top_y50, "edge from blocksComp by two points")
# GetEdgeNearPoint(theShape, thePoint)
pmidle = geompy.MakeVertex(50, 0, 50)
edge1 = geompy.GetEdgeNearPoint(blocksComp, pmidle)
@ -511,6 +522,11 @@ def TestOtherOperations (geompy, math):
geompy.addToStudyInFather(blocksComp, b0_image, "b0 image")
# GetShapesNearPoint(theShape, thePoint, theShapeType, theTolerance)
b0_faces_plus = geompy.GetShapesNearPoint(blocksComp, pb0_top_2_near, geompy.ShapeType["FACE"], 0.01)
geompy.addToStudyInFather(blocksComp, b0_faces_plus, "faces near point (40, 40, 40)")
# GetShapesOnPlane
faces_on_pln = geompy.GetShapesOnPlane(blocksComp, geompy.ShapeType["FACE"],
v_0pp, geompy.GEOM.ST_ONIN)

View File

@ -448,7 +448,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
# @return New GEOM_Object, containing the created point.
#
# @ref tui_creation_point "Example"
def MakeVertex(self,theX, theY, theZ):
def MakeVertex(self, theX, theY, theZ):
# Example: see GEOM_TestAll.py
theX,theY,theZ,Parameters = ParseParameters(theX, theY, theZ)
anObj = self.BasicOp.MakePointXYZ(theX, theY, theZ)
@ -2266,11 +2266,22 @@ class geompyDC(GEOM._objref_GEOM_Gen):
# @return New GEOM_Object, containing processed shape.
#
# @ref swig_todo "Example"
def ChangeOrientationShellCopy(self,theObject):
def ChangeOrientationShellCopy(self, theObject):
anObj = self.HealOp.ChangeOrientationCopy(theObject)
RaiseIfFailed("ChangeOrientationCopy", self.HealOp)
return anObj
## Try to limit tolerance of the given object by value \a theTolerance.
# @param theObject Shape to be processed.
# @param theTolerance Required tolerance value.
# @return New GEOM_Object, containing processed shape.
#
# @ref tui_limit_tolerance "Example"
def LimitTolerance(self, theObject, theTolerance = 1e-07):
anObj = self.HealOp.LimitTolerance(theObject, theTolerance)
RaiseIfFailed("LimitTolerance", self.HealOp)
return anObj
## 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.
@ -2280,7 +2291,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
# theOpenWires: Open wires on the free boundary of the given shape.
#
# @ref tui_measurement_tools_page "Example"
def GetFreeBoundary(self,theObject):
def GetFreeBoundary(self, theObject):
# Example: see GEOM_TestHealing.py
anObj = self.HealOp.GetFreeBoundary(theObject)
RaiseIfFailed("GetFreeBoundary", self.HealOp)
@ -3620,19 +3631,31 @@ class geompyDC(GEOM._objref_GEOM_Gen):
# @return New GEOM_Object, containing the found vertex.
#
# @ref swig_GetPoint "Example"
def GetPoint(self,theShape, theX, theY, theZ, theEpsilon):
def GetPoint(self, theShape, theX, theY, theZ, theEpsilon):
# Example: see GEOM_TestOthers.py
anObj = self.BlocksOp.GetPoint(theShape, theX, theY, theZ, theEpsilon)
RaiseIfFailed("GetPoint", self.BlocksOp)
return anObj
## Find a vertex of the given shape, which has minimal distance to the given point.
# @param theShape Any shape.
# @param thePoint Point, close to the desired vertex.
# @return New GEOM_Object, containing the found vertex.
#
# @ref swig_GetVertexNearPoint "Example"
def GetVertexNearPoint(self, theShape, thePoint):
# Example: see GEOM_TestOthers.py
anObj = self.BlocksOp.GetVertexNearPoint(theShape, thePoint)
RaiseIfFailed("GetVertexNearPoint", self.BlocksOp)
return anObj
## Get an edge, found in the given shape by two given vertices.
# @param theShape Block or a compound of blocks.
# @param thePoint1,thePoint2 Points, close to the ends of the desired edge.
# @return New GEOM_Object, containing the found edge.
#
# @ref swig_todo "Example"
def GetEdge(self,theShape, thePoint1, thePoint2):
# @ref swig_GetEdge "Example"
def GetEdge(self, theShape, thePoint1, thePoint2):
# Example: see GEOM_Spanner.py
anObj = self.BlocksOp.GetEdge(theShape, thePoint1, thePoint2)
RaiseIfFailed("GetEdge", self.BlocksOp)
@ -3644,7 +3667,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
# @return New GEOM_Object, containing the found edge.
#
# @ref swig_GetEdgeNearPoint "Example"
def GetEdgeNearPoint(self,theShape, thePoint):
def GetEdgeNearPoint(self, theShape, thePoint):
# Example: see GEOM_TestOthers.py
anObj = self.BlocksOp.GetEdgeNearPoint(theShape, thePoint)
RaiseIfFailed("GetEdgeNearPoint", self.BlocksOp)
@ -3692,7 +3715,7 @@ class geompyDC(GEOM._objref_GEOM_Gen):
# @return New GEOM_Object, containing the found face.
#
# @ref swig_GetFaceNearPoint "Example"
def GetFaceNearPoint(self,theShape, thePoint):
def GetFaceNearPoint(self, theShape, thePoint):
# Example: see GEOM_Spanner.py
anObj = self.BlocksOp.GetFaceNearPoint(theShape, thePoint)
RaiseIfFailed("GetFaceNearPoint", self.BlocksOp)
@ -3710,6 +3733,23 @@ class geompyDC(GEOM._objref_GEOM_Gen):
RaiseIfFailed("GetFaceByNormale", self.BlocksOp)
return anObj
## Find all subshapes of type \a theShapeType of the given shape,
# which have minimal distance to the given point.
# @param theShape Any shape.
# @param thePoint Point, close to the desired shape.
# @param theShapeType Defines what kind of subshapes is searched.
# @param theTolerance The tolerance for distances comparison. All shapes
# with distances to the given point in interval
# [minimal_distance, minimal_distance + theTolerance] will be gathered.
# @return New GEOM_Object, containing a group of all found shapes.
#
# @ref swig_GetShapesNearPoint "Example"
def GetShapesNearPoint(self, theShape, thePoint, theShapeType, theTolerance = 1e-07):
# Example: see GEOM_TestOthers.py
anObj = self.BlocksOp.GetShapesNearPoint(theShape, thePoint, theShapeType, theTolerance)
RaiseIfFailed("GetShapesNearPoint", self.BlocksOp)
return anObj
# end of l3_blocks_op
## @}

View File

@ -38,6 +38,7 @@ salomeinclude_HEADERS = \
RepairGUI_FreeFacesDlg.h \
RepairGUI_ChangeOrientationDlg.h \
RepairGUI_GlueDlg.h \
RepairGUI_LimitToleranceDlg.h \
RepairGUI_RemoveExtraEdgesDlg.h
# Libraries targets
@ -56,6 +57,7 @@ dist_libRepairGUI_la_SOURCES = \
RepairGUI_FreeFacesDlg.h \
RepairGUI_ChangeOrientationDlg.h \
RepairGUI_GlueDlg.h \
RepairGUI_LimitToleranceDlg.h \
RepairGUI_RemoveExtraEdgesDlg.h \
\
RepairGUI.cxx \
@ -70,6 +72,7 @@ dist_libRepairGUI_la_SOURCES = \
RepairGUI_FreeFacesDlg.cxx \
RepairGUI_ChangeOrientationDlg.cxx \
RepairGUI_GlueDlg.cxx \
RepairGUI_LimitToleranceDlg.cxx \
RepairGUI_RemoveExtraEdgesDlg.cxx
MOC_FILES = \
@ -84,6 +87,7 @@ MOC_FILES = \
RepairGUI_FreeFacesDlg_moc.cxx \
RepairGUI_ChangeOrientationDlg_moc.cxx \
RepairGUI_GlueDlg_moc.cxx \
RepairGUI_LimitToleranceDlg_moc.cxx \
RepairGUI_RemoveExtraEdgesDlg_moc.cxx
nodist_libRepairGUI_la_SOURCES = \

View File

@ -19,11 +19,10 @@
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// GEOM GEOMGUI : GUI for Geometry component
// File : RepairGUI.cxx
// Author : Damien COQUERET, Open CASCADE S.A.S.
// GEOM GEOMGUI : GUI for Geometry component
// File : RepairGUI.cxx
// Author : Damien COQUERET, Open CASCADE S.A.S.
//
#include "RepairGUI.h"
#include <GeometryGUI.h>
@ -43,8 +42,9 @@
#include "RepairGUI_FreeBoundDlg.h" // Method FREE BOUNDARIES
#include "RepairGUI_FreeFacesDlg.h" // Method FREE FACES
#include "RepairGUI_GlueDlg.h" // Method GLUE FACES
#include "RepairGUI_LimitToleranceDlg.h" // Method LIMIT TOLERANCE
#include "RepairGUI_ChangeOrientationDlg.h" // Method CHANGE ORIENTATION
#include "RepairGUI_RemoveExtraEdgesDlg.h" // Method REMOVE EXTRA EDGES
#include "RepairGUI_RemoveExtraEdgesDlg.h" // Method REMOVE EXTRA EDGES
//=======================================================================
// function : RepairGUI()
@ -77,18 +77,19 @@ bool RepairGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
QDialog* aDlg = NULL;
switch ( theCommandID ) {
case GEOMOp::OpSewing: aDlg = new RepairGUI_SewingDlg ( getGeometryGUI(), parent ); break;
case GEOMOp::OpGlueFaces: aDlg = new RepairGUI_GlueDlg ( getGeometryGUI(), parent ); break;
case GEOMOp::OpSuppressFaces: aDlg = new RepairGUI_SuppressFacesDlg ( getGeometryGUI(), parent ); break;
case GEOMOp::OpSuppressHoles: aDlg = new RepairGUI_RemoveHolesDlg ( getGeometryGUI(), parent ); break;
case GEOMOp::OpShapeProcess: aDlg = new RepairGUI_ShapeProcessDlg ( getGeometryGUI(), parent ); break;
case GEOMOp::OpCloseContour: aDlg = new RepairGUI_CloseContourDlg ( getGeometryGUI(), parent ); break;
case GEOMOp::OpRemoveIntWires: aDlg = new RepairGUI_RemoveIntWiresDlg ( getGeometryGUI(), parent ); break;
case GEOMOp::OpAddPointOnEdge: aDlg = new RepairGUI_DivideEdgeDlg ( getGeometryGUI(), parent ); break;
case GEOMOp::OpFreeBoundaries: aDlg = new RepairGUI_FreeBoundDlg ( getGeometryGUI(), parent ); break;
case GEOMOp::OpFreeFaces: aDlg = new RepairGUI_FreeFacesDlg ( getGeometryGUI(), parent ); break;
case GEOMOp::OpOrientation: aDlg = new RepairGUI_ChangeOrientationDlg ( getGeometryGUI(), parent ); break;
case GEOMOp::OpRemoveExtraEdges: aDlg = new RepairGUI_RemoveExtraEdgesDlg ( getGeometryGUI(), parent ); break;
case GEOMOp::OpSewing: aDlg = new RepairGUI_SewingDlg (getGeometryGUI(), parent); break;
case GEOMOp::OpGlueFaces: aDlg = new RepairGUI_GlueDlg (getGeometryGUI(), parent); break;
case GEOMOp::OpLimitTolerance: aDlg = new RepairGUI_LimitToleranceDlg (getGeometryGUI(), parent); break;
case GEOMOp::OpSuppressFaces: aDlg = new RepairGUI_SuppressFacesDlg (getGeometryGUI(), parent); break;
case GEOMOp::OpSuppressHoles: aDlg = new RepairGUI_RemoveHolesDlg (getGeometryGUI(), parent); break;
case GEOMOp::OpShapeProcess: aDlg = new RepairGUI_ShapeProcessDlg (getGeometryGUI(), parent); break;
case GEOMOp::OpCloseContour: aDlg = new RepairGUI_CloseContourDlg (getGeometryGUI(), parent); break;
case GEOMOp::OpRemoveIntWires: aDlg = new RepairGUI_RemoveIntWiresDlg (getGeometryGUI(), parent); break;
case GEOMOp::OpAddPointOnEdge: aDlg = new RepairGUI_DivideEdgeDlg (getGeometryGUI(), parent); break;
case GEOMOp::OpFreeBoundaries: aDlg = new RepairGUI_FreeBoundDlg (getGeometryGUI(), parent); break;
case GEOMOp::OpFreeFaces: aDlg = new RepairGUI_FreeFacesDlg (getGeometryGUI(), parent); break;
case GEOMOp::OpOrientation: aDlg = new RepairGUI_ChangeOrientationDlg (getGeometryGUI(), parent); break;
case GEOMOp::OpRemoveExtraEdges: aDlg = new RepairGUI_RemoveExtraEdgesDlg (getGeometryGUI(), parent); break;
default:
app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) );
break;

View File

@ -0,0 +1,441 @@
// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// GEOM RepairGUI : GUI for Geometry component
// File : RepairGUI_LimitToleranceDlg.cxx
#include "RepairGUI_LimitToleranceDlg.h"
#include <DlgRef.h>
#include <GeometryGUI.h>
#include <GEOMBase.h>
#include <SalomeApp_DoubleSpinBox.h>
#include <SalomeApp_Application.h>
#include <LightApp_SelectionMgr.h>
#include <SalomeApp_Study.h>
#include <SalomeApp_Tools.h>
#include <SUIT_Session.h>
#include <SUIT_Desktop.h>
#include <SUIT_MessageBox.h>
#include <SUIT_OverrideCursor.h>
#include <SUIT_ResourceMgr.h>
#include <SUIT_ViewWindow.h>
#include <SUIT_ViewManager.h>
#include <OCCViewer_ViewModel.h>
#include <SALOME_ListIteratorOfListIO.hxx>
#include <GEOMImpl_Types.hxx>
#include <TCollection_AsciiString.hxx>
#define DEFAULT_TOLERANCE_VALUE 1e-07
//=================================================================================
// class : RepairGUI_LimitToleranceDlg()
// purpose : Constructs a RepairGUI_LimitToleranceDlg which is a child of 'parent', with the
// name 'name' and widget flags set to 'f'.
// The dialog will by default be modeless, unless you set 'modal' to
// TRUE to construct a modal dialog.
//=================================================================================
RepairGUI_LimitToleranceDlg::RepairGUI_LimitToleranceDlg(GeometryGUI* theGeometryGUI,
QWidget* parent, bool modal)
: GEOMBase_Skeleton(theGeometryGUI, parent, modal)
{
QPixmap image0 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_LIMIT_TOLERANCE")));
QPixmap image1 (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
setWindowTitle(tr("GEOM_LIMIT_TOLERANCE_TITLE"));
/***************************************************************/
mainFrame()->GroupConstructors->setTitle(tr("GEOM_LIMIT_TOLERANCE_TITLE"));
mainFrame()->RadioButton1->setIcon(image0);
mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
mainFrame()->RadioButton2->close();
mainFrame()->RadioButton3->close();
GroupPoints = new DlgRef_1SelExt(centralWidget());
GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_SHAPE"));
GroupPoints->PushButton1->setIcon(image1);
GroupPoints->LineEdit1->setReadOnly(true);
QLabel* aTolLab = new QLabel(tr("GEOM_TOLERANCE"), GroupPoints->Box);
myTolEdt = new SalomeApp_DoubleSpinBox(GroupPoints->Box);
initSpinBox(myTolEdt, 0., 100., DEFAULT_TOLERANCE_VALUE, "len_tol_precision");
myTolEdt->setValue(DEFAULT_TOLERANCE_VALUE);
QGridLayout* boxLayout = new QGridLayout(GroupPoints->Box);
boxLayout->setMargin(0); boxLayout->setSpacing(6);
boxLayout->addWidget(aTolLab, 0, 0);
boxLayout->addWidget(myTolEdt, 0, 2);
QVBoxLayout* layout = new QVBoxLayout(centralWidget());
layout->setMargin(0); layout->setSpacing(6);
layout->addWidget(GroupPoints);
setHelpFileName("limit_tolerance_operation_page.html");
Init();
}
//=================================================================================
// function : ~RepairGUI_LimitToleranceDlg()
// purpose : Destroys the object and frees any allocated resources
//=================================================================================
RepairGUI_LimitToleranceDlg::~RepairGUI_LimitToleranceDlg()
{
}
//=================================================================================
// function : Init()
// purpose :
//=================================================================================
void RepairGUI_LimitToleranceDlg::Init()
{
/* init variables */
myEditCurrentArgument = GroupPoints->LineEdit1;
myObject = GEOM::GEOM_Object::_nil();
//myGeomGUI->SetState(0);
//globalSelection(GEOM_COMPOUND);
mainFrame()->GroupBoxPublish->show();
/* 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(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
initName(tr("LIMIT_TOLERANCE_NEW_OBJ_NAME"));
ConstructorsClicked(0);
activateSelection();
updateButtonState();
}
//=================================================================================
// function : ConstructorsClicked()
// purpose : Radio button management
//=================================================================================
void RepairGUI_LimitToleranceDlg::ConstructorsClicked(int constructorId)
{
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
GroupPoints->show();
GroupPoints->LineEdit1->setText("");
myEditCurrentArgument = GroupPoints->LineEdit1;
myEditCurrentArgument->setFocus();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
qApp->processEvents();
updateGeometry();
resize(minimumSizeHint());
updateButtonState();
activateSelection();
SelectionIntoArgument();
}
//=================================================================================
// function : ClickOnOk()
// purpose : Same than click on apply but close this dialog.
//=================================================================================
void RepairGUI_LimitToleranceDlg::ClickOnOk()
{
if (ClickOnApply())
ClickOnCancel();
}
//=================================================================================
// function : ClickOnApply()
// purpose :
//=================================================================================
bool RepairGUI_LimitToleranceDlg::ClickOnApply()
{
if (!onAcceptLocal())
return false;
initName();
ConstructorsClicked(0);
return true;
}
//=================================================================================
// function : SelectionIntoArgument()
// purpose : Called when selection
//=================================================================================
void RepairGUI_LimitToleranceDlg::SelectionIntoArgument()
{
myEditCurrentArgument->setText("");
myObject = GEOM::GEOM_Object::_nil();
LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
SALOME_ListIO aSelList;
aSelMgr->selectedObjects(aSelList);
if (aSelList.Extent() == 1) {
Handle(SALOME_InteractiveObject) anIO = aSelList.First();
Standard_Boolean aRes;
myObject = GEOMBase::ConvertIOinGEOMObject(anIO, aRes);
if (aRes)
myEditCurrentArgument->setText(GEOMBase::GetName(myObject));
}
updateButtonState();
}
//=================================================================================
// function : SetEditCurrentArgument()
// purpose :
//=================================================================================
void RepairGUI_LimitToleranceDlg::SetEditCurrentArgument()
{
const QObject* send = sender();
if (send == GroupPoints->PushButton1) {
myEditCurrentArgument->setFocus();
SelectionIntoArgument();
}
}
//=================================================================================
// function : LineEditReturnPressed()
// purpose :
//=================================================================================
void RepairGUI_LimitToleranceDlg::LineEditReturnPressed()
{
const QObject* send = sender();
if (send == GroupPoints->LineEdit1) {
myEditCurrentArgument = GroupPoints->LineEdit1;
GEOMBase_Skeleton::LineEditReturnPressed();
}
}
//=================================================================================
// function : ActivateThisDialog()
// purpose :
//=================================================================================
void RepairGUI_LimitToleranceDlg::ActivateThisDialog()
{
GEOMBase_Skeleton::ActivateThisDialog();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
activateSelection();
}
//=================================================================================
// function : enterEvent()
// purpose : Mouse enter onto the dialog to activate it
//=================================================================================
void RepairGUI_LimitToleranceDlg::enterEvent(QEvent*)
{
if (!mainFrame()->GroupConstructors->isEnabled())
ActivateThisDialog();
}
//=================================================================================
// function : createOperation
// purpose :
//=================================================================================
GEOM::GEOM_IOperations_ptr RepairGUI_LimitToleranceDlg::createOperation()
{
return getGeomEngine()->GetIHealingOperations(getStudyId());
}
//=================================================================================
// function : isValid
// purpose :
//=================================================================================
bool RepairGUI_LimitToleranceDlg::isValid(QString& msg)
{
double v = myTolEdt->value();
bool ok = myTolEdt->isValid(msg, true);
return !myObject->_is_nil() && (v > 0.) && ok;
}
//=================================================================================
// function : execute
// purpose :
//=================================================================================
bool RepairGUI_LimitToleranceDlg::execute(ObjectList& objects)
{
bool aResult = false;
objects.clear();
GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow(getOperation());
GEOM::GEOM_Object_var anObj = anOper->LimitTolerance(myObject, myTolEdt->value());
aResult = !anObj->_is_nil();
if (aResult) {
QStringList aParameters;
aParameters << myTolEdt->text();
anObj->SetParameters(aParameters.join(":").toLatin1().constData());
objects.push_back(anObj._retn());
}
return aResult;
}
//================================================================
// Function : onAccept
// Purpose : This method should be called from dialog's slots onOk() and onApply()
// It perfroms user input validation, then it
// performs a proper operation and manages transactions, etc.
//================================================================
bool RepairGUI_LimitToleranceDlg::onAcceptLocal()
{
if (!getStudy() || !(getStudy()->studyDS()))
return false;
_PTR(Study) aStudy = getStudy()->studyDS();
bool aLocked = aStudy->GetProperties()->IsLocked();
if (aLocked) {
MESSAGE("GEOMBase_Helper::onAccept - ActiveStudy is locked");
SUIT_MessageBox::warning(this, tr("WRN_WARNING"), tr("WRN_STUDY_LOCKED"), tr("BUT_OK"));
return false;
}
QString msg;
if (!isValid(msg)) {
showError(msg);
return false;
}
try {
if (openCommand()) {
SUIT_OverrideCursor wc;
myGeomGUI->getApp()->putInfo("");
ObjectList objects;
if (!execute(objects)) {
wc.suspend();
abortCommand();
showError();
}
else {
const int nbObjs = objects.size();
for (ObjectList::iterator it = objects.begin(); it != objects.end(); ++it) {
QString aName = getNewObjectName();
if (nbObjs > 1) {
if (aName.isEmpty())
aName = getPrefix(*it);
aName = GEOMBase::GetDefaultName(aName);
}
else {
// PAL6521: use a prefix, if some dialog box doesn't reimplement getNewObjectName()
if (aName.isEmpty())
aName = GEOMBase::GetDefaultName(getPrefix(*it));
}
addInStudy(*it, aName.toLatin1().data());
display(*it, false);
}
if (nbObjs) {
commitCommand();
updateObjBrowser();
myGeomGUI->getApp()->putInfo(QObject::tr("GEOM_PRP_DONE"));
}
else {
abortCommand();
}
// JFA 28.12.2004 BEGIN // To enable warnings
GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow(getOperation());
if (!CORBA::is_nil(anOper) && !anOper->IsDone()) {
wc.suspend();
QString msgw = QObject::tr(anOper->GetErrorCode());
SUIT_MessageBox::warning(this, tr("WRN_WARNING"), msgw, tr("BUT_OK"));
}
// JFA 28.12.2004 END
}
}
}
catch(const SALOME::SALOME_Exception& e) {
SalomeApp_Tools::QtCatchCorbaException(e);
abortCommand();
}
updateViewer();
activateSelection();
updateButtonState();
return true;
}
//=================================================================================
// function : activateSelection
// purpose : Activate selection
//=================================================================================
void RepairGUI_LimitToleranceDlg::activateSelection()
{
disconnect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
globalSelection(GEOM_ALLSHAPES);
if (myObject->_is_nil())
SelectionIntoArgument();
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
updateViewer();
}
//=================================================================================
// function : updateButtonState
// purpose : Update button state
//=================================================================================
void RepairGUI_LimitToleranceDlg::updateButtonState()
{
bool hasMainObj = !myObject->_is_nil();
buttonOk()->setEnabled(hasMainObj);
buttonApply()->setEnabled(hasMainObj);
}
//=================================================================================
// function : restoreSubShapes
// purpose :
//=================================================================================
void RepairGUI_LimitToleranceDlg::restoreSubShapes(SALOMEDS::Study_ptr theStudy,
SALOMEDS::SObject_ptr theSObject)
{
if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
// empty list of arguments means that all arguments should be restored
getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(),
GEOM::FSM_GetInPlace, /*theInheritFirstArg=*/true,
mainFrame()->CheckBoxAddPrefix->isChecked());
}
}

View File

@ -0,0 +1,83 @@
// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
// GEOM GEOMGUI : GUI for Geometry component
// File : RepairGUI_LimitToleranceDlg.h
#ifndef REPAIRGUI_LIMITTOLERANCEDLG_H
#define REPAIRGUI_LIMITTOLERANCEDLG_H
#include <GEOMBase_Skeleton.h>
class DlgRef_1SelExt;
class SalomeApp_DoubleSpinBox;
class QPushButton;
class QCheckBox;
//=================================================================================
// class : RepairGUI_LimitToleranceDlg
// purpose :
//=================================================================================
class RepairGUI_LimitToleranceDlg : public GEOMBase_Skeleton
{
Q_OBJECT
public:
RepairGUI_LimitToleranceDlg (GeometryGUI*, QWidget* = 0, bool = false);
~RepairGUI_LimitToleranceDlg();
protected:
// redefined from GEOMBase_Helper
virtual GEOM::GEOM_IOperations_ptr createOperation();
virtual bool isValid (QString&);
virtual bool execute (ObjectList&);
virtual void restoreSubShapes (SALOMEDS::Study_ptr, SALOMEDS::SObject_ptr);
private:
void Init();
void enterEvent (QEvent*);
void initSelection();
bool onAcceptLocal();
void activateSelection();
void updateButtonState();
private:
GEOM::GEOM_Object_var myObject;
DlgRef_1SelExt* GroupPoints;
SalomeApp_DoubleSpinBox* myTolEdt;
private slots:
void ClickOnOk();
bool ClickOnApply();
void ActivateThisDialog();
void LineEditReturnPressed();
void SelectionIntoArgument();
void SetEditCurrentArgument();
void ConstructorsClicked( int );
};
#endif // REPAIRGUI_LIMITTOLERANCEDLG_H