+ fix typos, strip trailing spaces, homogenize coding style

+ remove redundant header


git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5063 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d
This commit is contained in:
logari81 2011-10-25 17:07:23 +00:00
parent bdcb36c0f8
commit 61de5e037e
4 changed files with 118 additions and 128 deletions

View File

@ -88,11 +88,11 @@ public:
//@{
/// set this feature touched (cause recomputation on depndend features)
void touch(void);
/// test if this feature is touched
/// test if this feature is touched
bool isTouched(void) const {return StatusBits.test(0);}
/// reset this feature touched
/// reset this feature touched
void purgeTouched(void){StatusBits.reset(0);setPropertyStatus(0,false);}
/// set this feature to error
/// set this feature to error
bool isError(void) const {return StatusBits.test(1);}
bool isValid(void) const {return !StatusBits.test(1);}
/// remove the error from the object
@ -121,16 +121,16 @@ public:
* 0: no recompution is needed
* 1: recompution needed
* -1: the document examine all links of this object and if one is touched -> recompute
*/
*/
virtual short mustExecute(void) const;
/// get the status Message
const char *getStatusString(void) const;
/** Called in case of loosing a link
* Get called by the document when a object got deleted a link property of this
* object ist pointing to. The standard behaivour of the DocumentObject implementation
* is to reset the links to nothing. You may overide this method to implement
* Get called by the document when a object got deleted a link property of this
* object ist pointing to. The standard behaivour of the DocumentObject implementation
* is to reset the links to nothing. You may overide this method to implement
*additional or different behavior.
*/
virtual void onLostLinkToObject(DocumentObject*);
@ -148,10 +148,10 @@ public:
protected:
/** get called by the document to recompute this feature
* Normaly this method get called in the processing of
* Document::recompute().
* Normaly this method get called in the processing of
* Document::recompute().
* In execute() the outpupt properties get recomputed
* with the data from linked objects and objects own
* with the data from linked objects and objects own
* properties.
*/
virtual App::DocumentObjectExecReturn *execute(void);
@ -174,8 +174,8 @@ protected:
void setError(void){StatusBits.set(1);}
void resetError(void){StatusBits.reset(1);}
void setDocument(App::Document* doc);
/// get called befor the value is changed
/// get called before the value is changed
virtual void onBeforeChange(const Property* prop);
/// get called by the container when a property was changed
virtual void onChanged(const Property* prop);

View File

@ -32,7 +32,6 @@
#include <Base/Exception.h>
#include <Base/Reader.h>
#include <Base/Writer.h>
#include <Base/Console.h>
#include "Geometry.h"
#include "GeometryPy.h"

View File

@ -528,7 +528,7 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
{
const std::vector<Part::Geometry *> &geomlist = this->Geometry.getValues();
const std::vector<Constraint *> &constraints = this->Constraints.getValues();
assert(GeoId < int(geomlist.size()));
int GeoId1=-1, GeoId2=-1;
@ -566,50 +566,50 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
PointPos secondPos1 = Sketcher::none, secondPos2 = Sketcher::none;
ConstraintType constrType1 = Sketcher::PointOnObject, constrType2 = Sketcher::PointOnObject;
for (std::vector<Constraint *>::const_iterator it=constraints.begin(); it != constraints.end(); ++it)
{
Constraint *constr = *(it);
if(secondPos1 == Sketcher::none && (constr->First == GeoId1 && constr->Second == GeoId)) {
constrType1= Sketcher::Coincident;
secondPos1 = constr->FirstPos;
} else if(secondPos2 == Sketcher::none && (constr->First == GeoId2 && constr->Second == GeoId)) {
constrType2 = Sketcher::Coincident;
secondPos2 = constr->FirstPos;
}
for (std::vector<Constraint *>::const_iterator it=constraints.begin();
it != constraints.end(); ++it) {
Constraint *constr = *(it);
if (secondPos1 == Sketcher::none && (constr->First == GeoId1 && constr->Second == GeoId)) {
constrType1= Sketcher::Coincident;
secondPos1 = constr->FirstPos;
} else if (secondPos2 == Sketcher::none && (constr->First == GeoId2 && constr->Second == GeoId)) {
constrType2 = Sketcher::Coincident;
secondPos2 = constr->FirstPos;
}
}
// constrain the trimming points on the corresponding geometries
Sketcher::Constraint *newConstr = new Sketcher::Constraint();
newConstr->Type = constrType1;
newConstr->First = GeoId;
newConstr->FirstPos = end;
newConstr->Second = GeoId1;
if(constrType1 == Sketcher::Coincident) {
newConstr->SecondPos = secondPos1;
delConstraintOnPoint(GeoId1, secondPos1, false);
if (constrType1 == Sketcher::Coincident) {
newConstr->SecondPos = secondPos1;
delConstraintOnPoint(GeoId1, secondPos1, false);
}
addConstraint(newConstr);
// Reset the second pos
newConstr->SecondPos = Sketcher::none;
newConstr->Type = constrType2;
newConstr->First = newGeoId;
newConstr->FirstPos = start;
newConstr->Second = GeoId2;
if(constrType2 == Sketcher::Coincident) {
if (constrType2 == Sketcher::Coincident) {
newConstr->SecondPos = secondPos2;
delConstraintOnPoint(GeoId2, secondPos2, false);
}
addConstraint(newConstr);
// Reset the second pos
newConstr->SecondPos = Sketcher::none;
// new line segments colinear
newConstr->Type = Sketcher::Tangent;
newConstr->First = GeoId;
@ -633,35 +633,33 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
double x1 = (point1 - startPnt)*dir;
if (x1 >= 0.001*length && x1 <= 0.999*length) {
ConstraintType constrType = Sketcher::PointOnObject;
PointPos secondPos = Sketcher::none;
for (std::vector<Constraint *>::const_iterator it=constraints.begin(); it != constraints.end(); ++it)
{
ConstraintType constrType = Sketcher::PointOnObject;
PointPos secondPos = Sketcher::none;
for (std::vector<Constraint *>::const_iterator it=constraints.begin();
it != constraints.end(); ++it) {
Constraint *constr = *(it);
if((constr->First == GeoId1 && constr->Second == GeoId)) {
if ((constr->First == GeoId1 && constr->Second == GeoId)) {
constrType = Sketcher::Coincident;
secondPos = constr->FirstPos;
delConstraintOnPoint(GeoId1, constr->FirstPos, false);
break;
}
}
}
}
if (x1 > x0) { // trim line start
delConstraintOnPoint(GeoId, start, false);
movePoint(GeoId, start, point1);
// constrain the trimming point on the corresponding geometry
Sketcher::Constraint *newConstr = new Sketcher::Constraint();
newConstr->Type = constrType;
newConstr->First = GeoId;
newConstr->FirstPos = start;
newConstr->Second = GeoId1;
if(constrType == Sketcher::Coincident)
{
newConstr->SecondPos = secondPos;
}
if (constrType == Sketcher::Coincident)
newConstr->SecondPos = secondPos;
addConstraint(newConstr);
delete newConstr;
return 0;
@ -674,12 +672,10 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
newConstr->First = GeoId;
newConstr->FirstPos = end;
newConstr->Second = GeoId1;
if(constrType == Sketcher::Coincident)
{
newConstr->SecondPos = secondPos;
}
if (constrType == Sketcher::Coincident)
newConstr->SecondPos = secondPos;
addConstraint(newConstr);
delete newConstr;
return 0;
@ -719,46 +715,45 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
PointPos secondPos1 = Sketcher::none, secondPos2 = Sketcher::none;
ConstraintType constrType1 = Sketcher::PointOnObject, constrType2 = Sketcher::PointOnObject;
for (std::vector<Constraint *>::const_iterator it=constraints.begin(); it != constraints.end(); ++it)
{
Constraint *constr = *(it);
if(secondPos1 == Sketcher::none && (constr->First == GeoId1 && constr->Second == GeoId)) {
constrType1= Sketcher::Coincident;
secondPos1 = constr->FirstPos;
} else if(secondPos2 == Sketcher::none && (constr->First == GeoId2 && constr->Second == GeoId)) {
constrType2 = Sketcher::Coincident;
secondPos2 = constr->FirstPos;
}
for (std::vector<Constraint *>::const_iterator it=constraints.begin();
it != constraints.end(); ++it) {
Constraint *constr = *(it);
if (secondPos1 == Sketcher::none && (constr->First == GeoId1 && constr->Second == GeoId)) {
constrType1= Sketcher::Coincident;
secondPos1 = constr->FirstPos;
} else if(secondPos2 == Sketcher::none && (constr->First == GeoId2 && constr->Second == GeoId)) {
constrType2 = Sketcher::Coincident;
secondPos2 = constr->FirstPos;
}
}
// constrain the trimming points on the corresponding geometries
Sketcher::Constraint *newConstr = new Sketcher::Constraint();
newConstr->Type = constrType1;
newConstr->First = GeoId;
newConstr->FirstPos = start;
newConstr->Second = GeoId1;
if(constrType1 == Sketcher::Coincident) {
newConstr->SecondPos = secondPos1;
delConstraintOnPoint(GeoId1, secondPos1, false);
if (constrType1 == Sketcher::Coincident) {
newConstr->SecondPos = secondPos1;
delConstraintOnPoint(GeoId1, secondPos1, false);
}
addConstraint(newConstr);
// Reset secondpos in case it was set previously
// Reset secondpos in case it was set previously
newConstr->SecondPos = Sketcher::none;
// Add Second Constraint
newConstr->First = GeoId;
newConstr->FirstPos = end;
newConstr->Second = GeoId2;
if(constrType2 == Sketcher::Coincident) {
newConstr->SecondPos = secondPos2;
delConstraintOnPoint(GeoId2, secondPos2, false);
if (constrType2 == Sketcher::Coincident) {
newConstr->SecondPos = secondPos2;
delConstraintOnPoint(GeoId2, secondPos2, false);
}
addConstraint(newConstr);
delete newConstr;
@ -805,46 +800,46 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
PointPos secondPos1 = Sketcher::none, secondPos2 = Sketcher::none;
ConstraintType constrType1 = Sketcher::PointOnObject, constrType2 = Sketcher::PointOnObject;
for (std::vector<Constraint *>::const_iterator it=constraints.begin(); it != constraints.end(); ++it)
{
Constraint *constr = *(it);
if(secondPos1 == Sketcher::none &&
(constr->First == GeoId1 && constr->Second == GeoId)) {
constrType1= Sketcher::Coincident;
secondPos1 = constr->FirstPos;
} else if(secondPos2 == Sketcher::none &&
(constr->First == GeoId2 && constr->Second == GeoId)) {
constrType2 = Sketcher::Coincident;
secondPos2 = constr->FirstPos;
}
for (std::vector<Constraint *>::const_iterator it=constraints.begin();
it != constraints.end(); ++it) {
Constraint *constr = *(it);
if (secondPos1 == Sketcher::none &&
(constr->First == GeoId1 && constr->Second == GeoId)) {
constrType1= Sketcher::Coincident;
secondPos1 = constr->FirstPos;
} else if (secondPos2 == Sketcher::none &&
(constr->First == GeoId2 && constr->Second == GeoId)) {
constrType2 = Sketcher::Coincident;
secondPos2 = constr->FirstPos;
}
}
newConstr->Type = constrType1;
newConstr->First = GeoId;
newConstr->FirstPos = end;
newConstr->Second = GeoId1;
if(constrType1 == Sketcher::Coincident) {
if (constrType1 == Sketcher::Coincident) {
newConstr->SecondPos = secondPos1;
delConstraintOnPoint(GeoId1, secondPos1, false);
}
addConstraint(newConstr);
// Reset secondpos in case it was set previously
// Reset secondpos in case it was set previously
newConstr->SecondPos = Sketcher::none;
newConstr->Type = constrType2;
newConstr->First = newGeoId;
newConstr->FirstPos = start;
newConstr->Second = GeoId2;
if(constrType2 == Sketcher::Coincident) {
if (constrType2 == Sketcher::Coincident) {
newConstr->SecondPos = secondPos2;
delConstraintOnPoint(GeoId2, secondPos2, false);
}
addConstraint(newConstr);
newConstr->Type = Sketcher::Coincident;
@ -869,20 +864,20 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
}
if (GeoId1 >= 0) {
ConstraintType constrType = Sketcher::PointOnObject;
PointPos secondPos = Sketcher::none;
for (std::vector<Constraint *>::const_iterator it=constraints.begin(); it != constraints.end(); ++it)
{
Constraint *constr = *(it);
if((constr->First == GeoId1 && constr->Second == GeoId)) {
constrType = Sketcher::Coincident;
secondPos = constr->FirstPos;
delConstraintOnPoint(GeoId1, constr->FirstPos, false);
break;
for (std::vector<Constraint *>::const_iterator it=constraints.begin();
it != constraints.end(); ++it) {
Constraint *constr = *(it);
if ((constr->First == GeoId1 && constr->Second == GeoId)) {
constrType = Sketcher::Coincident;
secondPos = constr->FirstPos;
delConstraintOnPoint(GeoId1, constr->FirstPos, false);
break;
}
}
}
double theta1 = Base::fmod(atan2(point1.y - center.y, point1.x - center.x) - startAngle, 2.f*M_PI) * dir; // x1
if (theta1 >= 0.001*arcLength && theta1 <= 0.999*arcLength) {
if (theta1 > theta0) { // trim arc start
@ -895,12 +890,10 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
newConstr->First = GeoId;
newConstr->FirstPos = start;
newConstr->Second = GeoId1;
if(constrType == Sketcher::Coincident)
{
newConstr->SecondPos = secondPos;
}
if (constrType == Sketcher::Coincident)
newConstr->SecondPos = secondPos;
addConstraint(newConstr);
delete newConstr;
return 0;
@ -914,12 +907,10 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point)
newConstr->First = GeoId;
newConstr->FirstPos = end;
newConstr->Second = GeoId1;
if(constrType == Sketcher::Coincident)
{
newConstr->SecondPos = secondPos;
}
if (constrType == Sketcher::Coincident)
newConstr->SecondPos = secondPos;
addConstraint(newConstr);
delete newConstr;
return 0;
@ -1044,7 +1035,7 @@ void SketchObject::appendConflictMsg(const std::vector<int> &conflicting, std::s
ss << msg;
if (conflicting.size() > 0) {
ss << "Please remove at least one of the constraints (" << conflicting[0];
for (int i=1; i < conflicting.size(); i++)
for (unsigned int i=1; i < conflicting.size(); i++)
ss << ", " << conflicting[i];
ss << ")\n";
}

View File

@ -81,10 +81,10 @@ public:
/// delete external
int delExternal(int ConstrId);
/// returns non zero if the sketch contains conflicting constraints
/// returns non zero if the sketch contains conflicting constraints
int hasConflicts(void) const;
/// set the datum of a Distance or Angle constraint and solve
/// set the datum of a Distance or Angle constraint and solve
int setDatum(int ConstrId, double Datum);
/// move this point to a new location and solve
int movePoint(int geoIndex1, PointPos Pos1, const Base::Vector3d& toPoint, bool relative=false);