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, false);
138 case SEWING_NON_MANIFOLD:
139 Sew(&HI, anOriginalShape, aShape, true);
142 AddPointOnEdge(&HI, anOriginalShape, aShape);
144 case CHANGE_ORIENTATION:
145 ChangeOrientation(&HI, anOriginalShape, aShape);
147 case LIMIT_TOLERANCE:
148 LimitTolerance(&HI, anOriginalShape, aShape);
150 case FUSE_COLLINEAR_EDGES:
152 Handle(TColStd_HSequenceOfTransient) aVerts = HI.GetShapes();
153 FuseCollinearEdges(anOriginalShape, aVerts, aShape);
161 raiseNotDoneExeption( ShHealOper_ErrorExecution );
163 aFunction->SetValue(aShape);
165 log.SetTouched(Label());
169 //=======================================================================
170 //function : ShapeProcess
172 //=======================================================================
173 Standard_Boolean GEOMImpl_HealingDriver::ShapeProcess (GEOMImpl_IHealing* theHI,
174 const TopoDS_Shape& theOriginalShape,
175 TopoDS_Shape& theOutShape) const
177 Handle(TColStd_HArray1OfExtendedString) anOperators = theHI->GetOperators();
178 Handle(TColStd_HArray1OfExtendedString) aParams = theHI->GetParameters();
179 Handle(TColStd_HArray1OfExtendedString) aValues = theHI->GetValues();
181 if (anOperators.IsNull() || anOperators->Length() <= 0)
182 return Standard_False;
184 Standard_Integer nbParams = 0, nbValues = 0;
185 if (!aParams.IsNull()) {
186 nbParams = aParams->Length();
188 if (!aValues.IsNull()) {
189 nbValues = aValues->Length();
191 if (nbParams != nbValues)
192 return Standard_False;
194 ShHealOper_ShapeProcess aHealer;
195 TColStd_SequenceOfAsciiString anOperatorsAS, aParamsAS, aValuesAS;
197 for (i = 1; i <= anOperators->Length(); i++)
198 anOperatorsAS.Append(TCollection_AsciiString(anOperators->Value(i)));
200 aHealer.SetOperators(anOperatorsAS);
202 for (i = 1; i <= nbParams; i++) {
203 aHealer.SetParameter(TCollection_AsciiString(aParams->Value(i)),
204 TCollection_AsciiString(aValues->Value(i)));
207 aHealer.Perform(theOriginalShape, theOutShape);
209 if (!aHealer.isDone())
210 raiseNotDoneExeption( ShHealOper_NotError );
212 return Standard_True;
215 //=======================================================================
216 //function : SupressFaces
218 //=======================================================================
219 void SuppressFacesRec (const TopTools_SequenceOfShape& theShapesFaces,
220 const TopoDS_Shape& theOriginalShape,
221 TopoDS_Shape& theOutShape)
223 if ((theOriginalShape.ShapeType() != TopAbs_COMPOUND &&
224 theOriginalShape.ShapeType() != TopAbs_COMPSOLID))
226 ShHealOper_RemoveFace aHealer (theOriginalShape);
227 Standard_Boolean aResult = aHealer.Perform(theShapesFaces);
230 theOutShape = aHealer.GetResultShape();
232 raiseNotDoneExeption(aHealer.GetErrorStatus());
240 TopTools_MapOfShape mapShape;
241 TopoDS_Iterator It (theOriginalShape, Standard_True, Standard_True);
243 for (; It.More(); It.Next()) {
244 TopoDS_Shape aShape_i = It.Value();
245 if (mapShape.Add(aShape_i)) {
246 // check, if current shape contains at least one of faces to be removed
247 bool isFound = false;
248 TopTools_IndexedMapOfShape aShapes_i;
249 TopExp::MapShapes(aShape_i, aShapes_i);
250 for (int i = 1; i <= theShapesFaces.Length() && !isFound; i++) {
251 const TopoDS_Shape& aFace_i = theShapesFaces.Value(i);
252 if (aShapes_i.Contains(aFace_i)) isFound = true;
255 TopoDS_Shape anOutSh_i;
256 SuppressFacesRec(theShapesFaces, aShape_i, anOutSh_i);
257 if ( !anOutSh_i.IsNull() )
258 BB.Add(CC, anOutSh_i);
262 BB.Add(CC, aShape_i);
270 Standard_Boolean GEOMImpl_HealingDriver::SuppressFaces (GEOMImpl_IHealing* theHI,
271 const TopoDS_Shape& theOriginalShape,
272 TopoDS_Shape& theOutShape) const
274 Handle(TColStd_HArray1OfInteger) aFaces = theHI->GetFaces();
276 Standard_Boolean aResult = Standard_False;
278 if (aFaces.IsNull()) {
279 ShHealOper_RemoveFace aHealer (theOriginalShape);
280 aResult = aHealer.Perform();
283 theOutShape = aHealer.GetResultShape();
285 raiseNotDoneExeption(aHealer.GetErrorStatus());
288 TopTools_SequenceOfShape aShapesFaces;
289 TopTools_IndexedMapOfShape aShapes;
290 TopExp::MapShapes(theOriginalShape, aShapes);
291 for (int i = 1; i <= aFaces->Length(); i++) {
292 int indexOfFace = aFaces->Value(i);
293 TopoDS_Shape aFace = aShapes.FindKey(indexOfFace);
294 aShapesFaces.Append(aFace);
296 SuppressFacesRec(aShapesFaces, theOriginalShape, theOutShape);
297 if ((theOriginalShape.ShapeType() == TopAbs_COMPOUND ||
298 theOriginalShape.ShapeType() == TopAbs_COMPSOLID)) {
299 TopoDS_Shape aSh = theOutShape;
300 theOutShape = GEOMImpl_GlueDriver::GlueFaces(aSh, Precision::Confusion(), Standard_True);
304 return Standard_True;
307 //=======================================================================
308 //function : CloseContour
310 //=======================================================================
311 Standard_Boolean GEOMImpl_HealingDriver::CloseContour (GEOMImpl_IHealing* theHI,
312 const TopoDS_Shape& theOriginalShape,
313 TopoDS_Shape& theOutShape) const
315 Standard_Boolean isByVertex = theHI->GetIsCommonVertex();
316 Handle(TColStd_HArray1OfInteger) aWires = theHI->GetWires();
318 ShHealOper_CloseContour aHealer (theOriginalShape);
320 Standard_Boolean aResult = Standard_False;
321 if ( aWires.IsNull() ) {
322 if ( theOriginalShape.ShapeType() == TopAbs_WIRE )
323 aResult = aHealer.Perform(TopoDS::Wire(theOriginalShape), isByVertex, !isByVertex);
326 TopTools_SequenceOfShape aShapesWires;
327 TopTools_IndexedMapOfShape aShapes;
328 TopExp::MapShapes(theOriginalShape, aShapes);
329 for (int i = 1; i <= aWires->Length(); i++) {
330 int indexOfWire = aWires->Value(i);
331 TopoDS_Shape aWire = aShapes.FindKey(indexOfWire);
332 aShapesWires.Append(aWire);
335 aResult = aHealer.Perform( aShapesWires, isByVertex, !isByVertex );
339 theOutShape = aHealer.GetResultShape();
341 raiseNotDoneExeption( aHealer.GetErrorStatus() );
346 //=======================================================================
347 //function : RemoveIntWires
349 //=======================================================================
350 Standard_Boolean GEOMImpl_HealingDriver::RemoveIntWires (GEOMImpl_IHealing* theHI,
351 const TopoDS_Shape& theOriginalShape,
352 TopoDS_Shape& theOutShape) const
354 Handle(TColStd_HArray1OfInteger) aWires = theHI->GetWires();
356 ShHealOper_RemoveInternalWires aHealer(theOriginalShape);
358 Standard_Boolean aResult = Standard_False;
359 if (aWires.IsNull()) { // remove all faces
360 aResult = aHealer.Remove();
362 TopTools_SequenceOfShape aShapesWires;
363 TopTools_IndexedMapOfShape aShapes;
364 TopExp::MapShapes(theOriginalShape, aShapes);
365 for (int i = 1; i <= aWires->Length(); i++) {
366 int indexOfWire = aWires->Value(i);
367 TopoDS_Shape aWire = aShapes.FindKey(indexOfWire);
368 aShapesWires.Append(aWire);
371 aResult = aHealer.Remove(aShapesWires);
375 theOutShape = aHealer.GetResultShape();
377 raiseNotDoneExeption( aHealer.GetErrorStatus() );
382 //=======================================================================
383 //function : RemoveHoles
385 //=======================================================================
386 Standard_Boolean GEOMImpl_HealingDriver::RemoveHoles (GEOMImpl_IHealing* theHI,
387 const TopoDS_Shape& theOriginalShape,
388 TopoDS_Shape& theOutShape) const
390 Handle(TColStd_HArray1OfInteger) aWires = theHI->GetWires();
392 ShHealOper_FillHoles aHealer (theOriginalShape);
394 Standard_Boolean aResult = Standard_False;
395 if (aWires.IsNull()) { // remove all faces
396 aResult = aHealer.Fill();
398 TopTools_SequenceOfShape aShapesWires;
399 TopTools_IndexedMapOfShape aShapes;
400 TopExp::MapShapes(theOriginalShape, aShapes);
401 for (int i = 1; i <= aWires->Length(); i++) {
402 int indexOfWire = aWires->Value(i);
403 TopoDS_Shape aWire = aShapes.FindKey(indexOfWire);
404 aShapesWires.Append(aWire);
407 aResult = aHealer.Fill(aShapesWires);
411 theOutShape = aHealer.GetResultShape();
413 raiseNotDoneExeption( aHealer.GetErrorStatus() );
418 //=======================================================================
421 //=======================================================================
422 Standard_Boolean GEOMImpl_HealingDriver::Sew (GEOMImpl_IHealing* theHI,
423 const TopoDS_Shape& theOriginalShape,
424 TopoDS_Shape& theOutShape,
425 Standard_Boolean isAllowNonManifold) const
427 Standard_Real aTol = theHI->GetTolerance();
429 ShHealOper_Sewing aHealer (theOriginalShape, aTol);
431 // Set non-manifold mode.
432 aHealer.SetNonManifoldMode(isAllowNonManifold);
434 Standard_Boolean aResult = aHealer.Perform();
437 theOutShape = aHealer.GetResultShape();
439 raiseNotDoneExeption( aHealer.GetErrorStatus() );
444 //=======================================================================
445 //function : AddPointOnEdge
447 //=======================================================================
448 Standard_Boolean GEOMImpl_HealingDriver::AddPointOnEdge (GEOMImpl_IHealing* theHI,
449 const TopoDS_Shape& theOriginalShape,
450 TopoDS_Shape& theOutShape) const
452 Standard_Boolean isByParameter = theHI->GetIsByParameter();
453 Standard_Integer anIndex = theHI->GetIndex();
454 Standard_Real aValue = theHI->GetDevideEdgeValue();
456 ShHealOper_EdgeDivide aHealer (theOriginalShape);
458 Standard_Boolean aResult = Standard_False;
459 if (anIndex == -1) { // apply algorythm for the whole shape which is EDGE
460 if (theOriginalShape.ShapeType() == TopAbs_EDGE)
461 aResult = aHealer.Perform(TopoDS::Edge(theOriginalShape), aValue, isByParameter);
463 TopTools_IndexedMapOfShape aShapes;
464 TopExp::MapShapes(theOriginalShape, aShapes);
465 TopoDS_Shape aEdgeShape = aShapes.FindKey(anIndex);
466 if (aEdgeShape.ShapeType() == TopAbs_EDGE)
467 aResult = aHealer.Perform(TopoDS::Edge(aEdgeShape), aValue, isByParameter);
471 theOutShape = aHealer.GetResultShape();
473 raiseNotDoneExeption( aHealer.GetErrorStatus() );
479 //=======================================================================
480 //function : ChangeOrientation
482 //=======================================================================
483 Standard_Boolean GEOMImpl_HealingDriver::ChangeOrientation (GEOMImpl_IHealing* theHI,
484 const TopoDS_Shape& theOriginalShape,
485 TopoDS_Shape& theOutShape) const
487 ShHealOper_ChangeOrientation aHealer (theOriginalShape);
489 Standard_Boolean aResult = aHealer.Perform();
492 theOutShape = aHealer.GetResultShape();
494 raiseNotDoneExeption( aHealer.GetErrorStatus() );
499 //=======================================================================
500 //function : LimitTolerance
502 //=======================================================================
503 void GEOMImpl_HealingDriver::LimitTolerance (GEOMImpl_IHealing* theHI,
504 const TopoDS_Shape& theOriginalShape,
505 TopoDS_Shape& theOutShape) const
507 Standard_Real aTol = theHI->GetTolerance();
508 if (aTol < Precision::Confusion())
509 aTol = Precision::Confusion();
511 // 1. Make a copy to prevent the original shape changes.
512 TopoDS_Shape aShapeCopy;
513 TColStd_IndexedDataMapOfTransientTransient aMapTShapes;
514 TNaming_CopyShape::CopyTool(theOriginalShape, aMapTShapes, aShapeCopy);
516 // 2. Limit tolerance.
517 ShapeFix_ShapeTolerance aSFT;
518 aSFT.LimitTolerance(aShapeCopy, aTol, aTol, TopAbs_SHAPE);
520 // 3. Fix obtained shape.
521 Handle(ShapeFix_Shape) aSfs = new ShapeFix_Shape (aShapeCopy);
523 theOutShape = aSfs->Shape();
525 BRepCheck_Analyzer ana (theOutShape, Standard_True);
527 StdFail_NotDone::Raise("Non valid shape result");
530 //=======================================================================
531 //function : FuseCollinearEdges
533 //=======================================================================
534 void GEOMImpl_HealingDriver::FuseCollinearEdges (const TopoDS_Shape& theOriginalShape,
535 const Handle(TColStd_HSequenceOfTransient)& aVerts,
536 TopoDS_Shape& theOutShape)
538 if (theOriginalShape.ShapeType() != TopAbs_WIRE)
539 Standard_TypeMismatch::Raise("Not a wire is given");
542 Standard_Real AngTol = Precision::Angular();
543 Standard_Real LinTol = Precision::Confusion();
545 for (TopExp_Explorer ExV (theOriginalShape, TopAbs_VERTEX); ExV.More(); ExV.Next()) {
546 TopoDS_Vertex Vertex = TopoDS::Vertex(ExV.Current());
547 tol = BRep_Tool::Tolerance(Vertex);
552 // 1. Make a copy to prevent the original shape changes.
554 TColStd_IndexedDataMapOfTransientTransient aMapTShapes;
555 TNaming_CopyShape::CopyTool(theOriginalShape, aMapTShapes, aWire);
556 TopoDS_Wire theWire = TopoDS::Wire(aWire);
558 // 2. Sub-shapes of the wire
559 TopTools_MapOfShape aMapToRemove;
561 TopTools_IndexedMapOfShape anOldIndices;
562 TopExp::MapShapes(theOriginalShape, anOldIndices);
564 TopTools_IndexedMapOfShape aNewIndices;
565 TopExp::MapShapes(theWire, aNewIndices);
567 // 3. Collect vertices of the wire, same or equal to the given vertices
568 bool removeAll = false;
569 if (aVerts.IsNull() || aVerts->Length() < 1)
573 for (unsigned int ind = 1; ind <= aVerts->Length(); ind++) {
574 Handle(GEOM_Function) aRefShape = Handle(GEOM_Function)::DownCast(aVerts->Value(ind));
575 TopoDS_Shape aShape_i = aRefShape->GetValue();
576 if (aShape_i.IsNull())
577 Standard_NullObject::Raise("Null vertex given");
578 if (aShape_i.ShapeType() != TopAbs_VERTEX)
579 Standard_TypeMismatch::Raise("Shape to suppress is not a vertex");
581 // find vertices shared with the initial wire
582 if (anOldIndices.Contains(aShape_i)) {
583 aMapToRemove.Add(aNewIndices.FindKey(anOldIndices.FindIndex(aShape_i)));
585 // try to find by coords in the new wire
586 TopoDS_Vertex aVert = TopoDS::Vertex(aShape_i);
587 gp_Pnt aP = BRep_Tool::Pnt(aVert);
589 bool isFound = false;
590 TopTools_MapOfShape mapShape;
591 TopExp_Explorer exp (theWire, TopAbs_VERTEX);
592 for (; exp.More() && !isFound; exp.Next()) {
593 if (mapShape.Add(exp.Current())) {
594 TopoDS_Vertex aVi = TopoDS::Vertex(exp.Current());
595 gp_Pnt aPi = BRep_Tool::Pnt(aVi);
596 if (aPi.Distance(aP) < LinTol) {
597 aMapToRemove.Add(aVi);
607 BRepLib::BuildCurves3d(theWire);
608 Handle(ShapeFix_Shape) Fixer = new ShapeFix_Shape(theWire);
609 Fixer->SetPrecision(LinTol);
610 Fixer->SetMaxTolerance(LinTol);
612 theWire = TopoDS::Wire(Fixer->Shape());
615 TopoDS_Edge prevEdge;
616 TopTools_ListOfShape finalList, currChain;
618 BRepTools_WireExplorer wexp (theWire);
620 prevEdge = wexp.Current();
621 currChain.Append(prevEdge);
625 Standard_NullObject::Raise("Empty wire given");
628 for (; wexp.More(); wexp.Next()) {
629 TopoDS_Edge anEdge = wexp.Current();
630 TopoDS_Vertex CurVertex = wexp.CurrentVertex();
632 bool continueChain = false;
633 if (aMapToRemove.Contains(CurVertex) || removeAll) {
634 // if C1 -> continue chain
635 if (AreEdgesC1(prevEdge, anEdge)) {
636 continueChain = true;
640 if (!continueChain) {
641 if (currChain.Extent() == 1) {
642 // add one edge to the final list
643 finalList.Append(currChain.First());
646 // make wire from the list of edges
648 TopoDS_Wire aCurrWire;
649 B.MakeWire(aCurrWire);
650 TopTools_ListIteratorOfListOfShape itEdges (currChain);
651 for (; itEdges.More(); itEdges.Next()) {
652 TopoDS_Shape aValue = itEdges.Value();
653 B.Add(aCurrWire, TopoDS::Edge(aValue));
656 // make edge from the wire
657 TopoDS_Edge anEdge = GEOMImpl_ShapeDriver::MakeEdgeFromWire(aCurrWire, LinTol, AngTol);
659 // add this new edge to the final list
660 finalList.Append(anEdge);
665 // add one edge to the chain
666 currChain.Append(anEdge);
670 if (currChain.Extent() == 1) {
671 // add one edge to the final list
672 finalList.Append(currChain.First());
675 // make wire from the list of edges
677 TopoDS_Wire aCurrWire;
678 B.MakeWire(aCurrWire);
679 TopTools_ListIteratorOfListOfShape itEdges (currChain);
680 for (; itEdges.More(); itEdges.Next()) {
681 TopoDS_Shape aValue = itEdges.Value();
682 B.Add(aCurrWire, TopoDS::Edge(aValue));
685 // make edge from the wire
686 TopoDS_Edge anEdge = GEOMImpl_ShapeDriver::MakeEdgeFromWire(aCurrWire, LinTol, AngTol);
688 // add this new edge to the final list
689 finalList.Append(anEdge);
693 TopoDS_Wire aFinalWire;
694 B.MakeWire(aFinalWire);
695 TopTools_ListIteratorOfListOfShape itEdges (finalList);
696 for (; itEdges.More(); itEdges.Next()) {
697 TopoDS_Shape aValue = itEdges.Value();
698 B.Add(aFinalWire, TopoDS::Edge(aValue));
700 theOutShape = aFinalWire;
702 BRepCheck_Analyzer ana (theOutShape, Standard_True);
704 StdFail_NotDone::Raise("Non valid shape result");
707 //=======================================================================
708 //function : AreEdgesC1
710 //=======================================================================
711 Standard_Boolean GEOMImpl_HealingDriver::AreEdgesC1 (const TopoDS_Edge& E1, const TopoDS_Edge& E2)
713 BRepAdaptor_Curve aCurve1 (E1);
714 BRepAdaptor_Curve aCurve2 (E2);
716 if (aCurve1.Continuity() == GeomAbs_C0 || aCurve2.Continuity() == GeomAbs_C0)
717 return Standard_False;
719 Standard_Real tol, tolMax = Precision::Confusion();
720 for (TopExp_Explorer ExV1 (E1, TopAbs_VERTEX); ExV1.More(); ExV1.Next()) {
721 TopoDS_Vertex Vertex = TopoDS::Vertex(ExV1.Current());
722 tol = BRep_Tool::Tolerance(Vertex);
726 for (TopExp_Explorer ExV2 (E2, TopAbs_VERTEX); ExV2.More(); ExV2.Next()) {
727 TopoDS_Vertex Vertex = TopoDS::Vertex(ExV2.Current());
728 tol = BRep_Tool::Tolerance(Vertex);
733 Standard_Real f1, l1, f2, l2;
734 f1 = aCurve1.FirstParameter();
735 l1 = aCurve1.LastParameter();
736 f2 = aCurve2.FirstParameter();
737 l2 = aCurve2.LastParameter();
740 Standard_Real tmp = f1;
746 Standard_Real tmp = f2;
751 gp_Pnt pf1, pl1, pf2, pl2;
752 gp_Vec vf1, vl1, vf2, vl2;
753 aCurve1.D1(f1, pf1, vf1);
754 aCurve1.D1(l1, pl1, vl1);
755 aCurve2.D1(f2, pf2, vf2);
756 aCurve2.D1(l2, pl2, vl2);
758 // pf1--->---pl1.pf2--->---pl2
759 if (pl1.SquareDistance(pf2) < tolMax*tolMax) {
760 if (vl1.Angle(vf2) < Precision::Angular())
761 return Standard_True;
763 // pl1---<---pf1.pf2--->---pl2
764 else if (pf1.SquareDistance(pf2) < tolMax*tolMax) {
765 if (vf1.Angle(-vf2) < Precision::Angular())
766 return Standard_True;
768 // pf1--->---pl1.pl2---<---pf2
769 else if (pl1.SquareDistance(pl2) < tolMax*tolMax) {
770 if (vl1.Angle(-vl2) < Precision::Angular())
771 return Standard_True;
773 // pl1---<---pf1.pl2---<---pf2
775 if (vf1.Angle(vl2) < Precision::Angular())
776 return Standard_True;
779 return Standard_False;
782 //=======================================================================
783 //function : GEOMImpl_HealingDriver_Type_
785 //=======================================================================
786 Standard_EXPORT Handle_Standard_Type& GEOMImpl_HealingDriver_Type_()
789 static Handle_Standard_Type aType1 = STANDARD_TYPE(TFunction_Driver);
790 if ( aType1.IsNull()) aType1 = STANDARD_TYPE(TFunction_Driver);
791 static Handle_Standard_Type aType2 = STANDARD_TYPE(MMgt_TShared);
792 if ( aType2.IsNull()) aType2 = STANDARD_TYPE(MMgt_TShared);
793 static Handle_Standard_Type aType3 = STANDARD_TYPE(Standard_Transient);
794 if ( aType3.IsNull()) aType3 = STANDARD_TYPE(Standard_Transient);
797 static Handle_Standard_Transient _Ancestors[]= {aType1,aType2,aType3,NULL};
798 static Handle_Standard_Type _aType = new Standard_Type("GEOMImpl_HealingDriver",
799 sizeof(GEOMImpl_HealingDriver),
801 (Standard_Address)_Ancestors,
802 (Standard_Address)NULL);
807 //=======================================================================
808 //function : DownCast
810 //=======================================================================
812 const Handle(GEOMImpl_HealingDriver) Handle(GEOMImpl_HealingDriver)::DownCast(const Handle(Standard_Transient)& AnObject)
814 Handle(GEOMImpl_HealingDriver) _anOtherObject;
816 if (!AnObject.IsNull()) {
817 if (AnObject->IsKind(STANDARD_TYPE(GEOMImpl_HealingDriver))) {
818 _anOtherObject = Handle(GEOMImpl_HealingDriver)((Handle(GEOMImpl_HealingDriver)&)AnObject);
822 return _anOtherObject;