1 // Copyright (C) 2007-2012 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
22 #include <Standard_Stream.hxx>
24 #include <GEOMImpl_HealingDriver.hxx>
25 #include <GEOMImpl_Types.hxx>
26 #include <GEOMImpl_IHealing.hxx>
27 #include <GEOM_Function.hxx>
29 #include <GEOMImpl_GlueDriver.hxx>
30 #include <GEOMImpl_ShapeDriver.hxx>
32 #include <ShHealOper_ShapeProcess.hxx>
33 #include <ShHealOper_RemoveFace.hxx>
34 #include <ShHealOper_CloseContour.hxx>
35 #include <ShHealOper_RemoveInternalWires.hxx>
36 #include <ShHealOper_FillHoles.hxx>
37 #include <ShHealOper_Sewing.hxx>
38 #include <ShHealOper_EdgeDivide.hxx>
39 #include <ShHealOper_ChangeOrientation.hxx>
41 #include <TNaming_CopyShape.hxx>
43 #include <ShapeFix_ShapeTolerance.hxx>
44 #include <ShapeFix_Shape.hxx>
46 #include <BRep_Builder.hxx>
47 #include <BRepAdaptor_Curve.hxx>
48 #include <BRepCheck_Analyzer.hxx>
49 #include <BRepTools_WireExplorer.hxx>
52 #include <TopExp_Explorer.hxx>
54 #include <TopoDS_Iterator.hxx>
55 #include <TopTools_IndexedMapOfShape.hxx>
56 #include <TopTools_ListOfShape.hxx>
57 #include <TopTools_ListIteratorOfListOfShape.hxx>
59 #include <TColStd_IndexedDataMapOfTransientTransient.hxx>
61 #include <Precision.hxx>
63 #include <StdFail_NotDone.hxx>
64 #include <Standard_NullObject.hxx>
66 //=======================================================================
67 //function : raiseNotDoneExeption
68 //purpose : global function: forms error message and raises exeption
69 //=======================================================================
70 void raiseNotDoneExeption( const int theErrorStatus )
72 switch ( theErrorStatus )
74 case ShHealOper_NotError: StdFail_NotDone::Raise( "ShHealOper_NotError_msg" );
75 case ShHealOper_InvalidParameters: StdFail_NotDone::Raise( "ShHealOper_InvalidParameters_msg" );
76 case ShHealOper_ErrorExecution:
77 default: StdFail_NotDone::Raise( "ShHealOper_ErrorExecution_msg" );
81 //=======================================================================
84 //=======================================================================
85 const Standard_GUID& GEOMImpl_HealingDriver::GetID()
87 static Standard_GUID aHealingDriver("FF1BBB61-5D14-4df2-980B-3A668264EA16");
88 return aHealingDriver;
91 //=======================================================================
92 //function : GEOMImpl_HealingDriver
94 //=======================================================================
95 GEOMImpl_HealingDriver::GEOMImpl_HealingDriver()
99 //=======================================================================
102 //=======================================================================
103 Standard_Integer GEOMImpl_HealingDriver::Execute(TFunction_Logbook& log) const
105 if (Label().IsNull()) return 0;
106 Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
108 if (aFunction.IsNull()) return 0;
110 GEOMImpl_IHealing HI (aFunction);
111 Standard_Integer aType = aFunction->GetType();
112 Handle(GEOM_Function) anOriginalFunction = HI.GetOriginal();
113 if (anOriginalFunction.IsNull()) return 0;
114 TopoDS_Shape aShape, anOriginalShape = anOriginalFunction->GetValue();
115 if (anOriginalShape.IsNull()) return 0;
120 ShapeProcess(&HI, anOriginalShape, aShape);
123 SuppressFaces(&HI, anOriginalShape, aShape);
126 CloseContour(&HI, anOriginalShape, aShape);
128 case REMOVE_INT_WIRES:
129 RemoveIntWires(&HI, anOriginalShape, aShape);
132 RemoveHoles(&HI, anOriginalShape, aShape);
135 Sew(&HI, anOriginalShape, aShape);
138 AddPointOnEdge(&HI, anOriginalShape, aShape);
140 case CHANGE_ORIENTATION:
141 ChangeOrientation(&HI, anOriginalShape, aShape);
143 case LIMIT_TOLERANCE:
144 LimitTolerance(&HI, anOriginalShape, aShape);
146 case FUSE_COLLINEAR_EDGES:
148 Handle(TColStd_HSequenceOfTransient) aVerts = HI.GetShapes();
149 FuseCollinearEdges(anOriginalShape, aVerts, aShape);
157 raiseNotDoneExeption( ShHealOper_ErrorExecution );
159 aFunction->SetValue(aShape);
161 log.SetTouched(Label());
165 //=======================================================================
166 //function : ShapeProcess
168 //=======================================================================
169 Standard_Boolean GEOMImpl_HealingDriver::ShapeProcess (GEOMImpl_IHealing* theHI,
170 const TopoDS_Shape& theOriginalShape,
171 TopoDS_Shape& theOutShape) const
173 Handle(TColStd_HArray1OfExtendedString) anOperators = theHI->GetOperators();
174 Handle(TColStd_HArray1OfExtendedString) aParams = theHI->GetParameters();
175 Handle(TColStd_HArray1OfExtendedString) aValues = theHI->GetValues();
177 if (anOperators.IsNull() || anOperators->Length() <= 0)
178 return Standard_False;
180 Standard_Integer nbParams = 0, nbValues = 0;
181 if (!aParams.IsNull()) {
182 nbParams = aParams->Length();
184 if (!aValues.IsNull()) {
185 nbValues = aValues->Length();
187 if (nbParams != nbValues)
188 return Standard_False;
190 ShHealOper_ShapeProcess aHealer;
191 TColStd_SequenceOfAsciiString anOperatorsAS, aParamsAS, aValuesAS;
193 for (i = 1; i <= anOperators->Length(); i++)
194 anOperatorsAS.Append(TCollection_AsciiString(anOperators->Value(i)));
196 aHealer.SetOperators(anOperatorsAS);
198 for (i = 1; i <= nbParams; i++) {
199 aHealer.SetParameter(TCollection_AsciiString(aParams->Value(i)),
200 TCollection_AsciiString(aValues->Value(i)));
203 aHealer.Perform(theOriginalShape, theOutShape);
205 if (!aHealer.isDone())
206 raiseNotDoneExeption( ShHealOper_NotError );
208 return Standard_True;
211 //=======================================================================
212 //function : SupressFaces
214 //=======================================================================
215 void SuppressFacesRec (const TopTools_SequenceOfShape& theShapesFaces,
216 const TopoDS_Shape& theOriginalShape,
217 TopoDS_Shape& theOutShape)
219 if ((theOriginalShape.ShapeType() != TopAbs_COMPOUND &&
220 theOriginalShape.ShapeType() != TopAbs_COMPSOLID))
222 ShHealOper_RemoveFace aHealer (theOriginalShape);
223 Standard_Boolean aResult = aHealer.Perform(theShapesFaces);
226 theOutShape = aHealer.GetResultShape();
228 raiseNotDoneExeption(aHealer.GetErrorStatus());
236 TopTools_MapOfShape mapShape;
237 TopoDS_Iterator It (theOriginalShape, Standard_True, Standard_True);
239 for (; It.More(); It.Next()) {
240 TopoDS_Shape aShape_i = It.Value();
241 if (mapShape.Add(aShape_i)) {
242 // check, if current shape contains at least one of faces to be removed
243 bool isFound = false;
244 TopTools_IndexedMapOfShape aShapes_i;
245 TopExp::MapShapes(aShape_i, aShapes_i);
246 for (int i = 1; i <= theShapesFaces.Length() && !isFound; i++) {
247 const TopoDS_Shape& aFace_i = theShapesFaces.Value(i);
248 if (aShapes_i.Contains(aFace_i)) isFound = true;
251 TopoDS_Shape anOutSh_i;
252 SuppressFacesRec(theShapesFaces, aShape_i, anOutSh_i);
253 if ( !anOutSh_i.IsNull() )
254 BB.Add(CC, anOutSh_i);
258 BB.Add(CC, aShape_i);
266 Standard_Boolean GEOMImpl_HealingDriver::SuppressFaces (GEOMImpl_IHealing* theHI,
267 const TopoDS_Shape& theOriginalShape,
268 TopoDS_Shape& theOutShape) const
270 Handle(TColStd_HArray1OfInteger) aFaces = theHI->GetFaces();
272 Standard_Boolean aResult = Standard_False;
274 if (aFaces.IsNull()) {
275 ShHealOper_RemoveFace aHealer (theOriginalShape);
276 aResult = aHealer.Perform();
279 theOutShape = aHealer.GetResultShape();
281 raiseNotDoneExeption(aHealer.GetErrorStatus());
284 TopTools_SequenceOfShape aShapesFaces;
285 TopTools_IndexedMapOfShape aShapes;
286 TopExp::MapShapes(theOriginalShape, aShapes);
287 for (int i = 1; i <= aFaces->Length(); i++) {
288 int indexOfFace = aFaces->Value(i);
289 TopoDS_Shape aFace = aShapes.FindKey(indexOfFace);
290 aShapesFaces.Append(aFace);
292 SuppressFacesRec(aShapesFaces, theOriginalShape, theOutShape);
293 if ((theOriginalShape.ShapeType() == TopAbs_COMPOUND ||
294 theOriginalShape.ShapeType() == TopAbs_COMPSOLID)) {
295 TopoDS_Shape aSh = theOutShape;
296 theOutShape = GEOMImpl_GlueDriver::GlueFaces(aSh, Precision::Confusion(), Standard_True);
300 return Standard_True;
303 //=======================================================================
304 //function : CloseContour
306 //=======================================================================
307 Standard_Boolean GEOMImpl_HealingDriver::CloseContour (GEOMImpl_IHealing* theHI,
308 const TopoDS_Shape& theOriginalShape,
309 TopoDS_Shape& theOutShape) const
311 Standard_Boolean isByVertex = theHI->GetIsCommonVertex();
312 Handle(TColStd_HArray1OfInteger) aWires = theHI->GetWires();
314 ShHealOper_CloseContour aHealer (theOriginalShape);
316 Standard_Boolean aResult = Standard_False;
317 if ( aWires.IsNull() ) {
318 if ( theOriginalShape.ShapeType() == TopAbs_WIRE )
319 aResult = aHealer.Perform(TopoDS::Wire(theOriginalShape), isByVertex, !isByVertex);
322 TopTools_SequenceOfShape aShapesWires;
323 TopTools_IndexedMapOfShape aShapes;
324 TopExp::MapShapes(theOriginalShape, aShapes);
325 for (int i = 1; i <= aWires->Length(); i++) {
326 int indexOfWire = aWires->Value(i);
327 TopoDS_Shape aWire = aShapes.FindKey(indexOfWire);
328 aShapesWires.Append(aWire);
331 aResult = aHealer.Perform( aShapesWires, isByVertex, !isByVertex );
335 theOutShape = aHealer.GetResultShape();
337 raiseNotDoneExeption( aHealer.GetErrorStatus() );
342 //=======================================================================
343 //function : RemoveIntWires
345 //=======================================================================
346 Standard_Boolean GEOMImpl_HealingDriver::RemoveIntWires (GEOMImpl_IHealing* theHI,
347 const TopoDS_Shape& theOriginalShape,
348 TopoDS_Shape& theOutShape) const
350 Handle(TColStd_HArray1OfInteger) aWires = theHI->GetWires();
352 ShHealOper_RemoveInternalWires aHealer(theOriginalShape);
354 Standard_Boolean aResult = Standard_False;
355 if (aWires.IsNull()) { // remove all faces
356 aResult = aHealer.Remove();
358 TopTools_SequenceOfShape aShapesWires;
359 TopTools_IndexedMapOfShape aShapes;
360 TopExp::MapShapes(theOriginalShape, aShapes);
361 for (int i = 1; i <= aWires->Length(); i++) {
362 int indexOfWire = aWires->Value(i);
363 TopoDS_Shape aWire = aShapes.FindKey(indexOfWire);
364 aShapesWires.Append(aWire);
367 aResult = aHealer.Remove(aShapesWires);
371 theOutShape = aHealer.GetResultShape();
373 raiseNotDoneExeption( aHealer.GetErrorStatus() );
378 //=======================================================================
379 //function : RemoveHoles
381 //=======================================================================
382 Standard_Boolean GEOMImpl_HealingDriver::RemoveHoles (GEOMImpl_IHealing* theHI,
383 const TopoDS_Shape& theOriginalShape,
384 TopoDS_Shape& theOutShape) const
386 Handle(TColStd_HArray1OfInteger) aWires = theHI->GetWires();
388 ShHealOper_FillHoles aHealer (theOriginalShape);
390 Standard_Boolean aResult = Standard_False;
391 if (aWires.IsNull()) { // remove all faces
392 aResult = aHealer.Fill();
394 TopTools_SequenceOfShape aShapesWires;
395 TopTools_IndexedMapOfShape aShapes;
396 TopExp::MapShapes(theOriginalShape, aShapes);
397 for (int i = 1; i <= aWires->Length(); i++) {
398 int indexOfWire = aWires->Value(i);
399 TopoDS_Shape aWire = aShapes.FindKey(indexOfWire);
400 aShapesWires.Append(aWire);
403 aResult = aHealer.Fill(aShapesWires);
407 theOutShape = aHealer.GetResultShape();
409 raiseNotDoneExeption( aHealer.GetErrorStatus() );
414 //=======================================================================
417 //=======================================================================
418 Standard_Boolean GEOMImpl_HealingDriver::Sew (GEOMImpl_IHealing* theHI,
419 const TopoDS_Shape& theOriginalShape,
420 TopoDS_Shape& theOutShape) const
422 Standard_Real aTol = theHI->GetTolerance();
424 ShHealOper_Sewing aHealer (theOriginalShape, aTol);
426 Standard_Boolean aResult = aHealer.Perform();
429 theOutShape = aHealer.GetResultShape();
431 raiseNotDoneExeption( aHealer.GetErrorStatus() );
436 //=======================================================================
437 //function : AddPointOnEdge
439 //=======================================================================
440 Standard_Boolean GEOMImpl_HealingDriver::AddPointOnEdge (GEOMImpl_IHealing* theHI,
441 const TopoDS_Shape& theOriginalShape,
442 TopoDS_Shape& theOutShape) const
444 Standard_Boolean isByParameter = theHI->GetIsByParameter();
445 Standard_Integer anIndex = theHI->GetIndex();
446 Standard_Real aValue = theHI->GetDevideEdgeValue();
448 ShHealOper_EdgeDivide aHealer (theOriginalShape);
450 Standard_Boolean aResult = Standard_False;
451 if (anIndex == -1) { // apply algorythm for the whole shape which is EDGE
452 if (theOriginalShape.ShapeType() == TopAbs_EDGE)
453 aResult = aHealer.Perform(TopoDS::Edge(theOriginalShape), aValue, isByParameter);
455 TopTools_IndexedMapOfShape aShapes;
456 TopExp::MapShapes(theOriginalShape, aShapes);
457 TopoDS_Shape aEdgeShape = aShapes.FindKey(anIndex);
458 if (aEdgeShape.ShapeType() == TopAbs_EDGE)
459 aResult = aHealer.Perform(TopoDS::Edge(aEdgeShape), aValue, isByParameter);
463 theOutShape = aHealer.GetResultShape();
465 raiseNotDoneExeption( aHealer.GetErrorStatus() );
471 //=======================================================================
472 //function : ChangeOrientation
474 //=======================================================================
475 Standard_Boolean GEOMImpl_HealingDriver::ChangeOrientation (GEOMImpl_IHealing* theHI,
476 const TopoDS_Shape& theOriginalShape,
477 TopoDS_Shape& theOutShape) const
479 ShHealOper_ChangeOrientation aHealer (theOriginalShape);
481 Standard_Boolean aResult = aHealer.Perform();
484 theOutShape = aHealer.GetResultShape();
486 raiseNotDoneExeption( aHealer.GetErrorStatus() );
491 //=======================================================================
492 //function : LimitTolerance
494 //=======================================================================
495 void GEOMImpl_HealingDriver::LimitTolerance (GEOMImpl_IHealing* theHI,
496 const TopoDS_Shape& theOriginalShape,
497 TopoDS_Shape& theOutShape) const
499 Standard_Real aTol = theHI->GetTolerance();
500 if (aTol < Precision::Confusion())
501 aTol = Precision::Confusion();
503 // 1. Make a copy to prevent the original shape changes.
504 TopoDS_Shape aShapeCopy;
505 TColStd_IndexedDataMapOfTransientTransient aMapTShapes;
506 TNaming_CopyShape::CopyTool(theOriginalShape, aMapTShapes, aShapeCopy);
508 // 2. Limit tolerance.
509 ShapeFix_ShapeTolerance aSFT;
510 aSFT.LimitTolerance(aShapeCopy, aTol, aTol, TopAbs_SHAPE);
512 // 3. Fix obtained shape.
513 Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape (aShapeCopy);
515 theOutShape = aSfs->Shape();
517 BRepCheck_Analyzer ana (theOutShape, Standard_True);
519 StdFail_NotDone::Raise("Non valid shape result");
522 //=======================================================================
523 //function : FuseCollinearEdges
525 //=======================================================================
526 void GEOMImpl_HealingDriver::FuseCollinearEdges (const TopoDS_Shape& theOriginalShape,
527 const Handle(TColStd_HSequenceOfTransient)& aVerts,
528 TopoDS_Shape& theOutShape)
530 if (theOriginalShape.ShapeType() != TopAbs_WIRE)
531 Standard_TypeMismatch::Raise("Not a wire is given");
534 Standard_Real AngTol = Precision::Angular();
535 Standard_Real LinTol = Precision::Confusion();
537 for (TopExp_Explorer ExV (theOriginalShape, TopAbs_VERTEX); ExV.More(); ExV.Next()) {
538 TopoDS_Vertex Vertex = TopoDS::Vertex(ExV.Current());
539 tol = BRep_Tool::Tolerance(Vertex);
544 // 1. Make a copy to prevent the original shape changes.
546 TColStd_IndexedDataMapOfTransientTransient aMapTShapes;
547 TNaming_CopyShape::CopyTool(theOriginalShape, aMapTShapes, aWire);
548 TopoDS_Wire theWire = TopoDS::Wire(aWire);
550 // 2. Sub-shapes of the wire
551 TopTools_MapOfShape aMapToRemove;
553 TopTools_IndexedMapOfShape anOldIndices;
554 TopExp::MapShapes(theOriginalShape, anOldIndices);
556 TopTools_IndexedMapOfShape aNewIndices;
557 TopExp::MapShapes(theWire, aNewIndices);
559 // 3. Collect vertices of the wire, same or equal to the given vertices
560 bool removeAll = false;
561 if (aVerts.IsNull() || aVerts->Length() < 1)
565 for (unsigned int ind = 1; ind <= aVerts->Length(); ind++) {
566 Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aVerts->Value(ind));
567 TopoDS_Shape aShape_i = aRefShape->GetValue();
568 if (aShape_i.IsNull())
569 Standard_NullObject::Raise("Null vertex given");
570 if (aShape_i.ShapeType() != TopAbs_VERTEX)
571 Standard_TypeMismatch::Raise("Shape to suppress is not a vertex");
573 // find vertices shared with the initial wire
574 if (anOldIndices.Contains(aShape_i)) {
575 aMapToRemove.Add(aNewIndices.FindKey(anOldIndices.FindIndex(aShape_i)));
577 // try to find by coords in the new wire
578 TopoDS_Vertex aVert = TopoDS::Vertex(aShape_i);
579 gp_Pnt aP = BRep_Tool::Pnt(aVert);
581 bool isFound = false;
582 TopTools_MapOfShape mapShape;
583 TopExp_Explorer exp (theWire, TopAbs_VERTEX);
584 for (; exp.More() && !isFound; exp.Next()) {
585 if (mapShape.Add(exp.Current())) {
586 TopoDS_Vertex aVi = TopoDS::Vertex(exp.Current());
587 gp_Pnt aPi = BRep_Tool::Pnt(aVi);
588 if (aPi.Distance(aP) < LinTol) {
589 aMapToRemove.Add(aVi);
599 BRepLib::BuildCurves3d(theWire);
600 Handle(ShapeFix_Shape) Fixer = new ShapeFix_Shape(theWire);
601 Fixer->SetPrecision(LinTol);
602 Fixer->SetMaxTolerance(LinTol);
604 theWire = TopoDS::Wire(Fixer->Shape());
607 TopoDS_Edge prevEdge;
608 TopTools_ListOfShape finalList, currChain;
610 BRepTools_WireExplorer wexp (theWire);
612 prevEdge = wexp.Current();
613 currChain.Append(prevEdge);
617 Standard_NullObject::Raise("Empty wire given");
620 for (; wexp.More(); wexp.Next()) {
621 TopoDS_Edge anEdge = wexp.Current();
622 TopoDS_Vertex CurVertex = wexp.CurrentVertex();
624 bool continueChain = false;
625 if (aMapToRemove.Contains(CurVertex) || removeAll) {
626 // if C1 -> continue chain
627 if (AreEdgesC1(prevEdge, anEdge)) {
628 continueChain = true;
632 if (!continueChain) {
633 if (currChain.Extent() == 1) {
634 // add one edge to the final list
635 finalList.Append(currChain.First());
638 // make wire from the list of edges
640 TopoDS_Wire aCurrWire;
641 B.MakeWire(aCurrWire);
642 TopTools_ListIteratorOfListOfShape itEdges (currChain);
643 for (; itEdges.More(); itEdges.Next()) {
644 TopoDS_Shape aValue = itEdges.Value();
645 B.Add(aCurrWire, TopoDS::Edge(aValue));
648 // make edge from the wire
649 TopoDS_Edge anEdge = GEOMImpl_ShapeDriver::MakeEdgeFromWire(aCurrWire, LinTol, AngTol);
651 // add this new edge to the final list
652 finalList.Append(anEdge);
657 // add one edge to the chain
658 currChain.Append(anEdge);
662 if (currChain.Extent() == 1) {
663 // add one edge to the final list
664 finalList.Append(currChain.First());
667 // make wire from the list of edges
669 TopoDS_Wire aCurrWire;
670 B.MakeWire(aCurrWire);
671 TopTools_ListIteratorOfListOfShape itEdges (currChain);
672 for (; itEdges.More(); itEdges.Next()) {
673 TopoDS_Shape aValue = itEdges.Value();
674 B.Add(aCurrWire, TopoDS::Edge(aValue));
677 // make edge from the wire
678 TopoDS_Edge anEdge = GEOMImpl_ShapeDriver::MakeEdgeFromWire(aCurrWire, LinTol, AngTol);
680 // add this new edge to the final list
681 finalList.Append(anEdge);
685 TopoDS_Wire aFinalWire;
686 B.MakeWire(aFinalWire);
687 TopTools_ListIteratorOfListOfShape itEdges (finalList);
688 for (; itEdges.More(); itEdges.Next()) {
689 TopoDS_Shape aValue = itEdges.Value();
690 B.Add(aFinalWire, TopoDS::Edge(aValue));
692 theOutShape = aFinalWire;
694 BRepCheck_Analyzer ana (theOutShape, Standard_True);
696 StdFail_NotDone::Raise("Non valid shape result");
699 //=======================================================================
700 //function : AreEdgesC1
702 //=======================================================================
703 Standard_Boolean GEOMImpl_HealingDriver::AreEdgesC1 (const TopoDS_Edge& E1, const TopoDS_Edge& E2)
705 BRepAdaptor_Curve aCurve1 (E1);
706 BRepAdaptor_Curve aCurve2 (E2);
708 if (aCurve1.Continuity() == GeomAbs_C0 || aCurve2.Continuity() == GeomAbs_C0)
709 return Standard_False;
711 Standard_Real tol, tolMax = Precision::Confusion();
712 for (TopExp_Explorer ExV1 (E1, TopAbs_VERTEX); ExV1.More(); ExV1.Next()) {
713 TopoDS_Vertex Vertex = TopoDS::Vertex(ExV1.Current());
714 tol = BRep_Tool::Tolerance(Vertex);
718 for (TopExp_Explorer ExV2 (E2, TopAbs_VERTEX); ExV2.More(); ExV2.Next()) {
719 TopoDS_Vertex Vertex = TopoDS::Vertex(ExV2.Current());
720 tol = BRep_Tool::Tolerance(Vertex);
725 Standard_Real f1, l1, f2, l2;
726 f1 = aCurve1.FirstParameter();
727 l1 = aCurve1.LastParameter();
728 f2 = aCurve2.FirstParameter();
729 l2 = aCurve2.LastParameter();
732 Standard_Real tmp = f1;
738 Standard_Real tmp = f2;
743 gp_Pnt pf1, pl1, pf2, pl2;
744 gp_Vec vf1, vl1, vf2, vl2;
745 aCurve1.D1(f1, pf1, vf1);
746 aCurve1.D1(l1, pl1, vl1);
747 aCurve2.D1(f2, pf2, vf2);
748 aCurve2.D1(l2, pl2, vl2);
750 // pf1--->---pl1.pf2--->---pl2
751 if (pl1.SquareDistance(pf2) < tolMax*tolMax) {
752 if (vl1.Angle(vf2) < Precision::Angular())
753 return Standard_True;
755 // pl1---<---pf1.pf2--->---pl2
756 else if (pf1.SquareDistance(pf2) < tolMax*tolMax) {
757 if (vf1.Angle(-vf2) < Precision::Angular())
758 return Standard_True;
760 // pf1--->---pl1.pl2---<---pf2
761 else if (pl1.SquareDistance(pl2) < tolMax*tolMax) {
762 if (vl1.Angle(-vl2) < Precision::Angular())
763 return Standard_True;
765 // pl1---<---pf1.pl2---<---pf2
767 if (vf1.Angle(vl2) < Precision::Angular())
768 return Standard_True;
771 return Standard_False;
774 //=======================================================================
775 //function : GEOMImpl_HealingDriver_Type_
777 //=======================================================================
778 Standard_EXPORT Handle_Standard_Type& GEOMImpl_HealingDriver_Type_()
781 static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
782 if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
783 static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
784 if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
785 static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
786 if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
789 static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
790 static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_HealingDriver",
791 sizeof(GEOMImpl_HealingDriver),
793 (Standard_Address)_Ancestors,
794 (Standard_Address)NULL);
799 //=======================================================================
800 //function : DownCast
802 //=======================================================================
804 const Handle(GEOMImpl_HealingDriver) Handle(GEOMImpl_HealingDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
806 Handle(GEOMImpl_HealingDriver) _anOtherObject;
808 if (!AnObject.IsNull()) {
809 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_HealingDriver))) {
810 _anOtherObject = Handle(GEOMImpl_HealingDriver)((Handle(GEOMImpl_HealingDriver)&)AnObject);
814 return _anOtherObject;