1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 #include <Standard_Stream.hxx>
25 #include <GEOMImpl_HealingDriver.hxx>
26 #include <GEOMImpl_Types.hxx>
27 #include <GEOMImpl_IHealing.hxx>
28 #include <GEOM_Function.hxx>
30 #include <GEOMImpl_GlueDriver.hxx>
31 #include <GEOMImpl_ShapeDriver.hxx>
33 #include <ShHealOper_ShapeProcess.hxx>
34 #include <ShHealOper_RemoveFace.hxx>
35 #include <ShHealOper_CloseContour.hxx>
36 #include <ShHealOper_RemoveInternalWires.hxx>
37 #include <ShHealOper_FillHoles.hxx>
38 #include <ShHealOper_Sewing.hxx>
39 #include <ShHealOper_EdgeDivide.hxx>
40 #include <ShHealOper_ChangeOrientation.hxx>
42 #include <TNaming_CopyShape.hxx>
44 #include <ShapeFix_ShapeTolerance.hxx>
45 #include <ShapeFix_Shape.hxx>
47 #include <BRep_Builder.hxx>
48 #include <BRepAdaptor_Curve.hxx>
49 #include <BRepCheck_Analyzer.hxx>
50 #include <BRepTools_WireExplorer.hxx>
53 #include <TopExp_Explorer.hxx>
55 #include <TopoDS_Iterator.hxx>
56 #include <TopTools_IndexedMapOfShape.hxx>
57 #include <TopTools_ListOfShape.hxx>
58 #include <TopTools_ListIteratorOfListOfShape.hxx>
60 #include <TColStd_IndexedDataMapOfTransientTransient.hxx>
62 #include <Precision.hxx>
64 #include <StdFail_NotDone.hxx>
65 #include <Standard_NullObject.hxx>
67 //=======================================================================
68 //function : raiseNotDoneExeption
69 //purpose : global function: forms error message and raises exeption
70 //=======================================================================
71 void raiseNotDoneExeption( const int theErrorStatus )
73 switch ( theErrorStatus )
75 case ShHealOper_NotError: StdFail_NotDone::Raise( "ShHealOper_NotError_msg" );
76 case ShHealOper_InvalidParameters: StdFail_NotDone::Raise( "ShHealOper_InvalidParameters_msg" );
77 case ShHealOper_ErrorExecution:
78 default: StdFail_NotDone::Raise( "ShHealOper_ErrorExecution_msg" );
82 //=======================================================================
85 //=======================================================================
86 const Standard_GUID& GEOMImpl_HealingDriver::GetID()
88 static Standard_GUID aHealingDriver("FF1BBB61-5D14-4df2-980B-3A668264EA16");
89 return aHealingDriver;
92 //=======================================================================
93 //function : GEOMImpl_HealingDriver
95 //=======================================================================
96 GEOMImpl_HealingDriver::GEOMImpl_HealingDriver()
100 //=======================================================================
103 //=======================================================================
104 Standard_Integer GEOMImpl_HealingDriver::Execute(TFunction_Logbook& log) const
106 if (Label().IsNull()) return 0;
107 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
109 if (aFunction.IsNull()) return 0;
111 GEOMImpl_IHealing HI (aFunction);
112 Standard_Integer aType = aFunction->GetType();
113 Handle(GEOM_Function) anOriginalFunction = HI.GetOriginal();
114 if (anOriginalFunction.IsNull()) return 0;
115 TopoDS_Shape aShape, anOriginalShape = anOriginalFunction->GetValue();
116 if (anOriginalShape.IsNull()) return 0;
121 ShapeProcess(&HI, anOriginalShape, aShape);
124 SuppressFaces(&HI, anOriginalShape, aShape);
127 CloseContour(&HI, anOriginalShape, aShape);
129 case REMOVE_INT_WIRES:
130 RemoveIntWires(&HI, anOriginalShape, aShape);
133 RemoveHoles(&HI, anOriginalShape, aShape);
136 Sew(&HI, anOriginalShape, aShape);
139 AddPointOnEdge(&HI, anOriginalShape, aShape);
141 case CHANGE_ORIENTATION:
142 ChangeOrientation(&HI, anOriginalShape, aShape);
144 case LIMIT_TOLERANCE:
145 LimitTolerance(&HI, anOriginalShape, aShape);
147 case FUSE_COLLINEAR_EDGES:
149 Handle(TColStd_HSequenceOfTransient) aVerts = HI.GetShapes();
150 FuseCollinearEdges(anOriginalShape, aVerts, aShape);
158 raiseNotDoneExeption( ShHealOper_ErrorExecution );
160 aFunction->SetValue(aShape);
162 log.SetTouched(Label());
166 //=======================================================================
167 //function : ShapeProcess
169 //=======================================================================
170 Standard_Boolean GEOMImpl_HealingDriver::ShapeProcess (GEOMImpl_IHealing* theHI,
171 const TopoDS_Shape& theOriginalShape,
172 TopoDS_Shape& theOutShape) const
174 Handle(TColStd_HArray1OfExtendedString) anOperators = theHI->GetOperators();
175 Handle(TColStd_HArray1OfExtendedString) aParams = theHI->GetParameters();
176 Handle(TColStd_HArray1OfExtendedString) aValues = theHI->GetValues();
178 if (anOperators.IsNull() || anOperators->Length() <= 0)
179 return Standard_False;
181 Standard_Integer nbParams = 0, nbValues = 0;
182 if (!aParams.IsNull()) {
183 nbParams = aParams->Length();
185 if (!aValues.IsNull()) {
186 nbValues = aValues->Length();
188 if (nbParams != nbValues)
189 return Standard_False;
191 ShHealOper_ShapeProcess aHealer;
192 TColStd_SequenceOfAsciiString anOperatorsAS, aParamsAS, aValuesAS;
194 for (i = 1; i <= anOperators->Length(); i++)
195 anOperatorsAS.Append(TCollection_AsciiString(anOperators->Value(i)));
197 aHealer.SetOperators(anOperatorsAS);
199 for (i = 1; i <= nbParams; i++) {
200 aHealer.SetParameter(TCollection_AsciiString(aParams->Value(i)),
201 TCollection_AsciiString(aValues->Value(i)));
204 aHealer.Perform(theOriginalShape, theOutShape);
206 if (!aHealer.isDone())
207 raiseNotDoneExeption( ShHealOper_NotError );
209 return Standard_True;
212 //=======================================================================
213 //function : SupressFaces
215 //=======================================================================
216 void SuppressFacesRec (const TopTools_SequenceOfShape& theShapesFaces,
217 const TopoDS_Shape& theOriginalShape,
218 TopoDS_Shape& theOutShape)
220 if ((theOriginalShape.ShapeType() != TopAbs_COMPOUND &&
221 theOriginalShape.ShapeType() != TopAbs_COMPSOLID))
223 ShHealOper_RemoveFace aHealer (theOriginalShape);
224 Standard_Boolean aResult = aHealer.Perform(theShapesFaces);
227 theOutShape = aHealer.GetResultShape();
229 raiseNotDoneExeption(aHealer.GetErrorStatus());
237 TopTools_MapOfShape mapShape;
238 TopoDS_Iterator It (theOriginalShape, Standard_True, Standard_True);
240 for (; It.More(); It.Next()) {
241 TopoDS_Shape aShape_i = It.Value();
242 if (mapShape.Add(aShape_i)) {
243 // check, if current shape contains at least one of faces to be removed
244 bool isFound = false;
245 TopTools_IndexedMapOfShape aShapes_i;
246 TopExp::MapShapes(aShape_i, aShapes_i);
247 for (int i = 1; i <= theShapesFaces.Length() && !isFound; i++) {
248 const TopoDS_Shape& aFace_i = theShapesFaces.Value(i);
249 if (aShapes_i.Contains(aFace_i)) isFound = true;
252 TopoDS_Shape anOutSh_i;
253 SuppressFacesRec(theShapesFaces, aShape_i, anOutSh_i);
254 if ( !anOutSh_i.IsNull() )
255 BB.Add(CC, anOutSh_i);
259 BB.Add(CC, aShape_i);
267 Standard_Boolean GEOMImpl_HealingDriver::SuppressFaces (GEOMImpl_IHealing* theHI,
268 const TopoDS_Shape& theOriginalShape,
269 TopoDS_Shape& theOutShape) const
271 Handle(TColStd_HArray1OfInteger) aFaces = theHI->GetFaces();
273 Standard_Boolean aResult = Standard_False;
275 if (aFaces.IsNull()) {
276 ShHealOper_RemoveFace aHealer (theOriginalShape);
277 aResult = aHealer.Perform();
280 theOutShape = aHealer.GetResultShape();
282 raiseNotDoneExeption(aHealer.GetErrorStatus());
285 TopTools_SequenceOfShape aShapesFaces;
286 TopTools_IndexedMapOfShape aShapes;
287 TopExp::MapShapes(theOriginalShape, aShapes);
288 for (int i = 1; i <= aFaces->Length(); i++) {
289 int indexOfFace = aFaces->Value(i);
290 TopoDS_Shape aFace = aShapes.FindKey(indexOfFace);
291 aShapesFaces.Append(aFace);
293 SuppressFacesRec(aShapesFaces, theOriginalShape, theOutShape);
294 if ((theOriginalShape.ShapeType() == TopAbs_COMPOUND ||
295 theOriginalShape.ShapeType() == TopAbs_COMPSOLID)) {
296 TopoDS_Shape aSh = theOutShape;
297 theOutShape = GEOMImpl_GlueDriver::GlueFaces(aSh, Precision::Confusion(), Standard_True);
301 return Standard_True;
304 //=======================================================================
305 //function : CloseContour
307 //=======================================================================
308 Standard_Boolean GEOMImpl_HealingDriver::CloseContour (GEOMImpl_IHealing* theHI,
309 const TopoDS_Shape& theOriginalShape,
310 TopoDS_Shape& theOutShape) const
312 Standard_Boolean isByVertex = theHI->GetIsCommonVertex();
313 Handle(TColStd_HArray1OfInteger) aWires = theHI->GetWires();
315 ShHealOper_CloseContour aHealer (theOriginalShape);
317 Standard_Boolean aResult = Standard_False;
318 if ( aWires.IsNull() ) {
319 if ( theOriginalShape.ShapeType() == TopAbs_WIRE )
320 aResult = aHealer.Perform(TopoDS::Wire(theOriginalShape), isByVertex, !isByVertex);
323 TopTools_SequenceOfShape aShapesWires;
324 TopTools_IndexedMapOfShape aShapes;
325 TopExp::MapShapes(theOriginalShape, aShapes);
326 for (int i = 1; i <= aWires->Length(); i++) {
327 int indexOfWire = aWires->Value(i);
328 TopoDS_Shape aWire = aShapes.FindKey(indexOfWire);
329 aShapesWires.Append(aWire);
332 aResult = aHealer.Perform( aShapesWires, isByVertex, !isByVertex );
336 theOutShape = aHealer.GetResultShape();
338 raiseNotDoneExeption( aHealer.GetErrorStatus() );
343 //=======================================================================
344 //function : RemoveIntWires
346 //=======================================================================
347 Standard_Boolean GEOMImpl_HealingDriver::RemoveIntWires (GEOMImpl_IHealing* theHI,
348 const TopoDS_Shape& theOriginalShape,
349 TopoDS_Shape& theOutShape) const
351 Handle(TColStd_HArray1OfInteger) aWires = theHI->GetWires();
353 ShHealOper_RemoveInternalWires aHealer(theOriginalShape);
355 Standard_Boolean aResult = Standard_False;
356 if (aWires.IsNull()) { // remove all faces
357 aResult = aHealer.Remove();
359 TopTools_SequenceOfShape aShapesWires;
360 TopTools_IndexedMapOfShape aShapes;
361 TopExp::MapShapes(theOriginalShape, aShapes);
362 for (int i = 1; i <= aWires->Length(); i++) {
363 int indexOfWire = aWires->Value(i);
364 TopoDS_Shape aWire = aShapes.FindKey(indexOfWire);
365 aShapesWires.Append(aWire);
368 aResult = aHealer.Remove(aShapesWires);
372 theOutShape = aHealer.GetResultShape();
374 raiseNotDoneExeption( aHealer.GetErrorStatus() );
379 //=======================================================================
380 //function : RemoveHoles
382 //=======================================================================
383 Standard_Boolean GEOMImpl_HealingDriver::RemoveHoles (GEOMImpl_IHealing* theHI,
384 const TopoDS_Shape& theOriginalShape,
385 TopoDS_Shape& theOutShape) const
387 Handle(TColStd_HArray1OfInteger) aWires = theHI->GetWires();
389 ShHealOper_FillHoles aHealer (theOriginalShape);
391 Standard_Boolean aResult = Standard_False;
392 if (aWires.IsNull()) { // remove all faces
393 aResult = aHealer.Fill();
395 TopTools_SequenceOfShape aShapesWires;
396 TopTools_IndexedMapOfShape aShapes;
397 TopExp::MapShapes(theOriginalShape, aShapes);
398 for (int i = 1; i <= aWires->Length(); i++) {
399 int indexOfWire = aWires->Value(i);
400 TopoDS_Shape aWire = aShapes.FindKey(indexOfWire);
401 aShapesWires.Append(aWire);
404 aResult = aHealer.Fill(aShapesWires);
408 theOutShape = aHealer.GetResultShape();
410 raiseNotDoneExeption( aHealer.GetErrorStatus() );
415 //=======================================================================
418 //=======================================================================
419 Standard_Boolean GEOMImpl_HealingDriver::Sew (GEOMImpl_IHealing* theHI,
420 const TopoDS_Shape& theOriginalShape,
421 TopoDS_Shape& theOutShape) const
423 Standard_Real aTol = theHI->GetTolerance();
425 ShHealOper_Sewing aHealer (theOriginalShape, aTol);
427 Standard_Boolean aResult = aHealer.Perform();
430 theOutShape = aHealer.GetResultShape();
432 raiseNotDoneExeption( aHealer.GetErrorStatus() );
437 //=======================================================================
438 //function : AddPointOnEdge
440 //=======================================================================
441 Standard_Boolean GEOMImpl_HealingDriver::AddPointOnEdge (GEOMImpl_IHealing* theHI,
442 const TopoDS_Shape& theOriginalShape,
443 TopoDS_Shape& theOutShape) const
445 Standard_Boolean isByParameter = theHI->GetIsByParameter();
446 Standard_Integer anIndex = theHI->GetIndex();
447 Standard_Real aValue = theHI->GetDevideEdgeValue();
449 ShHealOper_EdgeDivide aHealer (theOriginalShape);
451 Standard_Boolean aResult = Standard_False;
452 if (anIndex == -1) { // apply algorythm for the whole shape which is EDGE
453 if (theOriginalShape.ShapeType() == TopAbs_EDGE)
454 aResult = aHealer.Perform(TopoDS::Edge(theOriginalShape), aValue, isByParameter);
456 TopTools_IndexedMapOfShape aShapes;
457 TopExp::MapShapes(theOriginalShape, aShapes);
458 TopoDS_Shape aEdgeShape = aShapes.FindKey(anIndex);
459 if (aEdgeShape.ShapeType() == TopAbs_EDGE)
460 aResult = aHealer.Perform(TopoDS::Edge(aEdgeShape), aValue, isByParameter);
464 theOutShape = aHealer.GetResultShape();
466 raiseNotDoneExeption( aHealer.GetErrorStatus() );
472 //=======================================================================
473 //function : ChangeOrientation
475 //=======================================================================
476 Standard_Boolean GEOMImpl_HealingDriver::ChangeOrientation (GEOMImpl_IHealing* theHI,
477 const TopoDS_Shape& theOriginalShape,
478 TopoDS_Shape& theOutShape) const
480 ShHealOper_ChangeOrientation aHealer (theOriginalShape);
482 Standard_Boolean aResult = aHealer.Perform();
485 theOutShape = aHealer.GetResultShape();
487 raiseNotDoneExeption( aHealer.GetErrorStatus() );
492 //=======================================================================
493 //function : LimitTolerance
495 //=======================================================================
496 void GEOMImpl_HealingDriver::LimitTolerance (GEOMImpl_IHealing* theHI,
497 const TopoDS_Shape& theOriginalShape,
498 TopoDS_Shape& theOutShape) const
500 Standard_Real aTol = theHI->GetTolerance();
501 if (aTol < Precision::Confusion())
502 aTol = Precision::Confusion();
504 // 1. Make a copy to prevent the original shape changes.
505 TopoDS_Shape aShapeCopy;
506 TColStd_IndexedDataMapOfTransientTransient aMapTShapes;
507 TNaming_CopyShape::CopyTool(theOriginalShape, aMapTShapes, aShapeCopy);
509 // 2. Limit tolerance.
510 ShapeFix_ShapeTolerance aSFT;
511 aSFT.LimitTolerance(aShapeCopy, aTol, aTol, TopAbs_SHAPE);
513 // 3. Fix obtained shape.
514 Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape (aShapeCopy);
516 theOutShape = aSfs->Shape();
518 BRepCheck_Analyzer ana (theOutShape, Standard_True);
520 StdFail_NotDone::Raise("Non valid shape result");
523 //=======================================================================
524 //function : FuseCollinearEdges
526 //=======================================================================
527 void GEOMImpl_HealingDriver::FuseCollinearEdges (const TopoDS_Shape& theOriginalShape,
528 const Handle(TColStd_HSequenceOfTransient)& aVerts,
529 TopoDS_Shape& theOutShape)
531 if (theOriginalShape.ShapeType() != TopAbs_WIRE)
532 Standard_TypeMismatch::Raise("Not a wire is given");
535 Standard_Real AngTol = Precision::Angular();
536 Standard_Real LinTol = Precision::Confusion();
538 for (TopExp_Explorer ExV (theOriginalShape, TopAbs_VERTEX); ExV.More(); ExV.Next()) {
539 TopoDS_Vertex Vertex = TopoDS::Vertex(ExV.Current());
540 tol = BRep_Tool::Tolerance(Vertex);
545 // 1. Make a copy to prevent the original shape changes.
547 TColStd_IndexedDataMapOfTransientTransient aMapTShapes;
548 TNaming_CopyShape::CopyTool(theOriginalShape, aMapTShapes, aWire);
549 TopoDS_Wire theWire = TopoDS::Wire(aWire);
551 // 2. Sub-shapes of the wire
552 TopTools_MapOfShape aMapToRemove;
554 TopTools_IndexedMapOfShape anOldIndices;
555 TopExp::MapShapes(theOriginalShape, anOldIndices);
557 TopTools_IndexedMapOfShape aNewIndices;
558 TopExp::MapShapes(theWire, aNewIndices);
560 // 3. Collect vertices of the wire, same or equal to the given vertices
561 bool removeAll = false;
562 if (aVerts.IsNull() || aVerts->Length() < 1)
566 for (unsigned int ind = 1; ind <= aVerts->Length(); ind++) {
567 Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aVerts->Value(ind));
568 TopoDS_Shape aShape_i = aRefShape->GetValue();
569 if (aShape_i.IsNull())
570 Standard_NullObject::Raise("Null vertex given");
571 if (aShape_i.ShapeType() != TopAbs_VERTEX)
572 Standard_TypeMismatch::Raise("Shape to suppress is not a vertex");
574 // find vertices shared with the initial wire
575 if (anOldIndices.Contains(aShape_i)) {
576 aMapToRemove.Add(aNewIndices.FindKey(anOldIndices.FindIndex(aShape_i)));
578 // try to find by coords in the new wire
579 TopoDS_Vertex aVert = TopoDS::Vertex(aShape_i);
580 gp_Pnt aP = BRep_Tool::Pnt(aVert);
582 bool isFound = false;
583 TopTools_MapOfShape mapShape;
584 TopExp_Explorer exp (theWire, TopAbs_VERTEX);
585 for (; exp.More() && !isFound; exp.Next()) {
586 if (mapShape.Add(exp.Current())) {
587 TopoDS_Vertex aVi = TopoDS::Vertex(exp.Current());
588 gp_Pnt aPi = BRep_Tool::Pnt(aVi);
589 if (aPi.Distance(aP) < LinTol) {
590 aMapToRemove.Add(aVi);
600 BRepLib::BuildCurves3d(theWire);
601 Handle(ShapeFix_Shape) Fixer = new ShapeFix_Shape(theWire);
602 Fixer->SetPrecision(LinTol);
603 Fixer->SetMaxTolerance(LinTol);
605 theWire = TopoDS::Wire(Fixer->Shape());
608 TopoDS_Edge prevEdge;
609 TopTools_ListOfShape finalList, currChain;
611 BRepTools_WireExplorer wexp (theWire);
613 prevEdge = wexp.Current();
614 currChain.Append(prevEdge);
618 Standard_NullObject::Raise("Empty wire given");
621 for (; wexp.More(); wexp.Next()) {
622 TopoDS_Edge anEdge = wexp.Current();
623 TopoDS_Vertex CurVertex = wexp.CurrentVertex();
625 bool continueChain = false;
626 if (aMapToRemove.Contains(CurVertex) || removeAll) {
627 // if C1 -> continue chain
628 if (AreEdgesC1(prevEdge, anEdge)) {
629 continueChain = true;
633 if (!continueChain) {
634 if (currChain.Extent() == 1) {
635 // add one edge to the final list
636 finalList.Append(currChain.First());
639 // make wire from the list of edges
641 TopoDS_Wire aCurrWire;
642 B.MakeWire(aCurrWire);
643 TopTools_ListIteratorOfListOfShape itEdges (currChain);
644 for (; itEdges.More(); itEdges.Next()) {
645 TopoDS_Shape aValue = itEdges.Value();
646 B.Add(aCurrWire, TopoDS::Edge(aValue));
649 // make edge from the wire
650 TopoDS_Edge anEdge = GEOMImpl_ShapeDriver::MakeEdgeFromWire(aCurrWire, LinTol, AngTol);
652 // add this new edge to the final list
653 finalList.Append(anEdge);
658 // add one edge to the chain
659 currChain.Append(anEdge);
663 if (currChain.Extent() == 1) {
664 // add one edge to the final list
665 finalList.Append(currChain.First());
668 // make wire from the list of edges
670 TopoDS_Wire aCurrWire;
671 B.MakeWire(aCurrWire);
672 TopTools_ListIteratorOfListOfShape itEdges (currChain);
673 for (; itEdges.More(); itEdges.Next()) {
674 TopoDS_Shape aValue = itEdges.Value();
675 B.Add(aCurrWire, TopoDS::Edge(aValue));
678 // make edge from the wire
679 TopoDS_Edge anEdge = GEOMImpl_ShapeDriver::MakeEdgeFromWire(aCurrWire, LinTol, AngTol);
681 // add this new edge to the final list
682 finalList.Append(anEdge);
686 TopoDS_Wire aFinalWire;
687 B.MakeWire(aFinalWire);
688 TopTools_ListIteratorOfListOfShape itEdges (finalList);
689 for (; itEdges.More(); itEdges.Next()) {
690 TopoDS_Shape aValue = itEdges.Value();
691 B.Add(aFinalWire, TopoDS::Edge(aValue));
693 theOutShape = aFinalWire;
695 BRepCheck_Analyzer ana (theOutShape, Standard_True);
697 StdFail_NotDone::Raise("Non valid shape result");
700 //=======================================================================
701 //function : AreEdgesC1
703 //=======================================================================
704 Standard_Boolean GEOMImpl_HealingDriver::AreEdgesC1 (const TopoDS_Edge& E1, const TopoDS_Edge& E2)
706 BRepAdaptor_Curve aCurve1 (E1);
707 BRepAdaptor_Curve aCurve2 (E2);
709 if (aCurve1.Continuity() == GeomAbs_C0 || aCurve2.Continuity() == GeomAbs_C0)
710 return Standard_False;
712 Standard_Real tol, tolMax = Precision::Confusion();
713 for (TopExp_Explorer ExV1 (E1, TopAbs_VERTEX); ExV1.More(); ExV1.Next()) {
714 TopoDS_Vertex Vertex = TopoDS::Vertex(ExV1.Current());
715 tol = BRep_Tool::Tolerance(Vertex);
719 for (TopExp_Explorer ExV2 (E2, TopAbs_VERTEX); ExV2.More(); ExV2.Next()) {
720 TopoDS_Vertex Vertex = TopoDS::Vertex(ExV2.Current());
721 tol = BRep_Tool::Tolerance(Vertex);
726 Standard_Real f1, l1, f2, l2;
727 f1 = aCurve1.FirstParameter();
728 l1 = aCurve1.LastParameter();
729 f2 = aCurve2.FirstParameter();
730 l2 = aCurve2.LastParameter();
733 Standard_Real tmp = f1;
739 Standard_Real tmp = f2;
744 gp_Pnt pf1, pl1, pf2, pl2;
745 gp_Vec vf1, vl1, vf2, vl2;
746 aCurve1.D1(f1, pf1, vf1);
747 aCurve1.D1(l1, pl1, vl1);
748 aCurve2.D1(f2, pf2, vf2);
749 aCurve2.D1(l2, pl2, vl2);
751 // pf1--->---pl1.pf2--->---pl2
752 if (pl1.SquareDistance(pf2) < tolMax*tolMax) {
753 if (vl1.Angle(vf2) < Precision::Angular())
754 return Standard_True;
756 // pl1---<---pf1.pf2--->---pl2
757 else if (pf1.SquareDistance(pf2) < tolMax*tolMax) {
758 if (vf1.Angle(-vf2) < Precision::Angular())
759 return Standard_True;
761 // pf1--->---pl1.pl2---<---pf2
762 else if (pl1.SquareDistance(pl2) < tolMax*tolMax) {
763 if (vl1.Angle(-vl2) < Precision::Angular())
764 return Standard_True;
766 // pl1---<---pf1.pl2---<---pf2
768 if (vf1.Angle(vl2) < Precision::Angular())
769 return Standard_True;
772 return Standard_False;
775 //=======================================================================
776 //function : GEOMImpl_HealingDriver_Type_
778 //=======================================================================
779 Standard_EXPORT Handle_Standard_Type& GEOMImpl_HealingDriver_Type_()
782 static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
783 if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
784 static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
785 if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
786 static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
787 if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
790 static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
791 static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_HealingDriver",
792 sizeof(GEOMImpl_HealingDriver),
794 (Standard_Address)_Ancestors,
795 (Standard_Address)NULL);
800 //=======================================================================
801 //function : DownCast
803 //=======================================================================
805 const Handle(GEOMImpl_HealingDriver) Handle(GEOMImpl_HealingDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
807 Handle(GEOMImpl_HealingDriver) _anOtherObject;
809 if (!AnObject.IsNull()) {
810 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_HealingDriver))) {
811 _anOtherObject = Handle(GEOMImpl_HealingDriver)((Handle(GEOMImpl_HealingDriver)&)AnObject);
815 return _anOtherObject;