#define FIND_GROUPS_BY_POINTS 1
+// Undefine below macro to enable workaround about fillet problem in MakePipeTShapeFillet
+// VSR 30/12/2014: macro enabled
+#define FILLET_FIX_TOLERANCE
+
//=============================================================================
/*!
* Constructor
aFillet->GetLastFunction()->SetDescription("");
TopoDS_Shape aFilletShape = aFillet->GetValue();
+
+#ifdef FILLET_FIX_TOLERANCE
+ // VSR: 30/12/2014: temporary workaround about Fillet problem
+ if (theHexMesh) {
+ GEOMUtils::FixShapeTolerance(aFilletShape, TopAbs_FACE);
+ }
+ else {
+ GEOMUtils::FixShapeCurves(aFilletShape);
+ }
+#endif
+
aFunction->SetValue(aFilletShape);
// END of fillet
aFillet->GetLastFunction()->SetDescription("");
TopoDS_Shape aFilletShape = aFillet->GetValue();
+
+#ifdef FILLET_FIX_TOLERANCE
+ // VSR: 30/12/2014: temporary workaround about Fillet problem
+ if (theHexMesh) {
+ GEOMUtils::FixShapeTolerance(aFilletShape, TopAbs_FACE);
+ }
+ else {
+ GEOMUtils::FixShapeCurves(aFilletShape);
+ }
+#endif
+
aFunction->SetValue(aFilletShape);
// END of fillet
#include <vector>
+// Undefine below macro to enable workaround about problem with wrong
+// tolerances of intersection curves in MakePipeTShape and MakeQuarterPipeTShape
+// VSR 30/12/2014: macro enabled
+#define FIX_CURVES_TOLERANCES
+
//=======================================================================
//function : GetID
//purpose :
//purpose :
//=======================================================================
TopoDS_Shape AdvancedEngine_PipeTShapeDriver::MakePipeTShape (const double r1, const double w1, const double l1,
- const double r2, const double w2, const double l2) const
+ const double r2, const double w2, const double l2) const
{
double r1Ext = r1 + w1;
double r2Ext = r2 + w2;
StdFail_NotDone::Raise("Coudn't cut cylinders");
}
- return Te.Shape();
+ TopoDS_Shape aShape = Te.Shape();
+
+ // VSR: 30/12/2014: temporary workaround about intersection curves problem
+#ifdef FIX_CURVES_TOLERANCES
+ GEOMUtils::FixShapeCurves(aShape);
+#endif
+
+ return aShape;
}
//=======================================================================
//purpose :
//=======================================================================
TopoDS_Shape AdvancedEngine_PipeTShapeDriver::MakeQuarterPipeTShape (const double r1, const double w1, const double l1,
- const double r2, const double w2, const double l2) const
+ const double r2, const double w2, const double l2) const
{
TopoDS_Shape Te = MakePipeTShape(r1, w1, l1, r2, w2, l2);
if (Te.IsNull())
StdFail_NotDone::Raise("Couldn't cut Pipe Tshape with box");
}
+ TopoDS_Shape aShape = Te4.Shape();
+
+ // VSR: 30/12/2014: temporary workaround about intersection curves problem
+#ifdef FIX_CURVES_TOLERANCES
+ GEOMUtils::FixShapeCurves(aShape);
+#endif
+
return Te4.Shape();
}
#include <TNaming_CopyShape.hxx>
-#include <ShapeFix_ShapeTolerance.hxx>
-#include <ShapeFix_Shape.hxx>
-
#include <BRep_Builder.hxx>
-#include <BRepAlgo.hxx>
#include <BRepAlgoAPI_Common.hxx>
#include <BRepAlgoAPI_Cut.hxx>
#include <BRepAlgoAPI_Fuse.hxx>
#include <BRepAlgoAPI_Section.hxx>
-#include <BRepCheck_Analyzer.hxx>
#include <BOPAlgo_CheckerSI.hxx>
#include <BOPDS_DS.hxx>
{
TopoDS_Shape aResult;
- if (theShape.IsNull() == Standard_False) {
+ if (!theShape.IsNull()) {
BlockFix_BlockFixAPI aTool;
aTool.OptimumNbFaces() = 0;
aTool.SetShape(theShape);
aTool.Perform();
- aResult = aTool.Shape();
-
- // Repair result
- BRepCheck_Analyzer anAna (aResult, false);
- Standard_Boolean isValid = anAna.IsValid();
+ TopoDS_Shape aShape = aTool.Shape();
- if (!isValid) {
+ if (GEOMUtils::CheckShape(aShape)) {
+ aResult = aShape;
+ }
+ else {
TopoDS_Shape aFixed;
ShHealOper_ShapeProcess aHealer;
-
aHealer.Perform(aResult, aFixed);
-
- if (aHealer.isDone()) {
+ if (aHealer.isDone() && GEOMUtils::CheckShape(aFixed))
aResult = aFixed;
- anAna.Init(aResult, false);
- isValid = anAna.IsValid();
- }
- }
-
- if (!isValid) {
- aResult.Nullify();
}
}
if (!aShape1.IsNull() && !aShape2.IsNull()) {
// check arguments for Mantis issue 0021019
- BRepCheck_Analyzer ana (aShape1, Standard_True);
- if (!ana.IsValid())
- StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is not valid");
- ana.Init(aShape2);
- if (!ana.IsValid())
+ if (!GEOMUtils::CheckShape(aShape1, true) || !GEOMUtils::CheckShape(aShape2, true))
StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is not valid");
if (isCheckSelfInte) {
aShape = aRefShape->GetValue();
if (!aShape.IsNull()) {
- BRepCheck_Analyzer anAna (aShape, Standard_True);
- if (!anAna.IsValid()) {
+ // check arguments for Mantis issue 0021019
+ if (!GEOMUtils::CheckShape(aShape, true))
StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is not valid");
- }
BOPAlgo_CheckerSI aCSI; // checker of self-interferences
for (i = 2; i <= nbShapes; i++) {
aRefShape = Handle(GEOM_Function)::DownCast(aShapes->Value(i));
aShape2 = aRefShape->GetValue();
- anAna.Init(aShape2);
-
- if (!anAna.IsValid()) {
+
+ if (!GEOMUtils::CheckShape(aShape2, true))
StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is not valid");
- }
if (isCheckSelfInte) {
BOPCol_ListOfShape aList2;
if (!aShape.IsNull()) {
// check arguments for Mantis issue 0021019
- BRepCheck_Analyzer anAna (aShape, Standard_True);
-
- if (!anAna.IsValid()) {
+ if (!GEOMUtils::CheckShape(aShape, true))
StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is not valid");
- }
BOPAlgo_CheckerSI aCSI; // checker of self-interferences
for (i = 1; i <= nbShapes; i++) {
aRefTool = Handle(GEOM_Function)::DownCast(aTools->Value(i));
aTool = aRefTool->GetValue();
- anAna.Init(aTool);
- if (!anAna.IsValid()) {
+ if (!GEOMUtils::CheckShape(aTool, true))
StdFail_NotDone::Raise("Boolean operation will not be performed, because argument shape is not valid");
- }
if (isCheckSelfInte) {
BOPCol_ListOfShape aList2;
}
// 08.07.2008 skl for bug 19761 from Mantis
- BRepCheck_Analyzer ana (aShape, Standard_True);
- ana.Init(aShape);
- if (!ana.IsValid()) {
- ShapeFix_ShapeTolerance aSFT;
- aSFT.LimitTolerance(aShape, Precision::Confusion(),
- Precision::Confusion(), TopAbs_SHAPE);
- Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(aShape);
- aSfs->Perform();
- aShape = aSfs->Shape();
- ana.Init(aShape);
- if (!ana.IsValid())
- Standard_ConstructionError::Raise("Boolean operation aborted : non valid shape result");
- }
+ if ( !GEOMUtils::CheckShape(aShape, true) && !GEOMUtils::FixShapeTolerance(aShape) )
+ Standard_ConstructionError::Raise("Boolean operation aborted : non valid shape result");
// BEGIN: Mantis issue 0021060: always limit tolerance of BOP result
// 1. Get shape parameters for comparison
TopoDS_Shape aShapeCopy;
TColStd_IndexedDataMapOfTransientTransient aMapTShapes;
TNaming_CopyShape::CopyTool(aShape, aMapTShapes, aShapeCopy);
- ShapeFix_ShapeTolerance aSFT;
- aSFT.LimitTolerance(aShapeCopy, Precision::Confusion(), Precision::Confusion(), TopAbs_SHAPE);
- Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape (aShapeCopy);
- aSfs->Perform();
- aShapeCopy = aSfs->Shape();
-
- // 3. Check parameters
- ana.Init(aShapeCopy);
- if (ana.IsValid()) {
+
+ if ( GEOMUtils::FixShapeTolerance(aShapeCopy) ) {
int iType, nbTypesCopy [TopAbs_SHAPE];
for (iType = 0; iType < TopAbs_SHAPE; ++iType)
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#include <Standard_Stream.hxx>
-
#include <GEOMImpl_ChamferDriver.hxx>
#include <GEOMImpl_IChamfer.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOMImpl_ILocalOperations.hxx>
#include <GEOMImpl_Block6Explorer.hxx>
-
+#include <GEOMUtils.hxx>
#include <GEOM_Function.hxx>
#include <BRepLib.hxx>
#include <BRepTools.hxx>
#include <BRepFilletAPI_MakeChamfer.hxx>
-#include <ShapeFix_Shape.hxx>
-#include <ShapeFix_ShapeTolerance.hxx>
-
#include <TopAbs.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Iterator.hxx>
-#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
-#include <Precision.hxx>
-#include <gp_Pnt.hxx>
#include <StdFail_NotDone.hxx>
//=======================================================================
return aChamferDriver;
}
-
//=======================================================================
//function : GEOMImpl_ChamferDriver
//purpose :
if (aShape.IsNull()) return 0;
// reduce tolerances
- ShapeFix_ShapeTolerance aSFT;
- aSFT.LimitTolerance(aShape, Precision::Confusion(),
- Precision::Confusion(), TopAbs_SHAPE);
- Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(aShape);
- aSfs->Perform();
- aShape = aSfs->Shape();
+ GEOMUtils::FixShapeTolerance( aShape );
// fix SameParameter flag
BRepLib::SameParameter(aShape, 1.E-5, Standard_True);
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#include <Standard_Stream.hxx>
-
#include <GEOMImpl_Fillet2dDriver.hxx>
#include <GEOMImpl_IFillet2d.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOMImpl_ILocalOperations.hxx>
#include <GEOMImpl_Block6Explorer.hxx>
#include <GEOM_Function.hxx>
+#include <GEOMUtils.hxx>
#include <BRepFilletAPI_MakeFillet2d.hxx>
-#include <BRepCheck_Analyzer.hxx>
-#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
-#include <TopoDS_Edge.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopAbs.hxx>
-#include <TopExp_Explorer.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopTools_MapOfShape.hxx>
-#include <ShapeFix_ShapeTolerance.hxx>
-#include <ShapeFix_Shape.hxx>
-
-#include <Precision.hxx>
-#include <gp_Pnt.hxx>
#include <StdFail_NotDone.hxx>
//=======================================================================
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#include <Standard_Stream.hxx>
-
#include <GEOMImpl_FilletDriver.hxx>
#include <GEOMImpl_IFillet.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOMImpl_ILocalOperations.hxx>
+#include <GEOMUtils.hxx>
#include <GEOM_Function.hxx>
#include <BRepFilletAPI_MakeFillet.hxx>
-#include <BRepCheck_Analyzer.hxx>
-#include <BRep_Tool.hxx>
-
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopAbs.hxx>
#include <TopExp_Explorer.hxx>
-
-#include <ShapeFix_ShapeTolerance.hxx>
-#include <ShapeFix_Shape.hxx>
-
-#include <Precision.hxx>
-#include <gp_Pnt.hxx>
#include <StdFail_NotDone.hxx>
-// VSR 08/12/2014: debug PipeTShape function
-// Uncomment the macro below to correct tolerance of resulting face after creating fillet
-#define FIX_FACE_TOLERANCE
-
-namespace
-{
- bool FixShape( TopoDS_Shape& shape,
- TopAbs_ShapeEnum type = TopAbs_SHAPE,
- Standard_Real tolerance = Precision::Confusion() )
- {
- ShapeFix_ShapeTolerance aSFT;
- aSFT.LimitTolerance( shape, tolerance, tolerance, type );
- Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape( shape );
- aSfs->Perform();
- shape = aSfs->Shape();
- BRepCheck_Analyzer ana( shape, false );
- return ana.IsValid();
- }
-}
+// Debug PipeTShape function: uncomment the macro below to correct tolerance
+// of resulting face after fillet creation
+// VSR 30/12/2014: macro disabled
+//#define FIX_FACE_TOLERANCE
+// Debug PipeTShape function: uncomment the macro below to correct tolerance
+// of resulting curves after fillet creation
+// VSR 30/12/2014: macro disabled
+//#define FIX_CURVES_TOLERANCES
//=======================================================================
//function : GetID
if (aShape.IsNull()) return 0;
-#ifdef FIX_FACE_TOLERANCE
- bool isOk = FixShape(aShape, TopAbs_FACE);
+#if defined(FIX_CURVES_TOLERANCES)
+ bool isOk = GEOMUtils::FixShapeCurves(aShape);
+#elif defined(FIX_FACE_TOLERANCE)
+ bool isOk = GEOMUtils::FixShapeTolerance(aShape, TopAbs_FACE);
#else
- // Check shape validity
- BRepCheck_Analyzer ana(aShape, false);
// 08.07.2008 added by skl during fixing bug 19761 from Mantis
- bool isOk = ana.IsValid() || FixShape(aShape);
+ bool isOk = GEOMUtils::CheckShape(aShape) || GEOMUtils::FixShapeTolerance(aShape);
#endif
if ( !isOk )
StdFail_NotDone::Raise("Fillet algorithm have produced an invalid shape result");
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#include <Standard_Stream.hxx>
-
#include <GEOMImpl_HealingDriver.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOMImpl_IHealing.hxx>
#include <TNaming_CopyShape.hxx>
-#include <ShapeFix_ShapeTolerance.hxx>
-#include <ShapeFix_Shape.hxx>
-
#include <BRep_Builder.hxx>
#include <BRepAdaptor_Curve.hxx>
-#include <BRepCheck_Analyzer.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <TopExp.hxx>
TNaming_CopyShape::CopyTool(theOriginalShape, aMapTShapes, aShapeCopy);
// 2. Limit tolerance.
- ShapeFix_ShapeTolerance aSFT;
- aSFT.LimitTolerance(aShapeCopy, aTol, aTol, aType);
-
- // 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())
+ if (!GEOMUtils::FixShapeTolerance(aShapeCopy, aType, aTol))
StdFail_NotDone::Raise("Non valid shape result");
+
+ theOutShape = aShapeCopy;
}
//=======================================================================
}
theOutShape = aFinalWire;
- BRepCheck_Analyzer ana (theOutShape, Standard_True);
- if (!ana.IsValid())
+ if (!GEOMUtils::CheckShape(theOutShape, true))
StdFail_NotDone::Raise("Non valid shape result");
}
#include <GEOMImpl_IOffset.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOM_Function.hxx>
+#include <GEOMUtils.hxx>
#include <BRepOffsetAPI_MakeOffsetShape.hxx>
-#include <BRep_Tool.hxx>
-#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
-#include <TopoDS_Vertex.hxx>
#include <TopAbs.hxx>
-#include <TopExp.hxx>
-
#include <BRepClass3d_SolidClassifier.hxx>
-
#include <Precision.hxx>
-#include <gp_Pnt.hxx>
-
-#include <BRepCheck_Analyzer.hxx>
-#include <ShapeFix_ShapeTolerance.hxx>
-#include <ShapeFix_Shape.hxx>
-
#include <Standard_ConstructionError.hxx>
#include <StdFail_NotDone.hxx>
-#include "utilities.h"
-
//=======================================================================
//function : GetID
//purpose :
return aOffsetDriver;
}
-
//=======================================================================
//function : GEOMImpl_OffsetDriver
//purpose :
aTol);
if (MO.IsDone()) {
aShape = MO.Shape();
- // 23.04.2010 skl for bug 21699 from Mantis
- BRepCheck_Analyzer ana (aShape, Standard_True);
- ana.Init(aShape);
- if (!ana.IsValid()) {
- ShapeFix_ShapeTolerance aSFT;
- aSFT.LimitTolerance(aShape, Precision::Confusion(),
- Precision::Confusion(), TopAbs_SHAPE);
- Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(aShape);
- aSfs->Perform();
- aShape = aSfs->Shape();
- ana.Init(aShape);
- if (!ana.IsValid())
- Standard_ConstructionError::Raise("Boolean operation aborted : non valid shape result");
- }
+ if ( !GEOMUtils::CheckShape(aShape, true) && !GEOMUtils::FixShapeTolerance(aShape) )
+ Standard_ConstructionError::Raise("Boolean operation aborted : non valid shape result");
}
else {
StdFail_NotDone::Raise("Offset construction failed");
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#include <Standard_Stream.hxx>
-
#include <GEOMImpl_PartitionDriver.hxx>
#include <GEOMImpl_IPartition.hxx>
#include <GEOMImpl_Types.hxx>
-
+#include <GEOMUtils.hxx>
#include <GEOM_Object.hxx>
#include <GEOM_Function.hxx>
-
#include <GEOMAlgo_Splitter.hxx>
#include <TDataStd_IntegerArray.hxx>
#include <TNaming_CopyShape.hxx>
-//#include <BRepBuilderAPI_Copy.hxx>
-#include <BRep_Tool.hxx>
-#include <BRepAlgo.hxx>
-#include <BRepTools.hxx>
-
#include <TopAbs.hxx>
#include <TopExp.hxx>
-#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopoDS_Wire.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_DataMapOfShapeShape.hxx>
-#include <ShapeFix_ShapeTolerance.hxx>
-#include <ShapeFix_Shape.hxx>
-
#include <TColStd_IndexedDataMapOfTransientTransient.hxx>
-#include <TColStd_ListIteratorOfListOfInteger.hxx>
-#include <TColStd_ListOfInteger.hxx>
#include <Standard_NullObject.hxx>
#include <StdFail_NotDone.hxx>
-#include <Precision.hxx>
-#include <gp_Pnt.hxx>
#include <BOPAlgo_CheckerSI.hxx>
#include <BOPCol_IndexedDataMapOfShapeListOfShape.hxx>
#include <BOPCol_ListOfShape.hxx>
Standard_ConstructionError::Raise("Partition aborted : non valid shape result");
//end of IPAL21418
- if (!BRepAlgo::IsValid(aShape)) {
- // 08.07.2008 added by skl during fixing bug 19761 from Mantis
- ShapeFix_ShapeTolerance aSFT;
- aSFT.LimitTolerance(aShape, Precision::Confusion(),
- Precision::Confusion(), TopAbs_SHAPE);
- Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(aShape);
- aSfs->Perform();
- aShape = aSfs->Shape();
- if (!BRepAlgo::IsValid(aShape))
- Standard_ConstructionError::Raise("Partition aborted : non valid shape result");
- }
+ if ( !GEOMUtils::CheckShape(aShape, true) && !GEOMUtils::FixShapeTolerance(aShape) )
+ Standard_ConstructionError::Raise("Partition aborted : non valid shape result");
aFunction->SetValue(aShape);
#include <ShapeAnalysis_Edge.hxx>
#include <ShapeFix_Face.hxx>
#include <ShapeFix_Shell.hxx>
-#include <ShapeFix_Shape.hxx>
-#include <ShapeFix_ShapeTolerance.hxx>
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_Sewing.hxx>
-#include <BRepCheck_Analyzer.hxx>
#include <BRepGProp.hxx>
#include <GeomFill_Trihedron.hxx>
#include <GeomFill_CorrectedFrenet.hxx>
if (aShape.IsNull()) return 0;
- BRepCheck_Analyzer ana (aShape, Standard_False);
- if (!ana.IsValid()) {
- ShapeFix_ShapeTolerance aSFT;
- aSFT.LimitTolerance(aShape,Precision::Confusion(),Precision::Confusion());
- Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(aShape);
- aSfs->SetPrecision(Precision::Confusion());
- aSfs->Perform();
- aShape = aSfs->Shape();
-
- ana.Init(aShape, Standard_False);
- if (!ana.IsValid())
- Standard_ConstructionError::Raise("Algorithm have produced an invalid shape result");
- }
+ if ( !GEOMUtils::CheckShape(aShape) && !GEOMUtils::FixShapeTolerance(aShape) )
+ Standard_ConstructionError::Raise("Algorithm have produced an invalid shape result");
if (aType != PIPE_BASE_PATH &&
aType != PIPE_SHELLS_WITHOUT_PATH) {
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#include <Standard_Stream.hxx>
-
-#include <Basics_OCCTVersion.hxx>
-
#include <GEOMImpl_PipePathDriver.hxx>
-
-#include <GEOMImpl_IShapesOperations.hxx>
#include <GEOMImpl_ShapeDriver.hxx>
#include <GEOMImpl_IPipePath.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOM_Function.hxx>
-#include <ShapeAnalysis_FreeBounds.hxx>
-#include <ShapeAnalysis_Edge.hxx>
-#include <ShapeFix_Face.hxx>
-#include <ShapeFix_Shell.hxx>
-#include <ShapeFix_Shape.hxx>
-#include <ShapeFix_ShapeTolerance.hxx>
-
-#include <BRep_Tool.hxx>
-#include <BRep_Builder.hxx>
-#include <BRepBuilderAPI_Copy.hxx>
-#include <BRepBuilderAPI_MakeFace.hxx>
-#include <BRepBuilderAPI_MakeWire.hxx>
-#include <BRepBuilderAPI_Sewing.hxx>
-#include <BRepCheck_Analyzer.hxx>
-#include <BRepGProp.hxx>
-#include <BRepOffsetAPI_MakePipe.hxx>
-#include <BRepOffsetAPI_MakePipeShell.hxx>
-
#include <BRepOffsetAPI_MiddlePath.hxx>
-
-#include <TopAbs.hxx>
-#include <TopExp.hxx>
-#include <TopExp_Explorer.hxx>
-#include <TopoDS.hxx>
-#include <TopoDS_Wire.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Solid.hxx>
-#include <TopoDS_Shell.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS_Compound.hxx>
-#include <TopTools_SequenceOfShape.hxx>
-#include <TopTools_HSequenceOfShape.hxx>
-#include <TopTools_IndexedDataMapOfShapeShape.hxx>
-#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
-#include <TopTools_ListIteratorOfListOfShape.hxx>
-
-#include <GProp_GProps.hxx>
-
-#include <GeomAPI_ProjectPointOnCurve.hxx>
-#include <GeomAPI_Interpolate.hxx>
-#include <Geom_TrimmedCurve.hxx>
-#include <Geom_Plane.hxx>
-#include <Geom_RectangularTrimmedSurface.hxx>
-#include <Geom_BezierSurface.hxx>
-#include <Geom_Line.hxx>
-#include <Geom_Conic.hxx>
-#include <Geom_BSplineCurve.hxx>
-#include <Geom_BSplineSurface.hxx>
-#include <GeomFill_BSplineCurves.hxx>
-#include <GeomConvert_ApproxCurve.hxx>
-#include <GeomConvert.hxx>
-
-#include <TColgp_SequenceOfPnt.hxx>
-#include <TColgp_HArray1OfPnt.hxx>
-#include <TColgp_Array2OfPnt.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
-
#include <Precision.hxx>
-
#include <Standard_NullObject.hxx>
-#include <Standard_TypeMismatch.hxx>
-#include <Standard_ConstructionError.hxx>
-
-#include "utilities.h"
//=======================================================================
//function : GetID
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#include <Standard_Stream.hxx>
-
#include <GEOMImpl_ScaleDriver.hxx>
#include <GEOMImpl_IScale.hxx>
#include <GEOMImpl_Types.hxx>
+#include <GEOMUtils.hxx>
#include <GEOM_Function.hxx>
-#include <ShapeFix_Shape.hxx>
-#include <ShapeFix_ShapeTolerance.hxx>
-
#include <BRepBuilderAPI_Transform.hxx>
#include <BRepBuilderAPI_GTransform.hxx>
#include <BRep_Tool.hxx>
-#include <BRepAlgo.hxx>
-#include <BRepCheck_Analyzer.hxx>
#include <TopAbs.hxx>
#include <TopExp.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
-#include <TopoDS_Vertex.hxx>
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include <Precision.hxx>
if (aShape.IsNull()) return 0;
- BRepCheck_Analyzer ana (aShape, Standard_False);
- if (!ana.IsValid()) {
- ShapeFix_ShapeTolerance aSFT;
- aSFT.LimitTolerance(aShape,Precision::Confusion(),Precision::Confusion());
- Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(aShape);
- aSfs->SetPrecision(Precision::Confusion());
- aSfs->Perform();
- aShape = aSfs->Shape();
-
- ana.Init(aShape, Standard_False);
- if (!ana.IsValid())
- Standard_ConstructionError::Raise("Scaling aborted : algorithm has produced an invalid shape result");
- }
+ if ( !GEOMUtils::CheckShape(aShape) && !GEOMUtils::FixShapeTolerance(aShape) )
+ Standard_ConstructionError::Raise("Scaling aborted : algorithm has produced an invalid shape result");
aFunction->SetValue(aShape);
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#include <Standard_Stream.hxx>
-
#include <GEOMImpl_ThruSectionsDriver.hxx>
#include <GEOMImpl_IThruSections.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOM_Function.hxx>
+#include <GEOMUtils.hxx>
#include <TColStd_HSequenceOfTransient.hxx>
#include <Precision.hxx>
-#include <BRepCheck_Analyzer.hxx>
#include <BRepOffsetAPI_ThruSections.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
-#include <TopExp_Explorer.hxx>
#include <TopoDS.hxx>
#include <TopAbs.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Shape.hxx>
-#include <Standard_NullObject.hxx>
#include <Standard_TypeMismatch.hxx>
#include <Standard_ConstructionError.hxx>
-#include <ShapeFix_Shape.hxx>
-#include <ShapeFix_ShapeTolerance.hxx>
-#include <Precision.hxx>
+
//=======================================================================
//function : GetID
//purpose :
return 0;
}
- BRepCheck_Analyzer ana (aShape, Standard_False);
- if (!ana.IsValid()) {
+ if ( !GEOMUtils::CheckShape(aShape) && !GEOMUtils::FixShapeTolerance(aShape) ) {
//algoritm thru section creats on the arcs invalid shapes gka
- ShapeFix_ShapeTolerance aSFT;
- aSFT.LimitTolerance(aShape,Precision::Confusion(),Precision::Confusion());
- Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(aShape);
- aSfs->SetPrecision(Precision::Confusion());
- aSfs->Perform();
- aShape = aSfs->Shape();
- //ana.Init(aShape, Standard_False);
- //if (!ana.IsValid())
// Standard_ConstructionError::Raise("Algorithm have produced an invalid shape result");
}
-
aFunction->SetValue(aShape);
log.SetTouched(Label());
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#include <Standard_Stream.hxx>
-
#include <GEOMImpl_TranslateDriver.hxx>
#include <GEOMImpl_ITranslate.hxx>
-#include <GEOMImpl_ITransformOperations.hxx>
#include <GEOMImpl_Types.hxx>
#include <GEOM_Function.hxx>
#include <GEOMUtils.hxx>
-#include <ShapeFix_Shape.hxx>
-#include <ShapeFix_ShapeTolerance.hxx>
-
#include <BRep_Tool.hxx>
#include <BRep_Builder.hxx>
-#include <BRepCheck_Analyzer.hxx>
-#include <BRepBuilderAPI_Transform.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Compound.hxx>
#include <TopAbs.hxx>
#include <TopExp.hxx>
-#include <TopoDS_Vertex.hxx>
-#include <TopoDS_Edge.hxx>
#include <gp_Trsf.hxx>
#include <gp_Pnt.hxx>
B.Add(aCompound, anOriginal.Located(aLocRes));
}
aShape = aCompound;
- //aShape = GEOMImpl_ITransformOperations::TranslateShape1D(anOriginal, &TI);
}
else if (aType == TRANSLATE_2D) {
Standard_Integer nbtimes1 = TI.GetNbIter1(), nbtimes2 = TI.GetNbIter2();
}
}
aShape = aCompound;
- //aShape = GEOMImpl_ITransformOperations::TranslateShape2D(anOriginal, &TI);
}
else return 0;
if (aShape.IsNull()) return 0;
- BRepCheck_Analyzer ana (aShape, Standard_True);
- if (!ana.IsValid()) {
- ShapeFix_ShapeTolerance aSFT;
- aSFT.LimitTolerance(aShape,Precision::Confusion(),Precision::Confusion());
- Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape(aShape);
- aSfs->SetPrecision(Precision::Confusion());
- aSfs->Perform();
- aShape = aSfs->Shape();
-
- ana.Init(aShape, Standard_False);
- if (!ana.IsValid())
- Standard_ConstructionError::Raise("Scaling aborted : algorithm has produced an invalid shape result");
- }
+ if ( !GEOMUtils::CheckShape(aShape, true) && !GEOMUtils::FixShapeTolerance(aShape) )
+ Standard_ConstructionError::Raise("Scaling aborted : algorithm has produced an invalid shape result");
aFunction->SetValue(aShape);
${CAS_TKG3d}
${CAS_TKV3d}
${CAS_TKGeomBase}
+ ${CAS_TKBO}
${LIBXML2_LIBRARIES}
${KERNEL_SALOMELocalTrace}
)
#include <Basics_OCCTVersion.hxx>
-#include <utilities.h>
#include <OpUtil.hxx>
#include <Utils_ExceptHandlers.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepBuilderAPI_Sewing.hxx>
+#include <BRepCheck_Analyzer.hxx>
+
#include <Bnd_Box.hxx>
+#include <BOPTools_AlgoTools.hxx>
+
#include <TopAbs.hxx>
#include <TopExp.hxx>
#include <TopoDS.hxx>
#include <ShapeAnalysis.hxx>
#include <ShapeFix_Shape.hxx>
+#include <ShapeFix_ShapeTolerance.hxx>
#include <ProjLib.hxx>
#include <ElSLib.hxx>
#include <vector>
#include <sstream>
+#include <algorithm>
#include <Standard_Failure.hxx>
#include <Standard_NullObject.hxx>
#define STD_SORT_ALGO 1
+// When the following macro is defined, ShapeFix_ShapeTolerance function is used to set max tolerance of curve
+// in GEOMUtils::FixShapeCurves function; otherwise less restrictive BRep_Builder::UpdateEdge/UpdateVertex
+// approach is used
+// VSR (29/12/2014): macro disabled
+//#define USE_LIMIT_TOLERANCE
+
namespace
{
/**
// function : ConvertTreeToString()
// purpose : Returns the string representation of dependency tree
//=======================================================================
-void GEOMUtils::ConvertTreeToString( const TreeModel &tree,
- std::string &treeStr )
+void GEOMUtils::ConvertTreeToString( const TreeModel& tree,
+ std::string& dependencyStr )
{
TreeModel::const_iterator i;
for ( i = tree.begin(); i != tree.end(); ++i ) {
- treeStr.append( i->first );
- treeStr.append( "-" );
+ dependencyStr.append( i->first );
+ dependencyStr.append( "-" );
std::vector<LevelInfo> upLevelList = i->second.first;
- treeStr.append( "upward" );
- parseWard( upLevelList, treeStr );
+ dependencyStr.append( "upward" );
+ parseWard( upLevelList, dependencyStr );
std::vector<LevelInfo> downLevelList = i->second.second;
- treeStr.append( "downward" );
- parseWard( downLevelList, treeStr );
+ dependencyStr.append( "downward" );
+ parseWard( downLevelList, dependencyStr );
}
}
// function : ConvertStringToTree()
// purpose : Returns the dependency tree
//=======================================================================
-void GEOMUtils::ConvertStringToTree( const std::string &theData,
- TreeModel &tree )
+void GEOMUtils::ConvertStringToTree( const std::string& dependencyStr,
+ TreeModel& tree )
{
std::size_t cursor = 0;
- while( theData.find('-',cursor) != std::string::npos ) //find next selected object
+ while( dependencyStr.find('-',cursor) != std::string::npos ) //find next selected object
{
- std::size_t objectIndex = theData.find( '-', cursor );
- std::string objectEntry = theData.substr( cursor, objectIndex - cursor );
+ std::size_t objectIndex = dependencyStr.find( '-', cursor );
+ std::string objectEntry = dependencyStr.substr( cursor, objectIndex - cursor );
cursor = objectIndex;
- std::size_t upwardIndexBegin = theData.find("{",cursor) + 1;
- std::size_t upwardIndexFinish = theData.find("}",upwardIndexBegin);
- LevelsList upwardList = parseWard( theData, cursor );
+ std::size_t upwardIndexBegin = dependencyStr.find("{",cursor) + 1;
+ std::size_t upwardIndexFinish = dependencyStr.find("}",upwardIndexBegin);
+ LevelsList upwardList = parseWard( dependencyStr, cursor );
- LevelsList downwardList = parseWard( theData, cursor );
+ LevelsList downwardList = parseWard( dependencyStr, cursor );
tree[objectEntry] = std::pair<LevelsList,LevelsList>( upwardList, downwardList );
}
}
+
+bool GEOMUtils::CheckShape( TopoDS_Shape& shape,
+ bool checkGeometry )
+{
+ BRepCheck_Analyzer analyzer( shape, checkGeometry );
+ return analyzer.IsValid();
+}
+
+bool GEOMUtils::FixShapeTolerance( TopoDS_Shape& shape,
+ TopAbs_ShapeEnum type,
+ Standard_Real tolerance )
+{
+ ShapeFix_ShapeTolerance aSft;
+ aSft.LimitTolerance( shape, tolerance, tolerance, type );
+ Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape( shape );
+ aSfs->Perform();
+ shape = aSfs->Shape();
+ return CheckShape( shape );
+}
+
+bool GEOMUtils::FixShapeTolerance( TopoDS_Shape& shape,
+ Standard_Real tolerance )
+{
+ return FixShapeTolerance( shape, TopAbs_SHAPE, tolerance );
+}
+
+bool GEOMUtils::FixShapeCurves( TopoDS_Shape& shape )
+{
+ Standard_Real aT, aTolE, aD, aDMax;
+ TopExp_Explorer aExpF, aExpE;
+ NCollection_DataMap<TopoDS_Edge, Standard_Real, TopTools_ShapeMapHasher> aDMETol;
+ aExpF.Init(shape, TopAbs_FACE);
+ for (; aExpF.More(); aExpF.Next()) {
+ const TopoDS_Face& aF = *(TopoDS_Face*)&aExpF.Current();
+ aExpE.Init(aF, TopAbs_EDGE);
+ for (; aExpE.More(); aExpE.Next()) {
+ const TopoDS_Edge& aE = *(TopoDS_Edge*)&aExpE.Current();
+ try {
+ if (!BOPTools_AlgoTools::ComputeTolerance(aF, aE, aDMax, aT)) {
+ continue;
+ }
+ }
+ catch(...) {
+ continue;
+ }
+ aTolE = BRep_Tool::Tolerance(aE);
+ if (aDMax < aTolE) continue;
+ if (aDMETol.IsBound(aE)) {
+ aD = aDMETol.Find(aE);
+ if (aDMax > aD) {
+ aDMETol.UnBind(aE);
+ aDMETol.Bind(aE, aDMax);
+ }
+ }
+ else {
+ aDMETol.Bind(aE, aDMax);
+ }
+ }
+ }
+ NCollection_DataMap<TopoDS_Edge, Standard_Real, TopTools_ShapeMapHasher>::Iterator aDMETolIt(aDMETol);
+#ifdef USE_LIMIT_TOLERANCE
+ ShapeFix_ShapeTolerance sat;
+#else
+ BRep_Builder b;
+#endif
+ for (; aDMETolIt.More(); aDMETolIt.Next()) {
+#ifdef USE_LIMIT_TOLERANCE
+ sat.LimitTolerance(aDMETolIt.Key(), aDMETolIt.Value()*1.001);
+#else
+ TopoDS_Iterator itv(aDMETolIt.Key());
+ for (; itv.More(); itv.Next())
+ b.UpdateVertex(TopoDS::Vertex(itv.Value()), aDMETolIt.Value()*1.001);
+ b.UpdateEdge(aDMETolIt.Key(), aDMETolIt.Value()*1.001);
+#endif
+ }
+ return CheckShape( shape );
+}
+
+bool GEOMUtils::Write( const TopoDS_Shape& shape, const char* fileName )
+{
+ return BRepTools::Write( shape, fileName );
+}
*/
Standard_EXPORT gp_Pnt ConvertClickToPoint( int x, int y, Handle(V3d_View) theView );
- Standard_EXPORT void ConvertTreeToString( const TreeModel &theTree,
- std::string &DependencyStr );
+ /*!
+ * \brief Convert dependency tree data to the string representation
+ *
+ * \param tree dependency tree data
+ * \param dependencyStr output string
+ */
+ Standard_EXPORT void ConvertTreeToString( const TreeModel& tree,
+ std::string& dependencyStr );
- Standard_EXPORT void ConvertStringToTree( const std::string &theDependencyStr,
- TreeModel &tree );
+ /*!
+ * \brief Restore dependency tree data from the string representation
+ *
+ * \param dependencyStr string representation of tree data
+ * \param tree output dependency tree data
+ */
+ Standard_EXPORT void ConvertStringToTree( const std::string& dependencyStr,
+ TreeModel& tree );
+ /*!
+ * \brief Check shape
+ *
+ * \param shape input shape object
+ * \param checkGeometry when set to \c true, causes check of underlying geometry
+ * in addition to the topology
+ * \return \c true if shape is valid or \c false otherwise
+ */
+ Standard_EXPORT bool CheckShape( TopoDS_Shape& shape, bool checkGeometry = false );
+
+ /*!
+ * \brief Limit shape tolerance to the given value
+ *
+ * \param shape shape being fixed
+ * \param type topology type which tolerance is to be limited; TopAbs_SHAPE means
+ * all types of topology
+ * \param tolerance expected tolerance value (1e-7 by default)
+ * \return \c true if resulting shape is valid
+ *
+ * \note Resulting tolerance of the shape is not mandatory equal to requested value
+ * as it might be changed by fixshape operation in order to get valid shape where possible
+ */
+ Standard_EXPORT bool FixShapeTolerance( TopoDS_Shape& shape,
+ TopAbs_ShapeEnum type,
+ Standard_Real tolerance = Precision::Confusion() );
+
+ /*!
+ * \brief Limit shape tolerance to the given value
+ * This is overloaded function, it behaves exactly as previous one
+ */
+ Standard_EXPORT bool FixShapeTolerance( TopoDS_Shape& shape,
+ Standard_Real tolerance = Precision::Confusion() );
+
+
+ /*!
+ * \brief Fix curves of the given shape
+ *
+ * The function checks each curve of the input shape in the following way:
+ * - compute deviation of the curve from the underlying surface in a set of points
+ * computed with the certain discretization step value
+ * - find maximum tolerance between computed deviation values
+ * - limit tolerance of the curve with the computed maximum value
+ *
+ * \param shape shape being fixed
+ * \return \c true if resulting shape is valid
+ */
+ Standard_EXPORT bool FixShapeCurves( TopoDS_Shape& shape );
+
+ /*!
+ * \brief Write shape to the BREP file
+ *
+ * \param source shape
+ * \return \c true if file was written or \c false otherwise
+ */
+ Standard_EXPORT bool Write( const TopoDS_Shape& shape,
+ const char* fileName );
};
#endif