Implement Check intersection level in Engine and TUI

This commit is contained in:
skv 2014-10-14 18:12:28 +04:00
parent 8e43b2d3fa
commit 8499f032ec
7 changed files with 82 additions and 8 deletions

View File

@ -187,6 +187,20 @@ module GEOM
FDT_String
};
/**
* This enumeration represents the level of checking shape on
* self-interference. It defines which interferferences will be checked.
*/
enum si_check_level
{
SI_V_V, // only V/V interferences
SI_V_E, // V/V and V/E interferences
SI_E_E, // V/V, V/E and E/E interferences
SI_V_F, // V/V, V/E, E/E and V/F interferences
SI_E_F, // V/V, V/E, E/E, V/F and E/F interferences
SI_ALL // all interferences
};
/*!
* \brief Object creation parameters
@ -4080,10 +4094,12 @@ module GEOM
/*!
* \brief Check a topology of the given shape on self-intersections presence.
* \param theShape Shape to check validity of.
* \param theCheckLevel the level of self-interference check.
* \param theIntersections Output. List of intersected sub-shapes IDs, it contains pairs of IDs.
* \return TRUE, if the shape does not have any self-intersections.
*/
boolean CheckSelfIntersections (in GEOM_Object theShape,
in long theCheckLevel,
out ListOfLong theIntersections);
/*!

View File

@ -1501,6 +1501,7 @@ TCollection_AsciiString GEOMImpl_IMeasureOperations::PrintShapeErrors
//=============================================================================
bool GEOMImpl_IMeasureOperations::CheckSelfIntersections
(Handle(GEOM_Object) theShape,
const SICheckLevel theCheckLevel,
Handle(TColStd_HSequenceOfInteger)& theIntersections)
{
SetErrorCode(KO);
@ -1534,6 +1535,7 @@ bool GEOMImpl_IMeasureOperations::CheckSelfIntersections
//
BOPAlgo_CheckerSI aCSI; // checker of self-interferences
aCSI.SetArguments(aLCS);
aCSI.SetLevelOfCheck(theCheckLevel);
// 1. Launch the checker
aCSI.Perform();

View File

@ -85,6 +85,20 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations {
SK_ADVANCED, // all advanced shapes (temporary implementation)
};
/**
* This enumeration represents the level of checking shape on
* self-interference. It defines which interferferences will be checked.
*/
enum SICheckLevel
{
SI_V_V = 0, // only V/V interferences
SI_V_E, // V/V and V/E interferences
SI_E_E, // V/V, V/E and E/E interferences
SI_V_F, // V/V, V/E, E/E and V/F interferences
SI_E_F, // V/V, V/E, E/E, V/F and E/F interferences
SI_ALL // all interferences
};
Standard_EXPORT ShapeKind KindOfShape (Handle(GEOM_Object) theShape,
Handle(TColStd_HSequenceOfInteger)& theIntegers,
Handle(TColStd_HSequenceOfReal)& theDoubles);
@ -141,6 +155,7 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations {
const std::list<ShapeError> &theErrors);
Standard_EXPORT bool CheckSelfIntersections (Handle(GEOM_Object) theShape,
const SICheckLevel theCheckLevel,
Handle(TColStd_HSequenceOfInteger)& theIntersections);
Standard_EXPORT TCollection_AsciiString IsGoodForSolid (Handle(GEOM_Object) theShape);

View File

@ -706,6 +706,7 @@ char* GEOM_IMeasureOperations_i::PrintShapeErrors
*/
//=============================================================================
CORBA::Boolean GEOM_IMeasureOperations_i::CheckSelfIntersections (GEOM::GEOM_Object_ptr theShape,
CORBA::Long theCheckLevel,
GEOM::ListOfLong_out theIntersections)
{
// Set a not done flag
@ -720,10 +721,35 @@ CORBA::Boolean GEOM_IMeasureOperations_i::CheckSelfIntersections (GEOM::GEOM_Obj
Handle(GEOM_Object) aShape = GetObjectImpl(theShape);
if (!aShape.IsNull()) {
GEOMImpl_IMeasureOperations::SICheckLevel aCheckLevel;
switch(theCheckLevel) {
case GEOM::SI_V_V:
aCheckLevel = GEOMImpl_IMeasureOperations::SI_V_V;
break;
case GEOM::SI_V_E:
aCheckLevel = GEOMImpl_IMeasureOperations::SI_V_E;
break;
case GEOM::SI_E_E:
aCheckLevel = GEOMImpl_IMeasureOperations::SI_E_E;
break;
case GEOM::SI_V_F:
aCheckLevel = GEOMImpl_IMeasureOperations::SI_V_F;
break;
case GEOM::SI_E_F:
aCheckLevel = GEOMImpl_IMeasureOperations::SI_E_F;
break;
case GEOM::SI_ALL:
default:
aCheckLevel = GEOMImpl_IMeasureOperations::SI_ALL;
break;
}
Handle(TColStd_HSequenceOfInteger) anIntegers = new TColStd_HSequenceOfInteger;
// Detect self-intersections
isGood = GetOperations()->CheckSelfIntersections(aShape, anIntegers);
isGood = GetOperations()->CheckSelfIntersections
(aShape, aCheckLevel, anIntegers);
int nbInts = anIntegers->Length();

View File

@ -97,6 +97,7 @@ class GEOM_I_EXPORT GEOM_IMeasureOperations_i :
const GEOM::GEOM_IMeasureOperations::ShapeErrors &theErrors);
CORBA::Boolean CheckSelfIntersections (GEOM::GEOM_Object_ptr theShape,
CORBA::Long theCheckLevel,
GEOM::ListOfLong_out theIntersections);
char* IsGoodForSolid (GEOM::GEOM_Object_ptr theShape);

View File

@ -10562,22 +10562,38 @@ class geomBuilder(object, GEOM._objref_GEOM_Gen):
## Detect self-intersections in the given shape.
# @param theShape Shape to check.
# @param theCheckLevel is the level of self-intersection check.
# Possible input values are:
# - GEOM.SI_V_V(0) - only V/V interferences
# - GEOM.SI_V_E(1) - V/V and V/E interferences
# - GEOM.SI_E_E(2) - V/V, V/E and E/E interferences
# - GEOM.SI_V_F(3) - V/V, V/E, E/E and V/F interferences
# - GEOM.SI_E_F(4) - V/V, V/E, E/E, V/F and E/F interferences
# - GEOM.SI_ALL(5) - all interferences.
# @return TRUE, if the shape contains no self-intersections.
#
# @ref tui_measurement_tools_page "Example"
@ManageTransactions("MeasuOp")
def CheckSelfIntersections(self, theShape):
def CheckSelfIntersections(self, theShape, theCheckLevel = GEOM.SI_ALL):
"""
Detect self-intersections in the given shape.
Parameters:
theShape Shape to check.
theCheckLevel is the level of self-intersection check.
Possible input values are:
- GEOM.SI_V_V(0) - only V/V interferences
- GEOM.SI_V_E(1) - V/V and V/E interferences
- GEOM.SI_E_E(2) - V/V, V/E and E/E interferences
- GEOM.SI_V_F(3) - V/V, V/E, E/E and V/F interferences
- GEOM.SI_E_F(4) - V/V, V/E, E/E, V/F and E/F interferences
- GEOM.SI_ALL(5) - all interferences.
Returns:
TRUE, if the shape contains no self-intersections.
"""
# Example: see GEOM_TestMeasures.py
(IsValid, Pairs) = self.MeasuOp.CheckSelfIntersections(theShape)
(IsValid, Pairs) = self.MeasuOp.CheckSelfIntersections(theShape, EnumToLong(theCheckLevel))
RaiseIfFailed("CheckSelfIntersections", self.MeasuOp)
return IsValid

View File

@ -291,7 +291,7 @@ bool MeasureGUI_CheckSelfIntersectionsDlg::findSelfIntersections
int nbPairs = 0;
try {
HasSelfInte = !anOper->CheckSelfIntersections(myObj, myInters);
HasSelfInte = !anOper->CheckSelfIntersections(myObj, GEOM::SI_ALL, myInters);
nbPairs = myInters->length()/2;
if (nbPairs*2 != myInters->length()) {
@ -384,12 +384,10 @@ void MeasureGUI_CheckSelfIntersectionsDlg::onInteListSelectionChanged()
{
erasePreview();
int aCurItem = myGrp->ListBox1->currentRow();
int aNbItems = myGrp->ListBox1->count();
if (aCurItem < 0)
return;
//int nbPairs = myInters->length()/2;
QStringList aSubShapeList;
TopoDS_Shape aSelShape;
if (!myObj->_is_nil() && GEOMBase::GetShape(myObj, aSelShape)) {