-// Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#include <BRep_Builder.hxx>
#include <BRepAdaptor_Curve.hxx>
+#include <BRepBuilderAPI_Copy.hxx>
#include <BRepTools_WireExplorer.hxx>
#include <TopExp.hxx>
//=======================================================================
//function : raiseNotDoneExeption
-//purpose : global function: forms error message and raises exeption
+//purpose : global function: forms error message and raises exception
//=======================================================================
void raiseNotDoneExeption( const int theErrorStatus )
{
switch ( theErrorStatus )
{
- case ShHealOper_NotError: StdFail_NotDone::Raise( "ShHealOper_NotError_msg" );
- case ShHealOper_InvalidParameters: StdFail_NotDone::Raise( "ShHealOper_InvalidParameters_msg" );
+ case ShHealOper_NotError: StdFail_NotDone::Raise( "ShHealOper_NotError_msg" ); break;
+ case ShHealOper_InvalidParameters: StdFail_NotDone::Raise( "ShHealOper_InvalidParameters_msg" ); break;
case ShHealOper_ErrorExecution:
- default: StdFail_NotDone::Raise( "ShHealOper_ErrorExecution_msg" );
+ default: StdFail_NotDone::Raise( "ShHealOper_ErrorExecution_msg" ); break;
}
}
//function : Execute
//purpose :
//=======================================================================
-Standard_Integer GEOMImpl_HealingDriver::Execute(TFunction_Logbook& log) const
+Standard_Integer GEOMImpl_HealingDriver::Execute(Handle(TFunction_Logbook)& log) const
{
if (Label().IsNull()) return 0;
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
aFunction->SetValue(aShape);
- log.SetTouched(Label());
+ log->SetTouched(Label());
return 1;
}
//function : ChangeOrientation
//purpose :
//=======================================================================
-Standard_Boolean GEOMImpl_HealingDriver::ChangeOrientation (GEOMImpl_IHealing* theHI,
+Standard_Boolean GEOMImpl_HealingDriver::ChangeOrientation (GEOMImpl_IHealing* /*theHI*/,
const TopoDS_Shape& theOriginalShape,
TopoDS_Shape& theOutShape) const
{
// 1. Make a copy to prevent the original shape changes.
TopoDS_Shape aShapeCopy;
{
- TColStd_IndexedDataMapOfTransientTransient aMapTShapes;
- TNaming_CopyShape::CopyTool(theOriginalShape, aMapTShapes, aShapeCopy);
+ BRepBuilderAPI_Copy aMC (theOriginalShape);
+ if (aMC.IsDone()) {
+ aShapeCopy = aMC.Shape();
+ }
+ else {
+ TColStd_IndexedDataMapOfTransientTransient aMapTShapes;
+ TNaming_CopyShape::CopyTool(theOriginalShape, aMapTShapes, aShapeCopy);
+ }
}
// 2. Limit tolerance.
theWire = TopoDS::Wire(Fixer->Shape());
*/
- TopoDS_Edge prevEdge;
- TopTools_ListOfShape finalList, currChain;
+ // Get the ordered list of edges.
+ TopTools_ListOfShape anEdges;
+ TopTools_ListOfShape aCurVertices;
+ BRepTools_WireExplorer aWExp (theWire);
- BRepTools_WireExplorer wexp (theWire);
- if (wexp.More()) {
- prevEdge = wexp.Current();
- currChain.Append(prevEdge);
- wexp.Next();
+ for (; aWExp.More(); aWExp.Next()) {
+ anEdges.Append(aWExp.Current());
+ aCurVertices.Append(aWExp.CurrentVertex());
}
- else {
+
+ if (anEdges.IsEmpty()) {
Standard_NullObject::Raise("Empty wire given");
}
- for (; wexp.More(); wexp.Next()) {
- TopoDS_Edge anEdge = wexp.Current();
- TopoDS_Vertex CurVertex = wexp.CurrentVertex();
+ // Treat the case if the wire is closed and first and last edges are C1.
+ Standard_Boolean isShift = Standard_False;
+
+ if (BRep_Tool::IsClosed(theWire)) {
+ // Wire is closed. Check if there are more than 2 edges in the wire.
+ if (!anEdges.First().IsSame(anEdges.Last())) {
+ isShift = Standard_True;
+ }
+ }
+
+ if (isShift) {
+ // Put first edge to the end of the list while the chain break is reached.
+ TopoDS_Shape aFirstEdge = anEdges.First();
+
+ while (isShift) {
+ isShift = Standard_False;
+
+ // Check if the first vertex should be kept
+ if (aMapToRemove.Contains(aCurVertices.First()) || removeAll) {
+ // Check if first and last edges are C1.
+ TopoDS_Edge anEdge1 = TopoDS::Edge(anEdges.Last());
+ TopoDS_Edge anEdge2 = TopoDS::Edge(anEdges.First());
+
+ if (AreEdgesC1(anEdge1, anEdge2)) {
+ // Make the first edge last.
+ anEdges.Append(anEdge2);
+ anEdges.RemoveFirst();
+ aCurVertices.Append(aCurVertices.First());
+ aCurVertices.RemoveFirst();
+
+ // Check if we reached the first edge again.
+ // Break the loop in this case.
+ isShift = !aFirstEdge.IsSame(anEdges.First());
+ }
+ }
+ }
+ }
+
+ TopTools_ListOfShape finalList, currChain;
+ TopTools_ListIteratorOfListOfShape anEIter(anEdges);
+ TopTools_ListIteratorOfListOfShape aVIter(aCurVertices);
+ TopoDS_Edge prevEdge = TopoDS::Edge(anEIter.Value());
+
+ currChain.Append(prevEdge);
+ anEIter.Next();
+ aVIter.Next();
+
+ for (; anEIter.More(); anEIter.Next(), aVIter.Next()) {
+ TopoDS_Edge anEdge = TopoDS::Edge(anEIter.Value());
+ const TopoDS_Shape &aCurVertex = aVIter.Value();
bool continueChain = false;
- if (aMapToRemove.Contains(CurVertex) || removeAll) {
+ if (aMapToRemove.Contains(aCurVertex) || removeAll) {
// if C1 -> continue chain
if (AreEdgesC1(prevEdge, anEdge)) {
continueChain = true;
AddParam( theParams, "Operation", op );
for ( int iP = aParams->Lower(), nbP = aParams->Upper(); iP <= nbP; ++iP )
{
- const TCollection_ExtendedString& par = aParams->Value(i);
+ const TCollection_ExtendedString& par = aParams->Value(iP);
TCollection_AsciiString parAscii( par );
if ( par.Search( op ) == 1 && parAscii.Value( op.Length() + 1 ) == '.' )
{
*stats = healer.GetStatistics();
}
-IMPLEMENT_STANDARD_HANDLE (GEOMImpl_HealingDriver,GEOM_BaseDriver);
-
-IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_HealingDriver,GEOM_BaseDriver);
+IMPLEMENT_STANDARD_RTTIEXT (GEOMImpl_HealingDriver,GEOM_BaseDriver)