Salome HOME
DCQ : new sketcher
authordcq <dcq@opencascade.com>
Tue, 4 May 2004 14:10:41 +0000 (14:10 +0000)
committerdcq <dcq@opencascade.com>
Tue, 4 May 2004 14:10:41 +0000 (14:10 +0000)
src/GEOM_SWIG/GEOM_Sketcher.py [new file with mode: 0644]
src/GEOM_SWIG/Makefile.in
src/GEOM_SWIG/batchmode_geompy.py
src/GEOM_SWIG/geompy.py
src/SKETCHER/GEOM_Sketcher.cxx [deleted file]
src/SKETCHER/GEOM_Sketcher.h [deleted file]
src/SKETCHER/GEOM_SketcherStatus.h [deleted file]
src/SKETCHER/Makefile.in
src/SKETCHER/Sketcher_Profile.cxx [new file with mode: 0644]
src/SKETCHER/Sketcher_Profile.hxx [new file with mode: 0644]

diff --git a/src/GEOM_SWIG/GEOM_Sketcher.py b/src/GEOM_SWIG/GEOM_Sketcher.py
new file mode 100644 (file)
index 0000000..fbdb7fb
--- /dev/null
@@ -0,0 +1,58 @@
+#  GEOM GEOM_SWIG : binding of C++ omplementaion with Python\r
+#\r
+#  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,\r
+#  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS \r
+# \r
+#  This library is free software; you can redistribute it and/or \r
+#  modify it under the terms of the GNU Lesser General Public \r
+#  License as published by the Free Software Foundation; either \r
+#  version 2.1 of the License. \r
+# \r
+#  This library is distributed in the hope that it will be useful, \r
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of \r
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU \r
+#  Lesser General Public License for more details. \r
+# \r
+#  You should have received a copy of the GNU Lesser General Public \r
+#  License along with this library; if not, write to the Free Software \r
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA \r
+# \r
+#  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org \r
+#\r
+#\r
+#\r
+#  File   : GEOM_Sketcher.py\r
+#  Author : Damien COQUERET, Open CASCADE\r
+#  Module : GEOM\r
+#  $Header$\r
+\r
+import geompy\r
+\r
+#SKETCHER INFOS\r
+#Init Sketcher\r
+#Create a string beginning by :"Sketcher:"\r
+#Each command must be separated by ":"\r
+#"F x y" : Create first point at X & Y\r
+\r
+#To Make Segment\r
+#"R angle" : Set the direction by angle\r
+#"D dx dy" : Set the direction by DX & DY\r
+\r
+#"TT x y" : Create by point at X & Y\r
+#"T dx dy" : Create by point with DX & DY\r
+#"L length" : Create by direction & Length\r
+#"IX x" : Create by direction & Intersect. X\r
+#"IY y" : Create by direction & Intersect. Y\r
+\r
+#To Make Arc\r
+#"C radius length" : Create by direction, radius and length(in degree)\r
+\r
+#To finish\r
+#"WW" : Close Wire\r
+\r
+#Create Sketcher\r
+Cmd = "Sketch:F 0 0:TT 0 100:C 100 180:WW"\r
+Sketcher = geompy.MakeSketcher(Cmd) #(string)->GEOM_Shape_ptr\r
+\r
+#Add In Study\r
+id_Sketcher = geompy.addToStudy(Sketcher, "Sketcher")\r
index 6ea27169e5a6c5df7004bcd6b1824540c6a7c841..a053a12a1af808e11612ed332f28f97d9d61942d 100644 (file)
@@ -51,7 +51,8 @@ EXPORT_PYSCRIPTS = libGEOM_Swig.py geompy.py batchmode_geompy.py \
                 GEOM_Partition2.py \
                 GEOM_Partition3.py \
                 GEOM_Partition4.py \
-                GEOM_Partition5.py
+                GEOM_Partition5.py \
+                GEOM_Sketcher.py
 
 LIB_CLIENT_IDL = SALOMEDS.idl \
                  SALOMEDS_Attributes.idl \
index 949050b04c5dd58dc3d57159c0eb9b33fbeeb7ac..041330f6a6c624f44cc208ace2450a4f7eb2289c 100644 (file)
@@ -164,6 +164,12 @@ def MakePlane(p1,d1,trimsize):
     anObj._set_Name(ior)
     return anObj
 
+def MakeSketcher(Cmd): 
+    anObj = geom.MakeSketcher(Cmd)
+    ior = orb.object_to_string(anObj)
+    anObj._set_Name(ior)
+    return anObj
+
 # -----------------------------------------------------------------------------
 # Create Geometry 3D
 # -----------------------------------------------------------------------------
index dada6eae5023d028875d1e95080a2664e5736638..6d0fca32abb907660ab4de4296b2088fc2103b67 100644 (file)
@@ -190,6 +190,12 @@ def MakePlane(p1,d1,trimsize):
     anObj._set_Name(ior)
     return anObj
 
+def MakeSketcher(Cmd): 
+    anObj = geom.MakeSketcher(Cmd)
+    ior = salome.orb.object_to_string(anObj)
+    anObj._set_Name(ior)
+    return anObj
+
 # -----------------------------------------------------------------------------
 # Create Geometry 3D
 # -----------------------------------------------------------------------------
diff --git a/src/SKETCHER/GEOM_Sketcher.cxx b/src/SKETCHER/GEOM_Sketcher.cxx
deleted file mode 100644 (file)
index 7734c2b..0000000
+++ /dev/null
@@ -1,1389 +0,0 @@
-//  GEOM SKETCHER : basic sketcher
-//
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  This library is free software; you can redistribute it and/or 
-//  modify it under the terms of the GNU Lesser General Public 
-//  License as published by the Free Software Foundation; either 
-//  version 2.1 of the License. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : GEOM_Sketcher.cxx
-//  Author : Nicolas REJNERI
-//  Module : GEOM
-//  $Header$
-
-using namespace std;
-#include "GEOM_Sketcher.h"
-#include "utilities.h"
-
-#include <qstring.h> 
-
-#include <Geom_Axis1Placement.hxx>
-#include <Geom_Circle.hxx>
-#include <Geom_Line.hxx>
-#include <Geom_CartesianPoint.hxx>
-#include <BRep_Tool.hxx>
-#include <BRepBuilderAPI_MakeEdge2d.hxx>
-#include <BRepBuilderAPI_MakeEdge.hxx>
-#include <BRepBuilderAPI_MakeVertex.hxx>
-#include <gp_Lin2d.hxx>
-#include <gp_Pln.hxx>
-#include <gp_Lin.hxx>
-#include <gp_Dir.hxx>
-#include <gp_Circ2d.hxx>
-#include <gp_Vec2d.hxx>
-#include <IntAna_IntConicQuad.hxx>
-#include <BRepLib.hxx>
-#include <TopExp.hxx>
-#include <ProjLib.hxx>
-#include <Precision.hxx>
-#include <ElSLib.hxx>
-#include <BRepTools_WireExplorer.hxx>
-#include <GccAna_Pnt2dBisec.hxx>
-#include <GeomAPI.hxx>
-#include <Geom2dAPI_ProjectPointOnCurve.hxx>
-#include <Geom2d_TrimmedCurve.hxx>
-#include <Geom2d_Circle.hxx>
-#include <gce_MakeCirc2d.hxx>
-#include <GccAna_Circ2d2TanRad.hxx>
-#include <GccAna_Circ2d2TanOn.hxx>
-#include <GccEnt.hxx>
-#include <GccEnt_QualifiedLin.hxx>
-#include <GccEnt_QualifiedCirc.hxx>
-#include <GccAna_Lin2dTanPer.hxx>
-#include <GccAna_Lin2dTanObl.hxx>
-#include <gce_MakeLin2d.hxx>
-#include <GCE2d_MakeArcOfCircle.hxx>
-#include <Precision.hxx>
-#include <ElCLib.hxx>
-#include <AIS_Point.hxx>
-#include <TColgp_HArray1OfPnt2d.hxx>
-#include <Geom2dAPI_Interpolate.hxx>
-#include <TColgp_Array1OfVec2d.hxx>
-#include <TColStd_HArray1OfBoolean.hxx>
-#include <GeomAPI_ProjectPointOnCurve.hxx>
-#include <DsgPrs_ArrowSide.hxx>
-#include <BRepBuilderAPI_Transform.hxx>
-
-#include <AIS_Drawer.hxx>
-#include <Prs3d_TextAspect.hxx>
-#include <Prs3d_LineAspect.hxx>
-#include <Graphic3d_NameOfFont.hxx>
-
-#include <TopoDS_Wire.hxx>
-
-/*!
-  \class GEOM_Sketcher GEOM_Sketcher.h
-  \brief ...
-*/
-
-Standard_Real resol = 1.0;    
-
-/*!
-  Constructor.
-*/
-Sketch::Sketch()
-{
-
-}
-
-/*!
-  Destructor.
-*/
-Sketch::~Sketch()
-{
-
-}
-
-
-/*!
-  Constructor.
-
-  \param V3d_Viewer
-*/
-Sketch::Sketch(const Handle(V3d_Viewer)& aViewer) :
-myInteractiveContext(new AIS_InteractiveContext(aViewer)),
-myAxisColor(Quantity_Color(Quantity_NOC_YELLOW)),
-myCurrentColor(Quantity_Color(Quantity_NOC_GREEN)),
-myWireColor(Quantity_Color(Quantity_NOC_RED))
-{
-       Init();
-}
-
-/*!
-  Constructor.
-
-  \param V3d_Viewer
-  \param Quantity_Color
-  \param Quantity_Color
-  \param Quantity_Color
-*/
-Sketch::Sketch(const Handle(V3d_Viewer)& aViewer,
-              const Quantity_Color& anAxisColor,
-              const Quantity_Color& aCurrentColor,
-              const Quantity_Color& aWireColor):
-myInteractiveContext(new AIS_InteractiveContext(aViewer)),
-myAxisColor(anAxisColor),
-myCurrentColor(aCurrentColor),
-myWireColor(aWireColor)
-{
-       Init();
-}
-
-/*!
-  Build the current edge in a graphic mode.
-  The first signature with view coordinates is used to connect to the move event from the user interface.
-  The second signature is used when the current point is known by 2d real coordinates.
-
-  \param Xp     
-  \param Yp     
-  \param V3d_View       
-*/
-void Sketch::MakeCurrentEdge(const Standard_Integer  Xp   ,
-                            const Standard_Integer  Yp   ,
-                            const Handle(V3d_View)& aView )
-{
-  /* 3d coordinates of the picked point */
-  Standard_Real Xv,Yv,Zv;
-  aView->Convert(Xp,Yp,Xv,Yv,Zv);
-  /* computation of real 2d coordinates in plane of sketch */
-  Standard_Real Vx,Vy,Vz;
-  aView->Proj(Vx,Vy,Vz);
-  gp_Dir D(Vx,Vy,Vz);
-  gp_Pnt P(Xv,Yv,Zv);
-  gp_Lin L(P,D);
-  Standard_Real X,Y;
-  gp_Pnt Sol;
-  IntAna_IntConicQuad Int(L,myPlane->Pln(),Precision::Angular());
-  if (Int.IsDone()) {
-    if (!Int.IsParallel()) {
-      if (Int.NbPoints() > 0 ) {
-       Sol = Int.Point(1);
-       ElSLib::Parameters(myPlane->Pln(),Sol,X,Y);
-      }
-    }
-  }
-  MakeCurrentEdge(X,Y);
-}
-
-/*!
-  Build the current edge in a graphic mode.
-  The first signature with view coordinates is used to connect to the move event from the user interface.
-  The second signature is used when the current point is known by 2d real coordinates.
-
-  \param X      
-  \param Y      
-*/
-void Sketch::MakeCurrentEdge(const Standard_Real  X, const Standard_Real Y)
-{
-  /* Create the current edge depending on the active mode */
-  switch (myCurrentStatus) {
-  case BEGIN_SKETCH:
-    myCurrentEdge = BRepBuilderAPI_MakeVertex(ElCLib::To3d(myPlane->Pln().Position().Ax2(),gp_Pnt2d(X,Y)));
-    break;
-  case SEGMENT:
-    MakeCurrentSegment(X,Y);
-    break;
-  case ARC_CHORD:
-    MakeCurrentSegment(X,Y);
-    break;
-  case ARC_CHORD_END:
-    MakeCurrentArc(X,Y);
-    break;
-  }
-  DisplayCurrentEdge();
-}
-
-/*!
-  Build the current edge in a graphic mode.
-  Function to connect to the input event from the user interface.
-*/
-void Sketch::ValidateEdge()
-{
-  gp_Pnt pt;
-  gp_Pnt2d pt2d;
-  switch (myCurrentStatus) {
-  case BEGIN_SKETCH:
-    {
-      myFirstPointSketch = TopoDS::Vertex(myCurrentEdge);
-      myPresentableWire = new AIS_Shape(myFirstPointSketch);
-      myPresentableWire->SetColor(myWireColor.Name());
-      myInteractiveContext->Display(myPresentableWire);
-      pt = BRep_Tool::Pnt(myFirstPointSketch);
-      pt2d = ProjLib::Project(myPlane->Pln(),pt);
-      myLastX = pt2d.X();
-      myLastY = pt2d.Y();
-      myCurrentStatus = SEGMENT;
-      break;   
-    }
-  case SEGMENT:
-    {
-      Standard_Real first,last;
-      TopLoc_Location L;
-      Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(TopoDS::Edge(myCurrentEdge),myPlane,L,first,last);
-      myCurrentEdge = BRepBuilderAPI_MakeEdge2d(Handle(Geom2d_Line)::DownCast(C)->Lin2d(),0.,myLengthDimension->Value());
-      if (myTransitionStatus == ANGLE || 
-         myTransitionStatus == LENGTH_FIXED ||
-         myTransitionStatus == X_FIXED ||
-         myTransitionStatus == Y_FIXED) 
-       myTransitionStatus = NOCONSTRAINT;
-      AddEdgeToWire();
-      break;
-    }
-  case ARC_CHORD:
-    {
-      myInteractiveContext->CloseLocalContext();
-      myInteractiveContext->OpenLocalContext();
-      gp_Pnt2d p1 (myLastX,myLastY);
-      pt = BRep_Tool::Pnt(TopExp::LastVertex(TopoDS::Edge(myCurrentEdge)));
-      gp_Pnt2d p2 = ProjLib::Project(myPlane->Pln(),pt);
-      GccAna_Pnt2dBisec ComputeMediatrice(p1,p2);
-      if (ComputeMediatrice.HasSolution()) {
-       myMediatrice = new Geom2d_Line(ComputeMediatrice.ThisSolution());
-       Handle(Geom_Curve) aMediatrice3d = GeomAPI::To3d(myMediatrice,myPlane->Pln());
-       myPresentableMediatrice = new AIS_Axis(Handle(Geom_Line)::DownCast(aMediatrice3d));
-       myInteractiveContext->Display(myPresentableMediatrice);
-      }
-      TopoDS_Edge e = BRepBuilderAPI_MakeEdge2d(gce_MakeCirc2d(gp_Pnt2d(0.,0),1.));
-      BRepLib::BuildCurve3d(e);
-      myLengthDimension->SetText(TCollection_ExtendedString());
-      myInteractiveContext->Redisplay(myLengthDimension,Standard_False);
-      if (myEdgesNumber == 0)
-       myPreviousEdge = TopoDS::Edge(myCurrentEdge);
-      pt2d = ProjLib::Project(myPlane->Pln(),pt);
-      myLastX = pt2d.X();
-      myLastY = pt2d.Y();
-      myTransitionStatus = NOCONSTRAINT;
-      myCurrentStatus = ARC_CHORD_END;
-      break;
-    }
-  case ARC_CHORD_END:
-    myCurrentStatus = ARC_CHORD;
-    AddEdgeToWire();   
-    break;
-  }
-}
-
-/*!
-  Add edge to current wire on an edge validation .
-*/
-void Sketch::AddEdgeToWire()
-{
-  myPreviousEdge = TopoDS::Edge(myCurrentEdge);
-  BRepLib::BuildCurve3d(myPreviousEdge);
-  myCurrentWire.Add(TopoDS::Edge(myPreviousEdge));
-  myEdgesNumber++;
-  myPresentableWire->Set( myCurrentWire.Wire() );
-  myInteractiveContext->Redisplay(myPresentableWire);
-  myConstructionMode.Append(myCurrentStatus);
-  myConstraintMode.Append(myTransitionStatus);
-  myInteractiveContext->CloseLocalContext();
-  gp_Pnt pt;
-  if (myPreviousEdge.Orientation() == TopAbs_FORWARD )
-    pt = BRep_Tool::Pnt(TopExp::LastVertex(TopoDS::Edge(myPreviousEdge)));
-  else 
-    pt = BRep_Tool::Pnt(TopExp::FirstVertex(TopoDS::Edge(myPreviousEdge)));
-  gp_Pnt2d pt2d= ProjLib::Project(myPlane->Pln(),pt);
-  myLastX = pt2d.X();
-  myLastY = pt2d.Y();
-}
-
-/*!
-  Set the numeric dimension for the current edge and validate creation.
-
-  \param aValue 
-  \return Standard_Boolean
-*/
-Standard_Boolean Sketch::SetDimension(Standard_Real& aValue)
-{
-  fitInResol(aValue); 
-  if (myCurrentStatus == SEGMENT ||
-      myCurrentStatus == ARC_CHORD){
-    Standard_Real first,last;
-    TopLoc_Location L;
-    Handle(Geom2d_Curve) C = 
-      BRep_Tool::CurveOnSurface(TopoDS::Edge(myCurrentEdge),myPlane,L,first,last);
-    myCurrentEdge = 
-      BRepBuilderAPI_MakeEdge2d(Handle(Geom2d_Line)::DownCast(C)->Lin2d(),0.,aValue);
-    DisplayCurrentEdge();
-    if (myTransitionStatus == NOCONSTRAINT) {
-      mySegmentLength = aValue;
-      myTransitionStatus = LENGTH_FIXED;
-    }
-    else
-      ValidateEdge();
-    return Standard_True;
-  }
-  
-  else if( myCurrentStatus == ARC_CHORD_END){
-    if (myTransitionStatus == TANGENT) return Standard_False;
-    gp_Pnt2d p;
-    if (myEdgesNumber > 0) {
-      if (myPreviousEdge.Orientation() == TopAbs_FORWARD)
-       p = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(TopExp::LastVertex(myPreviousEdge)));
-      else
-       p = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(TopExp::FirstVertex(myPreviousEdge)));
-    }
-    else
-      p = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(myFirstPointSketch));
-    GccAna_Circ2d2TanRad aSol(p, gp_Pnt2d(myLastX,myLastY),aValue,Precision::Confusion());
-    Standard_Real dist = RealLast();
-    if (aSol.NbSolutions() > 0) {
-      gp_Circ2d CirSol;
-      gp_Pnt2d pc = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(TopoDS::Vertex(myCenterCircle->Shape())));
-      for (Standard_Integer i =1; i<= aSol.NbSolutions(); i++) {
-       if (pc.Distance(aSol.ThisSolution(i).Location()) < dist)
-         CirSol = aSol.ThisSolution(i);
-      }
-      if (myCurrentEdge.Orientation() == TopAbs_FORWARD)
-       myCurrentEdge = BRepBuilderAPI_MakeEdge2d(aSol.ThisSolution(1),p,gp_Pnt2d(myLastX,myLastY));
-      else {   
-       myCurrentEdge = BRepBuilderAPI_MakeEdge2d(aSol.ThisSolution(1),gp_Pnt2d(myLastX,myLastY),p);
-       myCurrentEdge.Reverse();
-      }        
-      DisplayCurrentEdge();
-      ValidateEdge();  
-      return Standard_True;
-    }
-  }
-  
-  return Standard_False;
-}
-
-/*!
-  Set the numeric dimension for the current edge and validate creation.
-  
-  \param deltaX 
-  \param deltaY 
-*/
-void Sketch::SetDimension(Standard_Real& deltaX, Standard_Real& deltaY)
-{
-  fitInResol(deltaX); 
-  fitInResol(deltaY);
-  Standard_Real X = myLastX + deltaX;
-  Standard_Real Y = myLastY + deltaY;
-  MakeCurrentEdge(X,Y);
-  ValidateEdge();
-}
-
-/*!
-  Set the numeric value of the X coordinate of current point giving a deltaX relative to previous point.
-
-  \param deltaX 
-*/
-void Sketch::SetXDimension(Standard_Real& deltaX)
-{
-  fitInResol(deltaX); 
-  Standard_Real X = myLastX + deltaX;
-  Standard_Real Y = myLastY;
-  if ( deltaX == 0. )
-    Y = Y + 100.0 * Precision::Confusion();
-
-  if (myTransitionStatus == NOCONSTRAINT) {
-    MakeCurrentEdge(X,Y);
-    myTransitionStatus = X_FIXED;
-    mySegmentX = X;
-  }
-  else if (myTransitionStatus == Y_FIXED) {
-    myTransitionStatus = NOCONSTRAINT;
-    MakeCurrentEdge(X,mySegmentY);
-    ValidateEdge();
-  }
-  else if (myTransitionStatus == ANGLE) {
-    myTransitionStatus = NOCONSTRAINT;
-    Standard_Real angle;
-    if (0 <= mySegmentAngle &&  mySegmentAngle<= PI )
-      angle = PI - mySegmentAngle;
-    else
-      angle = mySegmentAngle - PI;
-    Y = X*Tan(angle);
-    MakeCurrentEdge(X,Y);
-    ValidateEdge();
-  }
-  else
-    myTransitionStatus = NOCONSTRAINT;
-}
-
-/*!
-  Set the numeric value of the Y coordinate of current point giving a deltaY relative to previous point.
-
-  \param deltaY 
-*/
-void Sketch::SetYDimension(Standard_Real& deltaY)
-{
-  fitInResol(deltaY); 
-  Standard_Real X = myLastX;
-  Standard_Real Y = myLastY + deltaY;
-
-  if ( deltaY == 0. )
-    X = X + 100.0 * Precision::Confusion();
-
-  if (myTransitionStatus == NOCONSTRAINT) {
-    MakeCurrentEdge(X,Y);
-    myTransitionStatus = Y_FIXED;
-    mySegmentY = Y;
-  }
-  else if (myTransitionStatus == X_FIXED) {
-    myTransitionStatus = NOCONSTRAINT;
-    MakeCurrentEdge(mySegmentX,Y);
-    ValidateEdge();
-  }
-  else if (myTransitionStatus == ANGLE) {
-    myTransitionStatus = NOCONSTRAINT;
-    Standard_Real angle;
-    if (0 <= mySegmentAngle &&  mySegmentAngle<= PI )
-      angle = PI - mySegmentAngle;
-    else
-      angle = mySegmentAngle - PI;
-    X = Y/Tan(angle);
-    MakeCurrentEdge(X,Y);
-    ValidateEdge();
-  }
-  else
-    myTransitionStatus = NOCONSTRAINT;
-}
-
-/*!
-  Set the numeric value of angle between 2 segments.
-
-  \param aValue 
-*/
-void Sketch::SetSegmentAngle(Standard_Real& aValue)
-{
-  if (myEdgesNumber > 0) {
-    Standard_Real First,Last;
-    TopLoc_Location L;
-    Standard_Real angle;
-    if (0 <= aValue &&  aValue<= PI )
-      angle = PI - aValue;
-    else
-      angle = aValue - PI;
-    Handle (Geom2d_Curve) PreviousCurve = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,First,Last);
-    if (PreviousCurve->IsKind(STANDARD_TYPE(Geom2d_Line))) {
-      Handle (Geom2d_Curve) PreviousCurve = BRep_Tool::CurveOnSurface(TopoDS::Edge(myPreviousEdge),myPlane,L,First,Last);
-      
-      GccAna_Lin2dTanObl aSol(gp_Pnt2d(myLastX,myLastY),Handle(Geom2d_Line)::DownCast(PreviousCurve)->Lin2d(),angle);
-      myCurrentEdge = BRepBuilderAPI_MakeEdge2d(aSol.ThisSolution(1),0.,myLengthDimension->Value());
-    }
-    if (myTransitionStatus == LENGTH_FIXED)  {
-      ValidateEdge();
-    }
-    else if (myTransitionStatus == X_FIXED)  {
-      Standard_Real length = mySegmentX/Cos(angle);
-      SetDimension(length);
-      ValidateEdge();
-    }
-    else if (myTransitionStatus == Y_FIXED)  {
-      Standard_Real length = mySegmentY/Sin(angle);
-      SetDimension(length);
-      ValidateEdge();
-    }
-    else {
-      mySegmentAngle = aValue;
-      myTransitionStatus = ANGLE;
-    }
-  }
-}
-
-/*!
-  Get the angle value between 2 segments.
-
-  \return Standard_Real
-*/
-Standard_Real Sketch::GetSegmentAngle()
-{
-  return mySegmentAngle;
-}
-
-/*!
-  Close automatically an open sketch.
-
-  \return TopoDS_Wire.  Return null shape if not possible.
-*/
-TopoDS_Wire Sketch::Close()
-{ 
-  myCurrentStatus = END_SKETCH;
-  myInteractiveContext->CloseAllContexts();
-  myInteractiveContext->EraseAll(Standard_False);
-  if (myEdgesNumber >= 2) {
-    BRepTools_WireExplorer Ex(myCurrentWire.Wire());
-    TopoDS_Vertex V1;
-    if (myPreviousEdge.Orientation() == TopAbs_FORWARD)
-      V1 = TopExp::LastVertex(myPreviousEdge);
-    else
-      V1 = TopExp::FirstVertex(myPreviousEdge);
-    myCurrentWire.Add(BRepBuilderAPI_MakeEdge(V1,myFirstPointSketch).Edge());
-    myEdgesNumber++;
-    return myCurrentWire.Wire();
-  }
-  else
-    return TopoDS_Wire();
-}
-
-
-
-/*!
-  Clear sketch presentation.
-*/
-void Sketch::Clear()
-{
-  myCurrentStatus = END_SKETCH;
-  myInteractiveContext->CloseAllContexts();
-  myInteractiveContext->EraseAll(Standard_False);
-}
-
-/*!
-  Terminate sketch without closing.
-
-  \return TopoDS_Wire. Return null shape if not possible.
-*/
-TopoDS_Wire Sketch::End()
-{
-  myCurrentStatus = END_SKETCH;
-  myInteractiveContext->CloseAllContexts();
-  myInteractiveContext->EraseAll(Standard_False);
-  if (myCurrentWire.IsDone()) {
-    return myCurrentWire.Wire();
-  }
-  else
-    return TopoDS_Wire();
-}
-
-
-/*!
-  Delete current edge.
-*/
-Standard_Boolean Sketch::Delete()
-{
-  myInteractiveContext->Erase(myAngleDimension,Standard_True,Standard_False);
-  myInteractiveContext->Erase(myLengthDimension,Standard_True,Standard_False);
-  myInteractiveContext->Erase(myRadiusDimension,Standard_True,Standard_False);
-  myInteractiveContext->Erase(myCenterCircle,Standard_True,Standard_False);
-  myInteractiveContext->Erase(myXDimension,Standard_True,Standard_False);
-  myInteractiveContext->Erase(myYDimension,Standard_True,Standard_False);
-  
-  if (myCurrentStatus == BEGIN_SKETCH) {
-    myCurrentStatus = END_SKETCH;
-    myInteractiveContext->CloseAllContexts();
-    myInteractiveContext->EraseAll(Standard_False);
-    return true;
-  }
-  else if(myCurrentStatus == SEGMENT   ||
-         myCurrentStatus == ARC_CHORD ) {
-    RemoveLastEdge();
-  }
-  else if(myCurrentStatus ==  ARC_CHORD_END) {
-    myCurrentStatus = ARC_CHORD;
-    myInteractiveContext->CloseAllContexts();
-  }
-  gp_Pnt pt;
-  if (myEdgesNumber == 0) {
-    //myInteractiveContext->EraseAll(Standard_False);
-    ChangeMode(BEGIN_SKETCH); // DCQ
-    pt = BRep_Tool::Pnt(myFirstPointSketch);
-  }
-  else {
-    if (myPreviousEdge.Orientation() == TopAbs_FORWARD )
-      pt = BRep_Tool::Pnt(TopExp::LastVertex(TopoDS::Edge(myPreviousEdge)));
-    else 
-      pt = BRep_Tool::Pnt(TopExp::FirstVertex(TopoDS::Edge(myPreviousEdge)));
-  }
-  gp_Pnt2d pt2d= ProjLib::Project(myPlane->Pln(),pt);
-  myLastX = pt2d.X();
-  myLastY = pt2d.Y();
-
-  return false;
-}
-
-/*!
-  Set a specific plane for sketch.
-
-  \param GeomyPlane     
-*/
-void Sketch::SetPlane(const Handle(Geom_Plane)& aPlane)
-{
-  myPlane = aPlane;
-}
-
-/*!
-  Set display parameters.
-
-  \param aColor 
-*/
-void Sketch::SetWireColor(const Quantity_Color& aColor)
-{
-  myWireColor = aColor;
-}
-
-/*!
-  Set display parameters.
-
-  \param aColor 
-*/
-void Sketch::SetCurrentColor(const Quantity_Color& aColor)
-{
-  myCurrentColor = aColor;
-}
-
-/*!
-  Set display parameters.
-  
-  \param aColor 
-*/
-void Sketch::SetAxisColor(const Quantity_Color& aColor)
-{
-  myAxisColor = aColor;
-}
-
-
-/*!
-  Change mode of construction line.
-
-  \param aMode : SEGMENT, ARC_CHORD.
-*/
-void Sketch::ChangeMode(const SketchStatus aMode)
-{
-  gp_Pnt2d p;
-  if (myEdgesNumber > 0) {
-    if (myPreviousEdge.Orientation() == TopAbs_FORWARD)
-      p = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(TopExp::LastVertex(myPreviousEdge)));
-    else
-      p = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(TopExp::FirstVertex(myPreviousEdge)));
-    myLastX = p.X();
-    myLastY = p.Y();
-    myInteractiveContext->CloseLocalContext(myInteractiveContext->IndexOfCurrentLocal());
-  }
-  if (!myCurrentStatus == BEGIN_SKETCH) 
-    myCurrentStatus = aMode; /* change the mode only when the sketch is not in state BEGIN_SKETCH, i.d. fist point has been fixed */
-
-}
-
-/*!
-  Set transition constraint between consecutive edges.
-
-  \param aStatus : NOCONSTRAINT, TANGENT, PERPENDICULAR, ANGLE, LENGTH_FIXED, X_FIXED, Y_FIXED.
-*/
-void Sketch::SetTransitionStatus(const TransitionStatus aStatus)
-{
-  myTransitionStatus = aStatus;
-}
-
-/*!
-  Set or unset the display of dimensions.
-
-  \param atype  
-  \param OnOff  
-*/
-void Sketch::SetParameterVisibility(const TypeOfParameter atype, const Standard_Boolean OnOff)
-{
-  switch (atype) {
-  case ANGLE_PARAMETER:
-    myIsAngleDimensionVisible = OnOff;
-    if (!myIsAngleDimensionVisible && !myAngleDimension.IsNull())
-      myInteractiveContext->Erase(myAngleDimension,Standard_True,Standard_False);
-    //else DCQ
-    //  DisplayCurrentEdge();
-    break;
-  case LENGTH_PARAMETER:
-    myIsLengthDimensionVisible = OnOff;
-    if (!myIsLengthDimensionVisible&& !myLengthDimension.IsNull())
-      myInteractiveContext->Erase(myLengthDimension,Standard_True,Standard_False);
-    //else DCQ
-    //  DisplayCurrentEdge();
-    break;
-  case RADIUS_PARAMETER:
-    myIsRadiusDimensionVisible = OnOff;
-    if (!myIsRadiusDimensionVisible&& !myRadiusDimension.IsNull()){
-      myInteractiveContext->Erase(myRadiusDimension,Standard_True,Standard_False);
-      myInteractiveContext->Erase(myCenterCircle,Standard_True,Standard_False);
-    }
-    //else DCQ
-    //  DisplayCurrentEdge();
-    break;
-  case XVALUE_PARAMETER:
-    myIsXDimensionVisible = OnOff;
-    if (!myIsXDimensionVisible&& !myXDimension.IsNull())
-      myInteractiveContext->Erase(myXDimension,Standard_True,Standard_False);
-    break;
-  case YVALUE_PARAMETER:
-    myIsYDimensionVisible = OnOff;
-    if (!myIsYDimensionVisible&& !myYDimension.IsNull())
-      myInteractiveContext->Erase(myYDimension,Standard_True,Standard_False);
-    break;
-  }
-}
-
-/*!
-  Hilight parameters.
-
-  \param atype  
-  \param acolor 
-*/
-void Sketch::HiligthWithColor(const TypeOfParameter atype, const Quantity_NameOfColor acolor)
-{
-  switch (atype) {
-  case ANGLE_PARAMETER:
-    myInteractiveContext->HilightWithColor(myAngleDimension, acolor);
-    break;
-  case LENGTH_PARAMETER:
-    myInteractiveContext->HilightWithColor(myLengthDimension, acolor);
-    break;
-  case RADIUS_PARAMETER:
-    myInteractiveContext->HilightWithColor(myRadiusDimension, acolor);
-    break;
-  case XVALUE_PARAMETER:
-    myInteractiveContext->HilightWithColor(myXDimension, acolor);
-    break;
-  case YVALUE_PARAMETER:
-    myInteractiveContext->HilightWithColor(myYDimension, acolor);
-    break;
-  }
-}
-
-       
-/*!
-  Unhilight parameters.
-
-  \param atype  
-*/
-void Sketch::Unhiligth(const TypeOfParameter atype)
-{
-  switch (atype) {
-  case ANGLE_PARAMETER:
-    myInteractiveContext->Unhilight(myAngleDimension);
-    break;
-  case LENGTH_PARAMETER:
-    myInteractiveContext->Unhilight(myLengthDimension);
-    break;
-  case RADIUS_PARAMETER:
-    myInteractiveContext->Unhilight(myRadiusDimension);
-    break;
-  case XVALUE_PARAMETER:
-    myInteractiveContext->Unhilight(myXDimension);
-    break;
-  case YVALUE_PARAMETER:
-    myInteractiveContext->Unhilight(myYDimension);
-    break;
-  }
-}
-
-/*!
-  Check if the edition of a type of parameter is relevant depending on sketch current status.
-
-  \param atype  
-  \return Standard_Boolean
-*/
-Standard_Boolean Sketch::IsValidCurrentParameter(const TypeOfParameter atype)
-{
-  switch (atype) {
-  case ANGLE_PARAMETER:
-    if (myCurrentStatus != SEGMENT && myCurrentStatus != ARC_CHORD) 
-      return Standard_False;
-    else if (myTransitionStatus == TANGENT || myTransitionStatus == PERPENDICULAR)  
-      return Standard_False;
-    else if (myEdgesNumber < 1)
-      return Standard_False;
-    else  {
-      TopLoc_Location L;
-      Standard_Real First,Last;
-      Handle (Geom2d_Curve) PreviousCurve = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,First,Last);
-      if (!PreviousCurve->IsKind(STANDARD_TYPE(Geom2d_Line))) 
-       return Standard_False;
-    }
-    break;
-  case LENGTH_PARAMETER:
-    if (myCurrentStatus != SEGMENT   && 
-       myCurrentStatus != ARC_CHORD /*&&
-                                         myCurrentStatus != CURVE_POINTS*/
-       ) 
-      return Standard_False;
-    else if (myTransitionStatus == LENGTH_FIXED) 
-      return Standard_False;
-    break;
-  case RADIUS_PARAMETER:
-    if (myCurrentStatus != ARC_CHORD_END)
-      return Standard_False;
-    break;
-  case XVALUE_PARAMETER:
-    if (myCurrentStatus != SEGMENT   && 
-       myCurrentStatus != ARC_CHORD /*&&
-                                         myCurrentStatus != CURVE_POINTS*/
-       ) 
-      return Standard_False;
-    else if (myTransitionStatus == X_FIXED) 
-      return Standard_False;
-    break;
-  case YVALUE_PARAMETER:
-    if (myCurrentStatus != SEGMENT   && 
-       myCurrentStatus != ARC_CHORD /*&&
-                                         myCurrentStatus != CURVE_POINTS*/
-       ) 
-      return Standard_False;
-    else if (myTransitionStatus == Y_FIXED) 
-      return Standard_False;
-    break;
-  }
-  return Standard_True;
-}
-
-/*!
-  Set a parameter value.
-
-  \param atype  
-  \param aValue 
-*/
-void Sketch::SetParameterValue(const TypeOfParameter atype, Standard_Real aValue)
-{
-  switch (atype) {
-  case ANGLE_PARAMETER:
-    SetSegmentAngle(aValue);
-    break;
-  case LENGTH_PARAMETER:
-    SetDimension(aValue);
-    break;
-  case RADIUS_PARAMETER:
-    SetDimension(aValue);
-    break;
-  case XVALUE_PARAMETER:
-    SetXDimension(aValue);
-    break;
-  case YVALUE_PARAMETER:
-    SetYDimension(aValue);
-    break;
-  }
-}
-
-/*!
-  Initialisation of sketch parameters or options.
-*/
-void Sketch::Init()
-{
-  myPlane = new Geom_Plane (0.,0.,1.,0.);
-  CreateConstraints();
-  BRepLib::Plane(myPlane);
-  myEdgesNumber = 0;
-  myCurrentStatus = BEGIN_SKETCH;
-  /* In order to update the visulisation of current objects by using Redisplay method from InteractiveContext */
-  myCurrentEdge = BRepBuilderAPI_MakeVertex(gp_Pnt(0.,0.,0.));         
-  myPresentableEdge = new AIS_Shape(myCurrentEdge);
-  myPresentableEdge->SetColor(myCurrentColor.Name());
-  myInteractiveContext->Display(myPresentableEdge);
-  myTransitionStatus = NOCONSTRAINT;
-  /* Init for display objects */
-  TopoDS_Vertex V1 = BRepBuilderAPI_MakeVertex(gp_Pnt(0.,0.,0.));
-  TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(10.,0.,0.));
-  myLengthDimension = new AIS_LengthDimension (V1,V2,myPlane,0.,TCollection_ExtendedString());
-  myXDimension = new AIS_LengthDimension (V1,V2,myPlane,0.,TCollection_ExtendedString(),gp_Pnt(),DsgPrs_AS_NONE,
-                                         AIS_TOD_Horizontal);
-  myYDimension = new AIS_LengthDimension (V1,V2,myPlane,0.,TCollection_ExtendedString(),gp_Pnt(),DsgPrs_AS_NONE,
-                                         AIS_TOD_Vertical);
-  myRadiusDimension = new AIS_LengthDimension (V1,V2,myPlane,0.,TCollection_ExtendedString());
-  myCenterCircle = new AIS_Shape(V1);
-  myIsLengthDimensionVisible = Standard_False;
-  myIsXDimensionVisible = Standard_False;
-  myIsYDimensionVisible = Standard_False;
-  myIsRadiusDimensionVisible = Standard_False;
-}
-
-/*!
-  Build the current segment.
-
-  \param X      
-  \param Y      
-*/
-void Sketch::MakeCurrentSegment(Standard_Real X, Standard_Real Y)
-{
-  if (myTransitionStatus == NOCONSTRAINT) 
-    myCurrentEdge = BRepBuilderAPI_MakeEdge2d(gp_Pnt2d(myLastX,myLastY), gp_Pnt2d(X,Y));
-  else if (myTransitionStatus == X_FIXED) 
-    myCurrentEdge = BRepBuilderAPI_MakeEdge2d(gp_Pnt2d(myLastX,myLastY),gp_Pnt2d(mySegmentX,Y));
-  else if (myTransitionStatus == Y_FIXED) 
-    myCurrentEdge = BRepBuilderAPI_MakeEdge2d(gp_Pnt2d(myLastX,myLastY),gp_Pnt2d(X,mySegmentY));
-  else if (myTransitionStatus == TANGENT && myEdgesNumber > 0) {
-    Standard_Real first,last;
-    TopLoc_Location L;
-    Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,first,last);
-    gp_Pnt2d p1;
-    gp_Vec2d Vt;
-    if (myPreviousEdge.Orientation() == TopAbs_FORWARD)
-      C->D1(last,p1,Vt);
-    else 
-      C->D1(first,p1,Vt);
-    gp_Lin2d aline(p1,Vt);
-    Geom2dAPI_ProjectPointOnCurve proj(gp_Pnt2d(X,Y),new Geom2d_Line(aline));
-    if (proj.NbPoints() > 0)
-      myCurrentEdge = BRepBuilderAPI_MakeEdge2d(p1,proj.Point(1));
-  }
-  else if (myTransitionStatus == PERPENDICULAR && myEdgesNumber > 0) {
-    Standard_Real first,last;
-    TopLoc_Location L;
-    Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,first,last);
-    gp_Pnt2d p1;
-    gp_Lin2d perpen;
-    if (myPreviousEdge.Orientation() == TopAbs_FORWARD)
-      C->D0(last,p1);
-    else 
-      C->D0(first,p1);
-    if (C->IsKind(STANDARD_TYPE(Geom2d_Line))) {
-      GccAna_Lin2dTanPer aSol(p1,Handle(Geom2d_Line)::DownCast(C)->Lin2d());
-      perpen = aSol.ThisSolution(1);
-    }
-    else if (C->IsKind(STANDARD_TYPE(Geom2d_Circle))) {
-      GccAna_Lin2dTanPer aSol(p1,Handle(Geom2d_Circle)::DownCast(C)->Circ2d());
-      perpen = aSol.ThisSolution(1);
-    }
-    Geom2dAPI_ProjectPointOnCurve proj(gp_Pnt2d(X,Y),new Geom2d_Line(perpen));
-    if (proj.NbPoints() > 0)
-      myCurrentEdge = BRepBuilderAPI_MakeEdge2d(p1,proj.Point(1));
-  }
-  else if (myTransitionStatus == ANGLE && myEdgesNumber > 0) {
-    Standard_Real First,Last;
-    TopLoc_Location L;
-    Handle (Geom2d_Curve) PreviousCurve = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,First,Last);
-    if (PreviousCurve->IsKind(STANDARD_TYPE(Geom2d_Line))) {
-      Handle (Geom2d_Curve) PreviousCurve = BRep_Tool::CurveOnSurface(TopoDS::Edge(myPreviousEdge),myPlane,L,First,Last);
-      Standard_Real angle;
-      if (0 <= mySegmentAngle &&  mySegmentAngle<= PI )
-       angle = PI - mySegmentAngle;
-      else
-       angle = mySegmentAngle - PI;
-      GccAna_Lin2dTanObl aSol(gp_Pnt2d(myLastX,myLastY),Handle(Geom2d_Line)::DownCast(PreviousCurve)->Lin2d(),angle);
-      Standard_Real dist = RealLast();
-      gp_Pnt2d pt(X,Y),ptproj;
-      for (Standard_Integer i =1; i<=aSol.NbSolutions(); i++) {
-       Geom2dAPI_ProjectPointOnCurve proj(pt,new Geom2d_Line(aSol.ThisSolution(i)));
-       if (pt.Distance(proj.Point(1)) < dist) {
-         dist = pt.Distance(proj.Point(1));
-         ptproj = proj.Point(1);
-       }
-      }
-      myCurrentEdge = BRepBuilderAPI_MakeEdge2d(gp_Pnt2d(myLastX,myLastY),ptproj);
-    }
-  }
-  else if (myTransitionStatus == LENGTH_FIXED && myEdgesNumber > 0) {
-    Standard_Real First,Last;
-    TopLoc_Location L;
-    Handle (Geom2d_Curve) PreviousCurve = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,First,Last);
-    if (PreviousCurve->IsKind(STANDARD_TYPE(Geom2d_Line))) {
-      Handle (Geom2d_Curve) PreviousCurve = BRep_Tool::CurveOnSurface(TopoDS::Edge(myPreviousEdge),myPlane,L,First,Last);
-      gp_Lin2d aline = gce_MakeLin2d(gp_Pnt2d(myLastX,myLastY), gp_Pnt2d(X,Y));
-      myCurrentEdge = BRepBuilderAPI_MakeEdge2d(aline,0.,mySegmentLength);
-    }
-  }
-}
-
-/*!
-  Build the current arc.
-
-  \param X      
-  \param Y      
-*/
-void Sketch::MakeCurrentArc(Standard_Real X, Standard_Real Y)
-{
-  gp_Circ2d CircSol;
-  Standard_Boolean OK(Standard_False);
-
-  if (myTransitionStatus == NOCONSTRAINT) {
-    GccAna_Circ2d2TanOn aSol(gp_Pnt2d(myLastX,myLastY), gp_Pnt2d(X,Y),myMediatrice->Lin2d(),Precision::Confusion());
-    if (aSol.NbSolutions() > 0){
-      CircSol = aSol.ThisSolution(1);
-      OK = Standard_True;
-    }
-  }
-  /* Tangency with previous edge */
-  else if (myTransitionStatus == TANGENT && myEdgesNumber > 0) {
-    Standard_Real first,last;
-    TopLoc_Location L;
-    Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,first,last);
-    if (C->IsKind(STANDARD_TYPE(Geom2d_Line))){
-      GccAna_Circ2d2TanOn aSol(GccEnt::Unqualified(Handle(Geom2d_Line)::DownCast(C)->Lin2d()), gp_Pnt2d(myLastX,myLastY),myMediatrice->Lin2d(),Precision::Confusion());
-      if (aSol.NbSolutions() > 0){
-       CircSol = aSol.ThisSolution(1);
-       OK = Standard_True;
-      }
-    }
-    else if (C->IsKind(STANDARD_TYPE(Geom2d_Circle))) {
-      GccAna_Circ2d2TanOn aSol(GccEnt::Unqualified(Handle(Geom2d_Circle)::DownCast(C)->Circ2d()), gp_Pnt2d(myLastX,myLastY),myMediatrice->Lin2d(),Precision::Confusion());
-      if (aSol.NbSolutions() > 0){
-       CircSol = aSol.ThisSolution(1);
-       OK = Standard_True;
-      }
-    }
-    else if(C->IsKind(STANDARD_TYPE(Geom2d_BSplineCurve))) {
-      gp_Pnt2d pc;
-      gp_Vec2d Vt;
-      C->D1(last,pc,Vt);
-      gp_Lin2d alin2d(pc,gp_Dir2d(Vt));
-      GccAna_Circ2d2TanOn aSol(GccEnt::Unqualified(alin2d), gp_Pnt2d(myLastX,myLastY),myMediatrice->Lin2d(),Precision::Confusion());
-      if (aSol.NbSolutions() > 0){
-       CircSol = aSol.ThisSolution(1);
-       OK = Standard_True;
-      }
-    }
-  }
-  /* Tangency with the perpendicular to the previous edge */
-  else if (myTransitionStatus == PERPENDICULAR && myEdgesNumber > 0) {
-    Standard_Real first,last;
-    TopLoc_Location L;
-    Handle(Geom2d_Curve) C = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,first,last);
-    gp_Pnt2d p1;
-    gp_Lin2d perpen;
-    if (myPreviousEdge.Orientation() == TopAbs_FORWARD)
-      C->D0(last,p1);
-    else 
-      C->D0(first,p1);
-    if (C->IsKind(STANDARD_TYPE(Geom2d_Line))) {
-      GccAna_Lin2dTanPer aSol(p1,Handle(Geom2d_Line)::DownCast(C)->Lin2d());
-      perpen = aSol.ThisSolution(1);
-    }
-    else if (C->IsKind(STANDARD_TYPE(Geom2d_Circle))) {
-      GccAna_Lin2dTanPer aSol(p1,Handle(Geom2d_Circle)::DownCast(C)->Circ2d());
-      perpen = aSol.ThisSolution(1);
-    }
-    GccAna_Circ2d2TanOn aSol(GccEnt::Unqualified(perpen), gp_Pnt2d(myLastX,myLastY),myMediatrice->Lin2d(),Precision::Confusion());
-    if (aSol.NbSolutions() > 0){
-      CircSol = aSol.ThisSolution(1);
-      OK = Standard_True;
-    }
-  }
-
-  gp_Pnt2d p;
-  if (myEdgesNumber > 0) {
-    if (myPreviousEdge.Orientation() == TopAbs_FORWARD)
-      p = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(TopExp::LastVertex(myPreviousEdge)));
-    else
-      p = ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(TopExp::FirstVertex(myPreviousEdge)));
-  }
-  else
-    p =  ProjLib::Project(myPlane->Pln(),BRep_Tool::Pnt(myFirstPointSketch));
-  if (OK){
-    gp_Vec2d V1(p,gp_Pnt2d(X,Y));
-    gp_Vec2d V2(p,gp_Pnt2d(myLastX,myLastY));
-    if (V1.Angle(V2) > 0 )
-      myCurrentEdge = BRepBuilderAPI_MakeEdge2d(CircSol,p,gp_Pnt2d(myLastX,myLastY));
-    else {     
-      myCurrentEdge = BRepBuilderAPI_MakeEdge2d(CircSol,gp_Pnt2d(myLastX,myLastY),p);
-      myCurrentEdge.Reverse();
-    }
-  }
-  else {
-    myCurrentStatus = ARC_CHORD;
-    myLastX = p.X();
-    myLastY = p.Y();
-    myInteractiveContext->CloseLocalContext();
-  }
-
-}
-
-/*!
-  Display the current edge under construction with it's dimension.
-*/
-void Sketch::DisplayCurrentEdge()
-{
-  myPresentableEdge->Set(myCurrentEdge);
-  myInteractiveContext->Redisplay(myPresentableEdge);
-  if (myCurrentStatus == SEGMENT ||
-      myCurrentStatus == ARC_CHORD ) {
-    /* Length dimension */
-    TopoDS_Vertex V1 = TopExp::FirstVertex(TopoDS::Edge(myCurrentEdge));
-    TopoDS_Vertex V2 = TopExp::LastVertex(TopoDS::Edge(myCurrentEdge));
-    DisplayLengthDimension(V1,V2);
-    /* Angular dimension */
-    DisplayAngleDimension();
-    DisplayXDimension(V1,V2);
-    DisplayYDimension(V1,V2);
-  }
-  else if (myCurrentStatus == ARC_CHORD_END ) 
-    DisplayRadiusDimension();
-  else {
-    TopoDS_Vertex V1 = TopoDS::Vertex(myCurrentEdge);
-    TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(gp_Pnt(0.,0.,0.));
-    DisplayXDimension(V1,V2);
-    DisplayYDimension(V1,V2);
-  }
-    
-}
-
-/*!
-  Display the current length dimension.
-
-  \param V1     
-  \param V2     
-*/
-void Sketch::DisplayLengthDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2)
-{
-  gp_Pnt p1 = BRep_Tool::Pnt(TopoDS::Vertex(V1));
-  gp_Pnt p2 = BRep_Tool::Pnt(TopoDS::Vertex(V2));
-  Standard_Real length = p1.Distance(p2);
-  if (length <= Precision::Confusion()) return;
-  myLengthDimension->SetFirstShape(V1);
-  myLengthDimension->SetSecondShape(V2);
-  fitInResol(length);
-  myLengthDimension->SetValue(length);
-  QString S;
-  S.sprintf("%.1f",length);
-  myLengthDimension->SetText(TCollection_ExtendedString(strdup(S)));
-  if (myIsLengthDimensionVisible) {
-    if (myInteractiveContext->IsDisplayed(myLengthDimension))
-      myInteractiveContext->Redisplay(myLengthDimension);
-    else
-      myInteractiveContext->Display(myLengthDimension);
-  }
-}
-
-/*!
-  Display the current X dimension.
-
-  \param V1     
-  \param V2     
-*/
-void Sketch::DisplayXDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2)
-{
-  if (myTransitionStatus != X_FIXED) {
-  gp_Pnt p1 = BRep_Tool::Pnt(TopoDS::Vertex(V1));
-  gp_Pnt p2 = BRep_Tool::Pnt(TopoDS::Vertex(V2));
-
-  gp_Lin aline(p1,myPlane->Pln().XAxis().Direction());
-  GeomAPI_ProjectPointOnCurve proj(p2,new Geom_Line(aline));
-
-  gp_Pnt pb = p1;
-
-  if (proj.NbPoints() > 0) {
-    Standard_Real length = p1.Distance(proj.Point(1));
-    if (length <= Precision::Confusion()) return;
-    myXDimension->SetFirstShape(V1);
-    myXDimension->SetSecondShape(V2);
-    fitInResol(length);
-    myXDimension->SetValue(length);
-    QString S;
-    S.sprintf("%.1f",length);
-    myXDimension->SetText(TCollection_ExtendedString(strdup(S)));
-    //    myXDimension->SetPosition(proj.Point(1));
-    pb.BaryCenter(5,proj.Point(1),5);
-    myXDimension->SetPosition(pb);
-    if (myIsXDimensionVisible) {
-      if (myInteractiveContext->IsDisplayed(myXDimension))
-       myInteractiveContext->Redisplay(myXDimension);
-      else
-       myInteractiveContext->Display(myXDimension);
-    }
-  }
-  } else
-    myInteractiveContext->Erase(myXDimension,Standard_True,Standard_False);
-}
-
-/*!
-  Display the current Y dimension.
-
-  \param V1     
-  \param V2     
-*/
-void Sketch::DisplayYDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2)
-{
-  if (myTransitionStatus != Y_FIXED) {
-
-  gp_Pnt p1 = BRep_Tool::Pnt(TopoDS::Vertex(V1));
-  gp_Pnt p2 = BRep_Tool::Pnt(TopoDS::Vertex(V2));
-  gp_Lin aline(p2 /*p1*/, myPlane->Pln().YAxis().Direction());
-  gp_Pnt pb = p2 /*p1*/;
-  GeomAPI_ProjectPointOnCurve proj(p1 /*p2*/,new Geom_Line(aline));
-  if (proj.NbPoints() > 0) {
-    Standard_Real length = /*p1*/ p2.Distance(proj.Point(1));
-    if (length <= Precision::Confusion()) return;
-    myYDimension->SetFirstShape(V1);
-    myYDimension->SetSecondShape(V2);
-    fitInResol(length);
-    myYDimension->SetValue(length);
-    QString S;
-    S.sprintf("%.1f",length);
-    myYDimension->SetText(TCollection_ExtendedString(strdup(S)));
-    pb.BaryCenter(5,proj.Point(1),5);
-    myYDimension->SetPosition(pb);
-    //    myYDimension->SetPosition(p2);
-    if (myIsYDimensionVisible) {
-      if (myInteractiveContext->IsDisplayed(myYDimension))
-       myInteractiveContext->Redisplay(myYDimension);
-      else
-       myInteractiveContext->Display(myYDimension);
-    }
-  }
-  } else
-    myInteractiveContext->Erase(myYDimension,Standard_True,Standard_False);
-}
-
-/*!
-  Display the current angle dimension.
-*/
-void Sketch::DisplayAngleDimension()
-{
-  if (!myIsAngleDimensionVisible)
-    return;
-  if (myEdgesNumber > 0) {
-    Standard_Real First,Last;
-    TopLoc_Location L;
-    Handle (Geom2d_Curve) PreviousCurve = BRep_Tool::CurveOnSurface(myPreviousEdge,myPlane,L,First,Last);
-    Handle (Geom2d_Curve) CurrentCurve = BRep_Tool::CurveOnSurface(TopoDS::Edge(myCurrentEdge),myPlane,L,First,Last);
-    if (PreviousCurve->IsKind(STANDARD_TYPE(Geom2d_Line)) && CurrentCurve->IsKind(STANDARD_TYPE(Geom2d_Line))) {
-      Standard_Real angle = Handle(Geom2d_Line)::DownCast(PreviousCurve)->Lin2d().Angle(Handle(Geom2d_Line)::DownCast(CurrentCurve)->Lin2d());
-      gp_Pnt2d apos;
-      if (0 <= angle && angle<= PI) 
-       angle = PI - angle;
-      else 
-       angle = PI + angle;
-      CurrentCurve->D0((First+Last)/5.,apos);
-      gp_Pnt apos3d = ElCLib::To3d(myPlane->Pln().Position().Ax2(),apos);
-      Standard_Real angtext = angle*180./PI;
-      mySegmentAngle = angle;
-      BRepLib::BuildCurve3d(TopoDS::Edge(myCurrentEdge));
-      fitInResol(angtext);
-                       
-      QString S;
-      S.sprintf("%.1f",angtext);
-      if (myInteractiveContext->IndexOfCurrentLocal() == 0) {
-       myInteractiveContext->OpenLocalContext();
-       myAngleDimension = new AIS_AngleDimension(myPreviousEdge,TopoDS::Edge(myCurrentEdge),myPlane,angle,
-                                                 TCollection_ExtendedString(strdup(S)));
-       myInteractiveContext->Display(myAngleDimension);
-      }
-      else {
-       myAngleDimension->SetSecondShape(myCurrentEdge);
-       myAngleDimension->SetValue(angle);
-       myAngleDimension->SetPosition(apos3d);
-       myAngleDimension->SetText(TCollection_ExtendedString(strdup(S)));
-       myInteractiveContext->Redisplay(myAngleDimension);
-      }
-    }
-  }
-}
-
-/*!
-  Display the current radius dimension.
-*/
-void Sketch::DisplayRadiusDimension()
-{
-  if (! myIsRadiusDimensionVisible)
-    return;
-  BRepLib::BuildCurve3d(TopoDS::Edge(myCurrentEdge));
-  Standard_Real First,Last;
-  Handle (Geom_Circle) C = Handle (Geom_Circle)::DownCast(BRep_Tool::Curve(TopoDS::Edge(myCurrentEdge),First,Last));
-  if (!C.IsNull()) {
-    Standard_Real R = C->Radius();
-    TopoDS_Shape V1 = BRepBuilderAPI_MakeVertex(C->Location());
-    gp_Pnt MidlePoint ;
-    C->D0((First+Last)/2.,MidlePoint);
-    TopoDS_Vertex V2 = BRepBuilderAPI_MakeVertex(MidlePoint);
-    myRadiusDimension->SetFirstShape(V1);
-    myRadiusDimension->SetSecondShape(V2);
-    myRadiusDimension->SetValue(R);
-    fitInResol(R);
-    QString S;
-    S.sprintf("%.1f",R);
-    myRadiusDimension->SetText(TCollection_ExtendedString(strdup(S)));
-    if (myInteractiveContext->IsDisplayed(myRadiusDimension))
-      myInteractiveContext->Redisplay(myRadiusDimension);
-    else
-      myInteractiveContext->Display(myRadiusDimension);
-    myCenterCircle->Set(V1);
-    if (myInteractiveContext->IsDisplayed(myCenterCircle))
-      myInteractiveContext->Redisplay(myCenterCircle);
-    else
-      myInteractiveContext->Display(myCenterCircle);
-  }
-}
-
-/*!
-  Remove last edge from the current wire.
-*/
-void Sketch::RemoveLastEdge()
-{
-  if (myEdgesNumber == 0) {
-    myCurrentStatus = END_SKETCH;
-    myInteractiveContext->CloseAllContexts();
-    myInteractiveContext->EraseAll(Standard_False);
-    return;
-  }
-  else {
-    BRepTools_WireExplorer Ex;
-    BRepBuilderAPI_MakeWire MW;
-    Standard_Integer index = 1;
-    myCurrentEdge = myPreviousEdge;
-    for (Ex.Init(myCurrentWire.Wire());Ex.More();Ex.Next()){
-      if (index <= myEdgesNumber-1) {
-       MW.Add(Ex.Current());
-       myPreviousEdge = Ex.Current();
-       index++;
-      }
-    }
-    myCurrentWire = MW;
-    myCurrentStatus = (SketchStatus)myConstructionMode(myEdgesNumber);
-    myTransitionStatus = (TransitionStatus)myConstraintMode(myEdgesNumber);
-    myEdgesNumber--;
-    myConstructionMode.Remove(index);
-    myConstraintMode.Remove(index);
-    if (myEdgesNumber == 0) 
-      myPresentableWire->Set(myFirstPointSketch);
-    else
-      myPresentableWire->Set(myCurrentWire.Wire());
-    myInteractiveContext->Redisplay(myPresentableWire);
-    myInteractiveContext->CloseLocalContext();
-    myPresentableEdge->Set(myCurrentEdge);
-    myInteractiveContext->Redisplay(myPresentableEdge);
-  }
-}
-
-/*!
-  Create initial constraints.
-*/
-void Sketch::CreateConstraints()
-{
-  Handle(Geom_Axis1Placement) xAxis = new Geom_Axis1Placement(myPlane->Pln().XAxis());
-  Handle(Geom_Axis1Placement) yAxis = new Geom_Axis1Placement(myPlane->Pln().YAxis());
-  myHAxis = new AIS_Axis(xAxis);
-  myVAxis = new AIS_Axis(yAxis);
-  myAngularAxis = myVAxis;
-  myHAxis->SetColor(myAxisColor.Name());
-  myVAxis->SetColor(myAxisColor.Name());
-  myAngularAxis->SetColor(myAxisColor.Name());
-}
-
-/*!
-  fitInResol.
-
-  \param toFit  
-  \param minIsResol     
-*/
-void Sketch::fitInResol(Standard_Real &toFit, Standard_Boolean minIsResol)
-{ 
-  Standard_Real sign =  (toFit < 0) ? -1. : +1.;
-  Standard_Real value = toFit + sign * resol/2.0; /* why "+ resol/2.0" ? because if resol = 0.5, 3.3 is rounded to 3.5 */
-  int nTimesResol = int(value/resol);
-  if ((nTimesResol == 0) &&  (minIsResol)) nTimesResol = 1;
-  toFit = nTimesResol*resol;
-}
-
-SketchStatus Sketch::GetCurrentStatus()
-{
-  return myCurrentStatus;
-}
-
-Standard_Integer Sketch::GetmyEdgesNumber()
-{
-  return myEdgesNumber;
-}
-
-
-
diff --git a/src/SKETCHER/GEOM_Sketcher.h b/src/SKETCHER/GEOM_Sketcher.h
deleted file mode 100644 (file)
index 89b12c0..0000000
+++ /dev/null
@@ -1,201 +0,0 @@
-//  GEOM SKETCHER : basic sketcher
-//
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  This library is free software; you can redistribute it and/or 
-//  modify it under the terms of the GNU Lesser General Public 
-//  License as published by the Free Software Foundation; either 
-//  version 2.1 of the License. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : GEOM_Sketcher.h
-//  Author : Nicolas REJNERI
-//  Module : GEOM
-//  $Header$
-
-#include "GEOM_SketcherStatus.h"
-
-#include <V3d_Viewer.hxx>
-#include <V3d_View.hxx>
-#include <BRepBuilderAPI_MakeWire.hxx>
-#include <Geom_Plane.hxx>
-#include <AIS_InteractiveContext.hxx>
-#include <AIS_Shape.hxx>
-#include <AIS_Axis.hxx>
-#include <TopoDS_Edge.hxx>
-#include <AIS_LengthDimension.hxx>
-#include <AIS_RadiusDimension.hxx>
-#include <AIS_AngleDimension.hxx>
-#include <Geom2d_Line.hxx>
-#include <TColStd_SequenceOfInteger.hxx>
-#include <TColgp_SequenceOfPnt2d.hxx>
-#include <gp_Vec2d.hxx>
-
-class Sketch  
-{
-public:
-        Sketch();
-       ~Sketch();
-       Sketch(const Handle(V3d_Viewer)& aViewer);
-        Sketch(const Handle(V3d_Viewer)& aViewer, 
-                      const Quantity_Color& anAxisColor,
-                      const Quantity_Color& aCurrentColor,
-                      const Quantity_Color& aWireColor);
-
-       static void fitInResol(Standard_Real &toFit, 
-                              Standard_Boolean minIsResol = Standard_False);
-
-       void MakeCurrentEdge(const Standard_Integer  Xp   ,
-                                    const Standard_Integer  Yp   ,
-                                    const Handle(V3d_View)& aView );
-       
-       void MakeCurrentEdge(const Standard_Real  X, const Standard_Real Y);
-
-       Standard_Boolean SetDimension(Standard_Real& aValue); 
-       void SetDimension(Standard_Real& deltaX,Standard_Real& deltaY);
-
-       void SetXDimension(Standard_Real& deltaX);
-       void SetYDimension(Standard_Real& deltaY);
-
-       void SetSegmentAngle(Standard_Real& aValue); 
-       Standard_Real GetSegmentAngle();
-
-       void ValidateEdge();
-
-       TopoDS_Wire Close();
-       TopoDS_Wire End();
-
-       void Clear();
-
-       Standard_Boolean Delete();
-
-       void SetPlane(const Handle(Geom_Plane)& aPlane);
-
-       void SetWireColor(const Quantity_Color& aColor);
-       void SetCurrentColor(const Quantity_Color& aColor);
-       void SetAxisColor(const Quantity_Color& aColor);
-
-       void SetParameterVisibility(const TypeOfParameter atype, 
-                                           const Standard_Boolean OnOff);
-
-       void HiligthWithColor(const TypeOfParameter atype, 
-                                     const Quantity_NameOfColor acolor);
-       void Unhiligth(const TypeOfParameter atype);
-
-       Standard_Boolean IsValidCurrentParameter(const TypeOfParameter atype);
-
-       void SetParameterValue(const TypeOfParameter atype, Standard_Real aValue);
-
-       void ChangeMode(const SketchStatus aMode);
-
-       void SetTransitionStatus(const TransitionStatus aStatus);
-
-       SketchStatus GetCurrentStatus(); 
-       Standard_Integer GetmyEdgesNumber();
-
-private :
-       
-       void Init();
-
-       void MakeCurrentSegment(Standard_Real X, Standard_Real Y);
-
-       void MakeCurrentArc(Standard_Real X, Standard_Real Y);
-
-       void DisplayCurrentEdge();
-
-       void DisplayLengthDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2);
-       void DisplayXDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2);
-       void DisplayYDimension(const TopoDS_Vertex& V1,const TopoDS_Vertex& V2);
-       void DisplayAngleDimension();
-       void DisplayRadiusDimension();
-
-       void AddEdgeToWire();
-
-       void RemoveLastEdge();
-
-       void CreateConstraints();
-
-private:
-       // Current status of construction
-       SketchStatus myCurrentStatus; 
-       // Transition status between arcs and segments
-       TransitionStatus myTransitionStatus;  
-       // Current wire
-       BRepBuilderAPI_MakeWire myCurrentWire;
-       // Current presentable wire
-       Handle_AIS_Shape myPresentableWire;   
-       // Number of edges into the current wire
-       Standard_Integer myEdgesNumber;       
-       // Store for each edge how it has been built i.d the value of myCurrentStatus
-       TColStd_SequenceOfInteger myConstructionMode; 
-       // Store for each edge how it has been built i.d the value of myTransitionStatus
-       TColStd_SequenceOfInteger myConstraintMode;  
-       // Current edge 
-       TopoDS_Shape myCurrentEdge; 
-       // Previous edge
-       TopoDS_Edge myPreviousEdge; 
-       // List of points to interpolate when computing a curve by interpolation
-       TColgp_SequenceOfPnt2d myPointsToInterpolate; 
-       // Tangent vector at beginning of curve
-       gp_Vec2d myTangentVector;         
-       // Tangent flag at beginning og curve
-       Standard_Boolean myTangentFlag;   
-       
-       // Origin of sketch
-       TopoDS_Vertex myFirstPointSketch; 
-       // Last x coordinate of end point of previous edge or picked point
-       Standard_Real myLastX; 
-       // Last y coordinate of end point of previous edge or picked point
-       Standard_Real myLastY; 
-       // angle between 2 segments when an ANGLE TransitionStatus is set.
-       Standard_Real mySegmentAngle;  
-       // Length of segment when the length of the segment is fixed before the angle
-       Standard_Real mySegmentLength; 
-       // Value of X fixed coordinate 
-       Standard_Real mySegmentX;                    
-       // Value of Y fixed Coordinate
-       Standard_Real mySegmentY;                    
-       Handle_AIS_Shape myPresentableEdge;          // Current presentable edge
-       Handle_AIS_LengthDimension myLengthDimension;// For display of current length segment dimension
-       Handle_AIS_LengthDimension myXDimension;     // For display of current X segment dimension
-       Handle_AIS_LengthDimension myYDimension;     // For display of current Y segment dimension
-       Handle_AIS_LengthDimension myRadiusDimension;// For display of current radius dimension
-       Handle_AIS_AngleDimension myAngleDimension;  // For display of current angle dimension
-       Standard_Boolean myIsLengthDimensionVisible; // Visibility flag for LengthDimension
-       Standard_Boolean myIsXDimensionVisible;      // Visibility flag for X Dimension
-       Standard_Boolean myIsYDimensionVisible;      // Visibility flag for Y Dimension
-       Standard_Boolean myIsRadiusDimensionVisible; // Visibility flag for RadiusDimension
-       Standard_Boolean myIsAngleDimensionVisible;  // Visibility flag for AngleDimension
-       Handle_AIS_Axis myPresentableMediatrice;     // Chord mediatrice of current circle as a presentable object
-       Handle_Geom2d_Line myMediatrice; // Chord mediatrice of current circle as a 2d line
-       Handle_AIS_Shape myCenterCircle; // to visualise center of current arc
-
-       Handle_AIS_Axis myHAxis;         // Horizontal axis
-       Handle_AIS_Axis myVAxis;         // Vertical axis
-       Handle_AIS_Axis myAngularAxis;   // Axis making a predefined angle with the previous edge
-
-       Quantity_Color myWireColor;      // Color of wire and of build edges
-       Quantity_Color myCurrentColor;   // Color of edge under construction
-       Quantity_Color myAxisColor;      // Color for axis
-       Handle_AIS_InteractiveContext myInteractiveContext; // Interactive context for display management
-       
-       Handle_Geom_Plane myPlane;       // Plane of sketch
-
-       BRepBuilderAPI_MakeWire myPasteWire;                                            
-       Standard_Integer myPasteEdgesNumber;
-       TColStd_SequenceOfInteger myPasteConstructionMode;
-       TColStd_SequenceOfInteger myPasteConstraintMode;        
-};
diff --git a/src/SKETCHER/GEOM_SketcherStatus.h b/src/SKETCHER/GEOM_SketcherStatus.h
deleted file mode 100644 (file)
index 4e3adbc..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-//  GEOM SKETCHER : basic sketcher
-//
-//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
-// 
-//  This library is free software; you can redistribute it and/or 
-//  modify it under the terms of the GNU Lesser General Public 
-//  License as published by the Free Software Foundation; either 
-//  version 2.1 of the License. 
-// 
-//  This library is distributed in the hope that it will be useful, 
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
-//  Lesser General Public License for more details. 
-// 
-//  You should have received a copy of the GNU Lesser General Public 
-//  License along with this library; if not, write to the Free Software 
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
-// 
-//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
-//
-//
-//
-//  File   : GEOM_SketcherStatus.h
-//  Author : Nicolas REJNERI
-//  Module : GEOM
-//  $Header$
-
-enum TransitionStatus {
-       NOCONSTRAINT, // no constraint between consecutive edges
-       TANGENT,      // arc and segment are tangent
-       PERPENDICULAR,// arc is tangent to the perpendicular to the segment
-       ANGLE,        // Angular constraint between 2 segments
-       LENGTH_FIXED, // Length of segment has been fixed 
-       X_FIXED,      // X coordinate for segment has been fixed
-       Y_FIXED       // Y coordinate for segment has been fixed
-       };
-
-enum TypeOfParameter {
-       ANGLE_PARAMETER,
-       LENGTH_PARAMETER,
-       RADIUS_PARAMETER,
-       XVALUE_PARAMETER,
-       YVALUE_PARAMETER
-       };
-
-enum SketchStatus {
-       BEGIN_SKETCH, // Begin sketch; no edges created yet
-       SEGMENT,      // Current mode for creation is segment
-       ARC_CHORD,    // Current mode for creation is arc by chord
-       ARC_CHORD_END,// Chord validated, waiting for radius or center
-       END_SKETCH    // End sketch
-};
index 3e988eb32831aca57b2f92958018e9b542f142c6..82c1e52e9af6e546ce096fbefd1163cc55e5ca54 100644 (file)
@@ -36,22 +36,16 @@ VPATH=.:@srcdir@:@top_srcdir@/idl
 
 # Libraries targets
 LIB = libGEOMSketcher.la 
-LIB_SRC = GEOM_Sketcher.cxx
-LIB_CLIENT_IDL = SALOME_Component.idl SALOMEDS.idl SALOME_Exception.idl GEOM_Shape.idl GEOM_Gen.idl
+LIB_SRC = Sketcher_Profile.cxx
+LIB_CLIENT_IDL = SALOME_Component.idl SALOMEDS.idl SALOME_Exception.idl
 
 # header files 
-EXPORT_HEADERS= GEOM_Sketcher.h \
-               GEOM_SketcherStatus.h
+EXPORT_HEADERS= Sketcher_Profile.hxx
 
 # additionnal information to compil and link file
-CPPFLAGS += $(OCC_INCLUDES) $(QT_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
-CXXFLAGS += $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome
-LDFLAGS  += $(QT_LIBS) $(CAS_LDPATH) -lTKTopAlgo -L${KERNEL_ROOT_DIR}/lib/salome
-
-# additional file to be cleaned
-MOSTLYCLEAN =
-CLEAN =
-DISTCLEAN =
+CPPFLAGS += $(OCC_INCLUDES) -I${KERNEL_ROOT_DIR}/include/salome
+CXXFLAGS += -I${KERNEL_ROOT_DIR}/include/salome
+LDFLAGS  += $(OCC_KERNEL_LIBS) $(OCC_MODELER_LIBS) -L${KERNEL_ROOT_DIR}/lib/salome
 
 @CONCLUDE@
 
diff --git a/src/SKETCHER/Sketcher_Profile.cxx b/src/SKETCHER/Sketcher_Profile.cxx
new file mode 100644 (file)
index 0000000..4df75a7
--- /dev/null
@@ -0,0 +1,382 @@
+//  GEOM SKETCHER : basic sketcher
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//
+//
+//
+//  File   : Sketcher_Profile.cxx
+//  Author : Damien COQUERET
+//  Module : GEOM
+//  $Header: 
+
+using namespace std;
+#include "Sketcher_Profile.hxx"
+
+#include <TopoDS_Vertex.hxx>
+#include <TopoDS_Face.hxx>
+#include <gp_Pln.hxx>
+#include <gp_Ax2.hxx>
+#include <BRepLib.hxx>
+#include <BRepBuilderAPI_MakeVertex.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+#include <Geom2d_Line.hxx>
+#include <Geom2d_Circle.hxx>
+#include <Geom_Surface.hxx>
+#include <Precision.hxx>
+#include <GeomAPI.hxx>
+
+#include <TCollection_AsciiString.hxx>
+
+#include <SALOMEconfig.h>
+#include CORBA_SERVER_HEADER(SALOMEDS)
+
+//=======================================================================
+// profile
+// command to build a profile
+//=======================================================================
+Sketcher_Profile::Sketcher_Profile()
+{
+}
+
+
+//=======================================================================
+// profile
+// command to build a profile
+//=======================================================================
+Sketcher_Profile::Sketcher_Profile(const char* aCmd)
+{
+  enum {line, circle, point, none} move;
+
+  Standard_Integer i = 1;
+  Standard_Real x0, y0, x, y, dx, dy;
+  x0 = y0 = x = y = dy = 0;
+  dx = 1;
+
+  Standard_Boolean first, stayfirst, face, close;
+  first = Standard_True;
+  stayfirst = face = close = Standard_False;
+
+  TopoDS_Shape S;
+  TopoDS_Vertex MP;
+  BRepBuilderAPI_MakeWire MW;
+  gp_Ax3 DummyHP(gp::XOY());
+  gp_Pln P(DummyHP);
+  TopLoc_Location TheLocation;
+  Handle(Geom_Surface) Surface;
+
+  myOK = Standard_False;
+
+  TCollection_AsciiString aCommand(CORBA::string_dup(aCmd));
+  TCollection_AsciiString aToken = aCommand.Token(":", 1);
+  int n = 0;
+  TCollection_AsciiString aTab[aCommand.Length()];
+  while(aToken.Length() != 0) {
+    if(aCommand.Token(":", n + 1).Length() > 0)
+      aTab[n] = aCommand.Token(":", n + 1);
+    aToken = aCommand.Token(":", ++n);
+  }
+  n = n - 1;
+  
+  while(i < n) {
+    Standard_Real length = 0, radius = 0, angle = 0;
+    move = point;
+
+    int n1 = 0;
+    TCollection_AsciiString a[aTab[0].Length()];
+    aToken = aTab[i].Token(" ", 1);
+    while(aToken.Length() != 0) {
+      if(aTab[i].Token(" ", n1 + 1).Length() > 0)
+       a[n1] = aTab[i].Token(" ", n1 + 1);
+      aToken = aTab[i].Token(" ", ++n1);
+    }
+    n1 = n1 - 1;
+
+    switch(a[0].Value(1))
+    {
+    case 'F':
+      {
+       if (n1 != 3) goto badargs;
+       if (!first) {
+         cout<<"profile : The F instruction must precede all moves"<<endl;
+         return;
+       }
+       x0 = x = a[1].RealValue();
+       y0 = y = a[2].RealValue();
+       stayfirst = Standard_True;
+       break;
+      }
+    case 'O':
+      {
+       if (n1 != 4) goto badargs;
+       P.SetLocation(gp_Pnt(a[1].RealValue(), a[2].RealValue(), a[3].RealValue()));
+       stayfirst = Standard_True;
+       break;
+      }
+    case 'P':
+      {
+       if (n1 != 7) goto badargs;
+       gp_Vec vn(a[1].RealValue(), a[2].RealValue(), a[3].RealValue());
+       gp_Vec vx(a[4].RealValue(), a[5].RealValue(), a[6].RealValue());
+       if (vn.Magnitude() <= Precision::Confusion() || vx.Magnitude() <= Precision::Confusion()) {
+         cout<<"profile : null direction"<<endl;
+         return;
+       }
+       gp_Ax2 ax(P.Location(), vn, vx);
+       P.SetPosition(ax);
+       stayfirst = Standard_True;
+       break;
+      }
+    case 'X':
+      {
+       if (n1 != 2) goto badargs;
+       length = a[1].RealValue();
+       if (a[0] == "XX")
+         length -= x;
+       dx = 1; dy = 0;
+       move = line;
+       break;
+      }
+    case 'Y':
+      {
+       if (n1 != 2) goto badargs;
+       length = a[1].RealValue();
+       if (a[0] == "YY")
+         length -= y;
+       dx = 0; dy = 1;
+       move = line;
+       break;
+      }
+    case 'L':
+      {
+       if (n1 != 2) goto badargs;
+       length = a[1].RealValue();
+       if (Abs(length) > Precision::Confusion())
+         move = line;
+       else
+         move = none;
+       break;
+      }
+    case 'T':
+      {
+       if (n1 != 3) goto badargs;
+       Standard_Real vx = a[1].RealValue();
+       Standard_Real vy = a[2].RealValue();
+       if (a[0] == "TT") {
+         vx -= x;
+         vy -= y;
+       }
+       length = Sqrt(vx * vx + vy * vy);
+       if (length > Precision::Confusion()) {
+         move = line;
+         dx = vx / length;
+         dy = vy / length;
+       }
+       else
+         move = none;
+       break;
+      }
+    case 'R':
+      {
+       if (n1 != 2) goto badargs;
+       angle = a[1].RealValue() * PI180;
+       if (a[0] == "RR") {
+         dx = Cos(angle);
+         dy = Sin(angle);
+       }
+       else {
+         Standard_Real c = Cos(angle);
+         Standard_Real s = Sin(angle);
+         Standard_Real t = c * dx - s * dy;
+         dy = s * dx + c * dy;
+         dx = t;
+       }
+       break;
+      }
+    case 'D':
+      {
+       if (n1 != 3) goto badargs;
+       Standard_Real vx = a[1].RealValue();
+       Standard_Real vy = a[2].RealValue();
+       length = Sqrt(vx * vx + vy * vy);
+       if (length > Precision::Confusion()) {
+         dx = vx / length;
+         dy = vy / length;
+       }
+       else
+         move = none;
+       break;
+      }
+    case 'C':
+      {
+       if (n1 != 3) goto badargs;
+       radius = a[1].RealValue();
+       if (Abs(radius) > Precision::Confusion()) {
+         angle = a[2].RealValue() * PI180;
+         move = circle;
+       }
+       else
+         move = none;
+       break;
+      }
+    case 'I':
+      {
+       if (n1 != 2) goto badargs;
+       length = a[1].RealValue();
+       if (a[0] == "IX") {
+         if (Abs(dx) < Precision::Confusion()) {
+           cout<<"profile : cannot intersect, arg "<<i-1<<endl;
+           return;
+         }
+         length = (length - x) / dx;
+       }
+       else if (a[0] == "IY") {
+         if (Abs(dy) < Precision::Confusion()) {
+           cout<<"profile : cannot intersect, arg "<<i-1<<endl;
+           return;
+         }
+         length = (length - y) / dy;
+       }
+       if (Abs(length) > Precision::Confusion())
+         move = line;
+       else
+         move = none;
+       break;
+      }
+    case 'W':
+      {
+       if (a[0] == "WW")
+         close = Standard_True;
+       else if(a[0] == "WF") {
+         close = Standard_True;
+         face = Standard_True;
+       }
+       i = n - 1;
+       break;
+      }
+    default:
+      {
+       cout<<"profile : unknown code "<<a[i]<<endl;
+       return;
+      }
+    }
+
+  again :
+    switch (move) 
+    {
+    case line :
+      {
+       if (length < 0) {
+         length = -length;
+         dx = -dx;
+         dy = -dy;
+       }
+       Handle(Geom2d_Line) l = new Geom2d_Line(gp_Pnt2d(x,y),gp_Dir2d(dx,dy));
+       MW.Add(BRepBuilderAPI_MakeEdge(GeomAPI::To3d(l,P),0,length));
+       x += length*dx;
+       y += length*dy;
+       break;
+      }
+    case circle :
+      {
+       Standard_Boolean sense = Standard_True;
+       if (radius < 0) {
+         radius = -radius;
+         sense = !sense;
+         dx = -dx;
+         dy = -dy;
+       }
+       gp_Ax2d ax(gp_Pnt2d(x-radius*dy,y+radius*dx),gp_Dir2d(dy,-dx));
+       if (angle < 0) {
+         angle = -angle;
+         sense = !sense;
+       }
+       Handle(Geom2d_Circle) c = new Geom2d_Circle(ax,radius,sense);
+       MW.Add(BRepBuilderAPI_MakeEdge(GeomAPI::To3d(c,P),0,angle));
+       gp_Pnt2d p;
+       gp_Vec2d v;
+       c->D1(angle,p,v);
+       x = p.X();
+       y = p.Y();
+       dx = v.X() / radius;
+       dy = v.Y() / radius;
+       break;
+      }
+    case point:
+      {
+       MP = BRepBuilderAPI_MakeVertex(gp_Pnt(x, y, 0.0));
+       break;
+      }
+    case none:
+      {
+       i = n - 1;
+       break;
+      }
+    }
+
+    // update first
+    first = stayfirst;
+    stayfirst = Standard_False;
+
+    if(!(dx == 0 && dy == 0))
+      myLastDir.SetCoord(dx, dy, 0.0);
+    else
+      return;
+    myLastPoint.SetX(x);
+    myLastPoint.SetY(y);
+
+    // next segment....
+    i++;
+    if ((i == n) && close) {
+      // the closing segment
+      dx = x0 - x;
+      dy = y0 - y;
+      length = Sqrt(dx * dx + dy * dy);
+      move = line;
+      if (length > Precision::Confusion()) {
+       dx = dx / length;
+       dy = dy / length;
+       goto again;
+      }
+    }
+  }
+
+  // get the result, face or wire
+  if (move == none)
+    return;
+  else if (move == point)
+    S = MP;
+  else if (face)
+    S = BRepBuilderAPI_MakeFace(P, MW.Wire());
+  else
+    S = MW;
+  
+  if(!TheLocation.IsIdentity())
+    S.Move(TheLocation);
+
+  myShape = S;
+  myOK = true;
+  return;
+
+  badargs :
+    cout<<"profile : bad number of arguments"<<endl;
+    return;
+}
diff --git a/src/SKETCHER/Sketcher_Profile.hxx b/src/SKETCHER/Sketcher_Profile.hxx
new file mode 100644 (file)
index 0000000..f8389f3
--- /dev/null
@@ -0,0 +1,54 @@
+//  GEOM SKETCHER : basic sketcher
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//
+//
+//
+//  File   : Sketcher_Profile.h
+//  Author : Damien COQUERET
+//  Module : GEOM
+//  $Header: 
+
+#include <gp_Pnt.hxx>
+#include <gp_Dir.hxx>
+#include <TopoDS_Shape.hxx>
+
+class Sketcher_Profile
+{
+
+public:
+  Sketcher_Profile();
+  Sketcher_Profile(const char* aCmd);
+
+private:
+  gp_Pnt myLastPoint;
+  gp_Dir myLastDir;
+
+  TopoDS_Shape myShape;
+  bool myOK;
+
+public:
+  gp_Pnt GetLastPoint(){return myLastPoint;};
+  gp_Dir GetLastDir(){return myLastDir;};
+
+  const TopoDS_Shape& GetShape(){return myShape;};
+  bool IsDone(){return myOK;};
+
+};