]> OCCT Git - occt-copy.git/commitdiff
Branch for version 6.6.0
authorjgv <jgv@opencascade.com>
Fri, 3 Oct 2014 13:03:10 +0000 (17:03 +0400)
committerbugmaster <bugmaster@opencascade.com>
Tue, 7 Oct 2014 11:12:27 +0000 (15:12 +0400)
13 files changed:
src/BRepFill/BRepFill_OffsetWire.cdl
src/BRepFill/BRepFill_OffsetWire.cxx
src/BRepOffsetAPI/BRepOffsetAPI_MakeOffset.cdl
src/BRepOffsetAPI/BRepOffsetAPI_MakeOffset.cxx
src/BRepTest/BRepTest_CurveCommands.cxx
src/BRepTest/BRepTest_MatCommands.cxx
src/MAT2d/MAT2d.cdl
src/MAT2d/MAT2d_BisectingLocus.cdl
src/MAT2d/MAT2d_BisectingLocus.gxx
src/MAT2d/MAT2d_Circuit.cdl
src/MAT2d/MAT2d_Circuit.cxx
src/MAT2d/MAT2d_Tool2d.cdl
src/MAT2d/MAT2d_Tool2d.cxx

index 8c2af33c91b1de32d4e840b5ed8c37bc14d215f0..092db05eeb61d43ac8b0742d53df489d9f1b287f 100755 (executable)
@@ -1,40 +1,39 @@
 -- Created on: 1995-04-19
 -- Created by: Yves FRICAUD
 -- Copyright (c) 1995-1999 Matra Datavision
--- Copyright (c) 1999-2012 OPEN CASCADE SAS
+-- Copyright (c) 1999-2014 OPEN CASCADE SAS
 --
--- The content of this file is subject to the Open CASCADE Technology Public
--- License Version 6.5 (the "License"). You may not use the content of this file
--- except in compliance with the License. Please obtain a copy of the License
--- at http://www.opencascade.org and read it completely before using this file.
+-- This file is part of Open CASCADE Technology software library.
 --
--- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
--- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+-- This library is free software; you can redistribute it and/or modify it under
+-- the terms of the GNU Lesser General Public License version 2.1 as published
+-- by the Free Software Foundation, with special exception defined in the file
+-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+-- distribution for complete text of the license and disclaimer of any warranty.
 --
--- The Original Code and all software distributed under the License is
--- distributed on an "AS IS" basis, without warranty of any kind, and the
--- Initial Developer hereby disclaims all such warranties, including without
--- limitation, any warranties of merchantability, fitness for a particular
--- purpose or non-infringement. Please see the License for the specific terms
--- and conditions governing the rights and limitations under the License.
-
-
+-- Alternatively, this file may be used under the terms of Open CASCADE
+-- commercial license or contractual agreement.
 
 class OffsetWire from BRepFill
 
        ---Purpose: Constructs a Offset Wire to a spine (wire or face) 
        --          on the left of spine.
-
+       --          The Wire or the Face must be planar.
 uses
 
     Face        from TopoDS,
     Shape       from TopoDS,
     JoinType    from GeomAbs,
     ListOfShape from TopTools,
+    SequenceOfShape from TopTools,
+    SequenceOfPnt from TColgp,
     DataMapOfShapeShape               from TopTools,
     IndexedDataMapOfOrientedShapeListOfShape from BRepFill,  
+    DataMapOfOrientedShapeListOfShape from BRepFill,  
     BisectingLocus                    from BRepMAT2d, 
-    LinkTopoBilo                      from BRepMAT2d
+    LinkTopoBilo                      from BRepMAT2d,
+    Bisec from Bisector,
+    TrimEdgeTool from BRepFill
     
 raises
     ConstructionError from Standard,
@@ -45,12 +44,14 @@ is
     Create returns OffsetWire from BRepFill;
 
     Create ( Spine : Face     from TopoDS; 
-            Join  : JoinType from GeomAbs  =  GeomAbs_Arc)
+            Join  : JoinType from GeomAbs  =  GeomAbs_Arc;
+            IsOpenResult : Boolean from Standard = Standard_False)
     returns OffsetWire from BRepFill;
 
     Init ( me    : in out;
           Spine : Face     from TopoDS; 
-          Join  : JoinType from GeomAbs  =  GeomAbs_Arc)
+          Join  : JoinType from GeomAbs  =  GeomAbs_Arc;
+          IsOpenResult : Boolean from Standard = Standard_False)
        ---Purpose: Initialize the evaluation of Offseting.
     raises
        ConstructionError from Standard
@@ -120,6 +121,16 @@ is
        ---Purpose: Add the OffsetWire <Other> to <me> and update <myMap>
     is static private;
     
+    UpdateDetromp (me; Detromp : in out DataMapOfOrientedShapeListOfShape from BRepFill;
+                      Shape1, Shape2 : Shape from TopoDS;
+                      Vertices : SequenceOfShape from TopTools;
+                      Params   : SequenceOfPnt   from TColgp;
+                      Bisec    : Bisec from Bisector;
+                      SOnE     : Boolean from Standard;
+                      EOnE     : Boolean from Standard;
+                      Trim     : TrimEdgeTool from BRepFill)
+    is static private;
+    
     MakeWires (me : in  out)
        ---Purpose: Constructs the wires with the trimmed offset edges.
     is static private;
@@ -133,6 +144,7 @@ fields
     mySpine     : Face      from TopoDS;
     myWorkSpine : Face      from TopoDS;
     myOffset    : Real      from Standard; -- >0 ;
+    myIsOpenResult : Boolean from Standard;
     myShape     : Shape     from TopoDS;
     myIsDone    : Boolean   from Standard;
     myJoinType  : JoinType  from GeomAbs;          
index d83fbae172660a10c4ffc214ae0b8cfcd6ae6713..6d3af0ed0b2ab4773e3e23dd5a17cb44156f6194 100755 (executable)
@@ -1,23 +1,18 @@
 // Created on: 1995-04-20
 // Created by: Bruno DUMORTIER
 // Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
 //
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
 //
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
 //
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
 
 //  Modified by skv - Fri Jul  8 11:21:38 2005 OCC9145
 
@@ -60,6 +55,7 @@
 #include <GeomAPI.hxx>
 #include <Geom_TrimmedCurve.hxx>
 #include <Geom_Circle.hxx>
+#include <Geom_Line.hxx>
 #include <Geom_OffsetCurve.hxx>
 #include <MAT_Arc.hxx>
 #include <MAT_Node.hxx>
 #include <DrawTrSurf.hxx>
 #include <DrawTrSurf_Curve2d.hxx>
 #include <DBRep.hxx>
-#endif
-
-#ifdef DEB
 static Standard_Boolean AffichGeom  = Standard_False;
 static Standard_Boolean Affich2d    = Standard_False;
 static Standard_Boolean AffichEdge  = Standard_False;
@@ -120,10 +113,6 @@ static Standard_Integer NbTRIMEDGES = 0;
 static Standard_Integer NbOFFSET    = 0;
 static Standard_Integer NbEDGES     = 0;
 static Standard_Integer NbBISSEC    = 0;
-#ifndef WNT
-static char tname[100];
-static Standard_CString name = tname ;
-#endif
 #endif
 
 //  Modified by Sergey KHROMOV - Thu Nov 16 17:24:39 2000 Begin
@@ -179,15 +168,6 @@ static void EdgeVertices (const TopoDS_Edge&   E,
   }
 }
                                      
-static void UpdateDetromp (TopTools_ListOfShape&           Detromp1, 
-                          TopTools_ListOfShape&           Detromp2, 
-                          const TopTools_SequenceOfShape& Vertices, 
-                          const TColgp_SequenceOfPnt&     Params, 
-                          const Bisector_Bisec&           Bisec,
-                          const Standard_Boolean          SOnE,
-                          const Standard_Boolean          EOnE,
-                          const BRepFill_TrimEdgeTool&    Trim);
-
 static Standard_Boolean VertexFromNode
 (const Handle(MAT_Node)&      aNode, 
  const Standard_Real          Offset,
@@ -201,10 +181,11 @@ static void StoreInMap (const TopoDS_Shape& V1,
 
 static void TrimEdge (const TopoDS_Edge&              CurrentEdge,
                      const TopTools_ListOfShape&     D,
-                           TopTools_SequenceOfShape& Sv,  
-                           TColStd_SequenceOfReal&   MapverPar,
-                           TopTools_SequenceOfShape& S,
-                           TopTools_IndexedDataMapOfShapeShape& MapVV);
+                      TopTools_SequenceOfShape& Sv,  
+                      TColStd_SequenceOfReal&   MapverPar,
+                      TopTools_SequenceOfShape& S,
+                      TopTools_IndexedDataMapOfShapeShape& MapVV,
+                      const Standard_Integer IndOfE);
 
 static Standard_Boolean DoubleOrNotInside (const TopTools_ListOfShape& EC,
                                           const TopoDS_Vertex&        V);
@@ -225,7 +206,29 @@ static void MakeOffset
  const TopoDS_Face&                          F,
  const Standard_Real                         Offset, 
  BRepFill_IndexedDataMapOfOrientedShapeListOfShape& Map,
- const Handle(Geom_Plane)&                   RefPlane);
+ const Handle(Geom_Plane)&                   RefPlane,
+ const Standard_Boolean                      IsOpenResult,
+ const TopoDS_Vertex *                       Ends);
+
+
+
+//=======================================================================
+//function : CheckFace
+//purpose  : Check if face contains an edge with C0 continuity
+//=======================================================================
+//
+static void CheckFace(const TopoDS_Face& theFace)
+  {
+  TopExp_Explorer ex(theFace,TopAbs_EDGE);
+  for(; ex.More(); ex.Next())
+    {
+    TopoDS_Edge anEdge=TopoDS::Edge(ex.Current());
+    Standard_Real f,l;
+    const Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(anEdge,theFace,f,l);
+    if (C->Continuity() == GeomAbs_C0)
+      Standard_ConstructionError::Raise("Initial shape contains an edge with C0 continuity");
+    }
+  }
 
 //=======================================================================
 //function : KPartCircle
@@ -250,9 +253,6 @@ static Standard_Boolean KPartCircle
     E = TopoDS::Edge(exp.Current());
     if (NbEdges > 1) return Standard_False;
   }
-  TopoDS_Vertex V1,V2;
-  TopExp::Vertices(E,V1,V2);
-  if (!V1.IsSame(V2)) return Standard_False;
 
   Standard_Real      f,l;
   TopLoc_Location    L;
@@ -263,6 +263,49 @@ static Standard_Boolean KPartCircle
     C = Ct->BasisCurve();
   }
 
+  TopoDS_Vertex V1,V2;
+  TopExp::Vertices(E,V1,V2);
+  if (!V1.IsSame(V2)) //may be case of line
+  {
+    if (!C->IsKind(STANDARD_TYPE(Geom_Line))) return Standard_False;
+    Handle(Geom_Line) LE = Handle(Geom_Line)::DownCast(C);
+    Standard_Real anOffset = myOffset;
+    if (E.Orientation() == TopAbs_REVERSED) anOffset *= -1;
+    
+    Handle(Geom2d_Curve) aPCurve;
+    Handle(Geom_Surface) aSurf;
+    TopLoc_Location aLoc;
+    BRep_Tool::CurveOnSurface(E, aPCurve, aSurf, aLoc, f, l);
+    Handle(Geom2dAdaptor_HCurve) AHC = new Geom2dAdaptor_HCurve(aPCurve, f, l);
+    Adaptor3d_OffsetCurve Off(AHC,anOffset);
+    Handle(Geom2d_Line) OLC = new Geom2d_Line(Off.Line());
+    Handle(Geom_Plane) aPlane = Handle(Geom_Plane)::DownCast(aSurf);
+    myShape = BRepLib_MakeEdge(OLC, aPlane, f, l);
+    BRepLib::BuildCurve3d(TopoDS::Edge(myShape));
+    
+    myShape.Orientation(E.Orientation());
+    myShape.Location(L);
+    if (Alt != 0.) {
+      BRepAdaptor_Surface S(mySpine,0);
+      gp_Ax1 Nor = S.Plane().Axis();
+      gp_Trsf T;
+      gp_Vec Trans(Nor.Direction());
+      Trans = Alt*Trans;
+      T.SetTranslation(Trans);
+      myShape.Move(TopLoc_Location(T));
+    }
+      
+    TopTools_ListOfShape LL;
+    LL.Append(myShape);
+    myMap.Add(E,LL);
+    
+    TopoDS_Edge myEdge = TopoDS::Edge(myShape);
+    myShape = BRepLib_MakeWire(myEdge);
+    
+    myIsDone = Standard_True;
+    return Standard_True;
+  }
+  
   if (!C->IsKind(STANDARD_TYPE(Geom_Circle))) return Standard_False;
   Handle(Geom_Circle) CE = Handle(Geom_Circle)::DownCast(C);
   Standard_Real anOffset = myOffset;
@@ -298,7 +341,8 @@ static Standard_Boolean KPartCircle
 //=======================================================================
 
 BRepFill_OffsetWire::BRepFill_OffsetWire() 
-:myIsDone(Standard_False)
+  : myIsOpenResult(Standard_False),
+    myIsDone(Standard_False)
 {
 }
 
@@ -309,29 +353,30 @@ BRepFill_OffsetWire::BRepFill_OffsetWire()
 //=======================================================================
 
 BRepFill_OffsetWire::BRepFill_OffsetWire(const TopoDS_Face&     Spine,
-                                        const GeomAbs_JoinType Join )
+                                        const GeomAbs_JoinType Join,
+                                         const Standard_Boolean IsOpenResult)
 {
-  Init(Spine,Join);
+  Init(Spine,Join,IsOpenResult);
 }
 
-
 //=======================================================================
 //function : Init
 //purpose  : 
 //=======================================================================
 
 void BRepFill_OffsetWire::Init(const TopoDS_Face&     Spine,
-                              const GeomAbs_JoinType Join )
+                              const GeomAbs_JoinType Join,
+                               const Standard_Boolean IsOpenResult)
 {
-  Standard_NotImplemented_Raise_if(Join > GeomAbs_Arc,
-                                  "Only GeomAbs_Arc is implemented");
-
   myIsDone   = Standard_False;
   TopoDS_Shape aLocalShape = Spine.Oriented(TopAbs_FORWARD);
   mySpine    = TopoDS::Face(aLocalShape);
 //  mySpine    = TopoDS::Face(Spine.Oriented(TopAbs_FORWARD));
   myJoinType = Join;
+  myIsOpenResult = IsOpenResult;
 
+  CheckFace(mySpine);
+  
   myMap.Clear();
   myMapSpine.Clear();
   //------------------------------------------------------------------
@@ -363,8 +408,8 @@ void BRepFill_OffsetWire::Init(const TopoDS_Face&     Spine,
 //   static BRepMAT2d_Explorer Exp;
 //  Modified by Sergey KHROMOV - Tue Nov 26 17:39:03 2002 End
   Exp.Perform(myWorkSpine);
-  myBilo.Compute(Exp,1,MAT_Left);
-  myLink.Perform(Exp,myBilo);
+  myBilo.Compute(Exp, 1 ,MAT_Left, myJoinType, myIsOpenResult);
+  myLink.Perform(Exp, myBilo);
 }
 
 
@@ -479,10 +524,11 @@ GeomAbs_JoinType BRepFill_OffsetWire::JoinType() const
 void BRepFill_OffsetWire::Perform (const Standard_Real Offset,
                                   const Standard_Real Alt)
 {
-//  Modified by skv - Fri Jul  8 11:21:38 2005 OCC9145 Begin
-  try {
+  //  Modified by skv - Fri Jul  8 11:21:38 2005 OCC9145 Begin
+  try
+  {
     OCC_CATCH_SIGNALS
-    myCallGen = Standard_False;
+      myCallGen = Standard_False;
     if (KPartCircle(mySpine,Offset,Alt,myShape,myMap,myIsDone)) return;
 
     TopoDS_Face oldWorkSpain = myWorkSpine;
@@ -490,7 +536,8 @@ void BRepFill_OffsetWire::Perform (const Standard_Real Offset,
     TopTools_ListOfShape BadEdges;
     CheckBadEdges(myWorkSpine,Offset,myBilo,myLink,BadEdges);
 
-    if(!BadEdges.IsEmpty()) {
+    if(!BadEdges.IsEmpty())
+    {
       // Modification of myWorkSpine;
       //cout << "Modification of myWorkSpine : " << BadEdges.Extent() << endl;
       BRepTools_Substitution aSubst;
@@ -501,127 +548,144 @@ void BRepFill_OffsetWire::Perform (const Standard_Real Offset,
       TColgp_SequenceOfPnt Points;
 
       for(; it.More(); it.Next()) {
-       aL.Clear();
-       Parameters.Clear();
-       Points.Clear();
-       const TopoDS_Shape& anE = it.Value();
-       TopoDS_Vertex Vf, Vl;
-       TopExp::Vertices(TopoDS::Edge(anE), Vf, Vl);
-
-       Standard_Real f, l;
-       Handle(Geom_Curve) G3d = BRep_Tool::Curve(TopoDS::Edge(anE),f,l);
-       GeomAdaptor_Curve  AC(G3d,f,l);
-
-       Standard_Boolean dummy = PerformCurve(Parameters, Points,
-                                             AC, aDefl, f, l, Precision::Confusion(),
-                                             2);
-
-       Standard_Integer NPnts = Points.Length();
-       if(NPnts > 2) {
-         //cout << NPnts << " points " << endl;
-         TopoDS_Vertex FV = Vf;
-         TopoDS_Vertex LV;
-         TopoDS_Edge newE;
-         Standard_Integer np;
-         for(np = 2; np < NPnts; np++) {
-           gp_Pnt LP = Points(np);
-           LV = BRepLib_MakeVertex(LP);
-           newE = BRepLib_MakeEdge(FV, LV);
-           aL.Append(newE);
-           FV = LV;
-         }
-         LV = Vl;
-         newE = BRepLib_MakeEdge(FV, LV);
-         aL.Append(newE);
-       }
-       else {
-         //cout << " 2 points " << endl;
-         TopoDS_Edge newE = BRepLib_MakeEdge(Vf, Vl);
-         aL.Append(newE);
-       }
-       //Update myMapSpine
-       if (myMapSpine.IsBound( anE ))
-         {
-           TopTools_ListIteratorOfListOfShape newit( aL );
-           for (; newit.More(); newit.Next())
-             {
-               TopoDS_Edge NewEdge = TopoDS::Edge( newit.Value() );
-               myMapSpine.Bind( NewEdge, myMapSpine(anE) );
-               TopoDS_Vertex NewV1, NewV2;
-               EdgeVertices( NewEdge, NewV1, NewV2 );
-               if (!myMapSpine.IsBound(NewV1)) myMapSpine.Bind( NewV1, myMapSpine(anE) );
-               if (!myMapSpine.IsBound(NewV2)) myMapSpine.Bind( NewV2, myMapSpine(anE) );
-             }
-           myMapSpine.UnBind( anE );
-         }
-       ///////////////////
-         aSubst.Substitute(anE, aL);
+        aL.Clear();
+        Parameters.Clear();
+        Points.Clear();
+        const TopoDS_Shape& anE = it.Value();
+
+        TopoDS_Vertex Vf, Vl;
+        TopExp::Vertices(TopoDS::Edge(anE), Vf, Vl);
+
+        Standard_Real f, l;
+        Handle(Geom_Curve) G3d = BRep_Tool::Curve(TopoDS::Edge(anE),f,l);
+        GeomAdaptor_Curve  AC(G3d,f,l);
+
+        PerformCurve(Parameters, Points, AC, aDefl, f, 
+                                          l, Precision::Confusion(), 2);
+
+        Standard_Integer NPnts = Points.Length();
+        if(NPnts > 2)
+        {
+          //cout << NPnts << " points " << endl;
+          TopoDS_Vertex FV = Vf;
+          TopoDS_Vertex LV;
+          TopoDS_Edge newE;
+          Standard_Integer np;
+          for(np = 2; np < NPnts; np++) {
+            gp_Pnt LP = Points(np);
+            LV = BRepLib_MakeVertex(LP);
+            newE = BRepLib_MakeEdge(FV, LV);
+            aL.Append(newE);
+            FV = LV;
+          }
+          LV = Vl;
+          newE = BRepLib_MakeEdge(FV, LV);
+          aL.Append(newE);
+        }
+        else
+        {
+          //cout << " 2 points " << endl;
+          TopoDS_Edge newE = BRepLib_MakeEdge(Vf, Vl);
+          aL.Append(newE);
+        }
+        //Update myMapSpine
+        if (myMapSpine.IsBound( anE ))
+        {
+          TopTools_ListIteratorOfListOfShape newit( aL );
+          for (; newit.More(); newit.Next())
+          {
+            TopoDS_Edge NewEdge = TopoDS::Edge( newit.Value() );
+            myMapSpine.Bind( NewEdge, myMapSpine(anE) );
+            TopoDS_Vertex NewV1, NewV2;
+            EdgeVertices( NewEdge, NewV1, NewV2 );
+            if (!myMapSpine.IsBound(NewV1)) myMapSpine.Bind( NewV1, myMapSpine(anE) );
+            if (!myMapSpine.IsBound(NewV2)) myMapSpine.Bind( NewV2, myMapSpine(anE) );
+          }
+          myMapSpine.UnBind( anE );
+        }
+        ///////////////////
+        aSubst.Substitute(anE, aL);
       }
 
       TopTools_DataMapOfShapeListOfShape wwmap;
       TopoDS_Iterator itws( myWorkSpine );
       for (; itws.More(); itws.Next())
-       {
-         TopoDS_Shape aWire = itws.Value();
-         aSubst.Build( aWire );
-         if (aSubst.IsCopied(aWire))
-           {
-             TopoDS_Wire NewWire = TopoDS::Wire( aSubst.Copy(aWire).First() );
-             NewWire.Closed( aWire.Closed() );
-             TopTools_ListOfShape Lw;
-             Lw.Append( NewWire );
-             wwmap.Bind( aWire, Lw );
-           }
-       }
+      {
+        TopoDS_Shape aWire = itws.Value();
+        aSubst.Build( aWire );
+        if (aSubst.IsCopied(aWire))
+        {
+          TopoDS_Wire NewWire = TopoDS::Wire( aSubst.Copy(aWire).First() );
+          NewWire.Closed( aWire.Closed() );
+          TopTools_ListOfShape Lw;
+          Lw.Append( NewWire );
+          wwmap.Bind( aWire, Lw );
+        }
+      }
       aSubst.Clear();
       TopTools_DataMapIteratorOfDataMapOfShapeListOfShape itmap( wwmap );
       for (; itmap.More(); itmap.Next())
-       aSubst.Substitute( itmap.Key(), itmap.Value() );
+        aSubst.Substitute( itmap.Key(), itmap.Value() );
+      
       aSubst.Build(myWorkSpine);
+      
       if(aSubst.IsCopied(myWorkSpine)) {
-       myWorkSpine = TopoDS::Face(aSubst.Copy(myWorkSpine).First());
-       //sprintf(name,"WS1");
-       //DBRep::Set(name,myWorkSpine);
-    
-       BRepMAT2d_Explorer newExp;
-       newExp.Perform(myWorkSpine);
-       BRepMAT2d_BisectingLocus newBilo;
-       BRepMAT2d_LinkTopoBilo newLink;
-       newBilo.Compute(newExp,1,MAT_Left);
-       newLink.Perform(newExp,newBilo);
-       PerformWithBiLo(myWorkSpine,Offset,newBilo,newLink,myJoinType,Alt);
-
-       myWorkSpine = oldWorkSpain;
+        myWorkSpine = TopoDS::Face(aSubst.Copy(myWorkSpine).First());
+
+        BRepMAT2d_Explorer newExp;
+        newExp.Perform(myWorkSpine);
+        BRepMAT2d_BisectingLocus newBilo;
+        BRepMAT2d_LinkTopoBilo newLink;
+        newBilo.Compute(newExp, 1, MAT_Left, myJoinType, myIsOpenResult);
+
+        if(!newBilo.IsDone())
+        {
+          myShape.Nullify();
+          myIsDone = Standard_False;
+          return;
+        }
+
+        newLink.Perform(newExp,newBilo);
+        PerformWithBiLo(myWorkSpine,Offset,newBilo,newLink,myJoinType,Alt);
+        myWorkSpine = oldWorkSpain;
       }
       else {
-       PerformWithBiLo(myWorkSpine,Offset,myBilo,myLink,myJoinType,Alt);
+        PerformWithBiLo(myWorkSpine,Offset,myBilo,myLink,myJoinType,Alt);
       }
-    
     }
-    else {
+    else
+    {
       PerformWithBiLo(myWorkSpine,Offset,myBilo,myLink,myJoinType,Alt);
     }
-
-  } catch (Standard_Failure) {
+  }
+  catch (...)//Every exception was caught.
+  {
     myShape.Nullify();
     myIsDone = Standard_False;
+    cout<<"An exception was caught in BRepFill_OffsetWire::Perform : ";
+    Standard_Failure::Caught()->Print(cout);
+    cout<<endl;
 
     return;
   }
-//  Modified by skv - Fri Jul  8 11:21:38 2005 OCC9145 End
-//  Modified by Sergey KHROMOV - Thu Mar 14 10:48:15 2002 Begin
-  TopExp_Explorer anExp(myShape, TopAbs_WIRE);
 
-  for (; anExp.More(); anExp.Next()) {
-    const TopoDS_Shape &aWire = anExp.Current();
-
-    if (!aWire.Closed()) {
-      myShape.Nullify();
-      myIsDone = Standard_False;
-      Standard_ConstructionError::Raise("Offset wire is not closed.");
+  //  Modified by skv - Fri Jul  8 11:21:38 2005 OCC9145 End
+  //  Modified by Sergey KHROMOV - Thu Mar 14 10:48:15 2002 Begin
+  if (!myIsOpenResult)
+  {
+    TopExp_Explorer anExp(myShape, TopAbs_WIRE);
+    
+    for (; anExp.More(); anExp.Next()) {
+      const TopoDS_Shape &aWire = anExp.Current();
+      
+      if (!aWire.Closed()) {
+        myShape.Nullify();
+        myIsDone = Standard_False;
+        Standard_ConstructionError::Raise("Offset wire is not closed.");
+      }
     }
   }
-//  Modified by Sergey KHROMOV - Thu Mar 14 10:48:16 2002 End
+  //  Modified by Sergey KHROMOV - Thu Mar 14 10:48:16 2002 End
 }
 
 //=======================================================================
@@ -672,9 +736,6 @@ void BRepFill_OffsetWire::PerformWithBiLo
  const GeomAbs_JoinType          Join,
  const Standard_Real             Alt)
 {
-  Standard_NotImplemented_Raise_if (Join > GeomAbs_Arc,
-                                   "Only GeomAbs_Arc is implemented");
-
   myIsDone     = Standard_False;
   TopoDS_Shape aLocalShape = Spine.Oriented(TopAbs_FORWARD);
   myWorkSpine  = TopoDS::Face(aLocalShape);
@@ -700,7 +761,8 @@ void BRepFill_OffsetWire::PerformWithBiLo
   //********************************
   // Calculate for a non null offset 
   //********************************
-  if (KPartCircle(mySpine,Offset,Alt,myShape,myMap,myIsDone)) return;
+  if (KPartCircle(mySpine,Offset,Alt,myShape,myMap,myIsDone))
+    return;
 
   BRep_Builder myBuilder;
   myBuilder.MakeCompound(TopoDS::Compound(myShape));
@@ -735,7 +797,16 @@ void BRepFill_OffsetWire::PerformWithBiLo
   //---------------------------------------------------------------
   // Construction of Circles and OffsetCurves
   //---------------------------------------------------------------
+
+  TopoDS_Vertex Ends [2];
+  if (myIsOpenResult)
+  {
+    TopoDS_Wire theWire;
+    TopoDS_Iterator iter(mySpine);
+    theWire = TopoDS::Wire(iter.Value());
+    TopExp::Vertices(theWire, Ends[0], Ends[1]);
+  }
+  
   for (Standard_Integer ic = 1; ic <= Locus.NumberOfContours(); ic++) {
     TopoDS_Shape PEE = Link.GeneratingShape(Locus.BasicElt(ic,Locus.NumberOfElts(ic)));
     TopoDS_Shape& PE = PEE ;      
@@ -746,14 +817,15 @@ void BRepFill_OffsetWire::PerformWithBiLo
                    myWorkSpine,myOffset,myMap,RefPlane);
       }
       else {
-       MakeOffset (TopoDS::Edge(SE),myWorkSpine,myOffset,myMap,RefPlane);
+       MakeOffset (TopoDS::Edge(SE),myWorkSpine,myOffset,myMap,RefPlane,
+                    myIsOpenResult, Ends);
        PE = SE;
       }
     }
   }
 
 
-#ifdef DEB
+#ifdef DRAW
   if (AffichEdge) {
     cout << " End Construction of geometric primitives "<<endl;
   }
@@ -781,6 +853,7 @@ void BRepFill_OffsetWire::PerformWithBiLo
     
 #ifdef DRAW
   if ( AffichGeom) {
+    char name[256];
     sprintf(name,"BISSEC_%d",NbBISSEC++);
     DrawTrSurf::Set(name,Bisec.Value());
   }
@@ -895,7 +968,7 @@ void BRepFill_OffsetWire::PerformWithBiLo
     if (!Detromp.IsBound(S[1])) Detromp.Bind(S[1],EmptyList);
 
     
-    UpdateDetromp (Detromp(S[0]), Detromp(S[1]), Vertices, Params, 
+    UpdateDetromp (Detromp, S[0], S[1], Vertices, Params, 
                   Bisec, StartOnEdge, EndOnEdge, Trim);
     //----------------------------------------------
     // Storage of vertices on parallel edges.
@@ -932,7 +1005,7 @@ void BRepFill_OffsetWire::PerformWithBiLo
     }
   }
   
-#ifdef DEB 
+#ifdef DRAW
   if (AffichEdge) {
     cout << " End Construction of vertices on offsets"<<endl;
   }
@@ -955,11 +1028,19 @@ void BRepFill_OffsetWire::PerformWithBiLo
     if (MapBis.IsBound(CurrentEdge)) {
       TopTools_SequenceOfShape S;
       if (!MapBis(CurrentEdge).IsEmpty()) {
+        Standard_Integer IndOfE = 0;
+        if (myIsOpenResult)
+        {
+          if (j == 1)
+            IndOfE = 1;
+          else if (j == myMap.Extent())
+            IndOfE = -1;
+        }
        TrimEdge (CurrentEdge,
                  Detromp  (CurrentSpine),
                  MapBis   (CurrentEdge) ,  
                  MapVerPar(CurrentEdge) ,
-                 S, MapVV);
+                 S, MapVV, IndOfE);
        for ( k = 1; k <= S.Length(); k++) {
          myMap(j).Append(S.Value(k));
        }
@@ -1108,7 +1189,7 @@ void BRepFill_OffsetWire::PrepareSpine()
     TopExp::MapShapes(IteF.Value(), TopAbs_EDGE, EdgeMap);
     Standard_Integer nbEdges = EdgeMap.Extent();
     
-    if (nbEdges == 1)
+    if (nbEdges == 1 && !myIsOpenResult) //in case of open wire there's no need to do it
       ForcedCut = 2;
 //  Modified by Sergey KHROMOV - Thu Nov 16 17:29:48 2000 End
 
@@ -1157,13 +1238,108 @@ void BRepFill_OffsetWire::PrepareSpine()
 
 #ifdef DRAW
   if ( AffichEdge) {
-    sprintf(name,"WS");
-    DBRep::Set(name,myWorkSpine);
+    DBRep::Set("WS",myWorkSpine);
   }
 #endif
 
 }
 
+//=======================================================================
+//function : UpdateDetromp
+//purpose  : For each interval on bissectrice defined by parameters
+//           test if the medium point is at a distance > offset        
+//           in this case vertices corresponding to the extremities of the interval
+//           are ranked in the proofing.
+//           => If the same vertex appears in the proofing, the 
+//           border of the zone of proximity is tangent to the offset .
+//=======================================================================
+
+void BRepFill_OffsetWire::UpdateDetromp (BRepFill_DataMapOfOrientedShapeListOfShape& Detromp,
+                                         const TopoDS_Shape& Shape1,
+                                         const TopoDS_Shape& Shape2,
+                                         const TopTools_SequenceOfShape& Vertices, 
+                                         const TColgp_SequenceOfPnt&     Params, 
+                                         const Bisector_Bisec&           Bisec,
+                                         const Standard_Boolean          SOnE,
+                                         const Standard_Boolean          EOnE,
+                                         const BRepFill_TrimEdgeTool&    Trim) const
+{
+  if (myJoinType == GeomAbs_Intersection &&
+      Vertices.Length() == 1 &&
+      !EOnE)
+  {
+    TopTools_IndexedMapOfShape Vmap1, Vmap2;
+    TopExp::MapShapes(Shape1, TopAbs_VERTEX, Vmap1);
+    TopExp::MapShapes(Shape2, TopAbs_VERTEX, Vmap2);
+    Standard_Boolean Adjacent = Standard_False;
+    for (Standard_Integer i = 1; i <= Vmap1.Extent(); i++)
+      for (Standard_Integer j = 1; j <= Vmap2.Extent(); j++)
+        if (Vmap1(i).IsSame(Vmap2(j)))
+        {
+          Adjacent = Standard_True;
+          break;
+        }
+    if (Adjacent)
+    {
+      Detromp(Shape1).Append(Vertices.First());
+      Detromp(Shape2).Append(Vertices.First());
+      return;
+    }
+  }
+  
+  Standard_Integer ii = 1;
+  Standard_Real    U1,U2;
+  TopoDS_Vertex    V1,V2;
+
+  Handle(Geom2d_Curve) Bis = Bisec.Value();
+
+  U1 = Bis->FirstParameter();
+  
+  if (SOnE) { 
+    // the first point of the bissectrice is on the offset
+    V1 = TopoDS::Vertex(Vertices.Value(ii));
+    ii++; 
+  }
+
+  while (ii <= Vertices.Length()) {
+    U2 = Params.Value(ii).X();
+    V2 = TopoDS::Vertex(Vertices.Value(ii));
+
+    gp_Pnt2d P = Bis->Value((U2 + U1)*0.5);  
+    if (!Trim.IsInside(P)) {
+      if (!V1.IsNull()) {
+        Detromp(Shape1).Append(V1);
+        Detromp(Shape2).Append(V1);
+      }
+      Detromp(Shape1).Append(V2);
+      Detromp(Shape2).Append(V2);
+    }
+    U1 = U2;
+    V1 = V2;
+    ii ++;
+  }
+
+  // test medium point between the last parameter and the end of the bissectrice.
+  U2 = Bis->LastParameter();
+  if (!EOnE) {
+    if (!Precision::IsInfinite(U2)) {
+      gp_Pnt2d P = Bis->Value((U2 + U1)*0.5);  
+      if (!Trim.IsInside(P)) {
+       if (!V1.IsNull()) {
+         Detromp(Shape1).Append(V1);
+         Detromp(Shape2).Append(V1);
+       }
+      }
+    }
+    else {
+      if (!V1.IsNull()) {
+       Detromp(Shape1).Append(V1);
+       Detromp(Shape2).Append(V1);
+      }
+    }
+  }    
+}
+
 //=======================================================================
 //function : MakeWires
 //purpose  : 
@@ -1325,260 +1501,266 @@ void BRepFill_OffsetWire::FixHoles()
 
   TopExp_Explorer Explo( mySpine, TopAbs_VERTEX );
   for (; Explo.More(); Explo.Next())
-    {
-      const TopoDS_Vertex& aVertex = TopoDS::Vertex( Explo.Current() );
-      Standard_Real Tol = BRep_Tool::Tolerance(aVertex);
-      if (Tol > MaxTol)
-       MaxTol = Tol;
-    }
+  {
+    const TopoDS_Vertex& aVertex = TopoDS::Vertex( Explo.Current() );
+    Standard_Real Tol = BRep_Tool::Tolerance(aVertex);
+    if (Tol > MaxTol)
+      MaxTol = Tol;
+  }
   MaxTol *= 100.;
 
   Explo.Init( myShape, TopAbs_WIRE );
   for (; Explo.More(); Explo.Next())
+  {
+    TopoDS_Shape aWire = Explo.Current();
+    // Remove duplicated edges
+    TopTools_DataMapOfShapeListOfShape EEmap;
+    TopoDS_Iterator it( aWire );
+    for (; it.More(); it.Next())
     {
-      TopoDS_Shape aWire = Explo.Current();
-      // Remove duplicated edges
-      TopTools_DataMapOfShapeListOfShape EEmap;
-      TopoDS_Iterator it( aWire );
-      for (; it.More(); it.Next())
-       {
-         const TopoDS_Shape& anEdge = it.Value();
-         if (! EEmap.IsBound( anEdge ))
-           {
-             TopTools_ListOfShape LE;
-             EEmap.Bind( anEdge, LE );
-           }
-         else
-           EEmap(anEdge).Append( anEdge );
-       }
-      aWire.Free( Standard_True );
-      TopTools_DataMapIteratorOfDataMapOfShapeListOfShape mapit( EEmap );
-      for (; mapit.More(); mapit.Next())
-       {
-         const TopTools_ListOfShape& LE = mapit.Value();
-         TopTools_ListIteratorOfListOfShape itl( LE );
-         for (; itl.More(); itl.Next())
-           BB.Remove( aWire, itl.Value() );
-       }
-      // Sorting
-      if (aWire.Closed())
-       ClosedWires.Append( aWire );
+      const TopoDS_Shape& anEdge = it.Value();
+      if (! EEmap.IsBound( anEdge ))
+      {
+        TopTools_ListOfShape LE;
+        EEmap.Bind( anEdge, LE );
+      }
       else
-       UnclosedWires.Append( aWire );
+        EEmap(anEdge).Append( anEdge );
     }
-  
+    aWire.Free( Standard_True );
+    TopTools_DataMapIteratorOfDataMapOfShapeListOfShape mapit( EEmap );
+    for (; mapit.More(); mapit.Next())
+    {
+      const TopTools_ListOfShape& LE = mapit.Value();
+      TopTools_ListIteratorOfListOfShape itl( LE );
+      for (; itl.More(); itl.Next())
+        BB.Remove( aWire, itl.Value() );
+    }
+    // Sorting
+    if (aWire.Closed())
+      ClosedWires.Append( aWire );
+    else
+      UnclosedWires.Append( aWire );
+  }
+
   while (!UnclosedWires.IsEmpty())
+  {
+    TopoDS_Wire& Base = TopoDS::Wire( UnclosedWires(1) );
+    TopoDS_Vertex Vf, Vl;
+    TopExp::Vertices( Base, Vf, Vl );
+    if(Vf.IsNull() || Vl.IsNull())
+      Standard_Failure::Raise("BRepFill_OffsetWire::FixHoles(): Wrong wire.");
+    gp_Pnt Pf, Pl;
+    Pf = BRep_Tool::Pnt(Vf);
+    Pl = BRep_Tool::Pnt(Vl);
+    Standard_Real DistF = RealLast(), DistL = RealLast();
+    Standard_Integer IndexF = 1, IndexL = 1;
+    Standard_Boolean IsFirstF = Standard_False, IsFirstL = Standard_False;
+    for (Standard_Integer i = 2; i <= UnclosedWires.Length(); i++)
+    {
+      TopoDS_Wire aWire = TopoDS::Wire( UnclosedWires(i) );
+      TopoDS_Vertex V1, V2;
+      TopExp::Vertices( aWire, V1, V2 );
+
+      if(V1.IsNull() || V2.IsNull())
+        Standard_Failure::Raise("BRepFill_OffsetWire::FixHoles(): Wrong wire.");
+
+      gp_Pnt P1, P2;
+      P1 = BRep_Tool::Pnt(V1);
+      P2 = BRep_Tool::Pnt(V2);
+      Standard_Real dist = Pf.Distance( P1 );
+      if (dist < DistF)
+      {
+        DistF = dist;
+        IndexF = i;
+        IsFirstF = Standard_True;
+      }
+      dist = Pf.Distance( P2 );
+      if (dist < DistF)
+      {
+        DistF = dist;
+        IndexF = i;
+        IsFirstF = Standard_False;
+      }
+      dist = Pl.Distance( P1 );
+      if (dist < DistL)
+      {
+        DistL = dist;
+        IndexL = i;
+        IsFirstL = Standard_True;
+      }
+      dist = Pl.Distance( P2 );
+      if (dist < DistL)
+      {
+        DistL = dist;
+        IndexL = i;
+        IsFirstL = Standard_False;
+      }
+    }
+    TopoDS_Wire theWire;
+    TopoDS_Edge theEdge;
+    TopoDS_Vertex theVertex;
+    Standard_Real CommonTol;
+    Standard_Boolean TryToClose = Standard_True;
+    if (DistF <= MaxTol && DistL <= MaxTol && IndexF == IndexL && IsFirstF == IsFirstL)
+    {
+      if (DistF < DistL)
+      {
+        DistL = RealLast();
+        IndexL++;
+      }
+      else
+      {
+        DistF = RealLast();
+        IndexF++;
+      }
+      TryToClose = Standard_False;
+    }
+    if (DistF <= MaxTol)
+    {
+      theWire = TopoDS::Wire( UnclosedWires(IndexF) );
+      TopoDS_Vertex V1, V2;
+      TopExp::Vertices( theWire, V1, V2 );
+      TopTools_IndexedDataMapOfShapeListOfShape VEmap;
+      TopExp::MapShapesAndAncestors( theWire, TopAbs_VERTEX, TopAbs_EDGE, VEmap );
+      theEdge = (IsFirstF)? TopoDS::Edge(VEmap.FindFromKey( V1 ).First()) :
+        TopoDS::Edge(VEmap.FindFromKey( V2 ).First());
+      TopoDS_Iterator it( theWire );
+      for (; it.More(); it.Next())
+      {
+        TopoDS_Edge anEdge = TopoDS::Edge( it.Value() );
+        if (IsFirstF) anEdge.Reverse();
+        if (!anEdge.IsSame( theEdge ))
+          BB.Add( Base, anEdge );
+      }
+      theVertex = (IsFirstF)? V1 : V2;
+      CommonTol = Max( BRep_Tool::Tolerance(Vf), BRep_Tool::Tolerance(theVertex) );
+      if (DistF <= CommonTol)
+      {
+        theEdge.Free( Standard_True );
+        Vf.Orientation( theVertex.Orientation() );
+        BB.Remove( theEdge, theVertex );
+        BB.Add( theEdge, Vf );
+        BB.UpdateVertex( Vf, CommonTol );
+        if (IsFirstF) theEdge.Reverse();
+        BB.Add( Base, theEdge );
+      }
+      else
+      {
+        if (IsFirstF) theEdge.Reverse();
+        BB.Add( Base, theEdge );
+        // Creating new edge from theVertex to Vf
+        TopoDS_Edge NewEdge = BRepLib_MakeEdge( theVertex, Vf );
+        BB.Add( Base, NewEdge );
+      }
+    }
+    if (DistL <= MaxTol && IndexL != IndexF)
+    {
+      theWire = TopoDS::Wire( UnclosedWires(IndexL) );
+      TopoDS_Vertex V1, V2;
+      TopExp::Vertices( theWire, V1, V2 );
+      TopTools_IndexedDataMapOfShapeListOfShape VEmap;
+      TopExp::MapShapesAndAncestors( theWire, TopAbs_VERTEX, TopAbs_EDGE, VEmap );
+      theEdge = (IsFirstL)? TopoDS::Edge(VEmap.FindFromKey( V1 ).First()) :
+        TopoDS::Edge(VEmap.FindFromKey( V2 ).First());
+      TopoDS_Iterator it( theWire );
+      for (; it.More(); it.Next())
+      {
+        TopoDS_Edge anEdge = TopoDS::Edge( it.Value() );
+        if (!IsFirstL) anEdge.Reverse();
+        if (!anEdge.IsSame( theEdge ))
+          BB.Add( Base, anEdge );
+      }
+      theVertex = (IsFirstL)? V1 : V2;
+      CommonTol = Max( BRep_Tool::Tolerance(Vl), BRep_Tool::Tolerance(theVertex) );
+      if (DistL <= CommonTol)
+      {
+        theEdge.Free( Standard_True );
+        Vl.Orientation( theVertex.Orientation() );
+        BB.Remove( theEdge, theVertex );
+        BB.Add( theEdge, Vl );
+        BB.UpdateVertex( Vl, CommonTol );
+        if (!IsFirstL) theEdge.Reverse();
+        BB.Add( Base, theEdge );
+      }
+      else
+      {
+        if (!IsFirstL) theEdge.Reverse();
+        BB.Add( Base, theEdge );
+        // Creating new edge from Vl to theVertex
+        TopoDS_Edge NewEdge = BRepLib_MakeEdge( Vl, theVertex );
+        BB.Add( Base, NewEdge );
+      }
+    }
+    // Check if it is possible to close resulting wire
+    if (TryToClose)
     {
-      TopoDS_Wire& Base = TopoDS::Wire( UnclosedWires(1) );
-      TopoDS_Vertex Vf, Vl;
       TopExp::Vertices( Base, Vf, Vl );
-      gp_Pnt Pf, Pl;
+      CommonTol = Max( BRep_Tool::Tolerance(Vf), BRep_Tool::Tolerance(Vl) );
+      TopTools_IndexedDataMapOfShapeListOfShape VEmap;
+      TopExp::MapShapesAndAncestors( Base, TopAbs_VERTEX, TopAbs_EDGE, VEmap );
+      TopoDS_Edge Efirst, Elast;
+      Efirst = TopoDS::Edge(VEmap.FindFromKey( Vf ).First());
+      Elast  = TopoDS::Edge(VEmap.FindFromKey( Vl ).First());
       Pf = BRep_Tool::Pnt(Vf);
       Pl = BRep_Tool::Pnt(Vl);
-      Standard_Real DistF = RealLast(), DistL = RealLast();
-      Standard_Integer IndexF, IndexL;
-      Standard_Boolean IsFirstF, IsFirstL;
-      for (Standard_Integer i = 2; i <= UnclosedWires.Length(); i++)
-       {
-         TopoDS_Wire aWire = TopoDS::Wire( UnclosedWires(i) );
-         TopoDS_Vertex V1, V2;
-         TopExp::Vertices( aWire, V1, V2 );
-         gp_Pnt P1, P2;
-         P1 = BRep_Tool::Pnt(V1);
-         P2 = BRep_Tool::Pnt(V2);
-         Standard_Real dist = Pf.Distance( P1 );
-         if (dist < DistF)
-           {
-             DistF = dist;
-             IndexF = i;
-             IsFirstF = Standard_True;
-           }
-         dist = Pf.Distance( P2 );
-         if (dist < DistF)
-           {
-             DistF = dist;
-             IndexF = i;
-             IsFirstF = Standard_False;
-           }
-         dist = Pl.Distance( P1 );
-         if (dist < DistL)
-           {
-             DistL = dist;
-             IndexL = i;
-             IsFirstL = Standard_True;
-           }
-         dist = Pl.Distance( P2 );
-         if (dist < DistL)
-           {
-             DistL = dist;
-             IndexL = i;
-             IsFirstL = Standard_False;
-           }
-       }
-      TopoDS_Wire theWire;
-      TopoDS_Edge theEdge;
-      TopoDS_Vertex theVertex;
-      Standard_Real CommonTol;
-      Standard_Boolean TryToClose = Standard_True;
-      if (DistF <= MaxTol && DistL <= MaxTol && IndexF == IndexL && IsFirstF == IsFirstL)
-       {
-         if (DistF < DistL)
-           {
-             DistL = RealLast();
-             IndexL++;
-           }
-         else
-           {
-             DistF = RealLast();
-             IndexF++;
-           }
-         TryToClose = Standard_False;
-       }
-      if (DistF <= MaxTol)
-       {
-         theWire = TopoDS::Wire( UnclosedWires(IndexF) );
-         TopoDS_Vertex V1, V2;
-         TopExp::Vertices( theWire, V1, V2 );
-         TopTools_IndexedDataMapOfShapeListOfShape VEmap;
-         TopExp::MapShapesAndAncestors( theWire, TopAbs_VERTEX, TopAbs_EDGE, VEmap );
-         theEdge = (IsFirstF)? TopoDS::Edge(VEmap.FindFromKey( V1 ).First()) :
-           TopoDS::Edge(VEmap.FindFromKey( V2 ).First());
-         TopoDS_Iterator it( theWire );
-         for (; it.More(); it.Next())
-           {
-             TopoDS_Edge anEdge = TopoDS::Edge( it.Value() );
-             if (IsFirstF) anEdge.Reverse();
-             if (!anEdge.IsSame( theEdge ))
-               BB.Add( Base, anEdge );
-           }
-         theVertex = (IsFirstF)? V1 : V2;
-         CommonTol = Max( BRep_Tool::Tolerance(Vf), BRep_Tool::Tolerance(theVertex) );
-         if (DistF <= CommonTol)
-           {
-             theEdge.Free( Standard_True );
-             Vf.Orientation( theVertex.Orientation() );
-             BB.Remove( theEdge, theVertex );
-             BB.Add( theEdge, Vf );
-             BB.UpdateVertex( Vf, CommonTol );
-             if (IsFirstF) theEdge.Reverse();
-             BB.Add( Base, theEdge );
-           }
-         else
-           {
-             if (IsFirstF) theEdge.Reverse();
-             BB.Add( Base, theEdge );
-             // Creating new edge from theVertex to Vf
-             TopoDS_Edge NewEdge = BRepLib_MakeEdge( theVertex, Vf );
-             BB.Add( Base, NewEdge );
-           }
-       }
-      if (DistL <= MaxTol && IndexL != IndexF)
-       {
-         theWire = TopoDS::Wire( UnclosedWires(IndexL) );
-         TopoDS_Vertex V1, V2;
-         TopExp::Vertices( theWire, V1, V2 );
-         TopTools_IndexedDataMapOfShapeListOfShape VEmap;
-         TopExp::MapShapesAndAncestors( theWire, TopAbs_VERTEX, TopAbs_EDGE, VEmap );
-         theEdge = (IsFirstL)? TopoDS::Edge(VEmap.FindFromKey( V1 ).First()) :
-           TopoDS::Edge(VEmap.FindFromKey( V2 ).First());
-         TopoDS_Iterator it( theWire );
-         for (; it.More(); it.Next())
-           {
-             TopoDS_Edge anEdge = TopoDS::Edge( it.Value() );
-             if (!IsFirstL) anEdge.Reverse();
-             if (!anEdge.IsSame( theEdge ))
-               BB.Add( Base, anEdge );
-           }
-         theVertex = (IsFirstL)? V1 : V2;
-         CommonTol = Max( BRep_Tool::Tolerance(Vl), BRep_Tool::Tolerance(theVertex) );
-         if (DistL <= CommonTol)
-           {
-             theEdge.Free( Standard_True );
-             Vl.Orientation( theVertex.Orientation() );
-             BB.Remove( theEdge, theVertex );
-             BB.Add( theEdge, Vl );
-             BB.UpdateVertex( Vl, CommonTol );
-             if (!IsFirstL) theEdge.Reverse();
-             BB.Add( Base, theEdge );
-           }
-         else
-           {
-             if (!IsFirstL) theEdge.Reverse();
-             BB.Add( Base, theEdge );
-             // Creating new edge from Vl to theVertex
-             TopoDS_Edge NewEdge = BRepLib_MakeEdge( Vl, theVertex );
-             BB.Add( Base, NewEdge );
-           }
-       }
-      // Check if it is possible to close resulting wire
-      if (TryToClose)
-       {
-         TopExp::Vertices( Base, Vf, Vl );
-         CommonTol = Max( BRep_Tool::Tolerance(Vf), BRep_Tool::Tolerance(Vl) );
-         TopTools_IndexedDataMapOfShapeListOfShape VEmap;
-         TopExp::MapShapesAndAncestors( Base, TopAbs_VERTEX, TopAbs_EDGE, VEmap );
-         TopoDS_Edge Efirst, Elast;
-         Efirst = TopoDS::Edge(VEmap.FindFromKey( Vf ).First());
-          Elast  = TopoDS::Edge(VEmap.FindFromKey( Vl ).First());
-          Pf = BRep_Tool::Pnt(Vf);
-          Pl = BRep_Tool::Pnt(Vl);
-          Standard_Real Dist = Pf.Distance(Pl);
-         if (Dist <= CommonTol)
-           {
-             Elast.Free( Standard_True );
-             Vf.Orientation( Vl.Orientation() );
-             BB.Remove( Elast, Vl );
-             BB.Add( Elast, Vf );
-             BB.UpdateVertex( Vf, CommonTol );
-             Base.Closed( Standard_True );
-           }
-         else if (Dist <= MaxTol)
-           {
-             // Creating new edge from Vl to Vf
-             TopoDS_Edge NewEdge = BRepLib_MakeEdge( Vf, Vl );
-             BB.Add( Base, NewEdge );
-             Base.Closed( Standard_True );
-           }
-       }
-      // Updating sequences ClosedWires and UnclosedWires
-      if (DistF <= MaxTol)
-       UnclosedWires.Remove( IndexF );
-      if (DistL <= MaxTol && IndexL != IndexF)
-       {
-         if (DistF <= MaxTol && IndexL > IndexF)
-           IndexL--;
-         UnclosedWires.Remove( IndexL );
-       }
-      if (Base.Closed())
-       {
-         ClosedWires.Append( Base );
-         UnclosedWires.Remove( 1 );
-       }
-      else if (DistF > MaxTol && DistL > MaxTol)
-       {
-         IsolatedWires.Append( Base );
-         UnclosedWires.Remove( 1 );
-       }
+      Standard_Real Dist = Pf.Distance(Pl);
+      if (Dist <= CommonTol)
+      {
+        Elast.Free( Standard_True );
+        Vf.Orientation( Vl.Orientation() );
+        BB.Remove( Elast, Vl );
+        BB.Add( Elast, Vf );
+        BB.UpdateVertex( Vf, CommonTol );
+        Base.Closed( Standard_True );
+      }
+      else if (Dist <= MaxTol)
+      {
+        // Creating new edge from Vl to Vf
+        TopoDS_Edge NewEdge = BRepLib_MakeEdge( Vf, Vl );
+        BB.Add( Base, NewEdge );
+        Base.Closed( Standard_True );
+      }
     }
-
-  // Updating myShape
-  if (ClosedWires.Length() + IsolatedWires.Length() == 1)
+    // Updating sequences ClosedWires and UnclosedWires
+    if (DistF <= MaxTol)
+      UnclosedWires.Remove( IndexF );
+    if (DistL <= MaxTol && IndexL != IndexF)
     {
-      if (!ClosedWires.IsEmpty())
-       myShape = ClosedWires.First();
-      else
-       myShape = IsolatedWires.First();
+      if (DistF <= MaxTol && IndexL > IndexF)
+        IndexL--;
+      UnclosedWires.Remove( IndexL );
     }
-  else
+    if (Base.Closed())
+    {
+      ClosedWires.Append( Base );
+      UnclosedWires.Remove( 1 );
+    }
+    else if (DistF > MaxTol && DistL > MaxTol)
     {
-      TopoDS_Compound R;
-      BB.MakeCompound( R );
-      for (i = 1; i <= ClosedWires.Length(); i++)
-       BB.Add( R, ClosedWires(i) );
-      for (i = 1; i <= IsolatedWires.Length(); i++)
-       BB.Add( R, IsolatedWires(i) );
-      myShape = R;
+      IsolatedWires.Append( Base );
+      UnclosedWires.Remove( 1 );
     }
+  }
+
+  // Updating myShape
+  if (ClosedWires.Length() + IsolatedWires.Length() == 1)
+  {
+    if (!ClosedWires.IsEmpty())
+      myShape = ClosedWires.First();
+    else
+      myShape = IsolatedWires.First();
+  }
+  else
+  {
+    TopoDS_Compound R;
+    BB.MakeCompound( R );
+    for (i = 1; i <= ClosedWires.Length(); i++)
+      BB.Add( R, ClosedWires(i) );
+    for (i = 1; i <= IsolatedWires.Length(); i++)
+      BB.Add( R, IsolatedWires(i) );
+    myShape = R;
+  }
 }
 
 //=======================================================================
@@ -1784,6 +1966,7 @@ void MakeCircle (const TopoDS_Edge&          E,
 
 #ifdef DRAW
   if ( AffichGeom && !OE.IsNull()) {
+    char name[256];
     sprintf(name,"OFFSET_%d",++NbOFFSET);
     DBRep::Set(name,OE);
   }
@@ -1799,7 +1982,9 @@ void MakeOffset (const TopoDS_Edge&        E,
                 const TopoDS_Face&        F,
                 const Standard_Real       Offset, 
                       BRepFill_IndexedDataMapOfOrientedShapeListOfShape& Map,
-                const Handle(Geom_Plane)& RefPlane)
+                const Handle(Geom_Plane)& RefPlane,
+                 const Standard_Boolean    IsOpenResult,
+                 const TopoDS_Vertex *     Ends)
 {
   Standard_Real f,l;
   Standard_Real anOffset = Offset;
@@ -1809,6 +1994,20 @@ void MakeOffset (const TopoDS_Edge&        E,
   Handle(Geom2d_Curve) G2d = BRep_Tool::CurveOnSurface(E,F,f,l);
   Handle(Geom2d_Curve) G2dOC;
 
+  Standard_Boolean ToExtendFirstPar = Standard_True;
+  Standard_Boolean ToExtendLastPar  = Standard_True;
+  if (IsOpenResult)
+  {
+    TopoDS_Vertex V1, V2;
+    TopExp::Vertices(E, V1, V2);
+    if (V1.IsSame(Ends[0]) ||
+        V1.IsSame(Ends[1]))
+      ToExtendFirstPar = Standard_False;
+    if (V2.IsSame(Ends[0]) ||
+        V2.IsSame(Ends[1]))
+      ToExtendLastPar  = Standard_False;
+  }
+
   Geom2dAdaptor_Curve  AC(G2d,f,l);
   if ( AC.GetType() == GeomAbs_Circle) {
     // if the offset is greater otr equal to the radius and the side of the  
@@ -1820,7 +2019,7 @@ void MakeOffset (const TopoDS_Edge&        E,
     Standard_Real Crossed = Xd.X()*Yd.Y()-Xd.Y()*Yd.X();
     Standard_Real Signe = ( Crossed > 0.) ? 1. : -1.;
 
-    if (anOffset*Signe < AC.Circle().Radius()) {
+    if (anOffset*Signe < AC.Circle().Radius() - Precision::Confusion()) {
 
       Handle(Geom2dAdaptor_HCurve) AHC = 
        new Geom2dAdaptor_HCurve(G2d);
@@ -1828,7 +2027,10 @@ void MakeOffset (const TopoDS_Edge&        E,
       Handle(Geom2d_Circle) CC = new Geom2d_Circle(Off.Circle());      
 
       Standard_Real Delta = 2*M_PI - l + f;
-      f -= 0.2*Delta; l += 0.2*Delta;
+      if (ToExtendFirstPar)
+        f -= 0.2*Delta;
+      if (ToExtendLastPar)
+        l += 0.2*Delta;
 
       G2dOC = new Geom2d_TrimmedCurve(CC,f,l);
     }
@@ -1839,7 +2041,10 @@ void MakeOffset (const TopoDS_Edge&        E,
     Adaptor3d_OffsetCurve Off(AHC,anOffset);
     Handle(Geom2d_Line)       CC = new Geom2d_Line(Off.Line());
     Standard_Real Delta = (l - f);
-    f -= Delta; l += Delta;
+    if (ToExtendFirstPar)
+      f -= Delta;
+    if (ToExtendLastPar)
+      l += Delta;
     G2dOC = new Geom2d_TrimmedCurve(CC,f,l);
   }
   else {
@@ -1860,6 +2065,7 @@ void MakeOffset (const TopoDS_Edge&        E,
 
 #ifdef DRAW  
     if (AffichGeom && !OE.IsNull()) {
+      char name[256];
       sprintf(name,"OFFSET_%d",++NbOFFSET);
       DBRep::Set(name,OE);
       Standard_Real ii = 0;
@@ -1869,77 +2075,6 @@ void MakeOffset (const TopoDS_Edge&        E,
   }
 }  
 
-//=======================================================================
-//function : UpdateDetromp
-//purpose  : For each interval on bissectrice defined by parameters
-//           test if the medium point is at a distance > offset        
-//           in this case vertices corresponding to the extremities of the interval
-//           are ranked in the proofing.
-//           => If the same vertex appears in the proofing, the 
-//           border of the zone of proximity is tangent to the offset .
-//=======================================================================
-
-void UpdateDetromp (TopTools_ListOfShape&           Detromp1,
-                   TopTools_ListOfShape&           Detromp2, 
-                   const TopTools_SequenceOfShape& Vertices, 
-                   const TColgp_SequenceOfPnt&     Params, 
-                   const Bisector_Bisec&           Bisec,
-                   const Standard_Boolean          SOnE,
-                   const Standard_Boolean          EOnE,
-                   const BRepFill_TrimEdgeTool&    Trim)
-{
-  Standard_Integer ii = 1;
-  Standard_Real    U1,U2;
-  TopoDS_Vertex    V1,V2;
-
-  Handle(Geom2d_Curve) Bis = Bisec.Value();
-
-  U1 = Bis->FirstParameter();
-  
-  if (SOnE) { 
-    // the first point of the bissectrice is on the offset
-    V1 = TopoDS::Vertex(Vertices.Value(ii));
-    ii++; 
-  }
-
-  while (ii <= Vertices.Length()) {
-    U2 = Params.Value(ii).X();
-    V2 = TopoDS::Vertex(Vertices.Value(ii));
-
-    gp_Pnt2d P = Bis->Value((U2 + U1)*0.5);  
-    if (!Trim.IsInside(P)) {
-      if (!V1.IsNull()) {
-         Detromp1.Append(V1);
-         Detromp2.Append(V1);
-      }
-      Detromp1.Append(V2);
-      Detromp2.Append(V2);
-    }
-    U1 = U2;
-    V1 = V2;
-    ii ++;
-  }
-
-  // test medium point between the last parameter and the end of the bissectrice.
-  U2 = Bis->LastParameter();
-  if (!EOnE) {
-    if (!Precision::IsInfinite(U2)) {
-      gp_Pnt2d P = Bis->Value((U2 + U1)*0.5);  
-      if (!Trim.IsInside(P)) {
-       if (!V1.IsNull()) {
-         Detromp1.Append(V1);
-         Detromp2.Append(V1);
-       }
-      }
-    }
-    else {
-      if (!V1.IsNull()) {
-       Detromp1.Append(V1);
-       Detromp2.Append(V1);
-      }
-    }
-  }    
-}
 
 //=======================================================================
 //function : VertexFromNode
@@ -2009,10 +2144,11 @@ void StoreInMap (const TopoDS_Shape& V1,
 
 void TrimEdge (const TopoDS_Edge&              E,
               const TopTools_ListOfShape&     Detromp,
-                    TopTools_SequenceOfShape& TheVer,
-                    TColStd_SequenceOfReal&   ThePar,
-                    TopTools_SequenceOfShape& S,
-                    TopTools_IndexedDataMapOfShapeShape& MapVV)
+               TopTools_SequenceOfShape& TheVer,
+               TColStd_SequenceOfReal&   ThePar,
+               TopTools_SequenceOfShape& S,
+               TopTools_IndexedDataMapOfShapeShape& MapVV,
+               const Standard_Integer IndOfE)
 {
   Standard_Boolean         Change = Standard_True;
   BRep_Builder             TheBuilder;
@@ -2083,44 +2219,93 @@ void TrimEdge (const TopoDS_Edge&              E,
   // the number of vertices should be even. The created edges  
   // go from a vertex with uneven index i to vertex i+1;
   //-----------------------------------------------------------
-  for (Standard_Integer k = 1; k < TheVer.Length(); k = k+2) {
+  if (IndOfE == 1 || IndOfE == -1) //open result and extreme edges of result
+  {
     TopoDS_Shape aLocalShape = E.EmptyCopied();
     TopoDS_Edge NewEdge = TopoDS::Edge(aLocalShape);
-//    TopoDS_Edge NewEdge = TopoDS::Edge(E.EmptyCopied());
-
-    if (NewEdge.Orientation() == TopAbs_REVERSED) {
-      TheBuilder.Add  (NewEdge,TheVer.Value(k)  .Oriented(TopAbs_REVERSED));
-      TheBuilder.Add  (NewEdge,TheVer.Value(k+1).Oriented(TopAbs_FORWARD));
+    TopoDS_Vertex V1, V2;
+    TopExp::Vertices(E, V1, V2);
+    Standard_Real fpar, lpar;
+    BRep_Tool::Range(E, fpar, lpar);
+    if (IndOfE == 1) //first edge of open wire
+    {
+      if (NewEdge.Orientation() == TopAbs_FORWARD)
+      {
+        TheBuilder.Add(NewEdge, V1.Oriented(TopAbs_FORWARD));
+        TheBuilder.Add(NewEdge, TheVer.First().Oriented(TopAbs_REVERSED));
+        TheBuilder.Range(NewEdge, fpar, ThePar.First());
+      }
+      else
+      {
+        //TheBuilder.Add(NewEdge, V1.Oriented(TopAbs_REVERSED));
+        //TheBuilder.Add(NewEdge, TheVer.First().Oriented(TopAbs_FORWARD));
+        TheBuilder.Add(NewEdge, TheVer.First().Oriented(TopAbs_REVERSED));
+        TheBuilder.Add(NewEdge, V2.Oriented(TopAbs_FORWARD));
+        TheBuilder.Range(NewEdge, ThePar.First(), lpar);
+      }
     }
-    else {      
-      TheBuilder.Add  (NewEdge,TheVer.Value(k)  .Oriented(TopAbs_FORWARD));
-      TheBuilder.Add  (NewEdge,TheVer.Value(k+1).Oriented(TopAbs_REVERSED));
+    else //last edge of open wire
+    {
+      if (NewEdge.Orientation() == TopAbs_FORWARD)
+      {
+        TheBuilder.Add(NewEdge, TheVer.First().Oriented(TopAbs_FORWARD));
+        TheBuilder.Add(NewEdge, V2.Oriented(TopAbs_REVERSED));
+        TheBuilder.Range(NewEdge, ThePar.First(), lpar);
+      }
+      else
+      {
+        //TheBuilder.Add(NewEdge, TheVer.First().Oriented(TopAbs_REVERSED));
+        //TheBuilder.Add(NewEdge, V2.Oriented(TopAbs_FORWARD));
+        TheBuilder.Add(NewEdge, V1.Oriented(TopAbs_REVERSED));
+        TheBuilder.Add(NewEdge, TheVer.First().Oriented(TopAbs_FORWARD));
+        TheBuilder.Range(NewEdge, fpar, ThePar.First());
+      }
     }
-
-
-    TheBuilder.Range(NewEdge,ThePar.Value(k),ThePar.Value(k+1));
-
+    S.Append(NewEdge);
+  }
+  else
+  {
+    for (Standard_Integer k = 1; k < TheVer.Length(); k = k+2) {
+      TopoDS_Shape aLocalShape = E.EmptyCopied();
+      TopoDS_Edge NewEdge = TopoDS::Edge(aLocalShape);
+      //    TopoDS_Edge NewEdge = TopoDS::Edge(E.EmptyCopied());
+      
+      if (NewEdge.Orientation() == TopAbs_REVERSED) {
+        TheBuilder.Add  (NewEdge,TheVer.Value(k)  .Oriented(TopAbs_REVERSED));
+        TheBuilder.Add  (NewEdge,TheVer.Value(k+1).Oriented(TopAbs_FORWARD));
+      }
+      else {      
+        TheBuilder.Add  (NewEdge,TheVer.Value(k)  .Oriented(TopAbs_FORWARD));
+        TheBuilder.Add  (NewEdge,TheVer.Value(k+1).Oriented(TopAbs_REVERSED));
+      }
+      
+      
+      TheBuilder.Range(NewEdge,ThePar.Value(k),ThePar.Value(k+1));
+      
 #ifdef DRAW
-    if ( AffichEdge) {
-      sprintf(name,"TRIMEDGE_%d",NbTRIMEDGES);
-      DBRep::Set(name,NewEdge);  
-    }
-    if (Affich2d) {
-      TopLoc_Location L;
-      Standard_Real f,l;
-      Handle(Geom_Surface) Surf;  
-      Handle(Geom2d_Curve) C;
-      BRep_Tool::CurveOnSurface(NewEdge,C,Surf,L,f,l);
-      sprintf(name,"OFFSET2d_%d",NbTRIMEDGES++);
-      Handle(Geom2d_TrimmedCurve) C2d = new Geom2d_TrimmedCurve(C,f,l);
-      Handle(DrawTrSurf_Curve2d) dr =
-       new DrawTrSurf_Curve2d(C2d,Standard_False);
-      dr->SetColor(Draw_bleu);
-      Draw::Set(name,dr);
-    }
+      if ( AffichEdge) {
+        char name[256];
+        sprintf(name,"TRIMEDGE_%d",NbTRIMEDGES);
+        DBRep::Set(name,NewEdge);  
+      }
+      if (Affich2d) {
+        TopLoc_Location L;
+        Standard_Real f,l;
+        Handle(Geom_Surface) Surf;  
+        Handle(Geom2d_Curve) C;
+        BRep_Tool::CurveOnSurface(NewEdge,C,Surf,L,f,l);
+        char name[256];
+        sprintf(name,"OFFSET2d_%d",NbTRIMEDGES++);
+        Handle(Geom2d_TrimmedCurve) C2d = new Geom2d_TrimmedCurve(C,f,l);
+        Handle(DrawTrSurf_Curve2d) dr =
+          new DrawTrSurf_Curve2d(C2d,Standard_False);
+        dr->SetColor(Draw_bleu);
+        Draw::Set(name,dr);
+      }
 #endif
-
-    S.Append(NewEdge);
+      
+      S.Append(NewEdge);
+    }
   }
 }
 
@@ -2299,14 +2484,22 @@ static Standard_Boolean PerformCurve (TColStd_SequenceOfReal& Parameters,
   Points.Append(Pdeb);
 
   C.D1(UU2,Pfin,Dfin);
-  QuasiFleche(C,Deflection*Deflection,
-             UU1,Pdeb,
-             Ddeb,
-             UU2,Pfin,
-             Dfin,
-             Nbmin,
-             EPSILON*EPSILON,
-             Parameters,Points);
+
+  const Standard_Real aDelta = UU2 - UU1;
+  const Standard_Real aDist = Pdeb.Distance(Pfin);
+
+  if((aDelta/aDist) > 5.0e-14)
+  {
+    QuasiFleche(C,Deflection*Deflection,
+                     UU1,Pdeb,
+                     Ddeb,
+                     UU2,Pfin,
+                     Dfin,
+                     Nbmin,
+                     EPSILON*EPSILON,
+                     Parameters,Points);
+  }
+
   return Standard_True;
 }
 //=======================================================================
@@ -2388,4 +2581,4 @@ static void QuasiFleche(const Adaptor3d_Curve& C,
                Parameters,Points);
   }
 }
-                       
+
index fad86aa800da92fd1a0a68e93eae77d9ac9d9e2e..2d7a5ab221fe1bee941d0534c649cfe6413e2d93 100755 (executable)
@@ -1,24 +1,18 @@
 -- Created on: 1995-09-18
 -- Created by: Bruno DUMORTIER
 -- Copyright (c) 1995-1999 Matra Datavision
--- Copyright (c) 1999-2012 OPEN CASCADE SAS
+-- Copyright (c) 1999-2014 OPEN CASCADE SAS
 --
--- The content of this file is subject to the Open CASCADE Technology Public
--- License Version 6.5 (the "License"). You may not use the content of this file
--- except in compliance with the License. Please obtain a copy of the License
--- at http://www.opencascade.org and read it completely before using this file.
+-- This file is part of Open CASCADE Technology software library.
 --
--- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
--- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+-- This library is free software; you can redistribute it and/or modify it under
+-- the terms of the GNU Lesser General Public License version 2.1 as published
+-- by the Free Software Foundation, with special exception defined in the file
+-- OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+-- distribution for complete text of the license and disclaimer of any warranty.
 --
--- The Original Code and all software distributed under the License is
--- distributed on an "AS IS" basis, without warranty of any kind, and the
--- Initial Developer hereby disclaims all such warranties, including without
--- limitation, any warranties of merchantability, fitness for a particular
--- purpose or non-infringement. Please see the License for the specific terms
--- and conditions governing the rights and limitations under the License.
-
-
+-- Alternatively, this file may be used under the terms of Open CASCADE
+-- commercial license or contractual agreement.
 
 class MakeOffset from BRepOffsetAPI inherits MakeShape from BRepBuilderAPI
 
@@ -46,13 +40,15 @@ is
     Create returns MakeOffset from BRepOffsetAPI;
        ---Purpose: Constructs an algorithm for creating an empty offset
     Create( Spine : Face from TopoDS;
-           Join  : JoinType from GeomAbs = GeomAbs_Arc)
+           Join  : JoinType from GeomAbs = GeomAbs_Arc;
+           IsOpenResult : Boolean from Standard = Standard_False)
     returns MakeOffset from BRepOffsetAPI;
        ---Purpose: Constructs an algorithm for creating an algorithm
        -- to build parallels to the spine Spine   
     Init( me    : in out;
          Spine : Face     from TopoDS; 
-         Join  : JoinType from GeomAbs  =  GeomAbs_Arc)
+         Join  : JoinType from GeomAbs  =  GeomAbs_Arc;
+         IsOpenResult : Boolean from Standard = Standard_False)
        ---Purpose: Initializes the algorithm to construct parallels to the spine Spine.
        -- Join defines the type of parallel generated by the
        -- salient vertices of the spine. The default type is
@@ -61,11 +57,13 @@ is
     is static;
     
     Create( Spine : Wire from TopoDS;
-           Join  : JoinType from GeomAbs = GeomAbs_Arc)
+           Join  : JoinType from GeomAbs = GeomAbs_Arc;
+           IsOpenResult : Boolean from Standard = Standard_False)
     returns MakeOffset from BRepOffsetAPI;
     
     Init( me    : in out;
-         Join  : JoinType from GeomAbs  =  GeomAbs_Arc)
+         Join  : JoinType from GeomAbs  =  GeomAbs_Arc;
+         IsOpenResult : Boolean from Standard = Standard_False)
        ---Purpose: Initialize the evaluation of Offseting.
     is static;
 
@@ -105,6 +103,7 @@ fields
     myIsInitialized : Boolean          from Standard;
     myLastIsLeft    : Boolean          from Standard;
     myJoin          : JoinType         from GeomAbs;   
+    myIsOpenResult  : Boolean          from Standard;  
     myFace          : Face             from TopoDS;
     myWires         : ListOfShape      from TopTools;   
     myLeft          : ListOfOffsetWire from BRepFill;
index bfdcb6d7bea022f1b2952db9cd7bc684011d79d7..a47a7df3259cf2b3ccae0b35975328b4a8110a97 100755 (executable)
@@ -1,24 +1,18 @@
 // Created on: 1995-09-18
 // Created by: Bruno DUMORTIER
 // Copyright (c) 1995-1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
 //
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
 //
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
 //
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
-
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
 
 #include <BRepOffsetAPI_MakeOffset.ixx>
 #include <BRepBuilderAPI_MakeFace.hxx>
@@ -60,9 +54,10 @@ BRepOffsetAPI_MakeOffset::BRepOffsetAPI_MakeOffset()
 //=======================================================================
 
 BRepOffsetAPI_MakeOffset::BRepOffsetAPI_MakeOffset(const TopoDS_Face& Spine, 
-                                      const GeomAbs_JoinType Join)
+                                                   const GeomAbs_JoinType Join,
+                                                   const Standard_Boolean IsOpenResult)
 {
-  Init(Spine, Join);
+  Init(Spine, Join, IsOpenResult);
 }
 
 
@@ -72,11 +67,13 @@ BRepOffsetAPI_MakeOffset::BRepOffsetAPI_MakeOffset(const TopoDS_Face& Spine,
 //=======================================================================
 
 void BRepOffsetAPI_MakeOffset::Init(const TopoDS_Face&     Spine,
-                             const GeomAbs_JoinType Join)
+                                    const GeomAbs_JoinType Join,
+                                    const Standard_Boolean IsOpenResult)
 {
   myFace          = Spine;
   myIsInitialized = Standard_True;
   myJoin          = Join;
+  myIsOpenResult  = IsOpenResult;
   TopExp_Explorer exp;
   for (exp.Init(myFace,TopAbs_WIRE); exp.More();exp.Next()) {
     myWires.Append(exp.Current());
@@ -89,11 +86,13 @@ void BRepOffsetAPI_MakeOffset::Init(const TopoDS_Face&     Spine,
 //=======================================================================
 
 BRepOffsetAPI_MakeOffset::BRepOffsetAPI_MakeOffset(const TopoDS_Wire& Spine, 
-                                       const GeomAbs_JoinType Join)
+                                                   const GeomAbs_JoinType Join,
+                                                   const Standard_Boolean IsOpenResult)
 {
   myWires.Append(Spine);
   myIsInitialized = Standard_True;
   myJoin = Join;
+  myIsOpenResult  = IsOpenResult;
 }
 
 //=======================================================================
@@ -101,18 +100,20 @@ BRepOffsetAPI_MakeOffset::BRepOffsetAPI_MakeOffset(const TopoDS_Wire& Spine,
 //purpose  : 
 //=======================================================================
 
-void BRepOffsetAPI_MakeOffset::Init(const GeomAbs_JoinType Join)
+void BRepOffsetAPI_MakeOffset::Init(const GeomAbs_JoinType Join,
+                                    const Standard_Boolean IsOpenResult)
 {
   myJoin = Join;
+  myIsOpenResult  = IsOpenResult;
 }
+
 //=======================================================================
 //function : BRepOffsetAPI_MakeOffset
 //purpose  : 
 //=======================================================================
 
 void BRepOffsetAPI_MakeOffset::AddWire(const TopoDS_Wire& Spine)
-                                           
+
 {
   myIsInitialized = Standard_True;
   myWires.Append(Spine);
@@ -124,10 +125,11 @@ void BRepOffsetAPI_MakeOffset::AddWire(const TopoDS_Wire& Spine)
 //=======================================================================
 
 static void BuildDomains(TopoDS_Face&               myFace,
-                        TopTools_ListOfShape&      WorkWires,
-                        BRepFill_ListOfOffsetWire& myAlgos,
-                        GeomAbs_JoinType           myJoin,
-                        Standard_Boolean           isPositive)
+                         TopTools_ListOfShape&      WorkWires,
+                         BRepFill_ListOfOffsetWire& myAlgos,
+                         GeomAbs_JoinType           myJoin,
+                         Standard_Boolean           myIsOpenResult,
+                         Standard_Boolean           isPositive)
 {
   BRepAlgo_FaceRestrictor  FR;
   TopoDS_Vertex            VF,VL;
@@ -146,14 +148,14 @@ static void BuildDomains(TopoDS_Face&               myFace,
   if (anExp.More()) {
     aWire2 = anExp.Current();
     if ((aWire1.Orientation() == aWire2.Orientation() && isPositive) ||
-       (aWire1.Orientation() == TopAbs::Complement(aWire2.Orientation()) && !isPositive)) {
-      TopTools_ListOfShape LWires;
-      TopTools_ListIteratorOfListOfShape itl;
-      for (itl.Initialize(WorkWires); itl.More(); itl.Next()) {
-       const TopoDS_Shape& W = itl.Value();
-       LWires.Append(W.Reversed());
-      }
-      WorkWires = LWires;
+      (aWire1.Orientation() == TopAbs::Complement(aWire2.Orientation()) && !isPositive)) {
+        TopTools_ListOfShape LWires;
+        TopTools_ListIteratorOfListOfShape itl;
+        for (itl.Initialize(WorkWires); itl.More(); itl.Next()) {
+          const TopoDS_Shape& W = itl.Value();
+          LWires.Append(W.Reversed());
+        }
+        WorkWires = LWires;
     }
   }
 //  Modified by Sergey KHROMOV - Thu Apr 26 16:04:44 2001 End
@@ -196,11 +198,11 @@ static void BuildDomains(TopoDS_Face&               myFace,
     for ( ; itW.More(); itW.Next()) {
       B.Add(F,itW.Value());
     }
-    BRepFill_OffsetWire Algo(F, myJoin);
+    BRepFill_OffsetWire Algo(F, myJoin, myIsOpenResult);
     myAlgos.Append(Algo);
     return;
   }
-  
+
   //====================================================
   // Classification of open wires.
   //====================================================  
@@ -227,21 +229,21 @@ static void BuildDomains(TopoDS_Face&               myFace,
       Standard_Real     Dist2Min = Precision::Infinite();
       Standard_Real     Found   = Standard_False;
       for (Standard_Integer ie = 1; ie <= ExtPS.NbExt(); ie++) {
-       Standard_Real X,Y;
-       if (ExtPS.SquareDistance(ie) < Dist2Min) {
-         Dist2Min = ExtPS.SquareDistance(ie);
-         Found   = Standard_True;
-         ExtPS.Point(ie).Parameter(X,Y);
-         PV.SetCoord(X,Y);
-       }
+        Standard_Real X,Y;
+        if (ExtPS.SquareDistance(ie) < Dist2Min) {
+          Dist2Min = ExtPS.SquareDistance(ie);
+          Found   = Standard_True;
+          ExtPS.Point(ie).Parameter(X,Y);
+          PV.SetCoord(X,Y);
+        }
       }
       if ( Found && (CL.Perform(PV) == TopAbs_IN)) {
-       // The face that contains a wire is found and it is removed from the list
-       B.Add(F,W);
-       LOW.Remove(itW);
+        // The face that contains a wire is found and it is removed from the list
+        B.Add(F,W);
+        LOW.Remove(itW);
       }
       else {
-       itW.Next();
+        itW.Next();
       }
     }
   }
@@ -249,7 +251,7 @@ static void BuildDomains(TopoDS_Face&               myFace,
   // Creation of algorithms on each domain.
   //========================================
   for (itF.Initialize(Faces); itF.More(); itF.Next()) {
-    BRepFill_OffsetWire Algo(TopoDS::Face(itF.Value()), myJoin);
+    BRepFill_OffsetWire Algo(TopoDS::Face(itF.Value()), myJoin, myIsOpenResult);
     myAlgos.Append(Algo);
   }
 }
@@ -259,54 +261,86 @@ static void BuildDomains(TopoDS_Face&               myFace,
 //purpose  : 
 //=======================================================================
 
-void BRepOffsetAPI_MakeOffset::Perform(const Standard_Real Offset, 
-                                const Standard_Real Alt)
+void BRepOffsetAPI_MakeOffset::Perform(const Standard_Real Offset,
+                                       const Standard_Real Alt)
 {
   StdFail_NotDone_Raise_if ( !myIsInitialized,
-                           "BRepOffsetAPI_MakeOffset : Perform without Init");
-
-  Standard_Integer i = 1;
-  BRepFill_ListIteratorOfListOfOffsetWire itOW;  
-  TopoDS_Compound Res;
-  BRep_Builder    B;
-  B.MakeCompound (Res);
-
-  myLastIsLeft = (Offset <= 0);
-  
-  if (Offset <= 0.) {
-    if (myLeft.IsEmpty()) {
-//  Modified by Sergey KHROMOV - Fri Apr 27 14:35:26 2001 Begin
-      BuildDomains(myFace,myWires,myLeft,myJoin, Standard_False);
-//  Modified by Sergey KHROMOV - Fri Apr 27 14:35:26 2001 End
-    }
-    for (itOW.Initialize(myLeft); itOW.More(); itOW.Next()) {
-      BRepFill_OffsetWire& Algo = itOW.Value();
-      Algo.Perform(Abs(Offset),Alt);
-      if (Algo.IsDone() && !Algo.Shape().IsNull()) {
-       B.Add(Res,Algo.Shape());
-       if (i == 1) myShape = Algo.Shape();
-       i++;
+    "BRepOffsetAPI_MakeOffset : Perform without Init");
+
+  try
+  {
+    Standard_Integer i = 1;
+    BRepFill_ListIteratorOfListOfOffsetWire itOW;
+    TopoDS_Compound Res;
+    BRep_Builder    B;
+    B.MakeCompound (Res);
+    myLastIsLeft = (Offset <= 0);
+
+    if( Offset <= 0. )
+    {
+      if( myLeft.IsEmpty() )
+      {
+        //  Modified by Sergey KHROMOV - Fri Apr 27 14:35:26 2001 Begin
+        BuildDomains(myFace,myWires,myLeft,myJoin,myIsOpenResult, Standard_False);
+        //  Modified by Sergey KHROMOV - Fri Apr 27 14:35:26 2001 End
+      }
+
+      for (itOW.Initialize(myLeft); itOW.More(); itOW.Next())
+      {
+        BRepFill_OffsetWire& Algo = itOW.Value();
+        Algo.Perform(Abs(Offset),Alt);
+        if (Algo.IsDone() && !Algo.Shape().IsNull())
+        {
+          B.Add(Res,Algo.Shape());
+          if (i == 1)
+            myShape = Algo.Shape();
+
+          i++;
+        }
       }
     }
-  }
-  else {
-    if (myRight.IsEmpty()) {
-//  Modified by Sergey KHROMOV - Fri Apr 27 14:35:28 2001 Begin
-      BuildDomains(myFace,myWires,myRight,myJoin, Standard_True);
-//  Modified by Sergey KHROMOV - Fri Apr 27 14:35:35 2001 End
-    }
-    for (itOW.Initialize(myRight); itOW.More(); itOW.Next()) {
-      BRepFill_OffsetWire& Algo = itOW.Value();
-      Algo.Perform(Offset,Alt);
-      if (Algo.IsDone() && !Algo.Shape().IsNull()) {
-       B.Add(Res,Algo.Shape());
-       if (i == 1) myShape = Algo.Shape();
-       i++;
+    else
+    {
+      if (myRight.IsEmpty())
+      {
+        //  Modified by Sergey KHROMOV - Fri Apr 27 14:35:28 2001 Begin
+        BuildDomains(myFace,myWires,myRight,myJoin,myIsOpenResult, Standard_True);
+        //  Modified by Sergey KHROMOV - Fri Apr 27 14:35:35 2001 End
+      }
+
+      for(itOW.Initialize(myRight); itOW.More(); itOW.Next())
+      {
+        BRepFill_OffsetWire& Algo = itOW.Value();
+        Algo.Perform(Offset,Alt);
+
+        if (Algo.IsDone() && !Algo.Shape().IsNull())
+        {
+          B.Add(Res,Algo.Shape());
+
+          if (i == 1)
+            myShape = Algo.Shape();
+
+          i++;
+        }
       }
     }
+
+    if( i > 2 )
+      myShape = Res;
+
+    if(myShape.IsNull())
+      NotDone();
+    else
+      Done();
+  }
+  catch(...) //Every exception was caught.
+  {
+    cout<<"An exception was caught in BRepOffsetAPI_MakeOffset::Perform : ";
+    Standard_ConstructionError::Caught()->Print(cout); 
+    cout<<endl;
+    NotDone();
+    myShape.Nullify();
   }
-  if (i > 2) myShape = Res;
-  Done();
 }
 
 //=======================================================================
@@ -326,7 +360,7 @@ void BRepOffsetAPI_MakeOffset::Build()
 //=======================================================================
 
 const TopTools_ListOfShape& BRepOffsetAPI_MakeOffset::Generated
-(const TopoDS_Shape& S)
+  (const TopoDS_Shape& S)
 {
   myGenerated.Clear();
   BRepFill_ListIteratorOfListOfOffsetWire itOW;
index ac1579ba75131923f35be29a211b607cc997d4a1..4bd0fb7f09ef7a2b97474b045c8b207e7698be8b 100755 (executable)
@@ -1486,23 +1486,28 @@ Standard_Integer mkoffset(Draw_Interpretor& di,
   if (n < 5) return 1;
   char name[100];
 
-  BRepOffsetAPI_MakeOffset Paral;  
+  BRepOffsetAPI_MakeOffset Paral;
+  GeomAbs_JoinType theJoinType = GeomAbs_Arc;
+  if (n >= 6 && strcmp(a[5], "i") == 0)
+    theJoinType = GeomAbs_Intersection;
+  Paral.Init(theJoinType);
   TopoDS_Shape Base = DBRep::Get(a[2],TopAbs_FACE);
 
-  if ( Base.IsNull()) {
+  if ( Base.IsNull())
+  {
     Base = DBRep::Get(a[2]);
     if (Base.IsNull()) return 1;
-    Paral.Init(GeomAbs_Arc);
+    Paral.Init(theJoinType);
     TopExp_Explorer exp;
-    for (exp.Init(Base,TopAbs_WIRE); exp.More(); exp.Next()) {
+    for (exp.Init(Base,TopAbs_WIRE); exp.More(); exp.Next())
+    {
       TopoDS_Wire aLocalShape = TopoDS::Wire(exp.Current());
       Paral.AddWire(aLocalShape);
-//      Paral.AddWire(TopoDS::Wire(exp.Current()));
     }
   }
-  else {
+  else
+  {
     Base.Orientation(TopAbs_FORWARD);
-//    Base = TopoDS::Face(Base.Oriented(TopAbs_FORWARD));
     Paral.Init(TopoDS::Face(Base));
   }
 
@@ -1512,22 +1517,77 @@ Standard_Integer mkoffset(Draw_Interpretor& di,
   Nb = Draw::Atoi(a[3]);
 
   Standard_Real Alt = 0.;
-  if ( n == 6) Alt = Draw::Atof(a[5]);
+  if ( n == 7)
+    Alt = Draw::Atof(a[6]);
+
   Standard_Integer Compt = 1;
 
-  for ( Standard_Integer i = 1; i <= Nb; i++) {
+  for ( Standard_Integer i = 1; i <= Nb; i++)
+  {
     U = i * dU;
     Paral.Perform(U,Alt);
-    if ( !Paral.IsDone()) {
-      //cout << " Parali aux fraises" << endl;
-      di << " Parali aux fraises" << "\n";
+
+    if ( !Paral.IsDone())
+    {
+      di << " Error: Offset is not done." << "\n";
+      return 1;
     }
-    else {
+    else
+    {
       Sprintf(name,"%s_%d", a[1], Compt++);
       char* temp = name; // portage WNT
       DBRep::Set(temp,Paral.Shape());
     }
   }
+
+  return 0;
+}
+
+//=======================================================================
+//function : openoffset
+//purpose  : 
+//=======================================================================
+
+Standard_Integer openoffset(Draw_Interpretor& di, 
+  Standard_Integer n, const char** a)
+{
+  if (n < 5) return 1;
+  char name[100];
+
+  TopoDS_Shape Base = DBRep::Get(a[2], TopAbs_WIRE);
+
+  GeomAbs_JoinType theJoinType = GeomAbs_Arc;
+  if (n == 6 && strcmp(a[5], "i") == 0)
+    theJoinType = GeomAbs_Intersection;
+  
+  BRepOffsetAPI_MakeOffset Paral(TopoDS::Wire(Base), theJoinType, Standard_True);
+
+  Standard_Real U, dU;
+  Standard_Integer Nb;
+  dU = Draw::Atof(a[4]);
+  Nb = Draw::Atoi(a[3]);
+
+  Standard_Integer Compt = 1;
+  
+  Standard_Real Alt = 0.;
+  for ( Standard_Integer i = 1; i <= Nb; i++)
+  {
+    U = i * dU;
+    Paral.Perform(U,Alt);
+
+    if ( !Paral.IsDone())
+    {
+      di << " Error: Offset is not done." << "\n";
+      return 1;
+    }
+    else
+    {
+      Sprintf(name,"%s_%d", a[1], Compt++);
+      char* temp = name; // portage WNT
+      DBRep::Set(temp,Paral.Shape());
+    }
+  }
+
   return 0;
 }
 
@@ -1795,9 +1855,12 @@ void  BRepTest::CurveCommands(Draw_Interpretor& theCommands)
                  profile2d,g);
 
   theCommands.Add("mkoffset",
-                 "mkoffset result face/compound of wires  nboffset stepoffset [alt]",__FILE__,
-                 mkoffset);
+    "mkoffset result face/compound of wires  nboffset stepoffset [jointype(a/i) [alt]]",__FILE__,
+    mkoffset);
 
+  theCommands.Add("openoffset",
+    "openoffset result wire nboffset stepoffset [jointype(a/i)]",__FILE__,
+    openoffset);
 
   theCommands.Add("mkedge",
                  "mkedge edge curve [surface] [pfirst plast] [vfirst [pfirst] vlast [plast]] ",__FILE__,
index 8010e5816f370dc0b709b2104b17b5d9e6cd794f..ae8402a929a86635c318cf51a0b17ea3e81c4300 100755 (executable)
@@ -105,9 +105,17 @@ static Standard_Integer drawcont(Draw_Interpretor& , Standard_Integer , const ch
 //           calculate the map of locations bisector on the contour defined by 
 //           the explorer.
 //==========================================================================
-static Standard_Integer mat(Draw_Interpretor& , Standard_Integer, const char**)
+static Standard_Integer mat(Draw_Interpretor&, Standard_Integer n, const char** a)
 {
-  MapBiLo.Compute(anExplo,1,SideOfMat);
+  GeomAbs_JoinType theJoinType = GeomAbs_Arc;
+  if (n  >= 2 && strcmp(a[1], "i") == 0)
+    theJoinType = GeomAbs_Intersection;
+
+  Standard_Boolean IsOpenResult = Standard_False;
+  if (n == 3 && strcmp(a[2], "o") == 0)
+    IsOpenResult = Standard_True;
+  
+  MapBiLo.Compute(anExplo, 1, SideOfMat, theJoinType, IsOpenResult);
   LinkComputed = Standard_False;
 
   return 0;
@@ -271,7 +279,7 @@ void BRepTest::MatCommands (Draw_Interpretor& theCommands)
 {
   theCommands.Add("topoload","load face",__FILE__,topoload);
   theCommands.Add("drawcont","display current contour",__FILE__,drawcont);
-  theCommands.Add("mat","computes the mat",__FILE__,mat);
+  theCommands.Add("mat","computes the mat: mat [a/i [o]]",__FILE__,mat);
   theCommands.Add("side","side left/right",__FILE__,side);
   theCommands.Add("result","result",__FILE__,result);
   theCommands.Add("zone","zone edge or vertex",__FILE__,zone);
index 5349ead8e77a79d842b0c896d0ed7b9880b89dac..a65e68a2afb35f60edc287a94701e4def97c82b8 100755 (executable)
@@ -27,7 +27,7 @@ package MAT2d
         --           Set of geometrys from Geom2d.
 
 uses
-
+    GeomAbs,
     MMgt,
     gp,
     Geom2d,
index b0081e15639d643f0bee6e6e49f5c11985bcde86..30831037d0db777ffc8066f4717f76c061f5455f 100755 (executable)
@@ -59,6 +59,7 @@ generic class BisectingLocus from MAT2d (Explorer as any)
        --         - The Nodes are the extremities of the arcs.
 
 uses
+    JoinType                 from GeomAbs,
     Graph                    from MAT,
     Arc                      from MAT,
     BasicElt                 from MAT,
@@ -79,7 +80,9 @@ is
     Compute (me        : in out ; 
             anExplo   : in out Explorer;
              LineIndex :        Integer       = 1;
-             aSide     :        Side from MAT = MAT_Left )
+             aSide     :        Side from MAT = MAT_Left;
+            aJoinType    :     JoinType from GeomAbs = GeomAbs_Arc;
+            IsOpenResult :     Boolean       = Standard_False)
        --- Purpose : Computation of the Bisector_Locus in a set of Lines 
        --            defined in <anExplo>.
        --            The bisecting locus are computed on the side <aSide>
@@ -165,11 +168,3 @@ fields
     nbContours  : Integer               from Standard; 
     
 end BisectingLocus;
-
-
-
-
-
-
-
-
index 15af9da8ff9fc03ee84d269a940947dd755a52af..8290176f20a85f1fd6343e5fc5aa92724ee7d04c 100755 (executable)
@@ -59,9 +59,11 @@ MAT2d_BisectingLocus::MAT2d_BisectingLocus()
 //purpose  : Calcul de la carte des lieux bisecteurs sur le contour defini par
 //           <anExplo>.
 //=============================================================================
-void MAT2d_BisectingLocus::Compute(      Explorer&        anExplo,
+void MAT2d_BisectingLocus::Compute(Explorer&        anExplo,
                                   const Standard_Integer IndexLine,
-                                  const MAT_Side         aSide    ) 
+                                   const MAT_Side         aSide,
+                                   const GeomAbs_JoinType aJoinType,
+                                   const Standard_Boolean IsOpenResult)
 {
   MAT2d_Mat2d                        TheMAT;
   Handle(MAT_ListOfBisector)         TheRoots = new MAT_ListOfBisector();
@@ -90,7 +92,7 @@ void MAT2d_BisectingLocus::Compute(      Explorer&        anExplo,
   //----------------------------------------------------------
   // Construction du circuit sur lequel est calcule la carte.
   //----------------------------------------------------------
-  Handle(MAT2d_Circuit) ACircuit = new MAT2d_Circuit();
+  Handle(MAT2d_Circuit) ACircuit = new MAT2d_Circuit(aJoinType, IsOpenResult);
 //  Modified by Sergey KHROMOV - Wed Mar  6 17:43:47 2002 Begin
 //   ACircuit->Perform(Figure,IndexLine,(aSide == MAT_Left));
   ACircuit->Perform(Figure,anExplo.GetIsClosed(), IndexLine,(aSide == MAT_Left));
@@ -100,6 +102,7 @@ void MAT2d_BisectingLocus::Compute(      Explorer&        anExplo,
   // Initialistion du Tool.
   // -----------------------
   theTool.Sense(aSide);
+  theTool.SetJoinType(aJoinType);
   theTool.InitItems(ACircuit);
 
   // --------------------------------------------
index 2fc25cbce903520430cefcfad0932c2d8954c60a..91ab45828b18a5ec6848ffe3d5c772858bd53697 100755 (executable)
@@ -32,7 +32,7 @@ inherits
        --           
 
 uses
-
+    JoinType                         from GeomAbs,
     SequenceOfInteger                from TColStd,
     Geometry                         from Geom2d,
     SequenceOfGeometry               from TColGeom2d,
@@ -47,7 +47,9 @@ uses
 
 is
 
-    Create returns mutable Circuit from MAT2d;
+    Create(aJoinType    : JoinType from GeomAbs  = GeomAbs_Arc;
+          IsOpenResult : Boolean  from Standard = Standard_False) 
+    returns mutable Circuit from MAT2d;
 
 ---Category:  Computation
 
@@ -58,6 +60,11 @@ is
             Trigo       :        Boolean)
     is static;     
     
+    IsSharpCorner(me; Geom1, Geom2 : Geometry from Geom2d;
+                     Direction : Real from Standard)
+    returns Boolean
+    is static private;
+    
     PassByLast(me ; C1,C2 : Connexion from MAT2d) 
     returns Boolean
     is static private;
@@ -135,6 +142,8 @@ fields
     connexionMap : DataMapOfIntegerConnexion       from MAT2d;
     linkRefEqui  : DataMapOfBiIntSequenceOfInteger from MAT2d;
     linesLength  : SequenceOfInteger               from TColStd; 
+    myJoinType     : JoinType from GeomAbs;
+    myIsOpenResult : Boolean  from Standard;
     
 end Circuit;
 
index d279aacb24ac76142a2f76a6b9743dd0b99d99f7..3481e3287e6d3b5146b148758fe6f5d9f967c888 100755 (executable)
@@ -72,16 +72,16 @@ static Standard_Real CrossProd(const Handle(Geom2d_Geometry)& Geom1,
                               const Handle(Geom2d_Geometry)& Geom2,
                                     Standard_Real&           DotProd);
 
-static Standard_Boolean IsSharpCorner (const Handle(Geom2d_Geometry)& Geom1,
-                                      const Handle(Geom2d_Geometry)& Geom2,
-                                      const Standard_Real&           Direction);
 
 //=============================================================================
 //function : Constructor
 //purpose :
 //=============================================================================
-MAT2d_Circuit::MAT2d_Circuit()
+MAT2d_Circuit::MAT2d_Circuit(const GeomAbs_JoinType aJoinType,
+                             const Standard_Boolean IsOpenResult)
 {
+  myJoinType = aJoinType;
+  myIsOpenResult = IsOpenResult;
 }
 
 //=============================================================================
@@ -208,6 +208,133 @@ void  MAT2d_Circuit::Perform
   ConstructCircuit(FigItem,IndRefLine,Road);
 }
 
+//=======================================================================
+//function : IsSharpCorner
+//purpose  : Return True Si le point commun entre <Geom1> et <Geom2> est 
+//           une cassure saillante par rapport <Direction>
+//=======================================================================
+
+Standard_Boolean MAT2d_Circuit::IsSharpCorner(const Handle(Geom2d_Geometry)& Geom1,
+                                              const Handle(Geom2d_Geometry)& Geom2,
+                                              const Standard_Real Direction) const
+{
+  Standard_Real    DotProd;
+  Standard_Real    ProVec = CrossProd (Geom1,Geom2,DotProd);
+  Standard_Integer NbTest = 1;
+  Standard_Real    DU = Precision::Confusion();
+  Handle(Geom2d_TrimmedCurve) C1,C2;
+
+  C1= Handle(Geom2d_TrimmedCurve)::DownCast(Geom1);
+  C2= Handle(Geom2d_TrimmedCurve)::DownCast(Geom2);
+//  Modified by Sergey KHROMOV - Thu Oct 24 19:02:46 2002 Begin
+// Add the same criterion as it is in MAT2d_Circuit::InitOpen(..)
+//  Standard_Real  TolAng = 1.E-5;
+  Standard_Real  TolAng = 1.E-8;
+//  Modified by Sergey KHROMOV - Thu Oct 24 19:02:47 2002 End
+
+  if (myJoinType == GeomAbs_Arc)
+  {
+    while (NbTest <= 10) {
+      if      ((ProVec)*Direction < -TolAng)                 
+        return Standard_True;                // Saillant.
+      if      ((ProVec)*Direction >  TolAng)
+        return Standard_False;              // Rentrant.
+      else { 
+        if (DotProd > 0) {
+          return Standard_False;            // Plat.
+        }
+        TolAng = 1.E-8;
+        Standard_Real U1 = C1->LastParameter()  - NbTest*DU;
+        Standard_Real U2 = C2->FirstParameter() + NbTest*DU;
+        gp_Dir2d Dir1(C1->DN(U1,1));
+        gp_Dir2d Dir2(C2->DN(U2,1));
+        DotProd = Dir1.Dot(Dir2);
+        ProVec  =  Dir1^Dir2;
+        NbTest++;
+      } 
+    }
+    
+    
+    
+    // Rebroussement.
+    // on calculde des paralleles aux deux courbes du cote du domaine
+    // de calcul
+    // Si pas dintersection => saillant.
+    // Sinon                => rentrant.
+    Standard_Real D ;
+    Standard_Real Tol   = Precision::Confusion();
+    Standard_Real MilC1 = (C1->LastParameter() + C1->FirstParameter())*0.5;
+    Standard_Real MilC2 = (C2->LastParameter() + C2->FirstParameter())*0.5;
+    gp_Pnt2d      P     = C1->Value(C1->LastParameter());
+    gp_Pnt2d      P1    = C1->Value(MilC1);
+    gp_Pnt2d      P2    = C2->Value(MilC2);
+    
+    D = Min(P1.Distance(P),P2.Distance(P));
+    D /= 10;
+    
+    if (Direction > 0.) D = -D;
+    
+    Handle(Geom2dAdaptor_HCurve) HC1 = new Geom2dAdaptor_HCurve(C1);
+    Handle(Geom2dAdaptor_HCurve) HC2 = new Geom2dAdaptor_HCurve(C2);
+    Adaptor3d_OffsetCurve OC1(HC1,D,MilC1,C1->LastParameter());
+    Adaptor3d_OffsetCurve OC2(HC2,D,C2->FirstParameter(),MilC2);
+    Geom2dInt_GInter Intersect; 
+    Intersect.Perform(OC1,OC2,Tol,Tol);
+    
+#ifdef DEB
+    static Standard_Boolean Affich = 0;
+    if (Affich) {
+#ifdef DRAW
+      Standard_Real DU1 = (OC1.LastParameter() - OC1.FirstParameter())/9.;
+      Standard_Real DU2 = (OC2.LastParameter() - OC2.FirstParameter())/9.;
+      for (Standard_Integer ki = 0; ki <= 9; ki++) {
+        gp_Pnt2d P1 = OC1.Value(OC1.FirstParameter()+ki*DU1);
+        gp_Pnt2d P2 = OC2.Value(OC2.FirstParameter()+ki*DU2);
+        Handle(Draw_Marker2D) dr1 = new Draw_Marker2D(P1,Draw_Plus,Draw_vert);
+        Handle(Draw_Marker2D) dr2 = new Draw_Marker2D(P2,Draw_Plus,Draw_rouge); 
+        dout << dr1;
+        dout << dr2;
+      }
+      dout.Flush();
+#endif
+    }
+#endif
+    
+    if (Intersect.IsDone() && !Intersect.IsEmpty()) {
+      return Standard_False;
+    }
+    else {
+      return Standard_True;
+    }
+  } //end of if (myJoinType == GeomAbs_Arc)
+  else if (myJoinType == GeomAbs_Intersection)
+  {
+    if (Abs(ProVec) <= TolAng &&
+        DotProd < 0)
+    {
+      while (NbTest <= 10)
+      {
+        Standard_Real U1 = C1->LastParameter()  - NbTest*DU;
+        Standard_Real U2 = C2->FirstParameter() + NbTest*DU;
+        gp_Dir2d Dir1(C1->DN(U1,1));
+        gp_Dir2d Dir2(C2->DN(U2,1));
+        DotProd = Dir1.Dot(Dir2);
+        ProVec  =  Dir1^Dir2;
+        if      ((ProVec)*Direction < -TolAng)                 
+          return Standard_True;                // Saillant.
+        if      ((ProVec)*Direction >  TolAng)
+          return Standard_False;              // Rentrant.
+        
+        NbTest++;
+      }
+      return Standard_False;
+    }
+    else
+      return Standard_False;
+  }
+  return Standard_False;
+}
+
 //=======================================================================
 //function : SubSequence
 //purpose  : 
@@ -357,13 +484,17 @@ void MAT2d_Circuit::InitOpen (TColGeom2d_SequenceOfGeometry& Line) const
 { 
   Handle(Geom2d_TrimmedCurve) Curve;
   Standard_Real               DotProd;
-  Curve = Handle(Geom2d_TrimmedCurve)::DownCast(Line.First());
-  Line.InsertBefore(1,new Geom2d_CartesianPoint(Curve->StartPoint()));
-  Curve = Handle(Geom2d_TrimmedCurve)::DownCast(Line.Last());
-  Line.Append(new Geom2d_CartesianPoint(Curve->EndPoint()));
 
-  for ( Standard_Integer i = 2; i <= Line.Length() - 2; i++) {
+  if (!myIsOpenResult)
+  {
+    Curve = Handle(Geom2d_TrimmedCurve)::DownCast(Line.First());
+    Line.InsertBefore(1,new Geom2d_CartesianPoint(Curve->StartPoint()));
+    Curve = Handle(Geom2d_TrimmedCurve)::DownCast(Line.Last());
+    Line.Append(new Geom2d_CartesianPoint(Curve->EndPoint()));
+  }
+
+  Standard_Integer addition = (myIsOpenResult)? 1 : 2;
+  for ( Standard_Integer i = addition; i <= Line.Length() - addition; i++) {
     if ( Abs(CrossProd(Line.Value(i),Line.Value(i+1),DotProd)) > 1.E-8 ||
         DotProd < 0. ) {
       Curve = Handle(Geom2d_TrimmedCurve)::DownCast(Line.Value(i));
@@ -394,15 +525,18 @@ const
   //--------------------------
   // Completion de la ligne.
   //--------------------------
-  for ( i = NbItems - 1; i > 1; i--){
-    Type = Line.Value(i)->DynamicType();
-    if ( Type == STANDARD_TYPE(Geom2d_CartesianPoint) ){
-      Line.Append(Line.Value(i));
-    }
-    else {
-      Curve = Handle(Geom2d_TrimmedCurve)::DownCast(Line.Value(i)->Copy());
-      Curve->Reverse();
-      Line.Append(Curve);
+  if (!myIsOpenResult)
+  {
+    for ( i = NbItems - 1; i > 1; i--){
+      Type = Line.Value(i)->DynamicType();
+      if ( Type == STANDARD_TYPE(Geom2d_CartesianPoint) ){
+        Line.Append(Line.Value(i));
+      }
+      else {
+        Curve = Handle(Geom2d_TrimmedCurve)::DownCast(Line.Value(i)->Copy());
+        Curve->Reverse();
+        Line.Append(Curve);
+      }
     }
   }
 
@@ -490,30 +624,34 @@ const
     ICorres++;
   }
   Corres(ICorres) = IndLine;
-  
-  for (i = 1; i < 2*NbItems - 2; i++) {
-    if (Corres(i) == 0) Corres(i) = Corres(2*NbItems - i);
-  }
 
+  if (!myIsOpenResult)
+  {
+    for (i = 1; i < 2*NbItems - 2; i++) {
+      if (Corres(i) == 0)
+        Corres(i) = Corres(2*NbItems - i);
+    }
+    
 #ifdef DEB
-  if (AffichCircuit) {
-    for (i = 1; i <= 2*NbItems - 2; i++) {
-      cout<< "Correspondance "<< i<<" -> "<<Corres(i)<<endl;
+    if (AffichCircuit) {
+      for (i = 1; i <= 2*NbItems - 2; i++) {
+        cout<< "Correspondance "<< i<<" -> "<<Corres(i)<<endl;
+      }
     }
-  }
 #endif
-
-  //----------------------------
-  // Mise a jour des Connexions.
-  //----------------------------
-  for ( i = 1; i <= NbConnexions; i++){
-    CC = ConnexionFrom.ChangeValue(i);
-    CC->IndexItemOnFirst(Corres(CC->IndexItemOnFirst()));
-  }
-
-  if (!ConnexionFather.IsNull()) {
-    ConnexionFather
-      ->IndexItemOnSecond(Corres(ConnexionFather->IndexItemOnSecond()));
+    
+    //----------------------------
+    // Mise a jour des Connexions.
+    //----------------------------
+    for ( i = 1; i <= NbConnexions; i++){
+      CC = ConnexionFrom.ChangeValue(i);
+      CC->IndexItemOnFirst(Corres(CC->IndexItemOnFirst()));
+    }
+    
+    if (!ConnexionFather.IsNull()) {
+      ConnexionFather
+        ->IndexItemOnSecond(Corres(ConnexionFather->IndexItemOnSecond()));
+    }
   }
 }
 
@@ -729,107 +867,6 @@ static Standard_Real CrossProd(const Handle(Geom2d_Geometry)& Geom1,
 }
 
 
-//=======================================================================
-//function : IsSharpCorner
-//purpose  : Return True Si le point commun entre <Geom1> et <Geom2> est 
-//           une cassure saillante par rapport <Direction>
-//=======================================================================
-
-static Standard_Boolean IsSharpCorner (const Handle(Geom2d_Geometry)& Geom1,
-                                      const Handle(Geom2d_Geometry)& Geom2,
-                                      const Standard_Real&           Direction)
-{    
-  Standard_Real    DotProd;
-  Standard_Real    ProVec = CrossProd (Geom1,Geom2,DotProd);
-  Standard_Integer NbTest = 1;
-  Standard_Real    DU = Precision::Confusion();
-  Handle(Geom2d_TrimmedCurve) C1,C2;
-
-  C1= Handle(Geom2d_TrimmedCurve)::DownCast(Geom1);
-  C2= Handle(Geom2d_TrimmedCurve)::DownCast(Geom2);
-//  Modified by Sergey KHROMOV - Thu Oct 24 19:02:46 2002 Begin
-// Add the same criterion as it is in MAT2d_Circuit::InitOpen(..)
-//  Standard_Real  TolAng = 1.E-5;
-  Standard_Real  TolAng = 1.E-8;
-//  Modified by Sergey KHROMOV - Thu Oct 24 19:02:47 2002 End
-
-  while (NbTest <= 10) {
-    if      ((ProVec)*Direction < -TolAng)                 
-      return Standard_True;                // Saillant.
-    if      ((ProVec)*Direction >  TolAng)
-      return Standard_False;              // Rentrant.
-    else { 
-      if (DotProd > 0) {
-       return Standard_False;            // Plat.
-      }
-      TolAng = 1.E-8;
-      Standard_Real U1 = C1->LastParameter()  - NbTest*DU;
-      Standard_Real U2 = C2->FirstParameter() + NbTest*DU;
-      gp_Dir2d Dir1(C1->DN(U1,1));
-      gp_Dir2d Dir2(C2->DN(U2,1));
-      DotProd = Dir1.Dot(Dir2);
-      ProVec  =  Dir1^Dir2;
-      NbTest++;
-    } 
-  }
-  
-
-  
-  // Rebroussement.
-  // on calculde des paralleles aux deux courbes du cote du domaine
-  // de calcul
-  // Si pas dintersection => saillant.
-  // Sinon                => rentrant.
-  Standard_Real D ;
-  Standard_Real Tol   = Precision::Confusion();
-  Standard_Real MilC1 = (C1->LastParameter() + C1->FirstParameter())*0.5;
-  Standard_Real MilC2 = (C2->LastParameter() + C2->FirstParameter())*0.5;
-  gp_Pnt2d      P     = C1->Value(C1->LastParameter());
-  gp_Pnt2d      P1    = C1->Value(MilC1);
-  gp_Pnt2d      P2    = C2->Value(MilC2);
-  
-  D = Min(P1.Distance(P),P2.Distance(P));
-  D /= 10;
-
-  if (Direction > 0.) D = -D;
-  
-  Handle(Geom2dAdaptor_HCurve) HC1 = new Geom2dAdaptor_HCurve(C1);
-  Handle(Geom2dAdaptor_HCurve) HC2 = new Geom2dAdaptor_HCurve(C2);
-  Adaptor3d_OffsetCurve OC1(HC1,D,MilC1,C1->LastParameter());
-  Adaptor3d_OffsetCurve OC2(HC2,D,C2->FirstParameter(),MilC2);
-  Geom2dInt_GInter Intersect; 
-  Intersect.Perform(OC1,OC2,Tol,Tol);
-  
-#ifdef DEB
-  static Standard_Boolean Affich = 0;
-  if (Affich) {
-    Standard_Real DU1 = (OC1.LastParameter() - OC1.FirstParameter())/9.;
-    Standard_Real DU2 = (OC2.LastParameter() - OC2.FirstParameter())/9.;
-    for (Standard_Integer ki = 0; ki <= 9; ki++) {
-      gp_Pnt2d P1 = OC1.Value(OC1.FirstParameter()+ki*DU1);
-      gp_Pnt2d P2 = OC2.Value(OC2.FirstParameter()+ki*DU2);
-#ifdef DRAW
-      Handle(Draw_Marker2D) dr1 = new Draw_Marker2D(P1,Draw_Plus,Draw_vert);
-      Handle(Draw_Marker2D) dr2 = new Draw_Marker2D(P2,Draw_Plus,Draw_rouge); 
-      dout << dr1;
-      dout << dr2;
-    }
-    dout.Flush();
-#else
-  }
-#endif
-  
-  }
-#endif
-  
-  if (Intersect.IsDone() && !Intersect.IsEmpty()) {
-    return Standard_False;
-  }
-  else {
-    return Standard_True;
-  }
-  return Standard_False;
-}
 
 
 
index 724484a4e93041c57b05a782aaae12bdbaad908f..7113cfdc2b7125e784f013c5d3581c1b4d4cccba 100755 (executable)
@@ -28,7 +28,7 @@ class Tool2d from MAT2d
 
 
 uses
-
+    JoinType                  from GeomAbs,
     Bisec                     from Bisector,
     Side                      from MAT,
     Bisector                  from MAT,
@@ -54,6 +54,9 @@ is
        --- Purpose :<aSide> defines the side of the computation of the map. 
     is static;
 
+    SetJoinType(me : in out ; aJoinType : JoinType from GeomAbs)
+    is static;
+
     InitItems(me          : in out                    ; 
               aCircuit    :        Circuit from MAT2d )
        --- Purpose : InitItems cuts the line in Items.
@@ -227,6 +230,7 @@ is
 fields
 
     theDirection          : Real;
+    theJoinType           : JoinType from GeomAbs;
     theNumberOfBisectors  : Integer;
     theNumberOfPnts       : Integer;
     theNumberOfVecs       : Integer;
index 48771a753effbf2c01575f49a65c95666fcc05b8..73efc72dd66d9175e302e3392e4bf0fa715af22b 100755 (executable)
@@ -1,24 +1,18 @@
 // Created on: 1993-07-12
 // Created by: Yves FRICAUD
 // Copyright (c) 1993-1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
 //
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
 //
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
 //
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
-
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
 
 #define Debug(expr)  cout<<" MAT2d_Tool2d.cxx  :  expr :"<<expr<<endl;
 
@@ -106,6 +100,7 @@ static Standard_Real MAT2d_TOLCONF = 1.e-7;
 MAT2d_Tool2d::MAT2d_Tool2d()
 {
   theDirection         = 1.;
+  theJoinType = GeomAbs_Arc; //default
   theNumberOfBisectors = 0;
   theNumberOfVecs      = 0;
   theNumberOfPnts      = 0;
@@ -138,6 +133,15 @@ void MAT2d_Tool2d::Sense(const MAT_Side aside)
   else                  theDirection = -1.;
 }
 
+//=============================================================================
+//function : SetJoinType
+//purpose  :
+//=============================================================================
+void MAT2d_Tool2d::SetJoinType(const GeomAbs_JoinType aJoinType)
+{
+  theJoinType = aJoinType;
+}
+
 //=============================================================================
 //function : NumberOfItems
 //purpose  :
@@ -412,8 +416,7 @@ void MAT2d_Tool2d::TrimBisec (      Bisector_Bisec&  B1,
   
   //gp_Vec2d             Tan1,Tan2;
   gp_Pnt2d             Ori; //PEdge;
-  Standard_Integer     IPrec,INext;
-  IPrec = (IndexEdge == 1)  ? theCircuit->NumberOfItems() : (IndexEdge - 1);
+  Standard_Integer     INext;
   INext = (IndexEdge == theCircuit->NumberOfItems()) ? 1  : (IndexEdge + 1);
   
   Handle(Standard_Type) EdgeType = theCircuit->Value(IndexEdge)->DynamicType();
@@ -541,7 +544,6 @@ Standard_Boolean MAT2d_Tool2d::Projection (const Standard_Integer IEdge   ,
   Handle(Standard_Type)       Type   = Elt->DynamicType();     
   Handle(Geom2d_TrimmedCurve) Curve; 
   Standard_Integer            INext;   
-  Standard_Real               ParameterOnC;
   Standard_Real               Eps = MAT2d_TOLCONF;//*10.;
 
   if (Type == STANDARD_TYPE(Geom2d_CartesianPoint)) {  
@@ -592,7 +594,6 @@ Standard_Boolean MAT2d_Tool2d::Projection (const Standard_Integer IEdge   ,
       if (Extremas.NbExt() == 0 ) return Standard_False; // Pas de solution!
       for (Standard_Integer i = 1; i <= Extremas.NbExt(); i++) {
        if (Extremas.SquareDistance(i) < Distance * Distance) {
-         ParameterOnC  = Extremas.Point(i).Parameter();
          Distance      = sqrt (Extremas.SquareDistance(i));
        }
       }
@@ -646,6 +647,9 @@ Standard_Boolean MAT2d_Tool2d::IsSameDistance (
   Standard_Real EpsDist = MAT2d_TOLCONF*100. ;
   Distance = Dist(1);
   for (Standard_Integer i = 1; i <= 4; i++){
+    if (theJoinType == GeomAbs_Intersection &&
+        Precision::IsInfinite(Dist(i)))
+      continue;
     if (Abs(Dist(i) - Distance) > EpsDist) {
       Distance = Precision::Infinite();
       return Standard_False;
@@ -666,7 +670,7 @@ Standard_Real MAT2d_Tool2d::IntersectBisector (
   Standard_Real    Tolerance     = MAT2d_TOLCONF;
   Standard_Real    Param1,Param2;
   Standard_Real    Parama,Paramb;
-  Standard_Real    Distance,DistanceMini;
+  Standard_Real    Distance = 0.,DistanceMini;
   Standard_Boolean SolutionValide;
   gp_Pnt2d         PointSolution;
 
@@ -1215,7 +1219,7 @@ IntRes2d_Domain  Domain(const Handle(Geom2d_TrimmedCurve)& Bisector1,
 //            Indice = 4 vert.
 //==========================================================================
 void MAT2d_DrawCurve(const Handle(Geom2d_Curve)& aCurve,
-                    const Standard_Integer      Indice)
+                    const Standard_Integer      /*Indice*/)
 {  
   Handle(Standard_Type)      type = aCurve->DynamicType();
   Handle(Geom2d_Curve)       curve,CurveDraw;