+/*!
+ \class Sketcher_Profile::Functor
+ \brief Generic functor class to process sketcher command
+ \internal
+*/
+
+class Sketcher_Profile::Functor
+{
+public:
+ Functor();
+ virtual ~Functor();
+
+ virtual void init( const TCollection_AsciiString& );
+
+ virtual void initCommand() = 0;
+ virtual void addPoint( const TCollection_AsciiString& x,
+ const TCollection_AsciiString& y ) = 0;
+ virtual void addAngle( const TCollection_AsciiString& angle ) = 0;
+ virtual void addSegmentParalX( const TCollection_AsciiString& x ) = 0;
+ virtual void addSegmentParalXToZero() = 0;
+ virtual void addSegmentParalY( const TCollection_AsciiString& y ) = 0;
+ virtual void addSegmentParalYToZero() = 0;
+ virtual void addSegmentAbsolute( const TCollection_AsciiString& x,
+ const TCollection_AsciiString& y ) = 0;
+ virtual void addSegmentRelative( const TCollection_AsciiString& dx,
+ const TCollection_AsciiString& dy ) = 0;
+ virtual void addSegmentLength( const TCollection_AsciiString& length ) = 0;
+ virtual void addSegmentX( const TCollection_AsciiString& x,
+ int CurrentIndex ) = 0;
+ virtual void addSegmentY( const TCollection_AsciiString& y,
+ int CurrentIndex ) = 0;
+ virtual void addSegmentAngleLength( const TCollection_AsciiString& angle,
+ const TCollection_AsciiString& length,
+ int& CurrentIndex ) = 0;
+ virtual void addSegmentAngleX( const TCollection_AsciiString& angle,
+ const TCollection_AsciiString& x,
+ int& CurrentIndex ) = 0;
+ virtual void addSegmentAngleY( const TCollection_AsciiString& angle,
+ const TCollection_AsciiString& y,
+ int& CurrentIndex ) = 0;
+ virtual void addSegmentDirectionLength( const TCollection_AsciiString& dx,
+ const TCollection_AsciiString& dy,
+ const TCollection_AsciiString& length,
+ int& CurrentIndex ) = 0;
+ virtual void addSegmentDirectionX( const TCollection_AsciiString& dx,
+ const TCollection_AsciiString& dy,
+ const TCollection_AsciiString& x,
+ int& CurrentIndex ) = 0;
+ virtual void addSegmentDirectionY( const TCollection_AsciiString& dx,
+ const TCollection_AsciiString& dy,
+ const TCollection_AsciiString& y,
+ int& CurrentIndex ) = 0;
+ virtual void addArcAbsolute( const TCollection_AsciiString& x,
+ const TCollection_AsciiString& y ) = 0;
+ virtual void addArcRelative( const TCollection_AsciiString& dx,
+ const TCollection_AsciiString& dy ) = 0;
+ virtual void addArcRadiusAbsolute( const TCollection_AsciiString& x,
+ const TCollection_AsciiString& y,
+ const TCollection_AsciiString& radius,
+ const TCollection_AsciiString& flag ) = 0;
+ virtual void addArcRadiusRelative( const TCollection_AsciiString& dx,
+ const TCollection_AsciiString& dy,
+ const TCollection_AsciiString& radius,
+ const TCollection_AsciiString& flag ) = 0;
+ virtual void addArcCenterAbsolute( const TCollection_AsciiString& x,
+ const TCollection_AsciiString& y,
+ const TCollection_AsciiString& xc,
+ const TCollection_AsciiString& yc,
+ const TCollection_AsciiString& flag1,
+ const TCollection_AsciiString& flag2 ) = 0;
+ virtual void addArcCenterRelative( const TCollection_AsciiString& dx,
+ const TCollection_AsciiString& dy,
+ const TCollection_AsciiString& xc,
+ const TCollection_AsciiString& yc,
+ const TCollection_AsciiString& flag1,
+ const TCollection_AsciiString& flag2 ) = 0;
+ virtual void addArcRadiusLength( const TCollection_AsciiString& radius,
+ const TCollection_AsciiString& length ) = 0;
+ virtual void addArcAngleRadiusLength( const TCollection_AsciiString& angle,
+ const TCollection_AsciiString& radius,
+ const TCollection_AsciiString& length ,
+ int& CurrentIndex ) = 0;
+ virtual void addArcDirectionRadiusLength( const TCollection_AsciiString& dx,
+ const TCollection_AsciiString& dy,
+ const TCollection_AsciiString& radius,
+ const TCollection_AsciiString& length ,
+ int& CurrentIndex ) = 0;
+ virtual void closeWire() = 0;
+ virtual void closeWireAndBuildFace() = 0;
+
+ virtual void nextCommand( int& CurrentIndex ) = 0;
+ virtual void makeResult() = 0;
+
+ void setNumberOfCommand( int n );
+ double error();
+ bool isOk();
+
+protected:
+ int myNumberOfCommand;
+ double myError;
+ bool myOk;
+};
+
+/*!
+ \class Sketcher_Profile::ShapeFunctor
+ \brief Functor that creates a shape from sketcher command
+ \internal
+*/
+
+class Sketcher_Profile::ShapeFunctor : public Functor
+{
+public:
+ ShapeFunctor();
+
+ virtual void initCommand();
+ virtual void addPoint( const TCollection_AsciiString& x,
+ const TCollection_AsciiString& y );
+ virtual void addAngle( const TCollection_AsciiString& angle );
+ virtual void addSegmentParalX( const TCollection_AsciiString& x );
+ virtual void addSegmentParalXToZero();
+ virtual void addSegmentParalY( const TCollection_AsciiString& y );
+ virtual void addSegmentParalYToZero();
+ virtual void setAngle( const TCollection_AsciiString& angle );
+ virtual void setDirection( const TCollection_AsciiString& dx,
+ const TCollection_AsciiString& dy );
+ virtual void addSegmentAbsolute( const TCollection_AsciiString& x,
+ const TCollection_AsciiString& y );
+ virtual void addSegmentRelative( const TCollection_AsciiString& dx,
+ const TCollection_AsciiString& dy );
+ virtual void addSegmentLength( const TCollection_AsciiString& length );
+ virtual void addSegmentX( const TCollection_AsciiString& x,
+ int CurrentIndex );
+ virtual void addSegmentY( const TCollection_AsciiString& y,
+ int CurrentIndex );
+ virtual void addSegmentAngleLength( const TCollection_AsciiString& angle,
+ const TCollection_AsciiString& length,
+ int& CurrentIndex );
+ virtual void addSegmentAngleX( const TCollection_AsciiString& angle,
+ const TCollection_AsciiString& x,
+ int& CurrentIndex );
+ virtual void addSegmentAngleY( const TCollection_AsciiString& angle,
+ const TCollection_AsciiString& y,
+ int& CurrentIndex );
+ virtual void addSegmentDirectionLength( const TCollection_AsciiString& dx,
+ const TCollection_AsciiString& dy,
+ const TCollection_AsciiString& length,
+ int& CurrentIndex );
+ virtual void addSegmentDirectionX( const TCollection_AsciiString& dx,
+ const TCollection_AsciiString& dy,
+ const TCollection_AsciiString& x,
+ int& CurrentIndex );
+ virtual void addSegmentDirectionY( const TCollection_AsciiString& dx,
+ const TCollection_AsciiString& dy,
+ const TCollection_AsciiString& y,
+ int& CurrentIndex );
+ virtual void addArcAbsolute( const TCollection_AsciiString& x,
+ const TCollection_AsciiString& y );
+ virtual void addArcRelative( const TCollection_AsciiString& dx,
+ const TCollection_AsciiString& dy );
+ virtual void addArcRadiusAbsolute( const TCollection_AsciiString& x,
+ const TCollection_AsciiString& y,
+ const TCollection_AsciiString& radius,
+ const TCollection_AsciiString& flag );
+ virtual void addArcRadiusRelative( const TCollection_AsciiString& dx,
+ const TCollection_AsciiString& dy,
+ const TCollection_AsciiString& radius,
+ const TCollection_AsciiString& flag );
+ virtual void addArcCenterAbsolute( const TCollection_AsciiString& x,
+ const TCollection_AsciiString& y,
+ const TCollection_AsciiString& xc,
+ const TCollection_AsciiString& yc,
+ const TCollection_AsciiString& flag1,
+ const TCollection_AsciiString& flag2 );
+ virtual void addArcCenterRelative( const TCollection_AsciiString& dx,
+ const TCollection_AsciiString& dy,
+ const TCollection_AsciiString& xc,
+ const TCollection_AsciiString& yc,
+ const TCollection_AsciiString& flag1,
+ const TCollection_AsciiString& flag2 );
+ virtual void addArcRadiusLength( const TCollection_AsciiString& radius,
+ const TCollection_AsciiString& length );
+ virtual void addArcAngleRadiusLength( const TCollection_AsciiString& angle,
+ const TCollection_AsciiString& radius,
+ const TCollection_AsciiString& length ,
+ int& CurrentIndex );
+ virtual void addArcDirectionRadiusLength( const TCollection_AsciiString& dx,
+ const TCollection_AsciiString& dy,
+ const TCollection_AsciiString& radius,
+ const TCollection_AsciiString& length ,
+ int& CurrentIndex );
+ virtual void closeWire();
+ virtual void closeWireAndBuildFace();
+
+ virtual void nextCommand( int& CurrentIndex );
+ virtual void makeResult();
+
+ TopoDS_Shape getShape();
+
+private:
+ void setMove( int& CurrentIndex );
+
+private:
+ Standard_Real myX0, myY0, myX, myY, myDx, myDy;
+ Standard_Boolean myFirst, myStayFirst, myFace, myClose;
+ Standard_Real myLength, myRadius, myAngle;
+
+ enum {line, circle, point, none} myMove;
+
+ TopLoc_Location TheLocation; // ?????????
+ gp_Pln myPlane;
+ TopoDS_Vertex myVertex;
+ BRepBuilderAPI_MakeWire myMakeWire;
+
+ TopoDS_Shape myShape;
+};
+
+/*!
+ \class Sketcher_Profile::ShapeFunctor
+ \brief Functor that generates a Python script from sketcher command
+ \internal
+*/
+
+class Sketcher_Profile::DumpFunctor : public Functor
+{
+public:
+ DumpFunctor();
+
+ virtual void init( const TCollection_AsciiString& );
+
+ virtual void initCommand();
+ virtual void addPoint( const TCollection_AsciiString& x,
+ const TCollection_AsciiString& y );
+ virtual void addAngle( const TCollection_AsciiString& angle );
+ virtual void addSegmentParalX( const TCollection_AsciiString& x );
+ virtual void addSegmentParalXToZero();
+ virtual void addSegmentParalY( const TCollection_AsciiString& y );
+ virtual void addSegmentParalYToZero();
+ virtual void addSegmentAbsolute( const TCollection_AsciiString& x,
+ const TCollection_AsciiString& y );
+ virtual void addSegmentRelative( const TCollection_AsciiString& dx,
+ const TCollection_AsciiString& dy );
+ virtual void addSegmentLength( const TCollection_AsciiString& length );
+ virtual void addSegmentX( const TCollection_AsciiString& x,
+ int CurrentIndex );
+ virtual void addSegmentY( const TCollection_AsciiString& y,
+ int CurrentIndex );
+ virtual void addSegmentAngleLength( const TCollection_AsciiString& angle,
+ const TCollection_AsciiString& length,
+ int& CurrentIndex );
+ virtual void addSegmentAngleX( const TCollection_AsciiString& angle,
+ const TCollection_AsciiString& x,
+ int& CurrentIndex );
+ virtual void addSegmentAngleY( const TCollection_AsciiString& angle,
+ const TCollection_AsciiString& y,
+ int& CurrentIndex );
+ virtual void addSegmentDirectionLength( const TCollection_AsciiString& dx,
+ const TCollection_AsciiString& dy,
+ const TCollection_AsciiString& length,
+ int& CurrentIndex );
+ virtual void addSegmentDirectionX( const TCollection_AsciiString& dx,
+ const TCollection_AsciiString& dy,
+ const TCollection_AsciiString& x,
+ int& CurrentIndex );
+ virtual void addSegmentDirectionY( const TCollection_AsciiString& dx,
+ const TCollection_AsciiString& dy,
+ const TCollection_AsciiString& y,
+ int& CurrentIndex );
+ virtual void addArcAbsolute( const TCollection_AsciiString& x,
+ const TCollection_AsciiString& y );
+ virtual void addArcRelative( const TCollection_AsciiString& dx,
+ const TCollection_AsciiString& dy );
+ virtual void addArcRadiusAbsolute( const TCollection_AsciiString& x,
+ const TCollection_AsciiString& y,
+ const TCollection_AsciiString& radius,
+ const TCollection_AsciiString& flag );
+ virtual void addArcRadiusRelative( const TCollection_AsciiString& dx,
+ const TCollection_AsciiString& dy,
+ const TCollection_AsciiString& radius,
+ const TCollection_AsciiString& flag );
+ virtual void addArcCenterAbsolute( const TCollection_AsciiString& x,
+ const TCollection_AsciiString& y,
+ const TCollection_AsciiString& xc,
+ const TCollection_AsciiString& yc,
+ const TCollection_AsciiString& flag1,
+ const TCollection_AsciiString& flag2 );
+ virtual void addArcCenterRelative( const TCollection_AsciiString& dx,
+ const TCollection_AsciiString& dy,
+ const TCollection_AsciiString& xc,
+ const TCollection_AsciiString& yc,
+ const TCollection_AsciiString& flag1,
+ const TCollection_AsciiString& flag2 );
+ virtual void addArcRadiusLength( const TCollection_AsciiString& radius,
+ const TCollection_AsciiString& length );
+ virtual void addArcAngleRadiusLength( const TCollection_AsciiString& angle,
+ const TCollection_AsciiString& radius,
+ const TCollection_AsciiString& length ,
+ int& CurrentIndex );
+ virtual void addArcDirectionRadiusLength( const TCollection_AsciiString& dx,
+ const TCollection_AsciiString& dy,
+ const TCollection_AsciiString& radius,
+ const TCollection_AsciiString& length ,
+ int& CurrentIndex );
+ virtual void closeWire();
+ virtual void closeWireAndBuildFace();
+
+ virtual void nextCommand( int& CurrentIndex );
+ virtual void makeResult();
+
+ TCollection_AsciiString getDescription();
+
+private:
+ TCollection_AsciiString myDescr;
+ TCollection_AsciiString mySketcherEntry;
+ TCollection_AsciiString myWPEntry;
+ TCollection_AsciiString myTail;
+ Standard_Boolean myFace;
+};
+
+//===========================================================================
+// Sketcher_Profile::Functor
+//===========================================================================
+
+/*!
+ \brief Constructor
+ \internal
+*/
+Sketcher_Profile::Functor::Functor() : myError( 0 ), myNumberOfCommand( 0 ), myOk( true )