TrajectoryDressUpObject.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include "PreCompiled.h"
00025
00026 #ifndef _PreComp_
00027 #endif
00028
00029 #include "TrajectoryDressUpObject.h"
00030
00031
00032 #include <Mod/Part/App/edgecluster.h>
00033 #include <Mod/Part/App/PartFeature.h>
00034 #include <TopoDS.hxx>
00035 #include <TopoDS_Edge.hxx>
00036 #include <TopoDS_Vertex.hxx>
00037 #include <BRep_Tool.hxx>
00038 #include <BRepAdaptor_Curve.hxx>
00039 #include <CPnts_AbscissaPoint.hxx>
00040 #include <TopExp.hxx>
00041 #include "Waypoint.h"
00042 #include "Trajectory.h"
00043
00044 using namespace Robot;
00045 using namespace App;
00046
00047 PROPERTY_SOURCE(Robot::TrajectoryDressUpObject, Robot::TrajectoryObject)
00048
00049 const char* TrajectoryDressUpObject::ContTypeEnums[]= {"DontChange","Continues","Discontinues",NULL};
00050 const char* TrajectoryDressUpObject::AddTypeEnums[] = {"DontChange","UseOrientation","AddPosition","AddOrintation","AddPositionAndOrientation",NULL};
00051
00052 TrajectoryDressUpObject::TrajectoryDressUpObject()
00053 {
00054
00055 ADD_PROPERTY_TYPE( Source, (0) , "TrajectoryDressUp",Prop_None,"Trajectory to dress up");
00056 ADD_PROPERTY_TYPE( Speed, (1000) , "TrajectoryDressUp",Prop_None,"Speed to use");
00057 ADD_PROPERTY_TYPE( UseSpeed , (0) , "TrajectoryDressUp",Prop_None,"Switch the speed usage on");
00058 ADD_PROPERTY_TYPE( Acceleration, (1000) , "TrajectoryDressUp",Prop_None,"Acceleration to use");
00059 ADD_PROPERTY_TYPE( UseAcceleration, (0) , "TrajectoryDressUp",Prop_None,"Switch the acceleration usage on");
00060 ADD_PROPERTY_TYPE( ContType, ((long)0) , "TrajectoryDressUp",Prop_None,"Define the dress up of continuity");
00061 ContType.setEnums(ContTypeEnums);
00062 ADD_PROPERTY_TYPE( PosAdd, (Base::Placement()) , "TrajectoryDressUp",Prop_None,"Position & Orientation to use");
00063 ADD_PROPERTY_TYPE( AddType, ((long)0) , "TrajectoryDressUp",Prop_None,"How to change the Position & Orientation");
00064 AddType.setEnums(AddTypeEnums);
00065
00066 }
00067
00068 TrajectoryDressUpObject::~TrajectoryDressUpObject()
00069 {
00070 }
00071
00072 App::DocumentObjectExecReturn *TrajectoryDressUpObject::execute(void)
00073 {
00074 Robot::Trajectory result;
00075
00076 App::DocumentObject* link = Source.getValue();
00077 if (!link)
00078 return new App::DocumentObjectExecReturn("No object linked");
00079 if (!link->getTypeId().isDerivedFrom(Robot::TrajectoryObject::getClassTypeId()))
00080 return new App::DocumentObjectExecReturn("Linked object is not a Trajectory object");
00081
00082 const std::vector<Waypoint*> &wps = static_cast<Robot::TrajectoryObject*>(link)->Trajectory.getValue().getWaypoints();
00083 for (std::vector<Waypoint*>::const_iterator it= wps.begin();it!=wps.end();++it) {
00084 Waypoint wpt = **it;
00085 if(UseSpeed.getValue())
00086 wpt.Velocity = Speed.getValue();
00087 if(UseAcceleration.getValue())
00088 wpt.Accelaration = Acceleration.getValue();
00089 switch(ContType.getValue()){
00090 case 0: break;
00091 case 1: wpt.Cont = true;break;
00092 case 2: wpt.Cont = false;break;
00093 default: assert(0);
00094 }
00095 switch(AddType.getValue()){
00096
00097 case 0: break;
00098
00099 case 1:
00100 wpt.EndPos.setRotation(PosAdd.getValue().getRotation());
00101 break;
00102
00103 case 2:
00104 wpt.EndPos.setPosition(wpt.EndPos.getPosition() + PosAdd.getValue().getPosition());
00105 break;
00106
00107 case 3:
00108 wpt.EndPos.setRotation(wpt.EndPos.getRotation() * PosAdd.getValue().getRotation());
00109 break;
00110
00111 case 4:
00112 wpt.EndPos= wpt.EndPos * PosAdd.getValue();
00113 break;
00114 default: assert(0);
00115 }
00116
00117 result.addWaypoint(wpt);
00118 }
00119
00120
00121 Trajectory.setValue(result);
00122
00123 return App::DocumentObject::StdReturn;
00124 }
00125
00126 void TrajectoryDressUpObject::onChanged(const Property* prop)
00127 {
00128
00129 App::GeoFeature::onChanged(prop);
00130 }