Sketcher::Sketch Class Reference

#include <Sketch.h>

Inheritance diagram for Sketcher::Sketch:
Base::Persistence Base::BaseClass

List of all members.

Classes

struct  GeoDef
 container element to store and work with the geometric elements of this sketch More...

Public Types

enum  GeoType {
  None = 0, Point = 1, Line = 2, Arc = 3,
  Circle = 4, Ellipse = 5
}

Public Member Functions

void addGeometry (const std::vector< Part::Geometry * > &geo)
 add unspecified geometry
int addGeometry (const Part::Geometry *geo)
 add unspecified geometry
void clear (void)
 delete all geometry and constraints, leave an empty sketch
int diagnose (void)
 returns the degree of freedom of a sketch and calculates a list of conflicting constraints
const std::vector< int > & getConflicting (void) const
bool getConstruction (int geoIndex) const
std::vector< Part::Geometry * > getGeometry (bool withConstrucionElements=true) const
 returns the actual geometry
virtual unsigned int getMemSize (void) const
 This method is used to get the size of objects It is not meant to have the exact size, it is more or less an estimation which runs fast! Is it two bytes or a GB?
Base::Vector3d getPoint (int geoId, PointPos pos)
 retrieves a point
int getPointId (int geoId, PointPos pos) const
 retrieves the index of a point
Py::Tuple getPyGeometry (void) const
 get the geometry as python objects
virtual Base::Type getTypeId (void) const
bool hasConflicts (void) const
int initMove (int geoIndex, PointPos pos)
 initializes a point (or curve) drag by setting the current sketch status as a reference
int movePoint (int geoIndex, PointPos pos, Base::Vector3d toPoint, bool relative=false)
 move this point (or curve) to a new location and solve.
virtual void Restore (Base::XMLReader &)
 This method is used to restore properties from an XML document.
virtual void Save (Base::Writer &) const
 This method is used to save properties to an XML document.
void setConstruction (int geoIndex, bool isConstruction=true)
 set a geometric element to a construction element
int setDatum (int constrId, double value)
 set the datum of a distance or angle constraint to a certain value and solve This can cause the solving to fail!
int setUpSketch (const std::vector< Part::Geometry * > &GeoList, const std::vector< Constraint * > &ConstraintList, bool withDiagnose=true)
 set the sketch up with geoms and constraints
 Sketch ()
int solve (void)
 solve the actual set up sketch
Part::TopoShape toShape (void) const
 return the actual geometry of the sketch a TopoShape
 ~Sketch ()



int addAngleConstraint (int geoIndex1, PointPos pos1, int geoIndex2, PointPos pos2, double value)
int addAngleConstraint (int geoIndex1, int geoIndex2, double value)
int addAngleConstraint (int geoIndex, double value)
 add an angle constraint on a line or between two lines
int addArc (const Part::GeomArcOfCircle &circleSegment)
 add a arc (circle segment)
int addCircle (const Part::GeomCircle &circle)
 add a circle
int addConstraint (const Constraint *constraint)
 add one constraint to the sketch
int addConstraints (const std::vector< Constraint * > &ConstraintList)
 constraints
int addCoordinateXConstraint (int geoIndex, PointPos pos, double value)
 add a fixed coordinate constraint to a point
int addCoordinateYConstraint (int geoIndex, PointPos pos, double value)
int addDistanceConstraint (int geoIndex1, PointPos pos1, int geoIndex2, PointPos pos2, double value)
int addDistanceConstraint (int geoIndex1, PointPos pos1, int geoIndex2, double value)
int addDistanceConstraint (int geoIndex1, int geoIndex2, double value)
int addDistanceConstraint (int geoIndex1, double value)
 add a length or distance constraint
int addDistanceXConstraint (int geoId1, PointPos pos1, int geoId2, PointPos pos2, double value)
int addDistanceXConstraint (int geoId, double value)
 add a horizontal distance constraint to two points or line ends
int addDistanceYConstraint (int geoId1, PointPos pos1, int geoId2, PointPos pos2, double value)
int addDistanceYConstraint (int geoId, double value)
 add a vertical distance constraint to two points or line ends
int addEllipse (const Part::GeomEllipse &ellipse)
 add a ellipse
int addEqualConstraint (int geoIndex1, int geoIndex2)
 add an equal length or radius constraints between two lines or between circles and arcs
int addHorizontalConstraint (int geoIndex1, PointPos pos1, int geoIndex2, PointPos pos2)
int addHorizontalConstraint (int geoIndex)
 add a horizontal constraint to a geometry
int addLine (const Part::GeomLineSegment &line)
 add an infinite line
int addLineSegment (const Part::GeomLineSegment &lineSegment)
 add a line segment
int addParallelConstraint (int geoIndex1, int geoIndex2)
 add a parallel constraint between two lines
int addPerpendicularConstraint (int geoIndex1, int geoIndex2)
 add a perpendicular constraint between two lines
int addPoint (const Base::Vector3d &point)
 add dedicated geometry
int addPointCoincidentConstraint (int geoIndex1, PointPos pos1, int geoIndex2, PointPos pos2)
 add a coincident constraint to two points of two geometries
int addPointOnObjectConstraint (int geoId1, PointPos pos1, int geoId2)
 add a point on line constraint
int addRadiusConstraint (int geoIndex, double value)
 add a radius constraint on a circle or an arc
int addSymmetricConstraint (int geoId1, PointPos pos1, int geoId2, PointPos pos2, int geoId3)
 add a symmetric constraint between two points with respect to a line
int addTangentConstraint (int geoIndex1, PointPos pos1, int geoIndex2, PointPos pos2)
int addTangentConstraint (int geoIndex1, PointPos pos1, int geoIndex2)
int addTangentConstraint (int geoIndex1, int geoIndex2)
 add a tangency constraint between two geometries
int addVerticalConstraint (int geoIndex1, PointPos pos1, int geoIndex2, PointPos pos2)
int addVerticalConstraint (int geoIndex)
 add a vertical constraint to a geometry

Static Public Member Functions

static void * create (void)
static Base::Type getClassTypeId (void)
static void init (void)

Public Attributes

float SolveTime

Protected Attributes

std::vector< GCS::ArcArcs
std::vector< GCS::CircleCircles
std::vector< int > Conflicting
int ConstraintsCounter
std::vector< double * > FixParameters
GCS::System GCSsys
std::vector< GeoDefGeoms
std::vector< double > InitParameters
bool isInitMove
std::vector< GCS::LineLines
std::vector< double > MoveParameters
std::vector< double * > Parameters
std::vector< GCS::PointPoints

Detailed Description

Definition at line 39 of file Sketch.h.


Member Enumeration Documentation

Enumerator:
None 
Point 
Line 
Arc 
Circle 
Ellipse 

Definition at line 177 of file Sketch.h.


Constructor & Destructor Documentation

Sketch::Sketch (  ) 

Definition at line 62 of file Sketch.cpp.

Sketch::~Sketch (  ) 

Definition at line 78 of file Sketch.cpp.

References clear().


Member Function Documentation

int Sketch::addAngleConstraint ( int  geoIndex1,
PointPos  pos1,
int  geoIndex2,
PointPos  pos2,
double  value 
)
int Sketch::addAngleConstraint ( int  geoIndex1,
int  geoIndex2,
double  value 
)
int Sketch::addAngleConstraint ( int  geoIndex,
double  value 
)

add an angle constraint on a line or between two lines

Definition at line 1109 of file Sketch.cpp.

References GCS::System::addConstraintP2PAngle(), draftlibs::fcvec::angle(), ConstraintsCounter, FixParameters, GCSsys, Geoms, RobotExample::l, Line, Lines, GCS::Line::p1, GCS::Line::p2, and Py::type().

Referenced by addConstraint().

int Sketch::addArc ( const Part::GeomArcOfCircle circleSegment  ) 
int Sketch::addCircle ( const Part::GeomCircle circle  ) 
int Sketch::addConstraint ( const Constraint constraint  ) 
int Sketch::addConstraints ( const std::vector< Constraint * > &  ConstraintList  ) 

constraints

add all constraints in the list

Definition at line 550 of file Sketch.cpp.

References addConstraint(), and Geoms.

Referenced by Sketcher::SketchPy::addConstraint(), and setUpSketch().

int Sketch::addCoordinateXConstraint ( int  geoIndex,
PointPos  pos,
double  value 
)

add a fixed coordinate constraint to a point

Definition at line 562 of file Sketch.cpp.

References GCS::System::addConstraintCoordinateX(), ConstraintsCounter, FixParameters, GCSsys, getPointId(), draftTools::p, and Points.

Referenced by addConstraint().

int Sketch::addCoordinateYConstraint ( int  geoIndex,
PointPos  pos,
double  value 
)
int Sketch::addDistanceConstraint ( int  geoIndex1,
PointPos  pos1,
int  geoIndex2,
PointPos  pos2,
double  value 
)
int Sketch::addDistanceConstraint ( int  geoIndex1,
PointPos  pos1,
int  geoIndex2,
double  value 
)
int Sketch::addDistanceConstraint ( int  geoIndex1,
int  geoIndex2,
double  value 
)

Definition at line 1025 of file Sketch.cpp.

References Base::Console(), Geoms, and Base::ConsoleSingleton::Warning().

int Sketch::addDistanceConstraint ( int  geoIndex1,
double  value 
)

add a length or distance constraint

Definition at line 1007 of file Sketch.cpp.

References GCS::System::addConstraintP2PDistance(), ConstraintsCounter, FixParameters, GCSsys, Geoms, RobotExample::l, Line, Lines, GCS::Line::p1, GCS::Line::p2, and Py::type().

Referenced by addConstraint().

int Sketch::addDistanceXConstraint ( int  geoId1,
PointPos  pos1,
int  geoId2,
PointPos  pos2,
double  value 
)
int Sketch::addDistanceXConstraint ( int  geoId,
double  value 
)

add a horizontal distance constraint to two points or line ends

Definition at line 592 of file Sketch.cpp.

References GCS::System::addConstraintDifference(), ConstraintsCounter, KDL::diff(), FixParameters, GCSsys, Geoms, RobotExample::l, Line, Lines, GCS::Line::p1, GCS::Line::p2, and Py::type().

Referenced by addConstraint().

int Sketch::addDistanceYConstraint ( int  geoId1,
PointPos  pos1,
int  geoId2,
PointPos  pos2,
double  value 
)
int Sketch::addDistanceYConstraint ( int  geoId,
double  value 
)

add a vertical distance constraint to two points or line ends

Definition at line 608 of file Sketch.cpp.

References GCS::System::addConstraintDifference(), ConstraintsCounter, KDL::diff(), FixParameters, GCSsys, Geoms, RobotExample::l, Line, Lines, GCS::Line::p1, GCS::Line::p2, and Py::type().

Referenced by addConstraint().

int Sketch::addEllipse ( const Part::GeomEllipse ellipse  ) 

add a ellipse

Definition at line 384 of file Sketch.cpp.

References Geoms.

int Sketch::addEqualConstraint ( int  geoIndex1,
int  geoIndex2 
)
void Sketch::addGeometry ( const std::vector< Part::Geometry * > &  geo  ) 

add unspecified geometry

Definition at line 186 of file Sketch.cpp.

References addGeometry().

int Sketch::addGeometry ( const Part::Geometry geo  ) 

add unspecified geometry

Definition at line 166 of file Sketch.cpp.

References addArc(), addCircle(), addLineSegment(), getClassTypeId(), and Part::Geometry::getTypeId().

Referenced by addGeometry().

int Sketch::addHorizontalConstraint ( int  geoIndex1,
PointPos  pos1,
int  geoIndex2,
PointPos  pos2 
)
int Sketch::addHorizontalConstraint ( int  geoIndex  ) 

add a horizontal constraint to a geometry

Definition at line 665 of file Sketch.cpp.

References GCS::System::addConstraintHorizontal(), ConstraintsCounter, GCSsys, Geoms, RobotExample::l, Line, Lines, and Py::type().

Referenced by addConstraint().

int Sketch::addLine ( const Part::GeomLineSegment line  ) 

add an infinite line

Definition at line 219 of file Sketch.cpp.

References Geoms.

int Sketch::addLineSegment ( const Part::GeomLineSegment lineSegment  ) 
int Sketch::addParallelConstraint ( int  geoIndex1,
int  geoIndex2 
)

add a parallel constraint between two lines

Definition at line 743 of file Sketch.cpp.

References GCS::System::addConstraintParallel(), ConstraintsCounter, GCSsys, Geoms, Mod::PartDesign::Scripts::Gear::l1, Mod::PartDesign::Scripts::Gear::l2, Line, Lines, and Py::type().

Referenced by addConstraint().

int Sketch::addPerpendicularConstraint ( int  geoIndex1,
int  geoIndex2 
)
int Sketch::addPoint ( const Base::Vector3d point  ) 
int Sketch::addPointCoincidentConstraint ( int  geoIndex1,
PointPos  pos1,
int  geoIndex2,
PointPos  pos2 
)

add a coincident constraint to two points of two geometries

Definition at line 724 of file Sketch.cpp.

References GCS::System::addConstraintP2PCoincident(), ConstraintsCounter, GCSsys, getPointId(), and Points.

Referenced by addConstraint().

int Sketch::addPointOnObjectConstraint ( int  geoId1,
PointPos  pos1,
int  geoId2 
)
int Sketch::addRadiusConstraint ( int  geoIndex,
double  value 
)

add a radius constraint on a circle or an arc

Definition at line 1083 of file Sketch.cpp.

References GCS::System::addConstraintArcRadius(), GCS::System::addConstraintCircleRadius(), Arc, Arcs, Circles, ConstraintsCounter, FixParameters, GCSsys, Geoms, and Py::type().

Referenced by addConstraint().

int Sketch::addSymmetricConstraint ( int  geoId1,
PointPos  pos1,
int  geoId2,
PointPos  pos2,
int  geoId3 
)

add a symmetric constraint between two points with respect to a line

Definition at line 1278 of file Sketch.cpp.

References GCS::System::addConstraintP2PSymmetric(), ConstraintsCounter, GCSsys, Geoms, getPointId(), RobotExample::l, Line, Lines, Points, and Py::type().

Referenced by addConstraint().

int Sketch::addTangentConstraint ( int  geoIndex1,
PointPos  pos1,
int  geoIndex2,
PointPos  pos2 
)
int Sketch::addTangentConstraint ( int  geoIndex1,
PointPos  pos1,
int  geoIndex2 
)
int Sketch::addTangentConstraint ( int  geoIndex1,
int  geoIndex2 
)
int Sketch::addVerticalConstraint ( int  geoIndex1,
PointPos  pos1,
int  geoIndex2,
PointPos  pos2 
)
int Sketch::addVerticalConstraint ( int  geoIndex  ) 

add a vertical constraint to a geometry

Definition at line 695 of file Sketch.cpp.

References GCS::System::addConstraintVertical(), ConstraintsCounter, GCSsys, Geoms, RobotExample::l, Line, Lines, and Py::type().

Referenced by addConstraint().

void Sketch::clear ( void   ) 

delete all geometry and constraints, leave an empty sketch

Definition at line 83 of file Sketch.cpp.

References Arcs, Circles, GCS::System::clear(), Conflicting, ConstraintsCounter, FixParameters, GCSsys, Geoms, isInitMove, Lines, Parameters, and Points.

Referenced by setUpSketch(), and ~Sketch().

void * Sketcher::Sketch::create ( void   )  [static]

Reimplemented from Base::Persistence.

Definition at line 60 of file Sketch.cpp.

int Sketch::diagnose ( void   ) 

returns the degree of freedom of a sketch and calculates a list of conflicting constraints

0 degrees of freedom correspond to a fully constrained sketch -1 degrees of freedom correspond to an over-constrained sketch positive degrees of freedom correspond to an under-constrained sketch

an over-constrained sketch will always contain conflicting constraints a fully constrained or under-constrained sketch may contain conflicting constraints or may not

Definition at line 1622 of file Sketch.cpp.

References Conflicting, GCS::System::diagnose(), GCSsys, GCS::System::isInit(), and Parameters.

Referenced by setUpSketch().

Base::Type Sketcher::Sketch::getClassTypeId ( void   )  [static]

Reimplemented from Base::Persistence.

Definition at line 60 of file Sketch.cpp.

Referenced by addGeometry(), and setUpSketch().

const std::vector<int>& Sketcher::Sketch::getConflicting ( void   )  const [inline]
bool Sketch::getConstruction ( int  geoIndex  )  const

Definition at line 439 of file Sketch.cpp.

References Geoms.

std::vector< Part::Geometry * > Sketch::getGeometry ( bool  withConstrucionElements = true  )  const
unsigned int Sketch::getMemSize ( void   )  const [virtual]

This method is used to get the size of objects It is not meant to have the exact size, it is more or less an estimation which runs fast! Is it two bytes or a GB?

Implements Base::Persistence.

Definition at line 1726 of file Sketch.cpp.

Base::Vector3d Sketch::getPoint ( int  geoId,
PointPos  pos 
)
int Sketch::getPointId ( int  geoId,
PointPos  pos 
) const
Py::Tuple Sketch::getPyGeometry ( void   )  const

get the geometry as python objects

Definition at line 403 of file Sketch.cpp.

References Arc, Py::asObject(), Ellipse, Geoms, Line, Point, Points, MovieTool::x, and MovieTool::y.

Referenced by Sketcher::SketchPy::getGeometries().

Base::Type Sketcher::Sketch::getTypeId ( void   )  const [virtual]

Reimplemented from Base::Persistence.

Definition at line 60 of file Sketch.cpp.

bool Sketcher::Sketch::hasConflicts ( void   )  const [inline]
void Sketcher::Sketch::init ( void   )  [static]

Reimplemented from Base::Persistence.

Definition at line 60 of file Sketch.cpp.

Referenced by initSketcher().

int Sketch::initMove ( int  geoIndex,
PointPos  pos 
)
int Sketch::movePoint ( int  geoIndex,
PointPos  pos,
Base::Vector3d  toPoint,
bool  relative = false 
)

move this point (or curve) to a new location and solve.

This will introduce some additional weak constraints expressing a condition for satisfying the new point location! The relative flag permits moving relatively to the current position

Definition at line 1548 of file Sketch.cpp.

References Arc, Sketcher::end, Geoms, hasConflicts(), initMove(), InitParameters, isInitMove, Line, Sketcher::mid, MoveParameters, Sketcher::none, solve(), Sketcher::start, Py::type(), Base::Vector3< _Precision >::x, and Base::Vector3< _Precision >::y.

Referenced by SketcherGui::ViewProviderSketch::mouseMove(), and Sketcher::SketchObject::movePoint().

void Sketch::Restore ( Base::XMLReader  )  [virtual]

This method is used to restore properties from an XML document.

It uses the XMLReader class, which bases on SAX, to read the in Save() written information. Again the Vector as an example:

 void PropertyVector::Restore(Base::XMLReader &reader)
 {
   // read my Element
   reader.readElement("PropertyVector");
   // get the value of my Attribute
   _cVec.x = (float)reader.getAttributeAsFloat("valueX");
   _cVec.y = (float)reader.getAttributeAsFloat("valueY");
   _cVec.z = (float)reader.getAttributeAsFloat("valueZ");
 }

Implements Base::Persistence.

Definition at line 1736 of file Sketch.cpp.

void Sketch::Save ( Base::Writer  )  const [virtual]

This method is used to save properties to an XML document.

A good example you'll find in PropertyStandard.cpp, e.g. the vector:

  void PropertyVector::Save (Writer &writer) const
  {
     writer << writer.ind() << "<PropertyVector valueX=\"" <<  _cVec.x <<
                                            "\" valueY=\"" <<  _cVec.y <<
                                            "\" valueZ=\"" <<  _cVec.z <<"\"/>" << endl;
  }

The writer.ind() expression writes the indention, just for pretty printing of the XML. As you see, the writing of the XML document is not done with a DOM implementation because of performance reasons. Therefore the programmer has to take care that a valid XML document is written. This means closing tags and writing UTF-8.

See also:
Base::Writer

Implements Base::Persistence.

Definition at line 1731 of file Sketch.cpp.

void Sketch::setConstruction ( int  geoIndex,
bool  isConstruction = true 
)

set a geometric element to a construction element

Definition at line 432 of file Sketch.cpp.

References Geoms.

int Sketch::setDatum ( int  constrId,
double  value 
)

set the datum of a distance or angle constraint to a certain value and solve This can cause the solving to fail!

Definition at line 1592 of file Sketch.cpp.

int Sketch::setUpSketch ( const std::vector< Part::Geometry * > &  GeoList,
const std::vector< Constraint * > &  ConstraintList,
bool  withDiagnose = true 
)
int Sketch::solve ( void   ) 
TopoShape Sketch::toShape ( void   )  const

return the actual geometry of the sketch a TopoShape

Definition at line 1636 of file Sketch.cpp.

References Part::TopoShape::_Shape, Base::Console(), Part::TopoShape::fuse(), Geoms, result, Base::ConsoleSingleton::Warning(), and Mesh2Shape::wires.

Referenced by Sketcher::SketchObject::execute().


Member Data Documentation

std::vector<GCS::Arc> Sketcher::Sketch::Arcs [protected]
std::vector<GCS::Circle> Sketcher::Sketch::Circles [protected]
std::vector<int> Sketcher::Sketch::Conflicting [protected]

Definition at line 205 of file Sketch.h.

Referenced by clear(), and diagnose().

std::vector<double*> Sketcher::Sketch::FixParameters [protected]
std::vector<GeoDef> Sketcher::Sketch::Geoms [protected]
std::vector<double> Sketcher::Sketch::InitParameters [protected]

Definition at line 210 of file Sketch.h.

Referenced by initMove(), movePoint(), and solve().

bool Sketcher::Sketch::isInitMove [protected]

Definition at line 216 of file Sketch.h.

Referenced by clear(), initMove(), movePoint(), and solve().

std::vector<GCS::Line> Sketcher::Sketch::Lines [protected]
std::vector<double> Sketcher::Sketch::MoveParameters [protected]

Definition at line 210 of file Sketch.h.

Referenced by initMove(), and movePoint().

std::vector<double*> Sketcher::Sketch::Parameters [protected]
std::vector<GCS::Point> Sketcher::Sketch::Points [protected]

The documentation for this class was generated from the following files:

Generated on Wed Nov 23 19:02:47 2011 for FreeCAD by  doxygen 1.6.1