mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-12-24 16:30:35 +05:00
[bos #29473] [EDF] (2022-T1) Advanced geometry features: conformity of non holed-face
This commit is contained in:
parent
89b8ea7bd7
commit
f190cc9ae6
45
doc/salome/examples/check_conformity.py
Normal file
45
doc/salome/examples/check_conformity.py
Normal file
@ -0,0 +1,45 @@
|
||||
# Check Conformity
|
||||
|
||||
import salome
|
||||
salome.salome_init_without_session()
|
||||
import GEOM
|
||||
from salome.geom import geomBuilder
|
||||
geompy = geomBuilder.New()
|
||||
|
||||
O = geompy.MakeVertex(0, 0, 0)
|
||||
OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
|
||||
OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
|
||||
OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
|
||||
Vertex_1 = geompy.MakeVertex(-30, -70, 0)
|
||||
Vertex_2 = geompy.MakeVertex(-30, 50, 0)
|
||||
Line_1 = geompy.MakeLineTwoPnt(Vertex_2, Vertex_1)
|
||||
Vertex_3 = geompy.MakeVertex(0, -50, 0)
|
||||
Vertex_4 = geompy.MakeVertex(-40, -10, 0)
|
||||
Vertex_5 = geompy.MakeVertex(0, 40, 0)
|
||||
Arc_1 = geompy.MakeArc(Vertex_5, Vertex_4, Vertex_3)
|
||||
Vertex_6 = geompy.MakeVertex(10, -50, 4)
|
||||
Vertex_7 = geompy.MakeVertex(10, -50, 10)
|
||||
Vertex_8 = geompy.MakeVertex(10, 40, 10)
|
||||
Arc_1_vertex_3 = geompy.GetSubShape(Arc_1, [3])
|
||||
Line_2 = geompy.MakeLineTwoPnt(Arc_1_vertex_3, Vertex_6)
|
||||
Line_3 = geompy.MakeLineTwoPnt(Vertex_6, Vertex_7)
|
||||
Line_4 = geompy.MakeLineTwoPnt(Vertex_7, Vertex_8)
|
||||
Vertex_9 = geompy.MakeVertex(15, 40, 10)
|
||||
Vertex_10 = geompy.MakeVertex(17, 0, 6)
|
||||
Vertex_11 = geompy.MakeVertex(17, 0, 3)
|
||||
Line_5 = geompy.MakeLineTwoPnt(Vertex_8, Vertex_9)
|
||||
Line_6 = geompy.MakeLineTwoPnt(Vertex_9, Vertex_10)
|
||||
Line_7 = geompy.MakeLineTwoPnt(Vertex_10, Vertex_11)
|
||||
Arc_1_vertex_2 = geompy.GetSubShape(Arc_1, [2])
|
||||
Line_8 = geompy.MakeLineTwoPnt(Vertex_11, Arc_1_vertex_2)
|
||||
Wire_1 = geompy.MakeWire([Arc_1, Line_2, Line_3, Line_4, Line_5, Line_6, Line_7, Line_8], 1e-07)
|
||||
Wire_2 = geompy.MakeWire([Line_1], 1e-07)
|
||||
Compound_1 = geompy.MakeCompound([Wire_1, Wire_2])
|
||||
|
||||
# Get CheckConformity tool
|
||||
cc = geompy.CheckConformity(Compound_1)
|
||||
valid = cc.isValid()
|
||||
dist = cc.distantShapes()
|
||||
small = cc.smallEdges()
|
||||
interfer = cc.interferingSubshapes()
|
||||
intersect = cc.selfIntersected2D()
|
@ -59,13 +59,14 @@ ENDIF(WIN32)
|
||||
|
||||
ADD_CUSTOM_TARGET(usr_docs ${CMAKE_COMMAND} -E make_directory tmp
|
||||
COMMAND ${CMAKE_COMMAND} -E make_directory tmp1
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${f} -o tmp/geomBuilder.py ${CMAKE_SOURCE_DIR}/src/GEOM_SWIG/geomBuilder.py
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${f} -o tmp/gsketcher.py ${CMAKE_SOURCE_DIR}/src/GEOM_SWIG/gsketcher.py
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${f} -o tmp/geomtools.py ${CMAKE_SOURCE_DIR}/src/GEOM_PY/geomtools.py
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${f} -o tmp/sketcher.py ${CMAKE_SOURCE_DIR}/src/GEOM_PY/sketcher.py
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${f} -o tmp/structelem.py ${CMAKE_SOURCE_DIR}/src/GEOM_PY/structelem/__init__.py
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${f} -o tmp/parts.py ${CMAKE_SOURCE_DIR}/src/GEOM_PY/structelem/parts.py
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${f} -o tmp/orientation.py ${CMAKE_SOURCE_DIR}/src/GEOM_PY/structelem/orientation.py
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${f} -o tmp/geomBuilder.py ${CMAKE_SOURCE_DIR}/src/GEOM_SWIG/geomBuilder.py
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${f} -o tmp/gsketcher.py ${CMAKE_SOURCE_DIR}/src/GEOM_SWIG/gsketcher.py
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${f} -o tmp/conformity.py ${CMAKE_SOURCE_DIR}/src/GEOM_SWIG/conformity.py
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${f} -o tmp/geomtools.py ${CMAKE_SOURCE_DIR}/src/GEOM_PY/geomtools.py
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${f} -o tmp/sketcher.py ${CMAKE_SOURCE_DIR}/src/GEOM_PY/sketcher.py
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${f} -o tmp/structelem.py ${CMAKE_SOURCE_DIR}/src/GEOM_PY/structelem/__init__.py
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${f} -o tmp/parts.py ${CMAKE_SOURCE_DIR}/src/GEOM_PY/structelem/parts.py
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${f} -o tmp/orientation.py ${CMAKE_SOURCE_DIR}/src/GEOM_PY/structelem/orientation.py
|
||||
COMMAND ${plugins_cmd}
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} doxyfile_tui
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} doxyfile_py
|
||||
|
55
doc/salome/gui/GEOM/input/check_conformity.doc
Normal file
55
doc/salome/gui/GEOM/input/check_conformity.doc
Normal file
@ -0,0 +1,55 @@
|
||||
/*!
|
||||
|
||||
\page check_conformity_page Check Conformity
|
||||
|
||||
The Check Conformity tool provides the user with a simple python API to analyze, available shape for Boolean Operations or not. \n
|
||||
Also tool provide advanced output to indicate imperfections in the input shape.
|
||||
|
||||
This is just a TUI functionality.
|
||||
|
||||
<b>TUI Commands:</b>
|
||||
|
||||
<UL>
|
||||
|
||||
<LI>
|
||||
<em>geompy.CheckConformity(shape),</em> \n
|
||||
where \n
|
||||
\em shape is the shape checked for validity. \n
|
||||
</LI>
|
||||
|
||||
The following functionality is available from the tool:
|
||||
<LI>
|
||||
<em>geompy.isValid()</em>
|
||||
|
||||
</LI>
|
||||
|
||||
<LI>
|
||||
<em>geompy.selfIntersected2D()</em>
|
||||
</LI>
|
||||
|
||||
<LI>
|
||||
<em>geompy.interferingSubshapes(shapeType1, shapeType2),</em>
|
||||
where \n
|
||||
\em shapeType1 is the first type of subshape. \n
|
||||
\em shapeType2 is the second type of subshape. \n
|
||||
</LI>
|
||||
|
||||
<LI>
|
||||
<em>geompy.smallEdges()</em>
|
||||
</LI>
|
||||
|
||||
<LI>
|
||||
<em>geompy.distantShapes(shapeType, subShapeType, tolerance),</em>
|
||||
where \n
|
||||
\em shapeType is the type of shape. \n
|
||||
\em subShapeType is the type of subshape. \n
|
||||
\em tolerance is available tolerance, by default used tolerance of sub-shape.
|
||||
</LI>
|
||||
|
||||
<LI>
|
||||
<em>geompy.updateTolerance()</em>
|
||||
</LI>
|
||||
</UL>
|
||||
See also a \ref tui_check_conformity_page "TUI example".
|
||||
|
||||
*/
|
6
doc/salome/gui/GEOM/input/tui_check_conformity.doc
Normal file
6
doc/salome/gui/GEOM/input/tui_check_conformity.doc
Normal file
@ -0,0 +1,6 @@
|
||||
/*!
|
||||
|
||||
\page tui_check_conformity_page Check Conformity
|
||||
\tui_script{check_conformity.py}
|
||||
|
||||
*/
|
@ -21,6 +21,7 @@
|
||||
<li>\subpage tui_check_self_intersections_page</li>
|
||||
<li>\subpage tui_check_self_intersections_fast_page</li>
|
||||
<li>\subpage tui_fast_intersection_page</li>
|
||||
<li>\subpage tui_check_conformity_page</li>
|
||||
</ul>
|
||||
|
||||
*/
|
||||
|
@ -29,6 +29,7 @@
|
||||
<li>\subpage boundaries_page "Check Free Boundaries"</li>
|
||||
<li>\subpage free_faces_page "Check Free Faces"</li>
|
||||
<li>\subpage check_shape_page "Check Shape"</li>
|
||||
<li>\subpage check_conformity_page "Check Conformity"</li>
|
||||
<li>\subpage check_compound_of_blocks_page "Check compound of blocks"</li>
|
||||
<li>\subpage get_non_blocks_page "Get non blocks"</li>
|
||||
<li>\subpage check_self_intersections_page "Detect Self-intersections"</li>
|
||||
|
@ -4745,6 +4745,94 @@ module GEOM
|
||||
in GEOM_Object thePoint,
|
||||
in GEOM_Object theDirection);
|
||||
|
||||
//! Methods and structure for implement CheckConformity tool
|
||||
|
||||
/*!
|
||||
* \brief Structure for store shapes from failed checks.
|
||||
* If failed check on small edges, then second shape is null
|
||||
*/
|
||||
struct PairOfShape
|
||||
{
|
||||
GEOM_Object first;
|
||||
GEOM_Object second;
|
||||
};
|
||||
|
||||
/*!
|
||||
* \brief Structure for store result of check
|
||||
* store type of check as number and failed shapes
|
||||
*/
|
||||
struct CheckResult
|
||||
{
|
||||
long type;
|
||||
PairOfShape failedShapes;
|
||||
};
|
||||
|
||||
typedef sequence<PairOfShape> SequenceOfPairOfShape;
|
||||
typedef sequence<CheckResult> CheckResults;
|
||||
|
||||
/*!
|
||||
* \brief Perform analyse of shape and return all failed checks.
|
||||
*
|
||||
* \param theShape Shape for check.
|
||||
*/
|
||||
CheckResults CheckConformityShape(in GEOM_Object theShape);
|
||||
|
||||
/*!
|
||||
* \brief Find all self-intersected 2D curves.
|
||||
*
|
||||
* \param theResults result of check - list of failed checks and sub-shapes.
|
||||
*/
|
||||
SequenceOfPairOfShape SelfIntersected2D(in CheckResults theResults);
|
||||
|
||||
/*!
|
||||
* \brief Find pairs of interfering sub-shapes, by default all pairs of interfering shapes are returned.
|
||||
* Avaliable types:
|
||||
* - vertices touched by tolerance;
|
||||
* - vertex touching an edge in the inner point;
|
||||
* - vertex lying on the inner point of a face;
|
||||
* - edges intersecting by inner points;
|
||||
* - edge touching/intersecting face in the inner point;
|
||||
* - faces intersection by inner point
|
||||
*
|
||||
* \param theResults result of check - list of failed checks and sub-shapes.
|
||||
* \param theShapeType1 Type of shape.
|
||||
* \param theShapeType2 Type of shape.
|
||||
*/
|
||||
SequenceOfPairOfShape InterferingSubshapes(in CheckResults theResults,
|
||||
in long theShapeType1,
|
||||
in long theShapeType2);
|
||||
|
||||
/*!
|
||||
* \brief Find edges, which are fully covered by tolerances of vertices.
|
||||
*
|
||||
* \param theResults result of check - list of failed checks and sub-shapes.
|
||||
*/
|
||||
ListOfGO SmallEdges(in CheckResults theResults);
|
||||
|
||||
/*!
|
||||
* \brief find remote objects (sub-shape on a shape).
|
||||
* Avaliable types:
|
||||
* - vertex far from edge;
|
||||
* - vertex far from face;
|
||||
* - edge far from face
|
||||
*
|
||||
* \param theResults result of check - list of failed checks and sub-shapes.
|
||||
* \param theShapeType Type of shape.
|
||||
* \param theSubShapeType Type of sub-shape.
|
||||
* \param theTolerance tolerance, by default used tolerance of sub-shape.
|
||||
*/
|
||||
SequenceOfPairOfShape DistantShapes(in CheckResults theResults,
|
||||
in long theShapeType,
|
||||
in long theSubShapeType,
|
||||
in double theTolerance);
|
||||
|
||||
/*!
|
||||
* \brief Compute possible tolerance for the shape, minimize tolerance of shape as well
|
||||
* as tolerance of sub-shapes as much as possible
|
||||
*
|
||||
* \param theShape Shape for update.
|
||||
*/
|
||||
double UpdateTolerance(in GEOM_Object theShape);
|
||||
};
|
||||
|
||||
// # GEOM_IGroupOperations:
|
||||
|
@ -120,6 +120,7 @@ SET(GEOMImpl_HEADERS
|
||||
GEOMImpl_IPipePath.hxx
|
||||
GEOMImpl_IRevolution.hxx
|
||||
GEOMImpl_IMeasure.hxx
|
||||
GEOMImpl_IConformity.hxx
|
||||
GEOMImpl_IShapes.hxx
|
||||
GEOMImpl_IShapeExtend.hxx
|
||||
GEOMImpl_IFilling.hxx
|
||||
@ -156,6 +157,7 @@ SET(GEOMImpl_HEADERS
|
||||
GEOMImpl_BlockDriver.hxx
|
||||
GEOMImpl_Block6Explorer.hxx
|
||||
GEOMImpl_MeasureDriver.hxx
|
||||
GEOMImpl_ConformityDriver.hxx
|
||||
GEOMImpl_PolylineDriver.hxx
|
||||
GEOMImpl_PolylineDumper.hxx
|
||||
GEOMImpl_CircleDriver.hxx
|
||||
@ -205,6 +207,7 @@ SET(GEOMImpl_SOURCES
|
||||
GEOMImpl_ITestOperations.cxx
|
||||
GEOMImpl_IPolyline2D.cxx
|
||||
GEOMImpl_ITransferData.cxx
|
||||
GEOMImpl_IConformity.cxx
|
||||
GEOMImpl_Gen.cxx
|
||||
GEOMImpl_PointDriver.cxx
|
||||
GEOMImpl_VectorDriver.cxx
|
||||
@ -233,6 +236,7 @@ SET(GEOMImpl_SOURCES
|
||||
GEOMImpl_BlockDriver.cxx
|
||||
GEOMImpl_Block6Explorer.cxx
|
||||
GEOMImpl_MeasureDriver.cxx
|
||||
GEOMImpl_ConformityDriver.cxx
|
||||
GEOMImpl_PolylineDriver.cxx
|
||||
GEOMImpl_PolylineDumper.cxx
|
||||
GEOMImpl_CircleDriver.cxx
|
||||
|
253
src/GEOMImpl/GEOMImpl_ConformityDriver.cxx
Normal file
253
src/GEOMImpl/GEOMImpl_ConformityDriver.cxx
Normal file
@ -0,0 +1,253 @@
|
||||
// Copyright (C) 2013-2022 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// 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, or (at your option) any later version.
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
||||
#include "GEOMImpl_ConformityDriver.hxx"
|
||||
|
||||
// internal includes
|
||||
#include "GEOMImpl_IConformity.hxx"
|
||||
|
||||
// KERNEL includes
|
||||
#include <utilities.h>
|
||||
#include <Basics_Utils.hxx>
|
||||
|
||||
// GEOM includes
|
||||
#include "GEOM_Function.hxx"
|
||||
#include "GEOMImpl_Types.hxx"
|
||||
|
||||
#include <BOPAlgo_ArgumentAnalyzer.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <BRepTools_ReShape.hxx>
|
||||
#include <BRepLib.hxx>
|
||||
#include <BRep_Tool.hxx>
|
||||
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <GEOMUtils.hxx>
|
||||
#include <TColStd_HArray2OfInteger.hxx>
|
||||
|
||||
namespace
|
||||
{
|
||||
//=======================================================================
|
||||
//function : ConvertShapesToIndices
|
||||
//purpose : Convert sub-shapes of shapes to sequence of indices
|
||||
//=======================================================================
|
||||
Handle(TColStd_HArray1OfInteger) ConvertShapesToIndices(const TopoDS_Shape& theShape,
|
||||
const TopTools_ListOfShape& theShapes)
|
||||
{
|
||||
Handle(TColStd_HArray1OfInteger) aSeqOfIDs = new TColStd_HArray1OfInteger(1, theShapes.Size());
|
||||
|
||||
TopTools_IndexedMapOfShape anIndices;
|
||||
TopExp::MapShapes(theShape, anIndices);
|
||||
|
||||
TopTools_ListIteratorOfListOfShape itSub(theShapes);
|
||||
for (int index = 1; itSub.More(); itSub.Next(), ++index)
|
||||
{
|
||||
int id = anIndices.FindIndex(itSub.Value());
|
||||
aSeqOfIDs->SetValue(index, id);
|
||||
}
|
||||
|
||||
return aSeqOfIDs;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ConvertShapesToIndices
|
||||
//purpose : Convert list of pair shapes to sequence of indices
|
||||
//=======================================================================
|
||||
Handle(TColStd_HArray2OfInteger) ConvertShapesToIndices(
|
||||
const TopoDS_Shape& theShape,
|
||||
const NCollection_List<std::pair<TopoDS_Shape, TopoDS_Shape>>& theShapes)
|
||||
{
|
||||
Handle(TColStd_HArray2OfInteger) aSeqOfIDs = new TColStd_HArray2OfInteger(1, theShapes.Size(), 1, 2);
|
||||
|
||||
TopTools_IndexedMapOfShape anIndices;
|
||||
TopExp::MapShapes(theShape, anIndices);
|
||||
|
||||
NCollection_List<std::pair<TopoDS_Shape, TopoDS_Shape>>::Iterator itSub(theShapes);
|
||||
for (int index = 1; itSub.More(); itSub.Next(), ++index)
|
||||
{
|
||||
int anID1 = anIndices.FindIndex(itSub.Value().first);
|
||||
aSeqOfIDs->SetValue(index, 1, anID1);
|
||||
|
||||
int anID2 = anIndices.FindIndex(itSub.Value().second);
|
||||
aSeqOfIDs->SetValue(index, 2, anID2);
|
||||
}
|
||||
|
||||
return aSeqOfIDs;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
const Standard_GUID& GEOMImpl_ConformityDriver::GetID()
|
||||
{
|
||||
static Standard_GUID aGUID("B77BABDA-C0A1-4E65-9B1E-7EFC4448077E");
|
||||
return aGUID;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GEOMImpl_ConformityDriver
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
GEOMImpl_ConformityDriver::GEOMImpl_ConformityDriver()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Execute
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Integer GEOMImpl_ConformityDriver::Execute(Handle(TFunction_Logbook)& log) const
|
||||
{
|
||||
if (Label().IsNull()) return 0;
|
||||
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
|
||||
GEOMImpl_IConformity aCI(aFunction);
|
||||
|
||||
Standard_Integer aType = aFunction->GetType();
|
||||
|
||||
Handle(GEOM_Function) aRefShape = aCI.GetShape();
|
||||
if (aRefShape.IsNull()) return 0;
|
||||
|
||||
TopoDS_Shape aShape = aRefShape->GetValue();
|
||||
|
||||
switch (aType)
|
||||
{
|
||||
case CONFORMITY_UPDATE_TOL:
|
||||
{
|
||||
Standard_Real aTolerance = updateTolerance(aShape);
|
||||
aFunction->SetReal(CHECKCONFORMITY_RET_TOLERANCE, aTolerance);
|
||||
}
|
||||
break;
|
||||
case CONFORMITY_CHECK_SHAPE:
|
||||
{
|
||||
NCollection_List<std::pair<TopoDS_Shape, TopoDS_Shape>> aFailedShape;
|
||||
Handle(TColStd_HArray1OfInteger) aTypesOfCheck;
|
||||
checkShape(aShape, aFailedShape, aTypesOfCheck);
|
||||
|
||||
Handle(TColStd_HArray2OfInteger) anArray = ConvertShapesToIndices(aShape, aFailedShape);
|
||||
aFunction->SetIntegerArray(CHECKCONFORMITY_RET_TYPES_CHECKS, aTypesOfCheck);
|
||||
aCI.SetListOfShapesIndices(anArray);
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : checkShape
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void GEOMImpl_ConformityDriver::checkShape(const TopoDS_Shape & theShape,
|
||||
NCollection_List<std::pair<TopoDS_Shape, TopoDS_Shape>>& theFailedShape,
|
||||
Handle(TColStd_HArray1OfInteger)& theTypesOfCheck) const
|
||||
{
|
||||
BOPAlgo_ArgumentAnalyzer anAnalyzer;
|
||||
performAnalyze(theShape, anAnalyzer);
|
||||
|
||||
const BOPAlgo_ListOfCheckResult& aResult = anAnalyzer.GetCheckResult();
|
||||
theTypesOfCheck = new TColStd_HArray1OfInteger(1, aResult.Size());
|
||||
|
||||
BOPAlgo_ListOfCheckResult::Iterator anIter(aResult);
|
||||
for (int index = 1; anIter.More(); anIter.Next(), ++index)
|
||||
{
|
||||
theTypesOfCheck->SetValue(index, anIter.Value().GetCheckStatus());
|
||||
std::pair<TopoDS_Shape, TopoDS_Shape> aPair;
|
||||
aPair.first = anIter.Value().GetFaultyShapes1().First();
|
||||
if (anIter.Value().GetFaultyShapes1().Size() != 1)
|
||||
aPair.second = anIter.Value().GetFaultyShapes1().Last();
|
||||
theFailedShape.Append(aPair);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : updateTolerance
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Real GEOMImpl_ConformityDriver::updateTolerance(const TopoDS_Shape& theShape) const
|
||||
{
|
||||
Standard_Real aTolerance = INFINITY;
|
||||
|
||||
TopoDS_Shape aResShape = theShape;
|
||||
|
||||
BRepLib::UpdateTolerances(aResShape, Standard_False);
|
||||
|
||||
for (const auto& aType : { TopAbs_VERTEX, TopAbs_EDGE, TopAbs_FACE })
|
||||
{
|
||||
for (TopExp_Explorer anExp(aResShape, aType); anExp.More(); anExp.Next())
|
||||
{
|
||||
Standard_Real aCurTolerance = INFINITY;
|
||||
switch (aType)
|
||||
{
|
||||
case TopAbs_VERTEX:
|
||||
aCurTolerance = BRep_Tool::Tolerance(TopoDS::Vertex(anExp.Value()));
|
||||
break;
|
||||
case TopAbs_EDGE:
|
||||
aCurTolerance = BRep_Tool::Tolerance(TopoDS::Edge(anExp.Value()));
|
||||
break;
|
||||
case TopAbs_FACE:
|
||||
aCurTolerance = BRep_Tool::Tolerance(TopoDS::Face(anExp.Value()));
|
||||
break;
|
||||
}
|
||||
aTolerance = Min(aTolerance, aCurTolerance);
|
||||
}
|
||||
}
|
||||
|
||||
TopoDS_Shape aShape = theShape;
|
||||
GEOMUtils::FixShapeTolerance(aShape, aTolerance, Standard_True);
|
||||
|
||||
Standard_Real aResTol = 0.;
|
||||
for (const auto& aType : { TopAbs_VERTEX, TopAbs_EDGE, TopAbs_FACE })
|
||||
{
|
||||
for (TopExp_Explorer anExp(aShape, aType); anExp.More(); anExp.Next())
|
||||
{
|
||||
Standard_Real aCurTolerance = INFINITY;
|
||||
switch (aType)
|
||||
{
|
||||
case TopAbs_VERTEX:
|
||||
aCurTolerance = BRep_Tool::Tolerance(TopoDS::Vertex(anExp.Value()));
|
||||
break;
|
||||
case TopAbs_EDGE:
|
||||
aCurTolerance = BRep_Tool::Tolerance(TopoDS::Edge(anExp.Value()));
|
||||
break;
|
||||
case TopAbs_FACE:
|
||||
aCurTolerance = BRep_Tool::Tolerance(TopoDS::Face(anExp.Value()));
|
||||
break;
|
||||
}
|
||||
aResTol = Max(aResTol, aCurTolerance);
|
||||
}
|
||||
}
|
||||
|
||||
return aResTol;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : performAnalyze
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void GEOMImpl_ConformityDriver::performAnalyze(const TopoDS_Shape& theShape,
|
||||
BOPAlgo_ArgumentAnalyzer& theAnalyzer) const
|
||||
{
|
||||
theAnalyzer.SetShape1(theShape);
|
||||
|
||||
theAnalyzer.CurveOnSurfaceMode() = Standard_True;
|
||||
theAnalyzer.SelfInterMode() = Standard_True;
|
||||
theAnalyzer.SmallEdgeMode() = Standard_True;
|
||||
|
||||
theAnalyzer.Perform();
|
||||
}
|
62
src/GEOMImpl/GEOMImpl_ConformityDriver.hxx
Normal file
62
src/GEOMImpl/GEOMImpl_ConformityDriver.hxx
Normal file
@ -0,0 +1,62 @@
|
||||
// Copyright (C) 2013-2022 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// 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, or (at your option) any later version.
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
||||
#ifndef _GEOMImpl_ConformityDriver_HXX_
|
||||
#define _GEOMImpl_ConformityDriver_HXX_
|
||||
|
||||
#include "GEOM_BaseDriver.hxx"
|
||||
|
||||
#include <Standard_Transient.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
#include <BOPAlgo_ArgumentAnalyzer.hxx>
|
||||
|
||||
DEFINE_STANDARD_HANDLE(GEOMImpl_ConformityDriver, GEOM_BaseDriver)
|
||||
|
||||
class GEOMImpl_ConformityDriver : public GEOM_BaseDriver
|
||||
{
|
||||
|
||||
public:
|
||||
Standard_EXPORT GEOMImpl_ConformityDriver();
|
||||
Standard_EXPORT ~GEOMImpl_ConformityDriver() {};
|
||||
|
||||
Standard_EXPORT static const Standard_GUID& GetID();
|
||||
Standard_EXPORT virtual Standard_Integer Execute(Handle(TFunction_Logbook)& log) const;
|
||||
Standard_EXPORT Standard_Boolean MustExecute(const Handle(TFunction_Logbook)&) const { return Standard_True; }
|
||||
Standard_EXPORT virtual void Validate(Handle(TFunction_Logbook)&) const {}
|
||||
|
||||
private:
|
||||
Standard_EXPORT void checkShape(const TopoDS_Shape& theShape,
|
||||
NCollection_List<std::pair<TopoDS_Shape, TopoDS_Shape>>& theFailedShape,
|
||||
Handle(TColStd_HArray1OfInteger)& theTypesOfCheck) const;
|
||||
|
||||
Standard_EXPORT Standard_Real updateTolerance(const TopoDS_Shape& theShape) const;
|
||||
|
||||
Standard_EXPORT virtual bool GetCreationInformation(std::string& /*theOperationName*/,
|
||||
std::vector<GEOM_Param>& /*params*/)
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
private:
|
||||
void performAnalyze(const TopoDS_Shape& theShape, BOPAlgo_ArgumentAnalyzer& theAnalyzer) const;
|
||||
|
||||
};
|
||||
|
||||
#endif // _GEOMImpl_ConformityDriver_HXX_
|
@ -83,6 +83,7 @@
|
||||
#include <GEOMImpl_GlueDriver.hxx>
|
||||
#include <GEOMImpl_MeasureDriver.hxx>
|
||||
#include <GEOMImpl_FieldDriver.hxx>
|
||||
#include <GEOMImpl_ConformityDriver.hxx>
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
@ -163,6 +164,7 @@ GEOMImpl_Gen::GEOMImpl_Gen()
|
||||
// Measurements
|
||||
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_MeasureDriver::GetID(), new GEOMImpl_MeasureDriver());
|
||||
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_PatchFaceDriver::GetID(), new GEOMImpl_PatchFaceDriver());
|
||||
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_ConformityDriver::GetID(), new GEOMImpl_ConformityDriver());
|
||||
|
||||
// Field
|
||||
TFunction_DriverTable::Get()->AddDriver(GEOMImpl_FieldDriver::GetID(), new GEOMImpl_FieldDriver());
|
||||
|
60
src/GEOMImpl/GEOMImpl_IConformity.cxx
Normal file
60
src/GEOMImpl/GEOMImpl_IConformity.cxx
Normal file
@ -0,0 +1,60 @@
|
||||
// Copyright (C) 2013-2022 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// 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, or (at your option) any later version.
|
||||
//
|
||||
// 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
|
||||
//
|
||||
#include "GEOMImpl_IConformity.hxx"
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* SetListOfShapesIndices
|
||||
* Input 2D array of indexes converted into 1D array
|
||||
*/
|
||||
//=============================================================================
|
||||
void GEOMImpl_IConformity::SetListOfShapesIndices(const Handle(TColStd_HArray2OfInteger)& theArrayOfIndexes)
|
||||
{
|
||||
Handle(TColStd_HArray1OfInteger) anArray = new TColStd_HArray1OfInteger(1, theArrayOfIndexes->Size());
|
||||
|
||||
for (Standard_Integer aRow = 1; aRow <= theArrayOfIndexes->NbRows(); ++aRow)
|
||||
{
|
||||
anArray->SetValue(2 * aRow - 1, theArrayOfIndexes->Value(aRow, 1));
|
||||
anArray->SetValue(2 * aRow, theArrayOfIndexes->Value(aRow, 2));
|
||||
}
|
||||
|
||||
_func->SetIntegerArray(CHECKCONFORMITY_RET_LIST_OF_INDEXES, anArray);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* GetListOfShapesIndices
|
||||
* Get cached 1D array of indexes and converted into 2D array of indexes
|
||||
*/
|
||||
//=============================================================================
|
||||
Handle(TColStd_HArray2OfInteger) GEOMImpl_IConformity::GetListOfShapesIndices()
|
||||
{
|
||||
Handle(TColStd_HArray1OfInteger) anArray = _func->GetIntegerArray(CHECKCONFORMITY_RET_LIST_OF_INDEXES);
|
||||
|
||||
Standard_Integer aLength = anArray->Size() / 2;
|
||||
Handle(TColStd_HArray2OfInteger) aResArray = new TColStd_HArray2OfInteger(1, aLength, 1, 2);
|
||||
|
||||
for (Standard_Integer anIndex = 1; anIndex <= aLength; ++anIndex)
|
||||
{
|
||||
aResArray->SetValue(anIndex, 1, anArray->Value(2 * anIndex - 1));
|
||||
aResArray->SetValue(anIndex, 2, anArray->Value(2 * anIndex));
|
||||
}
|
||||
|
||||
return aResArray;
|
||||
}
|
70
src/GEOMImpl/GEOMImpl_IConformity.hxx
Normal file
70
src/GEOMImpl/GEOMImpl_IConformity.hxx
Normal file
@ -0,0 +1,70 @@
|
||||
// Copyright (C) 2013-2022 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// 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, or (at your option) any later version.
|
||||
//
|
||||
// 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
|
||||
//
|
||||
|
||||
#ifndef _GEOMImpl_IConformity_HXX_
|
||||
#define _GEOMImpl_IConformity_HXX_
|
||||
|
||||
#include "GEOM_Function.hxx"
|
||||
#include <TColStd_HArray2OfInteger.hxx>
|
||||
#include <TColStd_HArray2OfTransient.hxx>
|
||||
|
||||
#define CHECKCONFORMITY_ARG_SHAPE 1
|
||||
#define CHECKCONFORMITY_ARG_SHAPETYPE_1 2
|
||||
#define CHECKCONFORMITY_ARG_SHAPETYPE_2 3
|
||||
#define CHECKCONFORMITY_ARG_TOLERANCE 4
|
||||
|
||||
#define CHECKCONFORMITY_RET_TOLERANCE 5
|
||||
#define CHECKCONFORMITY_RET_ISVALID 6
|
||||
#define CHECKCONFORMITY_RET_SHAPES_IDS 7
|
||||
#define CHECKCONFORMITY_RET_TYPES_CHECKS 8
|
||||
#define CHECKCONFORMITY_RET_LIST_OF_INDEXES 9
|
||||
#define CHECKCONFORMITY_RET_LIST_SHAPES 10
|
||||
|
||||
class GEOMImpl_IConformity
|
||||
{
|
||||
public:
|
||||
GEOMImpl_IConformity(Handle(GEOM_Function) theFunction)
|
||||
: _func(theFunction)
|
||||
{
|
||||
}
|
||||
|
||||
void SetShape(Handle(GEOM_Function) theRef)
|
||||
{
|
||||
_func->SetReference(CHECKCONFORMITY_ARG_SHAPE, theRef);
|
||||
}
|
||||
Handle(GEOM_Function) GetShape()
|
||||
{
|
||||
return _func->GetReference(CHECKCONFORMITY_ARG_SHAPE);
|
||||
}
|
||||
|
||||
void SetShapeType1(int theShapeType) { _func->SetInteger(CHECKCONFORMITY_ARG_SHAPETYPE_1, theShapeType); }
|
||||
Standard_Integer GetShapeType1() { return _func->GetInteger(CHECKCONFORMITY_ARG_SHAPETYPE_1); }
|
||||
void SetShapeType2(int theShapeType) { _func->SetInteger(CHECKCONFORMITY_ARG_SHAPETYPE_2, theShapeType); }
|
||||
Standard_Integer GetShapeType2() { return _func->GetInteger(CHECKCONFORMITY_ARG_SHAPETYPE_2); }
|
||||
void SetTolerance(double theTolerance) { _func->SetReal(CHECKCONFORMITY_ARG_TOLERANCE, theTolerance); }
|
||||
Standard_Real GetTolerance() { return _func->GetReal(CHECKCONFORMITY_ARG_TOLERANCE); }
|
||||
|
||||
void SetListOfShapesIndices(const Handle(TColStd_HArray2OfInteger)& theArrayOfIndexes);
|
||||
Handle(TColStd_HArray2OfInteger) GetListOfShapesIndices();
|
||||
|
||||
private:
|
||||
Handle(GEOM_Function) _func;
|
||||
};
|
||||
|
||||
#endif // _GEOMImpl_IConformity_HXX_
|
@ -29,6 +29,9 @@
|
||||
|
||||
#include <GEOMImpl_Types.hxx>
|
||||
|
||||
#include <GEOMImpl_IConformity.hxx>
|
||||
#include <GEOMImpl_ConformityDriver.hxx>
|
||||
|
||||
#include <GEOMUtils.hxx>
|
||||
|
||||
#include <GEOMAlgo_AlgoTools.hxx>
|
||||
@ -46,6 +49,7 @@
|
||||
#include <BOPDS_DS.hxx>
|
||||
#include <BOPDS_MapOfPair.hxx>
|
||||
#include <BOPDS_Pair.hxx>
|
||||
#include <BOPTools_AlgoTools.hxx>
|
||||
#include <BRepBndLib.hxx>
|
||||
#include <BRepBuilderAPI_Copy.hxx>
|
||||
#include <BRepCheck_ListIteratorOfListOfStatus.hxx>
|
||||
@ -2787,6 +2791,339 @@ Handle(GEOM_Object) GEOMImpl_IMeasureOperations::SurfaceCurvatureByPointAndDirec
|
||||
return aCV;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* SelfIntersected2D
|
||||
* Find all self-intersected 2D curves.
|
||||
* \param theChecks list of failed checks, contains type of check and failed shapes
|
||||
*/
|
||||
//=============================================================================
|
||||
std::list<GEOMImpl_IMeasureOperations::CoupleOfObjects>
|
||||
GEOMImpl_IMeasureOperations::SelfIntersected2D(const std::list<FailedChecks>& theChecks)
|
||||
{
|
||||
SetErrorCode(KO);
|
||||
MESSAGE("GEOMImpl_IMeasureOperations::selfIntersected2D");
|
||||
|
||||
std::list<GEOMImpl_IMeasureOperations::CoupleOfObjects> aSelfInters2D;
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS;
|
||||
for (std::list<FailedChecks>::const_iterator anIter(theChecks.begin());
|
||||
anIter != theChecks.end(); ++anIter)
|
||||
{
|
||||
if (anIter->TypeOfCheck == BOPAlgo_CheckStatus::BOPAlgo_InvalidCurveOnSurface)
|
||||
aSelfInters2D.push_back(anIter->FailedShapes);
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure& aFail)
|
||||
{
|
||||
SetErrorCode(aFail.GetMessageString());
|
||||
return aSelfInters2D;
|
||||
}
|
||||
|
||||
SetErrorCode(OK);
|
||||
return aSelfInters2D;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
static bool checkTypes(const GEOMImpl_IMeasureOperations::CoupleOfObjects& theShapes,
|
||||
const int theShapeType1,
|
||||
const int theShapeType2)
|
||||
{
|
||||
if (theShapeType1 == -1 && theShapeType2 == -1)
|
||||
return true;
|
||||
|
||||
TopAbs_ShapeEnum aShapeType1 = theShapes.first.IsNull()
|
||||
? TopAbs_SHAPE
|
||||
: theShapes.first->GetValue().ShapeType();
|
||||
TopAbs_ShapeEnum aShapeType2 = theShapes.second.IsNull()
|
||||
? TopAbs_SHAPE
|
||||
: theShapes.second->GetValue().ShapeType();
|
||||
|
||||
if (theShapeType1 == -1)
|
||||
return aShapeType1 == theShapeType2 || aShapeType2 == theShapeType2;
|
||||
else if (theShapeType2 == -1)
|
||||
return aShapeType1 == theShapeType1 || aShapeType2 == theShapeType1;
|
||||
return (aShapeType1 == theShapeType1 && aShapeType2 == theShapeType2) ||
|
||||
(aShapeType1 == theShapeType2 && aShapeType2 == theShapeType1);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* InterferingSubshapes
|
||||
* Find pairs of interfering sub-shapes, by default all pairs of interfering shapes are returned.
|
||||
* \param theChecks list of failed checks, contains type of check and failed shapes
|
||||
* \param theShapeType1 Type of shape.
|
||||
* \param theShapeType2 Type of shape.
|
||||
*/
|
||||
//=============================================================================
|
||||
std::list<GEOMImpl_IMeasureOperations::CoupleOfObjects>
|
||||
GEOMImpl_IMeasureOperations::InterferingSubshapes
|
||||
(const std::list<FailedChecks>& theChecks,
|
||||
const int theShapeType1,
|
||||
const int theShapeType2)
|
||||
{
|
||||
SetErrorCode(KO);
|
||||
MESSAGE("GEOMImpl_IMeasureOperations::interferingSubshapes");
|
||||
|
||||
std::list<GEOMImpl_IMeasureOperations::CoupleOfObjects> anInterfer;
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS;
|
||||
for (std::list<FailedChecks>::const_iterator anIter(theChecks.begin());
|
||||
anIter != theChecks.end(); ++anIter)
|
||||
{
|
||||
if (anIter->TypeOfCheck == BOPAlgo_CheckStatus::BOPAlgo_SelfIntersect &&
|
||||
checkTypes(anIter->FailedShapes, theShapeType1, theShapeType2))
|
||||
anInterfer.push_back(anIter->FailedShapes);
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure& aFail)
|
||||
{
|
||||
SetErrorCode(aFail.GetMessageString());
|
||||
return anInterfer;
|
||||
}
|
||||
|
||||
SetErrorCode(OK);
|
||||
return anInterfer;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* SmallEdges
|
||||
* Find edges, which are fully covered by tolerances of vertices.
|
||||
* \param theChecks list of failed checks, contains type of check and failed shapes
|
||||
*/
|
||||
//=============================================================================
|
||||
Handle(TColStd_HSequenceOfTransient) GEOMImpl_IMeasureOperations::SmallEdges(
|
||||
const std::list<FailedChecks>& theChecks)
|
||||
{
|
||||
SetErrorCode(KO);
|
||||
MESSAGE("GEOMImpl_IMeasureOperations::smallEdges");
|
||||
|
||||
Handle(TColStd_HSequenceOfTransient) aSmallEdges = new TColStd_HSequenceOfTransient;
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS;
|
||||
for (std::list<FailedChecks>::const_iterator anIter(theChecks.begin());
|
||||
anIter != theChecks.end(); ++anIter)
|
||||
{
|
||||
if (anIter->TypeOfCheck == BOPAlgo_CheckStatus::BOPAlgo_TooSmallEdge)
|
||||
aSmallEdges->Append(anIter->FailedShapes.first);
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure& aFail)
|
||||
{
|
||||
SetErrorCode(aFail.GetMessageString());
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SetErrorCode(OK);
|
||||
return aSmallEdges;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* DistantShapes
|
||||
* find remote objects (sub-shape on a shape).
|
||||
* \param theShape Shape for check.
|
||||
* \param theShapeType Type of shape.
|
||||
* \param theSubShapeType Type of sub-shape.
|
||||
* \param theTolerance tolerance.
|
||||
*/
|
||||
//=============================================================================
|
||||
std::list<GEOMImpl_IMeasureOperations::CoupleOfObjects>
|
||||
GEOMImpl_IMeasureOperations::DistantShapes
|
||||
(const std::list<FailedChecks>& theChecks,
|
||||
const int theShapeType,
|
||||
const int theSubShapeType,
|
||||
double theTolerance)
|
||||
{
|
||||
SetErrorCode(KO);
|
||||
MESSAGE("GEOMImpl_IMeasureOperations::distantShapes");
|
||||
|
||||
std::list<GEOMImpl_IMeasureOperations::CoupleOfObjects> aDistShapes;
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS;
|
||||
for (std::list<FailedChecks>::const_iterator anIter(theChecks.begin());
|
||||
anIter != theChecks.end(); ++anIter)
|
||||
{
|
||||
Handle(GEOM_Object) aSubShape = anIter->FailedShapes.first;
|
||||
Handle(GEOM_Object) aShape = anIter->FailedShapes.second;
|
||||
if ((anIter->TypeOfCheck == BOPAlgo_CheckStatus::BOPAlgo_InvalidCurveOnSurface ||
|
||||
anIter->TypeOfCheck == BOPAlgo_CheckStatus::BOPAlgo_IncompatibilityOfVertex ||
|
||||
anIter->TypeOfCheck == BOPAlgo_CheckStatus::BOPAlgo_IncompatibilityOfEdge ||
|
||||
anIter->TypeOfCheck == BOPAlgo_CheckStatus::BOPAlgo_IncompatibilityOfFace) &&
|
||||
aShape && (theShapeType == -1 || aShape->GetValue().ShapeType() == theShapeType) &&
|
||||
aSubShape && (theSubShapeType == -1 || aSubShape->GetValue().ShapeType() == theSubShapeType))
|
||||
{
|
||||
gp_XYZ aP1, aP2;
|
||||
Standard_Real aDist = Precision::Infinite();
|
||||
if (anIter->TypeOfCheck == BOPAlgo_CheckStatus::BOPAlgo_InvalidCurveOnSurface)
|
||||
aDist = ComputeTolerance(aSubShape, aShape);
|
||||
if (aDist > theTolerance)
|
||||
aDistShapes.push_back(anIter->FailedShapes);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure& aFail)
|
||||
{
|
||||
SetErrorCode(aFail.GetMessageString());
|
||||
return aDistShapes;
|
||||
}
|
||||
|
||||
SetErrorCode(OK);
|
||||
return aDistShapes;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* CheckConformityShape
|
||||
* Perform analyse of shape and find imperfections in the shape.
|
||||
* \param theShape Shape for analyse.
|
||||
*/
|
||||
//=============================================================================
|
||||
void GEOMImpl_IMeasureOperations::CheckConformityShape(Handle(GEOM_Object) theShape, std::list<FailedChecks>& theChecks)
|
||||
{
|
||||
SetErrorCode(KO);
|
||||
MESSAGE("GEOMImpl_IMeasureOperations::checkShape");
|
||||
|
||||
Handle(GEOM_Object) aConformity = GetEngine()->AddObject(GEOM_CHECKCONFORMITY);
|
||||
Handle(GEOM_Function) aFunction = aConformity->AddFunction(GEOMImpl_ConformityDriver::GetID(), CONFORMITY_CHECK_SHAPE);
|
||||
if (aFunction.IsNull()) return;
|
||||
|
||||
//Check if the function is set correctly
|
||||
if (aFunction->GetDriverGUID() != GEOMImpl_ConformityDriver::GetID()) return;
|
||||
|
||||
GEOMImpl_IConformity aCI(aFunction);
|
||||
|
||||
Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
|
||||
if (aRefShape.IsNull()) return;
|
||||
|
||||
aCI.SetShape(aRefShape);
|
||||
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS;
|
||||
if (!GetSolver()->ComputeFunction(aFunction))
|
||||
{
|
||||
SetErrorCode("Failed: checkShape");
|
||||
return;
|
||||
}
|
||||
Handle(TColStd_HArray1OfInteger) aTypesChecks = aFunction->GetIntegerArray(CHECKCONFORMITY_RET_TYPES_CHECKS);
|
||||
Handle(TColStd_HArray2OfInteger) aRes = aCI.GetListOfShapesIndices();
|
||||
if (aRes.IsNull())
|
||||
return;
|
||||
|
||||
for (Standard_Integer anIndex = 1; anIndex <= aRes->NbRows(); ++anIndex)
|
||||
{
|
||||
std::pair<Handle(GEOM_Object), Handle(GEOM_Object)> aPair;
|
||||
Handle(TColStd_HArray1OfInteger) anArray;
|
||||
anArray = new TColStd_HArray1OfInteger(1, 1);
|
||||
anArray->SetValue(1, aRes->Value(anIndex, 1));
|
||||
|
||||
Handle(GEOM_Object) anObj = GetEngine()->AddSubShape(theShape, anArray);
|
||||
if (!anObj.IsNull())
|
||||
aPair.first = anObj;
|
||||
|
||||
anArray = new TColStd_HArray1OfInteger(1, 1);
|
||||
anArray->SetValue(1, aRes->Value(anIndex, 2));
|
||||
|
||||
anObj = GetEngine()->AddSubShape(theShape, anArray);
|
||||
if (!anObj.IsNull())
|
||||
aPair.second = anObj;
|
||||
theChecks.push_back({ aTypesChecks->Value(anIndex), aPair });
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure& aFail)
|
||||
{
|
||||
SetErrorCode(aFail.GetMessageString());
|
||||
return;
|
||||
}
|
||||
|
||||
SetErrorCode(OK);
|
||||
return;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* UpdateTolerance
|
||||
* Compute possible tolerance for the shape, minimize tolerance of shape as well
|
||||
* as tolerance of sub-shapes as much as possible
|
||||
* \param theShape Shape for compute tolerance.
|
||||
*/
|
||||
//=============================================================================
|
||||
double GEOMImpl_IMeasureOperations::UpdateTolerance(Handle(GEOM_Object) theShape)
|
||||
{
|
||||
SetErrorCode(KO);
|
||||
MESSAGE("GEOMImpl_IMeasureOperations::updateTolerance");
|
||||
|
||||
double aResTol = -1;
|
||||
Handle(GEOM_Object) aConformity = GetEngine()->AddObject(GEOM_CHECKCONFORMITY);
|
||||
Handle(GEOM_Function) aFunction = aConformity->AddFunction(GEOMImpl_ConformityDriver::GetID(), CONFORMITY_UPDATE_TOL);
|
||||
if (aFunction.IsNull()) return aResTol;
|
||||
|
||||
//Check if the function is set correctly
|
||||
if (aFunction->GetDriverGUID() != GEOMImpl_ConformityDriver::GetID()) return aResTol;
|
||||
|
||||
GEOMImpl_IConformity aCI(aFunction);
|
||||
|
||||
Handle(GEOM_Function) aRefShape = theShape->GetLastFunction();
|
||||
if (aRefShape.IsNull()) return aResTol;
|
||||
|
||||
aCI.SetShape(aRefShape);
|
||||
|
||||
try
|
||||
{
|
||||
OCC_CATCH_SIGNALS;
|
||||
if (!GetSolver()->ComputeFunction(aFunction))
|
||||
{
|
||||
SetErrorCode("Failed: updateTolerance");
|
||||
return aResTol;
|
||||
}
|
||||
aResTol = aFunction->GetReal(CHECKCONFORMITY_RET_TOLERANCE);
|
||||
}
|
||||
catch (Standard_Failure& aFail)
|
||||
{
|
||||
SetErrorCode(aFail.GetMessageString());
|
||||
return aResTol;
|
||||
}
|
||||
|
||||
SetErrorCode(OK);
|
||||
return aResTol;
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* ComputeTolerance
|
||||
* Compute distance from the edge to the face.
|
||||
*/
|
||||
//=============================================================================
|
||||
double GEOMImpl_IMeasureOperations::ComputeTolerance(Handle(GEOM_Object) theEdge,
|
||||
Handle(GEOM_Object) theFace)
|
||||
{
|
||||
double aMaxDist = Precision::Infinite();
|
||||
if (theEdge.IsNull() || theFace.IsNull())
|
||||
return aMaxDist;
|
||||
|
||||
Handle(GEOM_Function) aRefEdge = theEdge->GetLastFunction();
|
||||
Handle(GEOM_Function) aRefFace = theFace->GetLastFunction();
|
||||
if (aRefEdge.IsNull() || aRefFace.IsNull())
|
||||
return aMaxDist;
|
||||
|
||||
TopoDS_Edge aEdge = TopoDS::Edge(aRefEdge->GetValue());
|
||||
TopoDS_Face aFace = TopoDS::Face(aRefFace->GetValue());
|
||||
if (aEdge.IsNull() || aFace.IsNull())
|
||||
return aMaxDist;
|
||||
|
||||
double aParam = 0.0;
|
||||
BOPTools_AlgoTools::ComputeTolerance(aFace, aEdge, aMaxDist, aParam);
|
||||
return aMaxDist;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FillErrorsSub
|
||||
//purpose : Fill the errors list of subshapes on shape.
|
||||
|
@ -217,6 +217,28 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations {
|
||||
Standard_EXPORT Standard_Real MinSurfaceCurvatureByPoint (Handle(GEOM_Object) theSurf,
|
||||
Handle(GEOM_Object) thePoint);
|
||||
|
||||
// Methods checking the shapes which are not applicable to modelling operations
|
||||
typedef std::pair< Handle(GEOM_Object), Handle(GEOM_Object)> CoupleOfObjects;
|
||||
struct FailedChecks
|
||||
{
|
||||
Standard_Integer TypeOfCheck;
|
||||
CoupleOfObjects FailedShapes;
|
||||
};
|
||||
|
||||
Standard_EXPORT std::list<CoupleOfObjects> SelfIntersected2D(const std::list<FailedChecks>& theChecks);
|
||||
Standard_EXPORT std::list<CoupleOfObjects> InterferingSubshapes(const std::list<FailedChecks>& theChecks,
|
||||
const int theShapeType1,
|
||||
const int theShapeType2);
|
||||
Standard_EXPORT Handle(TColStd_HSequenceOfTransient) SmallEdges(const std::list<FailedChecks>& theChecks);
|
||||
Standard_EXPORT std::list<CoupleOfObjects> DistantShapes(const std::list<FailedChecks>& theChecks,
|
||||
const int theShapeType,
|
||||
const int theSubShapeType,
|
||||
double theTolerance);
|
||||
Standard_EXPORT void CheckConformityShape(Handle(GEOM_Object) theShape, std::list<FailedChecks>& theChecks);
|
||||
|
||||
Standard_EXPORT double ComputeTolerance(Handle(GEOM_Object) theEdge, Handle(GEOM_Object) theFace);
|
||||
Standard_EXPORT double UpdateTolerance(Handle(GEOM_Object) theShape);
|
||||
|
||||
Standard_EXPORT Handle(GEOM_Object) SurfaceCurvatureByPointAndDirection
|
||||
(Handle(GEOM_Object) theSurf,
|
||||
Handle(GEOM_Object) thePoint,
|
||||
|
@ -125,6 +125,8 @@
|
||||
|
||||
#define GEOM_PATCH_FACE 60
|
||||
|
||||
#define GEOM_CHECKCONFORMITY 62
|
||||
|
||||
//GEOM_Function types
|
||||
|
||||
#define COPY_WITH_REF 1
|
||||
@ -396,6 +398,10 @@
|
||||
#define TD_GET_IN_PLACE_OLD 2
|
||||
#define TD_GET_IN_PLACE_BY_HISTORY 3
|
||||
|
||||
// Conformity operations
|
||||
#define CONFORMITY_UPDATE_TOL 2
|
||||
#define CONFORMITY_CHECK_SHAPE 3
|
||||
|
||||
// Plugins specified constants
|
||||
#define PLUGIN_NAME "Plugin Name"
|
||||
|
||||
|
@ -1243,3 +1243,203 @@ GEOM::GEOM_Object_ptr GEOM_IMeasureOperations_i::SurfaceCurvatureByPointAndDirec
|
||||
|
||||
return GetObject(anObject);
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* SelfIntersected2D
|
||||
* Find all self-intersected 2D curves.
|
||||
* \param theShape Shape for check.
|
||||
*/
|
||||
//=============================================================================
|
||||
GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape* GEOM_IMeasureOperations_i::SelfIntersected2D(
|
||||
const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts)
|
||||
{
|
||||
GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape_var aSeq =
|
||||
new GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape;
|
||||
|
||||
// Perform patch face operation
|
||||
std::list<GEOMImpl_IMeasureOperations::FailedChecks> aResults;
|
||||
ConvertToList(theResuts, aResults);
|
||||
|
||||
std::list<GEOMImpl_IMeasureOperations::CoupleOfObjects> aSelfInters = GetOperations()->SelfIntersected2D(aResults);
|
||||
if (!GetOperations()->IsDone() || aSelfInters.empty())
|
||||
return aSeq._retn();
|
||||
|
||||
Standard_Integer aLength = aSelfInters.size();
|
||||
aSeq->length(aLength);
|
||||
std::list<GEOMImpl_IMeasureOperations::CoupleOfObjects>::iterator anIter(aSelfInters.begin());
|
||||
for (Standard_Integer i = 0; i < aLength; i++, ++anIter)
|
||||
{
|
||||
aSeq[i].first = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).first));
|
||||
aSeq[i].second = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).second));
|
||||
}
|
||||
|
||||
return aSeq._retn();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* InterferingSubshapes
|
||||
* Find pairs of interfering sub-shapes, by default all pairs of interfering shapes are returned.
|
||||
* \param theShape Shape for check.
|
||||
* \param theShapeType1 Type of shape.
|
||||
* \param theShapeType2 Type of shape.
|
||||
*/
|
||||
//=============================================================================
|
||||
GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape* GEOM_IMeasureOperations_i::InterferingSubshapes(
|
||||
const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts,
|
||||
const CORBA::Long theShapeType1,
|
||||
const CORBA::Long theShapeType2)
|
||||
{
|
||||
GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape_var aSeq =
|
||||
new GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape;
|
||||
|
||||
// Perform patch face operation
|
||||
std::list<GEOMImpl_IMeasureOperations::FailedChecks> aResults;
|
||||
ConvertToList(theResuts, aResults);
|
||||
|
||||
std::list<GEOMImpl_IMeasureOperations::CoupleOfObjects> aSelfInterf =
|
||||
GetOperations()->InterferingSubshapes(aResults, theShapeType1, theShapeType2);
|
||||
if (!GetOperations()->IsDone() || aSelfInterf.empty())
|
||||
return aSeq._retn();
|
||||
|
||||
Standard_Integer aLength = aSelfInterf.size();
|
||||
aSeq->length(aLength);
|
||||
std::list<GEOMImpl_IMeasureOperations::CoupleOfObjects>::iterator anIter(aSelfInterf.begin());
|
||||
for (Standard_Integer i = 0; i < aLength; i++, ++anIter)
|
||||
{
|
||||
aSeq[i].first = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).first));
|
||||
aSeq[i].second = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).second));
|
||||
}
|
||||
|
||||
return aSeq._retn();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* SmallEdges
|
||||
* Find edges, which are fully covered by tolerances of vertices.
|
||||
* \param theShape Shape for check.
|
||||
*/
|
||||
//=============================================================================
|
||||
GEOM::ListOfGO* GEOM_IMeasureOperations_i::SmallEdges(const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts)
|
||||
{
|
||||
GEOM::ListOfGO_var aSeq = new GEOM::ListOfGO;
|
||||
|
||||
std::list<GEOMImpl_IMeasureOperations::FailedChecks> aResults;
|
||||
ConvertToList(theResuts, aResults);
|
||||
|
||||
//Get the reference shape
|
||||
Handle(TColStd_HSequenceOfTransient) aSmallEdges = GetOperations()->SmallEdges(aResults);
|
||||
if (!GetOperations()->IsDone() || aSmallEdges.IsNull())
|
||||
return aSeq._retn();
|
||||
|
||||
Standard_Integer aLength = aSmallEdges->Length();
|
||||
aSeq->length(aLength);
|
||||
for (Standard_Integer i = 1; i <= aLength; i++)
|
||||
aSeq[i - 1] = GetObject(Handle(::GEOM_Object)::DownCast(aSmallEdges->Value(i)));
|
||||
|
||||
return aSeq._retn();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* DistantShapes
|
||||
* find remote objects (sub-shape on a shape).
|
||||
* \param theShape Shape for check.
|
||||
* \param theShapeType Type of shape.
|
||||
* \param theSubShapeType Type of sub-shape.
|
||||
* \param theTolerance tolerance.
|
||||
*/
|
||||
//=============================================================================
|
||||
GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape* GEOM_IMeasureOperations_i::DistantShapes(
|
||||
const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts,
|
||||
const CORBA::Long theShapeType,
|
||||
const CORBA::Long theSubShapeType,
|
||||
const CORBA::Double theTolerance)
|
||||
{
|
||||
GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape_var aSeq =
|
||||
new GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape;
|
||||
|
||||
std::list<GEOMImpl_IMeasureOperations::FailedChecks> aResults;
|
||||
ConvertToList(theResuts, aResults);
|
||||
|
||||
// Perform patch face operation
|
||||
std::list<GEOMImpl_IMeasureOperations::CoupleOfObjects> aDistantS =
|
||||
GetOperations()->DistantShapes(aResults, theShapeType, theSubShapeType, theTolerance);
|
||||
if (!GetOperations()->IsDone() || aDistantS.empty())
|
||||
return aSeq._retn();
|
||||
|
||||
Standard_Integer aLength = aDistantS.size();
|
||||
aSeq->length(aLength);
|
||||
std::list<GEOMImpl_IMeasureOperations::CoupleOfObjects>::iterator anIter(aDistantS.begin());
|
||||
for (Standard_Integer i = 0; i < aLength; i++, ++anIter)
|
||||
{
|
||||
aSeq[i].first = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).first));
|
||||
aSeq[i].second = GetObject(Handle(::GEOM_Object)::DownCast((*anIter).second));
|
||||
}
|
||||
|
||||
return aSeq._retn();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* CheckConformityShape
|
||||
* Perform all required checks
|
||||
*/
|
||||
//=============================================================================
|
||||
GEOM::GEOM_IMeasureOperations::CheckResults* GEOM_IMeasureOperations_i::CheckConformityShape(
|
||||
GEOM::GEOM_Object_ptr theShape)
|
||||
{
|
||||
GEOM::GEOM_IMeasureOperations::CheckResults_var aRes = new GEOM::GEOM_IMeasureOperations::CheckResults;
|
||||
|
||||
//Get the reference shape
|
||||
Handle(::GEOM_Object) aShapeRef = GetObjectImpl(theShape);
|
||||
if (aShapeRef.IsNull()) return nullptr;
|
||||
|
||||
std::list<GEOMImpl_IMeasureOperations::FailedChecks> aChecks;
|
||||
GetOperations()->CheckConformityShape(aShapeRef, aChecks);
|
||||
|
||||
Standard_Integer aLength = aChecks.size();
|
||||
aRes->length(aLength);
|
||||
std::list<GEOMImpl_IMeasureOperations::FailedChecks>::const_iterator anIntIt = aChecks.cbegin();
|
||||
for (Standard_Integer i = 0; i < aLength; i++, ++anIntIt)
|
||||
{
|
||||
aRes[i].type = (*anIntIt).TypeOfCheck;
|
||||
aRes[i].failedShapes.first = GetObject(Handle(::GEOM_Object)::DownCast((*anIntIt).FailedShapes.first));
|
||||
aRes[i].failedShapes.second = GetObject(Handle(::GEOM_Object)::DownCast((*anIntIt).FailedShapes.second));
|
||||
}
|
||||
|
||||
return aRes._retn();
|
||||
}
|
||||
|
||||
//=============================================================================
|
||||
/*!
|
||||
* UpdateTolerance
|
||||
* Compute possible tolerance for the shape, minimize tolerance of shape as well
|
||||
* as tolerance of sub-shapes as much as possible
|
||||
* \param theShape Shape for check.
|
||||
*/
|
||||
//=============================================================================
|
||||
CORBA::Double GEOM_IMeasureOperations_i::UpdateTolerance(GEOM::GEOM_Object_ptr theShape)
|
||||
{
|
||||
//Get the reference shape
|
||||
Handle(::GEOM_Object) aShapeRef = GetObjectImpl(theShape);
|
||||
if (aShapeRef.IsNull())
|
||||
return false;
|
||||
|
||||
return GetOperations()->UpdateTolerance(aShapeRef);
|
||||
}
|
||||
|
||||
void GEOM_IMeasureOperations_i::ConvertToList(const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts,
|
||||
std::list<GEOMImpl_IMeasureOperations::FailedChecks>& theListOfResults)
|
||||
{
|
||||
for (Standard_Integer i = 0; i < theResuts.length(); ++i)
|
||||
{
|
||||
GEOMImpl_IMeasureOperations::FailedChecks aCheck;
|
||||
aCheck.TypeOfCheck = theResuts[i].type;
|
||||
aCheck.FailedShapes.first = GetObjectImpl(theResuts[i].failedShapes.first);
|
||||
aCheck.FailedShapes.second = GetObjectImpl(theResuts[i].failedShapes.second);
|
||||
theListOfResults.push_back(aCheck);
|
||||
}
|
||||
}
|
||||
|
@ -170,8 +170,33 @@ class GEOM_I_EXPORT GEOM_IMeasureOperations_i :
|
||||
GEOM::GEOM_Object_ptr thePoint,
|
||||
GEOM::GEOM_Object_ptr theDirection);
|
||||
|
||||
// Methods for class CheckConformity
|
||||
GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape* SelfIntersected2D(
|
||||
const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts);
|
||||
|
||||
GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape* InterferingSubshapes(
|
||||
const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts,
|
||||
const CORBA::Long theShapeType1,
|
||||
const CORBA::Long theShapeType2);
|
||||
|
||||
GEOM::ListOfGO* SmallEdges(const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts);
|
||||
|
||||
GEOM::GEOM_IMeasureOperations::SequenceOfPairOfShape* DistantShapes(
|
||||
const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts,
|
||||
const CORBA::Long theShapeType,
|
||||
const CORBA::Long theSubShapeType,
|
||||
const CORBA::Double theTolerance);
|
||||
|
||||
GEOM::GEOM_IMeasureOperations::CheckResults* CheckConformityShape(GEOM::GEOM_Object_ptr theShape);
|
||||
|
||||
CORBA::Double UpdateTolerance(GEOM::GEOM_Object_ptr theShape);
|
||||
|
||||
::GEOMImpl_IMeasureOperations* GetOperations()
|
||||
{ return (::GEOMImpl_IMeasureOperations*)GetImpl(); }
|
||||
|
||||
private:
|
||||
void ConvertToList(const GEOM::GEOM_IMeasureOperations::CheckResults& theResuts,
|
||||
std::list <GEOMImpl_IMeasureOperations::FailedChecks>& theListOfResults);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -72,6 +72,7 @@ SET(_python_SCRIPTS
|
||||
geomBuilder.py
|
||||
gsketcher.py
|
||||
canonicalrecognition.py
|
||||
conformity.py
|
||||
)
|
||||
|
||||
# Advanced scripts
|
||||
|
322
src/GEOM_SWIG/conformity.py
Normal file
322
src/GEOM_SWIG/conformity.py
Normal file
@ -0,0 +1,322 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (C) 2014-2022 EDF R&D, OPEN CASCADE
|
||||
#
|
||||
# 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, or (at your option) any later version.
|
||||
#
|
||||
# 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
|
||||
#
|
||||
# Author : Alexey SOZINOV, Open CASCADE S.A.S.
|
||||
|
||||
|
||||
## @defgroup check_conformity CheckConformity - Wrapper to find imperfections in the shape
|
||||
# @{
|
||||
# @details
|
||||
# This tool provides the user with a simple python API
|
||||
# to analyze, available shape for Boolean Operations or not.
|
||||
# Also tool provide advanced output to indicate imperfections in the input shape.
|
||||
# @n Example:
|
||||
# @code
|
||||
# import GEOM
|
||||
# from salome.geom import geomBuilder
|
||||
# from salome.geom.CheckConformity import CheckConformity
|
||||
#
|
||||
# geompy = geomBuilder.New()
|
||||
#
|
||||
# O = geompy.MakeVertex(0, 0, 0)
|
||||
# OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
|
||||
# OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
|
||||
# OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
|
||||
# Vertex_1 = geompy.MakeVertex(-30, -70, 0)
|
||||
# Vertex_2 = geompy.MakeVertex(-30, 50, 0)
|
||||
# Line_1 = geompy.MakeLineTwoPnt(Vertex_2, Vertex_1)
|
||||
# Vertex_3 = geompy.MakeVertex(0, -50, 0)
|
||||
# Vertex_4 = geompy.MakeVertex(-40, -10, 0)
|
||||
# Vertex_5 = geompy.MakeVertex(0, 40, 0)
|
||||
# Arc_1 = geompy.MakeArc(Vertex_5, Vertex_4, Vertex_3)
|
||||
# Vertex_6 = geompy.MakeVertex(10, -50, 4)
|
||||
# Vertex_7 = geompy.MakeVertex(10, -50, 10)
|
||||
# Vertex_8 = geompy.MakeVertex(10, 40, 10)
|
||||
# Arc_1_vertex_3 = geompy.GetSubShape(Arc_1, [3])
|
||||
# Line_2 = geompy.MakeLineTwoPnt(Arc_1_vertex_3, Vertex_6)
|
||||
# Line_3 = geompy.MakeLineTwoPnt(Vertex_6, Vertex_7)
|
||||
# Line_4 = geompy.MakeLineTwoPnt(Vertex_7, Vertex_8)
|
||||
# Vertex_9 = geompy.MakeVertex(15, 40, 10)
|
||||
# Vertex_10 = geompy.MakeVertex(17, 0, 6)
|
||||
# Vertex_11 = geompy.MakeVertex(17, 0, 3)
|
||||
# Line_5 = geompy.MakeLineTwoPnt(Vertex_8, Vertex_9)
|
||||
# Line_6 = geompy.MakeLineTwoPnt(Vertex_9, Vertex_10)
|
||||
# Line_7 = geompy.MakeLineTwoPnt(Vertex_10, Vertex_11)
|
||||
# Arc_1_vertex_2 = geompy.GetSubShape(Arc_1, [2])
|
||||
# Line_8 = geompy.MakeLineTwoPnt(Vertex_11, Arc_1_vertex_2)
|
||||
# Wire_1 = geompy.MakeWire([Arc_1, Line_2, Line_3, Line_4, Line_5, Line_6, Line_7, Line_8], 1e-07)
|
||||
# Wire_2 = geompy.MakeWire([Line_1], 1e-07)
|
||||
# Compound_1 = geompy.MakeCompound([Wire_1, Wire_2])
|
||||
#
|
||||
# # Create class CheckConformity for check shape
|
||||
# cc = CheckConformity(Compound_1, geompy)
|
||||
# valid = cc.isValid()
|
||||
# dist = cc.distantShapes()
|
||||
# small = cc.smallEdges()
|
||||
# interfer = cc.interferingSubshapes()
|
||||
# intersect = cc.selfIntersected2D()
|
||||
#
|
||||
# geompy.addToStudy( O, 'O' )
|
||||
# geompy.addToStudy( OX, 'OX' )
|
||||
# geompy.addToStudy( OY, 'OY' )
|
||||
# geompy.addToStudy( OZ, 'OZ' )
|
||||
# geompy.addToStudy( Vertex_1, 'Vertex_1' )
|
||||
# geompy.addToStudy( Vertex_2, 'Vertex_2' )
|
||||
# geompy.addToStudy( Line_1, 'Line_1' )
|
||||
# geompy.addToStudy( Vertex_3, 'Vertex_3' )
|
||||
# geompy.addToStudy( Vertex_4, 'Vertex_4' )
|
||||
# geompy.addToStudy( Vertex_5, 'Vertex_5' )
|
||||
# geompy.addToStudy( Arc_1, 'Arc_1' )
|
||||
# geompy.addToStudy( Vertex_6, 'Vertex_6' )
|
||||
# geompy.addToStudy( Vertex_7, 'Vertex_7' )
|
||||
# geompy.addToStudy( Vertex_8, 'Vertex_8' )
|
||||
# geompy.addToStudyInFather( Arc_1, Arc_1_vertex_3, 'Arc_1:vertex_3' )
|
||||
# geompy.addToStudy( Line_2, 'Line_2' )
|
||||
# geompy.addToStudy( Line_3, 'Line_3' )
|
||||
# geompy.addToStudy( Line_4, 'Line_4' )
|
||||
# geompy.addToStudy( Vertex_9, 'Vertex_9' )
|
||||
# geompy.addToStudy( Vertex_10, 'Vertex_10' )
|
||||
# geompy.addToStudy( Vertex_11, 'Vertex_11' )
|
||||
# geompy.addToStudy( Line_5, 'Line_5' )
|
||||
# geompy.addToStudy( Line_6, 'Line_6' )
|
||||
# geompy.addToStudy( Line_7, 'Line_7' )
|
||||
# geompy.addToStudyInFather( Arc_1, Arc_1_vertex_2, 'Arc_1:vertex_2' )
|
||||
# geompy.addToStudy( Line_8, 'Line_8' )
|
||||
# geompy.addToStudy( Wire_1, 'Wire_1' )
|
||||
# geompy.addToStudy( Wire_2, 'Wire_2' )
|
||||
# geompy.addToStudy( Compound_1, 'Compound_1' )
|
||||
#
|
||||
# salome.sg.updateObjBrowser()
|
||||
#
|
||||
# @endcode
|
||||
# @n Additional examples can be found as unit tests in the source code.
|
||||
# @}
|
||||
|
||||
|
||||
## An interface to find imperfections in the shape.
|
||||
# Use geompy.CheckConformity(shape) method to obtain an instance of this class
|
||||
#
|
||||
# @ref tui_check_conformity_page "Example"
|
||||
# @ingroup check_conformity
|
||||
class CheckConformity:
|
||||
AUTO = -1
|
||||
|
||||
"""
|
||||
Check Conformity interface
|
||||
|
||||
Example of usage:
|
||||
cc = CheckConformity(Lot4_twistedFace_brep_1, geompy)
|
||||
valid = cc.isValid()
|
||||
dist = cc.distantShapes(geompy.ShapeType["EDGE"], geompy.ShapeType["VERTEX"])
|
||||
small = cc.smallEdges()
|
||||
interfer = cc.interferingSubshapes()
|
||||
interferEV = cc.interferingSubshapes(geompy.ShapeType["EDGE"], geompy.ShapeType["VERTEX"])
|
||||
interferVV = cc.interferingSubshapes(geompy.ShapeType["VERTEX], geompy.ShapeType["VERTEX"])
|
||||
intersect = cc.selfIntersected2D()
|
||||
"""
|
||||
|
||||
def __init__(self, shape, geompyD):
|
||||
self.geompyD = geompyD
|
||||
self.myShape = shape
|
||||
self.myIsChecked = False;
|
||||
self.myResults = []
|
||||
|
||||
## Perform analyse of shape.
|
||||
#
|
||||
# @return New List, which contains pair: type of check and single of pair failed sub-shapes.
|
||||
def __checkShape(self):
|
||||
"""
|
||||
Perform analyse of shape.
|
||||
|
||||
Returns:
|
||||
New List, which contains pair: type of check and single of pair failed sub-shapes.
|
||||
"""
|
||||
anOp = self.geompyD.GetIMeasureOperations()
|
||||
self.myResults = anOp.CheckConformityShape(self.myShape)
|
||||
self.myIsChecked = True
|
||||
|
||||
## Check whether the shape is applicable for Boolean Operations.
|
||||
#
|
||||
# @return Boolean value True if shape is applicable for Boolean Operations, otherwise - False
|
||||
def isValid(self):
|
||||
"""
|
||||
check whether the shape is applicable for Boolean Operations.
|
||||
|
||||
Returns:
|
||||
Boolean value True if shape is applicable for Boolean Operations, otherwise - False.
|
||||
|
||||
Example of usage:
|
||||
Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
|
||||
cc = CheckConformity(Box_1, geompy)
|
||||
isValid = cc.isValid()
|
||||
"""
|
||||
if not self.myIsChecked:
|
||||
self.__checkShape()
|
||||
return len(self.myResults) == 0
|
||||
|
||||
## Find all self-intersected 2D curves.
|
||||
#
|
||||
# @return New List, of pair sub-shape, which has self-intersected in 2D
|
||||
def selfIntersected2D(self):
|
||||
"""
|
||||
Find all self-intersected 2D curves.
|
||||
|
||||
Returns:
|
||||
New List, of pair sub-shape, which has self-intersected in 2D/
|
||||
|
||||
Example of usage:
|
||||
Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
|
||||
cc = CheckConformity(Box_1, geompy)
|
||||
selfIntersected2D = cc.selfIntersected2D()
|
||||
"""
|
||||
if not self.myIsChecked:
|
||||
self.__checkShape()
|
||||
|
||||
anOp = self.geompyD.GetIMeasureOperations()
|
||||
return anOp.SelfIntersected2D(self.myResults)
|
||||
|
||||
## Find pairs of interfering sub-shapes:
|
||||
# - vertices touched by tolerance;
|
||||
# - vertex touching an edge in the inner point;
|
||||
# - vertex lying on the inner point of a face;
|
||||
# - edges intersecting by inner points;
|
||||
# - edge touching/intersecting face in the inner point;
|
||||
# - faces intersection by inner point
|
||||
#
|
||||
# Types of interfering shapes could be specified,
|
||||
# by default all pairs of interfering shapes are returned.
|
||||
#
|
||||
# @param shapeType1 first type of shape
|
||||
# @param shapeType2 second type of shape
|
||||
#
|
||||
# @return New List, of pairs of interfering shapes with given types (if they was specified)
|
||||
def interferingSubshapes(self, shapeType1 = AUTO, shapeType2 = AUTO):
|
||||
"""
|
||||
Find pairs of interfering sub-shapes:
|
||||
- vertices touched by tolerance
|
||||
- vertex touching an edge in the inner point
|
||||
- vertex lying on the inner point of a face
|
||||
- edges intersecting by inner points
|
||||
- edge touching/intersecting face in the inner point
|
||||
- faces intersection by inner point
|
||||
|
||||
Types of interfering shapes could be specified, by default all pairs of
|
||||
interfering shapes are returned.
|
||||
|
||||
Parameters:
|
||||
shapeType1 first type of shape
|
||||
shapeType2 second type of shape
|
||||
|
||||
Returns:
|
||||
New List, of pairs of interfering shapes with given types (if they was specified)
|
||||
|
||||
Example of usage:
|
||||
Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
|
||||
cc = CheckConformity(Box_1, geompy)
|
||||
interferingSubshapes = cc.interferingSubshapes()
|
||||
interferingSubshapesVV = cc.interferingSubshapes(geompy.ShapeType["VERTEX"], geompy.ShapeType["VERTEX"])
|
||||
"""
|
||||
if not self.myIsChecked:
|
||||
self.__checkShape()
|
||||
|
||||
anOp = self.geompyD.GetIMeasureOperations()
|
||||
return anOp.InterferingSubshapes(self.myResults, shapeType1, shapeType2)
|
||||
|
||||
## Find edges, which are fully covered by tolerances of vertices.
|
||||
#
|
||||
# @return New List of edges, which are fully covered by tolerances of vertices
|
||||
def smallEdges(self):
|
||||
"""
|
||||
Find edges, which are fully covered by tolerances of vertices.
|
||||
|
||||
Returns:
|
||||
New List of edges, which are fully covered by tolerances of vertices.
|
||||
|
||||
Example of usage:
|
||||
Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
|
||||
cc = CheckConformity(Box_1, geompy)
|
||||
smallEdges = cc.smallEdges()
|
||||
"""
|
||||
if not self.myIsChecked:
|
||||
self.__checkShape()
|
||||
|
||||
anOp = self.geompyD.GetIMeasureOperations()
|
||||
return anOp.SmallEdges(self.myResults)
|
||||
|
||||
## Find remote objects (sub-shape on a shape):
|
||||
# - vertex far from edge;
|
||||
# - vertex far from face;
|
||||
# - edge far from face
|
||||
#
|
||||
# Sub-shape which are lying far from its parent shape more than the given tolerance.
|
||||
#
|
||||
# @param shapeType type of shape
|
||||
# @param subShapeType type of sub-shape
|
||||
# @param tolerance available tolerance, by default used tolerance of sub-shape.
|
||||
#
|
||||
# @return New List, of pair of sub-shape with given types,
|
||||
# that lying far from its parent shape more than the given tolerance.
|
||||
def distantShapes(self, shapeType = AUTO, subShapeType = AUTO, tolerance = -1.0):
|
||||
"""
|
||||
Find remote objects (sub-shape on a shape):
|
||||
- vertex far from edge;
|
||||
- vertex far from face;
|
||||
- edge far from face
|
||||
|
||||
Sub-shape which are lying far from its parent shape more than the given tolerance.
|
||||
|
||||
Parameters:
|
||||
shapeType type of shape
|
||||
subShapeType type of sub-shape
|
||||
tolerance available tolerance, by default used tolerance of sub-shape.
|
||||
|
||||
Returns:
|
||||
New List, of pair of sub-shape with given types,
|
||||
that lying far from its parent shape more than the given tolerance
|
||||
|
||||
Example of usage:
|
||||
Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
|
||||
cc = CheckConformity(Box_1, geompy)
|
||||
distantShapes = cc.distantShapes(geompy.ShapeType["EDGE"], geompy.ShapeType["VERTEX"])
|
||||
"""
|
||||
if not self.myIsChecked:
|
||||
self.__checkShape()
|
||||
|
||||
anOp = self.geompyD.GetIMeasureOperations()
|
||||
return anOp.DistantShapes(self.myResults, shapeType, subShapeType, tolerance)
|
||||
|
||||
## Compute possible tolerance for the shape,
|
||||
# minimize tolerance of shape as well as tolerance of sub-shapes as much as possible .
|
||||
#
|
||||
# @return New value of tolerance.
|
||||
def updateTolerance(self):
|
||||
"""
|
||||
Compute possible tolerance for the shape,
|
||||
minimize tolerance of shape as well as tolerance of sub-shapes as much as possible.
|
||||
|
||||
Returns:
|
||||
New value of tolerance.
|
||||
|
||||
Example of usage:
|
||||
Box_1 = geompy.MakeBoxDXDYDZ(200, 200, 200)
|
||||
cc = CheckConformity(Box_1, geompy)
|
||||
toler = cc.updateTolerance()
|
||||
"""
|
||||
anOp = self.geompyD.GetIMeasureOperations()
|
||||
return anOp.UpdateTolerance(self.myShape)
|
@ -261,6 +261,7 @@ import functools
|
||||
|
||||
from salome.geom.gsketcher import Sketcher3D, Sketcher2D, Polyline2D
|
||||
from salome.geom.canonicalrecognition import CanonicalRecognition
|
||||
from salome.geom.conformity import CheckConformity
|
||||
|
||||
# In case the omniORBpy EnumItem class does not fully support Python 3
|
||||
# (for instance in version 4.2.1-2), the comparison ordering methods must be
|
||||
@ -14036,6 +14037,25 @@ class geomBuilder(GEOM._objref_GEOM_Gen):
|
||||
RaiseIfFailed("Tesselate", self.TestOp)
|
||||
return r
|
||||
|
||||
## Obtain a shape checker
|
||||
# @return An instance of @ref conformity.CheckConformity "CheckConformity" interface
|
||||
#
|
||||
# @ref tui_conformity_page "Example"
|
||||
def CheckConformity (self, shape):
|
||||
"""
|
||||
Obtain a shape checker.
|
||||
|
||||
Example of usage:
|
||||
conf = geompy.CheckConformity(shape)
|
||||
valid = conf.isValid()
|
||||
si2d = conf.selfIntersected2D()
|
||||
dist = conf.distantShapes()
|
||||
small = conf.smallEdges()
|
||||
interfer = cc.interferingSubshapes()
|
||||
"""
|
||||
conf = CheckConformity (shape, self)
|
||||
return conf
|
||||
|
||||
# end of l2_testing
|
||||
## @}
|
||||
|
||||
|
136
test/data/test_twisted_face.brep
Normal file
136
test/data/test_twisted_face.brep
Normal file
File diff suppressed because one or more lines are too long
34
test/test_conformity.py
Normal file
34
test/test_conformity.py
Normal file
@ -0,0 +1,34 @@
|
||||
# Check shape applicability for Boolean Operations
|
||||
|
||||
import salome
|
||||
salome.salome_init_without_session()
|
||||
import GEOM
|
||||
from salome.geom import geomBuilder
|
||||
geompy = geomBuilder.New()
|
||||
|
||||
from inspect import getfile
|
||||
from os.path import abspath, dirname, join
|
||||
|
||||
data_dir = abspath(join(dirname(getfile(lambda: None)), 'data'))
|
||||
shape = geompy.ImportBREP(join(data_dir, 'test_twisted_face.brep'))
|
||||
|
||||
tol = geompy.Tolerance(shape)
|
||||
|
||||
# perform all checks
|
||||
check = geompy.CheckConformity(shape)
|
||||
assert(not check.isValid())
|
||||
assert(len(check.smallEdges()) == 4)
|
||||
assert(len(check.selfIntersected2D()) == 2)
|
||||
assert(len(check.interferingSubshapes()) == 6)
|
||||
for p in check.interferingSubshapes():
|
||||
assert(geomBuilder.EnumToLong(p.first.GetShapeType()) == geompy.ShapeType["VERTEX"] and
|
||||
geomBuilder.EnumToLong(p.second.GetShapeType()) == geompy.ShapeType["VERTEX"])
|
||||
assert(len(check.distantShapes()) == 2)
|
||||
for p in check.distantShapes():
|
||||
assert(geomBuilder.EnumToLong(p.first.GetShapeType()) == geompy.ShapeType["EDGE"] and
|
||||
geomBuilder.EnumToLong(p.second.GetShapeType()) == geompy.ShapeType["FACE"])
|
||||
assert(len(check.distantShapes(tolerance = 300.0)) == 1)
|
||||
assert(len(check.distantShapes(tolerance = 400.0)) == 0)
|
||||
|
||||
newTol = check.updateTolerance()
|
||||
assert(newTol < max(tol))
|
@ -19,11 +19,13 @@
|
||||
|
||||
SET(ALL_TESTS
|
||||
test_perf_01.py
|
||||
test_patch_face_01.py
|
||||
)
|
||||
|
||||
IF(${OpenCASCADE_VERSION}.${OpenCASCADE_SP_VERSION} VERSION_GREATER "7.5.3.3")
|
||||
LIST(APPEND ALL_TESTS
|
||||
test_point_cloud_on_face.py
|
||||
test_CR.py
|
||||
test_conformity.py
|
||||
)
|
||||
ENDIF()
|
||||
|
Loading…
Reference in New Issue
Block a user