Integrate Werners & Jans double branch

Move from float to double
Further suggestions for float -> double move
Moved Tools2D from float to double
More suggestions for float->double move from Gui subdirectory
Changes to FEM constraint visuals for float->double move
Suggested changes for float -> double move
Suggestions for Part module moving float -> double
This commit is contained in:
jriegel
2013-09-22 21:55:11 +02:00
parent 78ba09a490
commit 00ea24e07e
64 changed files with 719 additions and 589 deletions

View File

@@ -36,7 +36,7 @@ PROPERTY_SOURCE(App::Annotation, App::DocumentObject)
Annotation::Annotation()
{
ADD_PROPERTY(LabelText ,(""));
ADD_PROPERTY(Position,(Base::Vector3f()));
ADD_PROPERTY(Position,(Base::Vector3d()));
}
Annotation::~Annotation()
@@ -51,8 +51,8 @@ PROPERTY_SOURCE(App::AnnotationLabel, App::DocumentObject)
AnnotationLabel::AnnotationLabel()
{
ADD_PROPERTY_TYPE(LabelText,(""),"Label",Prop_Output,"Text label of the annotation");
ADD_PROPERTY_TYPE(BasePosition,(Base::Vector3f()),"Label",Prop_Output,"Base position");
ADD_PROPERTY_TYPE(TextPosition,(Base::Vector3f()),"Label",Prop_Output,"Text position");
ADD_PROPERTY_TYPE(BasePosition,(Base::Vector3d()),"Label",Prop_Output,"Base position");
ADD_PROPERTY_TYPE(TextPosition,(Base::Vector3d()),"Label",Prop_Output,"Text position");
}
AnnotationLabel::~AnnotationLabel()

View File

@@ -35,9 +35,9 @@ PROPERTY_SOURCE(App::MeasureDistance, App::DocumentObject)
MeasureDistance::MeasureDistance()
{
ADD_PROPERTY_TYPE(P1,(Base::Vector3f()),"Measurement",Prop_None,"First point of measurement");
ADD_PROPERTY_TYPE(P2,(Base::Vector3f()),"Measurement",Prop_None,"Second point of measurement");
ADD_PROPERTY_TYPE(Distance,(0.0f) ,"Measurement",App::PropertyType(Prop_ReadOnly|Prop_Output),
ADD_PROPERTY_TYPE(P1,(Base::Vector3d()),"Measurement",Prop_None,"First point of measurement");
ADD_PROPERTY_TYPE(P2,(Base::Vector3d()),"Measurement",Prop_None,"Second point of measurement");
ADD_PROPERTY_TYPE(Distance,(0.0) ,"Measurement",App::PropertyType(Prop_ReadOnly|Prop_Output),
"Distance between the points");
}

View File

@@ -75,21 +75,21 @@ PropertyVector::~PropertyVector()
// Base class implementer
void PropertyVector::setValue(const Base::Vector3f &vec)
void PropertyVector::setValue(const Base::Vector3d &vec)
{
aboutToSetValue();
_cVec=vec;
hasSetValue();
}
void PropertyVector::setValue(float x, float y, float z)
void PropertyVector::setValue(double x, double y, double z)
{
aboutToSetValue();
_cVec=Vector3f(x,y,z);
_cVec.Set(x,y,z);
hasSetValue();
}
const Base::Vector3f & PropertyVector::getValue(void)const
const Base::Vector3d & PropertyVector::getValue(void)const
{
return _cVec;
}
@@ -104,34 +104,33 @@ void PropertyVector::setPyObject(PyObject *value)
if (PyObject_TypeCheck(value, &(Base::VectorPy::Type))) {
Base::VectorPy *pcObject = static_cast<Base::VectorPy*>(value);
Base::Vector3d* val = pcObject->getVectorPtr();
Base::Vector3f vec((float)val->x,(float)val->y,(float)val->z);
setValue(vec);
setValue(*val);
}
else if (PyTuple_Check(value)&&PyTuple_Size(value)==3) {
PyObject* item;
Base::Vector3f cVec;
Base::Vector3d cVec;
// x
item = PyTuple_GetItem(value,0);
if (PyFloat_Check(item))
cVec.x = (float)PyFloat_AsDouble(item);
cVec.x = PyFloat_AsDouble(item);
else if (PyInt_Check(item))
cVec.x = (float)PyInt_AsLong(item);
cVec.x = (double)PyInt_AsLong(item);
else
throw Base::TypeError("Not allowed type used in tuple (float expected)...");
// y
item = PyTuple_GetItem(value,1);
if (PyFloat_Check(item))
cVec.y = (float)PyFloat_AsDouble(item);
cVec.y = PyFloat_AsDouble(item);
else if (PyInt_Check(item))
cVec.y = (float)PyInt_AsLong(item);
cVec.y = (double)PyInt_AsLong(item);
else
throw Base::TypeError("Not allowed type used in tuple (float expected)...");
// z
item = PyTuple_GetItem(value,2);
if (PyFloat_Check(item))
cVec.z = (float)PyFloat_AsDouble(item);
cVec.z = PyFloat_AsDouble(item);
else if (PyInt_Check(item))
cVec.z = (float)PyInt_AsLong(item);
cVec.z = (double)PyInt_AsLong(item);
else
throw Base::TypeError("Not allowed type used in tuple (float expected)...");
setValue( cVec );
@@ -154,9 +153,9 @@ void PropertyVector::Restore(Base::XMLReader &reader)
reader.readElement("PropertyVector");
// get the value of my Attribute
aboutToSetValue();
_cVec.x = (float)reader.getAttributeAsFloat("valueX");
_cVec.y = (float)reader.getAttributeAsFloat("valueY");
_cVec.z = (float)reader.getAttributeAsFloat("valueZ");
_cVec.x = reader.getAttributeAsFloat("valueX");
_cVec.y = reader.getAttributeAsFloat("valueY");
_cVec.z = reader.getAttributeAsFloat("valueZ");
hasSetValue();
}
@@ -208,7 +207,7 @@ int PropertyVectorList::getSize(void) const
return static_cast<int>(_lValueList.size());
}
void PropertyVectorList::setValue(const Base::Vector3f& lValue)
void PropertyVectorList::setValue(const Base::Vector3d& lValue)
{
aboutToSetValue();
_lValueList.resize(1);
@@ -216,7 +215,7 @@ void PropertyVectorList::setValue(const Base::Vector3f& lValue)
hasSetValue();
}
void PropertyVectorList::setValue(float x, float y, float z)
void PropertyVectorList::setValue(double x, double y, double z)
{
aboutToSetValue();
_lValueList.resize(1);
@@ -224,7 +223,7 @@ void PropertyVectorList::setValue(float x, float y, float z)
hasSetValue();
}
void PropertyVectorList::setValues(const std::vector<Base::Vector3f>& values)
void PropertyVectorList::setValues(const std::vector<Base::Vector3d>& values)
{
aboutToSetValue();
_lValueList = values;
@@ -245,7 +244,7 @@ void PropertyVectorList::setPyObject(PyObject *value)
{
if (PyList_Check(value)) {
Py_ssize_t nSize = PyList_Size(value);
std::vector<Base::Vector3f> values;
std::vector<Base::Vector3d> values;
values.resize(nSize);
for (Py_ssize_t i=0; i<nSize;++i) {
@@ -260,8 +259,7 @@ void PropertyVectorList::setPyObject(PyObject *value)
else if (PyObject_TypeCheck(value, &(VectorPy::Type))) {
Base::VectorPy *pcObject = static_cast<Base::VectorPy*>(value);
Base::Vector3d* val = pcObject->getVectorPtr();
Base::Vector3f vec((float)val->x,(float)val->y,(float)val->z);
setValue(vec);
setValue(*val);
}
else if (PyTuple_Check(value) && PyTuple_Size(value) == 3) {
PropertyVector val;
@@ -298,7 +296,7 @@ void PropertyVectorList::SaveDocFile (Base::Writer &writer) const
Base::OutputStream str(writer.Stream());
uint32_t uCt = (uint32_t)getSize();
str << uCt;
for (std::vector<Base::Vector3f>::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) {
for (std::vector<Base::Vector3d>::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) {
str << it->x << it->y << it->z;
}
}
@@ -308,8 +306,8 @@ void PropertyVectorList::RestoreDocFile(Base::Reader &reader)
Base::InputStream str(reader);
uint32_t uCt=0;
str >> uCt;
std::vector<Base::Vector3f> values(uCt);
for (std::vector<Base::Vector3f>::iterator it = values.begin(); it != values.end(); ++it) {
std::vector<Base::Vector3d> values(uCt);
for (std::vector<Base::Vector3d>::iterator it = values.begin(); it != values.end(); ++it) {
str >> it->x >> it->y >> it->z;
}
setValues(values);
@@ -331,7 +329,7 @@ void PropertyVectorList::Paste(const Property &from)
unsigned int PropertyVectorList::getMemSize (void) const
{
return static_cast<unsigned int>(_lValueList.size() * sizeof(Base::Vector3f));
return static_cast<unsigned int>(_lValueList.size() * sizeof(Base::Vector3d));
}
//**************************************************************************
@@ -425,25 +423,25 @@ void PropertyMatrix::Restore(Base::XMLReader &reader)
reader.readElement("PropertyMatrix");
// get the value of my Attribute
aboutToSetValue();
_cMat[0][0] = (float)reader.getAttributeAsFloat("a11");
_cMat[0][1] = (float)reader.getAttributeAsFloat("a12");
_cMat[0][2] = (float)reader.getAttributeAsFloat("a13");
_cMat[0][3] = (float)reader.getAttributeAsFloat("a14");
_cMat[0][0] = reader.getAttributeAsFloat("a11");
_cMat[0][1] = reader.getAttributeAsFloat("a12");
_cMat[0][2] = reader.getAttributeAsFloat("a13");
_cMat[0][3] = reader.getAttributeAsFloat("a14");
_cMat[1][0] = (float)reader.getAttributeAsFloat("a21");
_cMat[1][1] = (float)reader.getAttributeAsFloat("a22");
_cMat[1][2] = (float)reader.getAttributeAsFloat("a23");
_cMat[1][3] = (float)reader.getAttributeAsFloat("a24");
_cMat[1][0] = reader.getAttributeAsFloat("a21");
_cMat[1][1] = reader.getAttributeAsFloat("a22");
_cMat[1][2] = reader.getAttributeAsFloat("a23");
_cMat[1][3] = reader.getAttributeAsFloat("a24");
_cMat[2][0] = (float)reader.getAttributeAsFloat("a31");
_cMat[2][1] = (float)reader.getAttributeAsFloat("a32");
_cMat[2][2] = (float)reader.getAttributeAsFloat("a33");
_cMat[2][3] = (float)reader.getAttributeAsFloat("a34");
_cMat[2][0] = reader.getAttributeAsFloat("a31");
_cMat[2][1] = reader.getAttributeAsFloat("a32");
_cMat[2][2] = reader.getAttributeAsFloat("a33");
_cMat[2][3] = reader.getAttributeAsFloat("a34");
_cMat[3][0] = (float)reader.getAttributeAsFloat("a41");
_cMat[3][1] = (float)reader.getAttributeAsFloat("a42");
_cMat[3][2] = (float)reader.getAttributeAsFloat("a43");
_cMat[3][3] = (float)reader.getAttributeAsFloat("a44");
_cMat[3][0] = reader.getAttributeAsFloat("a41");
_cMat[3][1] = reader.getAttributeAsFloat("a42");
_cMat[3][2] = reader.getAttributeAsFloat("a43");
_cMat[3][3] = reader.getAttributeAsFloat("a44");
hasSetValue();
}

View File

@@ -72,12 +72,12 @@ public:
/** Sets the property
*/
void setValue(const Base::Vector3f &vec);
void setValue(float x, float y, float z);
void setValue(const Base::Vector3d &vec);
void setValue(double x, double y, double z);
/** This method returns a string representation of the property
*/
const Base::Vector3f &getValue(void) const;
const Base::Vector3d &getValue(void) const;
const char* getEditorName(void) const {
return "Gui::PropertyEditor::PropertyVectorItem";
}
@@ -92,11 +92,11 @@ public:
virtual void Paste(const Property &from);
virtual unsigned int getMemSize (void) const {
return sizeof(Base::Vector3f);
return sizeof(Base::Vector3d);
}
private:
Base::Vector3f _cVec;
Base::Vector3d _cVec;
};
@@ -122,21 +122,21 @@ public:
/** Sets the property
*/
void setValue(const Base::Vector3f&);
void setValue(float x, float y, float z);
void setValue(const Base::Vector3d&);
void setValue(double x, double y, double z);
/// index operator
const Base::Vector3f& operator[] (const int idx) const {
const Base::Vector3d& operator[] (const int idx) const {
return _lValueList.operator[] (idx);
}
void set1Value (const int idx, const Base::Vector3f& value) {
void set1Value (const int idx, const Base::Vector3d& value) {
_lValueList.operator[] (idx) = value;
}
void setValues (const std::vector<Base::Vector3f>& values);
void setValues (const std::vector<Base::Vector3d>& values);
const std::vector<Base::Vector3f> &getValues(void) const {
const std::vector<Base::Vector3d> &getValues(void) const {
return _lValueList;
}
@@ -155,7 +155,7 @@ public:
virtual unsigned int getMemSize (void) const;
private:
std::vector<Base::Vector3f> _lValueList;
std::vector<Base::Vector3d> _lValueList;
};
/** Vector properties

View File

@@ -896,14 +896,14 @@ PropertyFloat::~PropertyFloat()
//**************************************************************************
// Base class implementer
void PropertyFloat::setValue(float lValue)
void PropertyFloat::setValue(double lValue)
{
aboutToSetValue();
_dValue=lValue;
hasSetValue();
}
float PropertyFloat::getValue(void) const
double PropertyFloat::getValue(void) const
{
return _dValue;
}
@@ -917,12 +917,12 @@ void PropertyFloat::setPyObject(PyObject *value)
{
if (PyFloat_Check(value)) {
aboutToSetValue();
_dValue = (float) PyFloat_AsDouble(value);
_dValue = PyFloat_AsDouble(value);
hasSetValue();
}
else if(PyInt_Check(value)) {
aboutToSetValue();
_dValue = (float) PyInt_AsLong(value);
_dValue = PyInt_AsLong(value);
hasSetValue();
}
else {
@@ -942,7 +942,7 @@ void PropertyFloat::Restore(Base::XMLReader &reader)
// read my Element
reader.readElement("Float");
// get the value of my Attribute
setValue((float)reader.getAttributeAsFloat("value"));
setValue(reader.getAttributeAsFloat("value"));
}
Property *PropertyFloat::Copy(void) const
@@ -994,7 +994,7 @@ const PropertyFloatConstraint::Constraints* PropertyFloatConstraint::getConstra
void PropertyFloatConstraint::setPyObject(PyObject *value)
{
if (PyFloat_Check(value)) {
float temp = (float)PyFloat_AsDouble(value);
double temp = PyFloat_AsDouble(value);
if (_ConstStruct) {
if (temp > _ConstStruct->UpperBound)
temp = _ConstStruct->UpperBound;
@@ -1007,7 +1007,7 @@ void PropertyFloatConstraint::setPyObject(PyObject *value)
hasSetValue();
}
else if (PyInt_Check(value)) {
float temp = (float)PyInt_AsLong(value);
double temp = (double)PyInt_AsLong(value);
if (_ConstStruct) {
if (temp > _ConstStruct->UpperBound)
temp = _ConstStruct->UpperBound;
@@ -1060,7 +1060,7 @@ int PropertyFloatList::getSize(void) const
return static_cast<int>(_lValueList.size());
}
void PropertyFloatList::setValue(float lValue)
void PropertyFloatList::setValue(double lValue)
{
aboutToSetValue();
_lValueList.resize(1);
@@ -1068,7 +1068,7 @@ void PropertyFloatList::setValue(float lValue)
hasSetValue();
}
void PropertyFloatList::setValues(const std::vector<float>& values)
void PropertyFloatList::setValues(const std::vector<double>& values)
{
aboutToSetValue();
_lValueList = values;
@@ -1087,7 +1087,7 @@ void PropertyFloatList::setPyObject(PyObject *value)
{
if (PyList_Check(value)) {
Py_ssize_t nSize = PyList_Size(value);
std::vector<float> values;
std::vector<double> values;
values.resize(nSize);
for (Py_ssize_t i=0; i<nSize;++i) {
@@ -1098,13 +1098,13 @@ void PropertyFloatList::setPyObject(PyObject *value)
throw Base::TypeError(error);
}
values[i] = (float) PyFloat_AsDouble(item);
values[i] = PyFloat_AsDouble(item);
}
setValues(values);
}
else if (PyFloat_Check(value)) {
setValue((float) PyFloat_AsDouble(value));
setValue(PyFloat_AsDouble(value));
}
else {
std::string error = std::string("type must be float or list of float, not ");
@@ -1145,7 +1145,7 @@ void PropertyFloatList::SaveDocFile (Base::Writer &writer) const
Base::OutputStream str(writer.Stream());
uint32_t uCt = (uint32_t)getSize();
str << uCt;
for (std::vector<float>::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) {
for (std::vector<double>::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) {
str << *it;
}
}
@@ -1155,8 +1155,8 @@ void PropertyFloatList::RestoreDocFile(Base::Reader &reader)
Base::InputStream str(reader);
uint32_t uCt=0;
str >> uCt;
std::vector<float> values(uCt);
for (std::vector<float>::iterator it = values.begin(); it != values.end(); ++it) {
std::vector<double> values(uCt);
for (std::vector<double>::iterator it = values.begin(); it != values.end(); ++it) {
str >> *it;
}
setValues(values);
@@ -1178,7 +1178,7 @@ void PropertyFloatList::Paste(const Property &from)
unsigned int PropertyFloatList::getMemSize (void) const
{
return static_cast<unsigned int>(_lValueList.size() * sizeof(float));
return static_cast<unsigned int>(_lValueList.size() * sizeof(double));
}
//**************************************************************************

View File

@@ -427,8 +427,8 @@ public:
virtual ~PropertyFloat();
void setValue(float lValue);
float getValue(void) const;
void setValue(double lValue);
double getValue(void) const;
virtual const char* getEditorName(void) const { return "Gui::PropertyEditor::PropertyFloatItem"; }
@@ -441,10 +441,10 @@ public:
virtual Property *Copy(void) const;
virtual void Paste(const Property &from);
virtual unsigned int getMemSize (void) const{return sizeof(float);}
virtual unsigned int getMemSize (void) const{return sizeof(double);}
protected:
float _dValue;
double _dValue;
};
/** Constraint float properties
@@ -475,7 +475,7 @@ public:
//@{
/// the boundary struct
struct Constraints {
float LowerBound, UpperBound, StepSize;
double LowerBound, UpperBound, StepSize;
};
/** setting the boundaries
* This sets the constraint struct. It can be dynamcly
@@ -522,16 +522,16 @@ public:
/** Sets the property
*/
void setValue(float);
void setValue(double);
/// index operator
float operator[] (const int idx) const {return _lValueList.operator[] (idx);}
double operator[] (const int idx) const {return _lValueList.operator[] (idx);}
void set1Value (const int idx, float value){_lValueList.operator[] (idx) = value;}
void setValues (const std::vector<float>& values);
void set1Value (const int idx, double value){_lValueList.operator[] (idx) = value;}
void setValues (const std::vector<double>& values);
const std::vector<float> &getValues(void) const{return _lValueList;}
const std::vector<double> &getValues(void) const{return _lValueList;}
virtual PyObject *getPyObject(void);
virtual void setPyObject(PyObject *);
@@ -547,7 +547,7 @@ public:
virtual unsigned int getMemSize (void) const;
private:
std::vector<float> _lValueList;
std::vector<double> _lValueList;
};

View File

@@ -116,12 +116,12 @@ void PropertyLength::setPyObject(PyObject *value)
setValue(UnitsApi::toDblWithUserPrefs(Length,value));
#else
float val=0.0f;
double val=0.0f;
if (PyFloat_Check(value)) {
val = (float) PyFloat_AsDouble(value);
val = PyFloat_AsDouble(value);
}
else if(PyInt_Check(value)) {
val = (float) PyInt_AsLong(value);
val = (double) PyInt_AsLong(value);
}
else {
std::string error = std::string("type must be float or int, not ");

View File

@@ -457,6 +457,133 @@ bool Matrix4D::toAxisAngle (Vector3f& rclBase, Vector3f& rclDir, float& rfAngle,
return true;
}
bool Matrix4D::toAxisAngle (Vector3d& rclBase, Vector3d& rclDir, double& rfAngle, double& fTranslation) const
{
// First check if the 3x3 submatrix is orthogonal
for ( int i=0; i<3; i++ ) {
// length must be one
if ( fabs(dMtrx4D[0][i]*dMtrx4D[0][i]+dMtrx4D[1][i]*dMtrx4D[1][i]+dMtrx4D[2][i]*dMtrx4D[2][i]-1.0) > 0.01 )
return false;
// scalar product with other rows must be zero
if ( fabs(dMtrx4D[0][i]*dMtrx4D[0][(i+1)%3]+dMtrx4D[1][i]*dMtrx4D[1][(i+1)%3]+dMtrx4D[2][i]*dMtrx4D[2][(i+1)%3]) > 0.01 )
return false;
}
// Okay, the 3x3 matrix is orthogonal.
// Note: The section to get the rotation axis and angle was taken from WildMagic Library.
//
// Let (x,y,z) be the unit-length axis and let A be an angle of rotation.
// The rotation matrix is R = I + sin(A)*P + (1-cos(A))*P^2 where
// I is the identity and
//
// +- -+
// P = | 0 -z +y |
// | +z 0 -x |
// | -y +x 0 |
// +- -+
//
// If A > 0, R represents a counterclockwise rotation about the axis in
// the sense of looking from the tip of the axis vector towards the
// origin. Some algebra will show that
//
// cos(A) = (trace(R)-1)/2 and R - R^t = 2*sin(A)*P
//
// In the event that A = pi, R-R^t = 0 which prevents us from extracting
// the axis through P. Instead note that R = I+2*P^2 when A = pi, so
// P^2 = (R-I)/2. The diagonal entries of P^2 are x^2-1, y^2-1, and
// z^2-1. We can solve these for axis (x,y,z). Because the angle is pi,
// it does not matter which sign you choose on the square roots.
//
// For more details see also http://www.math.niu.edu/~rusin/known-math/97/rotations
double fTrace = dMtrx4D[0][0] + dMtrx4D[1][1] + dMtrx4D[2][2];
double fCos = 0.5*(fTrace-1.0);
rfAngle = acos(fCos); // in [0,PI]
if ( rfAngle > 0.0f )
{
if ( rfAngle < F_PI )
{
rclDir.x = (dMtrx4D[2][1]-dMtrx4D[1][2]);
rclDir.y = (dMtrx4D[0][2]-dMtrx4D[2][0]);
rclDir.z = (dMtrx4D[1][0]-dMtrx4D[0][1]);
rclDir.Normalize();
}
else
{
// angle is PI
double fHalfInverse;
if ( dMtrx4D[0][0] >= dMtrx4D[1][1] )
{
// r00 >= r11
if ( dMtrx4D[0][0] >= dMtrx4D[2][2] )
{
// r00 is maximum diagonal term
rclDir.x = (0.5*sqrt(dMtrx4D[0][0] - dMtrx4D[1][1] - dMtrx4D[2][2] + 1.0));
fHalfInverse = 0.5/rclDir.x;
rclDir.y = (fHalfInverse*dMtrx4D[0][1]);
rclDir.z = (fHalfInverse*dMtrx4D[0][2]);
}
else
{
// r22 is maximum diagonal term
rclDir.z = (0.5*sqrt(dMtrx4D[2][2] - dMtrx4D[0][0] - dMtrx4D[1][1] + 1.0));
fHalfInverse = 0.5/rclDir.z;
rclDir.x = (fHalfInverse*dMtrx4D[0][2]);
rclDir.y = (fHalfInverse*dMtrx4D[1][2]);
}
}
else
{
// r11 > r00
if ( dMtrx4D[1][1] >= dMtrx4D[2][2] )
{
// r11 is maximum diagonal term
rclDir.y = (0.5*sqrt(dMtrx4D[1][1] - dMtrx4D[0][0] - dMtrx4D[2][2] + 1.0));
fHalfInverse = 0.5/rclDir.y;
rclDir.x = (fHalfInverse*dMtrx4D[0][1]);
rclDir.z = (fHalfInverse*dMtrx4D[1][2]);
}
else
{
// r22 is maximum diagonal term
rclDir.z = (0.5*sqrt(dMtrx4D[2][2] - dMtrx4D[0][0] - dMtrx4D[1][1] + 1.0));
fHalfInverse = 0.5/rclDir.z;
rclDir.x = (fHalfInverse*dMtrx4D[0][2]);
rclDir.y = (fHalfInverse*dMtrx4D[1][2]);
}
}
}
}
else
{
// The angle is 0 and the matrix is the identity. Any axis will
// work, so just use the x-axis.
rclDir.x = 1.0;
rclDir.y = 0.0;
rclDir.z = 0.0;
rclBase.x = 0.0;
rclBase.y = 0.0;
rclBase.z = 0.0;
}
// This is the translation part in axis direction
fTranslation = (dMtrx4D[0][3]*rclDir.x+dMtrx4D[1][3]*rclDir.y+dMtrx4D[2][3]*rclDir.z);
Vector3d cPnt(dMtrx4D[0][3],dMtrx4D[1][3],dMtrx4D[2][3]);
cPnt = cPnt - fTranslation * rclDir;
// This is the base point of the rotation axis
if ( rfAngle > 0.0f )
{
double factor = 0.5*(1.0+fTrace)/sin(rfAngle);
rclBase.x = (0.5*(cPnt.x+factor*(rclDir.y*cPnt.z-rclDir.z*cPnt.y)));
rclBase.y = (0.5*(cPnt.y+factor*(rclDir.z*cPnt.x-rclDir.x*cPnt.z)));
rclBase.z = (0.5*(cPnt.z+factor*(rclDir.x*cPnt.y-rclDir.y*cPnt.x)));
}
return true;
}
void Matrix4D::transform (const Vector3f& rclVct, const Matrix4D& rclMtrx)
{
move(-rclVct);

View File

@@ -110,12 +110,16 @@ public:
/// moves the coordinatesystem for the x,y,z value
void move (float x, float y, float z)
{ move(Vector3f(x,y,z)); }
void move (double x, double y, double z)
{ move(Vector3d(x,y,z)); }
/// moves the coordinatesystem for the vector
void move (const Vector3f& rclVct);
void move (const Vector3d& rclVct);
/// scale for the vector
void scale (float x, float y, float z)
{ scale(Vector3f(x,y,z)); }
void scale (double x, double y, double z)
{ scale(Vector3d(x,y,z)); }
/// scale for the x,y,z value
void scale (const Vector3f& rclVct);
void scale (const Vector3d& rclVct);
@@ -133,6 +137,7 @@ public:
void rotLine (const Vector3d& rclBase, const Vector3d& rclDir, double fAngle);
/// Extract the rotation axis and angle. Therefore the 3x3 submatrix must be orthogonal.
bool toAxisAngle (Vector3f& rclBase, Vector3f& rclDir, float& fAngle, float& fTranslation) const;
bool toAxisAngle (Vector3d& rclBase, Vector3d& rclDir, double& fAngle, double& fTranslation) const;
/// transform (move,scale,rotate) around a point
void transform (const Vector3f& rclVct, const Matrix4D& rclMtrx);
void transform (const Vector3d& rclVct, const Matrix4D& rclMtrx);

View File

@@ -75,9 +75,9 @@ public:
* // 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");
* _cVec.x = reader.getAttributeAsFloat("valueX");
* _cVec.y = reader.getAttributeAsFloat("valueY");
* _cVec.z = reader.getAttributeAsFloat("valueZ");
* }
* \endcode
*/

View File

@@ -23,7 +23,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
#ifndef _PreComp_
# include <cstdlib>
# include <set>
#endif
@@ -33,22 +33,22 @@
using namespace Base;
float Vector2D::GetAngle (const Vector2D &rclVect) const
double Vector2D::GetAngle (const Vector2D &rclVect) const
{
float fDivid, fNum;
double fDivid, fNum;
fDivid = Length() * rclVect.Length();
if ((fDivid < -1e-10f) || (fDivid > 1e-10f))
if ((fDivid < -1e-10) || (fDivid > 1e-10))
{
fNum = (*this * rclVect) / fDivid;
if (fNum < -1)
return F_PI;
else
if (fNum > 1)
return 0.0F;
return 0.0;
else
return float(acos(fNum));
return acos(fNum);
}
else
return -FLOAT_MAX; // division by zero
@@ -56,8 +56,8 @@ float Vector2D::GetAngle (const Vector2D &rclVect) const
void Vector2D::ProjToLine (const Vector2D &rclPt, const Vector2D &rclLine)
{
float l = rclLine.Length();
float t1 = (rclPt * rclLine) / l;
double l = rclLine.Length();
double t1 = (rclPt * rclLine) / l;
Vector2D clNormal = rclLine;
clNormal.Normalize();
clNormal.Scale(t1);
@@ -178,16 +178,16 @@ bool BoundBox2D::Contains (const Vector2D &rclV) const
BoundBox2D Line2D::CalcBoundBox (void) const
{
BoundBox2D clBB;
clBB.fMinX = std::min<float> (clV1.fX, clV2.fX);
clBB.fMinY = std::min<float> (clV1.fY, clV2.fY);
clBB.fMaxX = std::max<float> (clV1.fX, clV2.fX);
clBB.fMaxY = std::max<float> (clV1.fY, clV2.fY);
clBB.fMinX = std::min<double> (clV1.fX, clV2.fX);
clBB.fMinY = std::min<double> (clV1.fY, clV2.fY);
clBB.fMaxX = std::max<double> (clV1.fX, clV2.fX);
clBB.fMaxY = std::max<double> (clV1.fY, clV2.fY);
return clBB;
}
bool Line2D::Intersect (const Line2D& rclLine, Vector2D &rclV) const
{
float m1, m2, b1, b2;
double m1, m2, b1, b2;
// calc coefficients
if (fabs (clV2.fX - clV1.fX) > 1e-10)
@@ -225,7 +225,7 @@ bool Line2D::Intersect (const Line2D& rclLine, Vector2D &rclV) const
return true; /*** RETURN TRUE (intersection) **********/
}
Vector2D Line2D::FromPos (float fDistance) const
Vector2D Line2D::FromPos (double fDistance) const
{
Vector2D clDir(clV2 - clV1);
clDir.Normalize();
@@ -249,18 +249,18 @@ BoundBox2D Polygon2D::CalcBoundBox (void) const
BoundBox2D clBB;
for (i = 0; i < _aclVct.size(); i++)
{
clBB.fMinX = std::min<float> (clBB.fMinX, _aclVct[i].fX);
clBB.fMinY = std::min<float> (clBB.fMinY, _aclVct[i].fY);
clBB.fMaxX = std::max<float> (clBB.fMaxX, _aclVct[i].fX);
clBB.fMaxY = std::max<float> (clBB.fMaxY, _aclVct[i].fY);
clBB.fMinX = std::min<double> (clBB.fMinX, _aclVct[i].fX);
clBB.fMinY = std::min<double> (clBB.fMinY, _aclVct[i].fY);
clBB.fMaxX = std::max<double> (clBB.fMaxX, _aclVct[i].fX);
clBB.fMaxY = std::max<double> (clBB.fMaxY, _aclVct[i].fY);
}
return clBB;
}
static short _CalcTorsion (float *pfLine, float fX, float fY)
static short _CalcTorsion (double *pfLine, double fX, double fY)
{
short sQuad[2], i;
float fResX;
double fResX;
// Klassifizierung der beiden Polygonpunkte in Quadranten
for (i = 0; i < 2; i++)
@@ -297,7 +297,7 @@ bool Polygon2D::Contains (const Vector2D &rclV) const
// Ermittelt mit dem Verfahren der Windungszahl, ob ein Punkt innerhalb
// eines Polygonzugs enthalten ist.
// Summe aller Windungszahlen gibt an, ob ja oder nein.
float pfTmp[4];
double pfTmp[4];
unsigned long i;
short sTorsion = 0;
@@ -358,7 +358,7 @@ void Polygon2D::Intersect (const Polygon2D &rclPolygon, std::list<Polygon2D> &rc
Line2D clLine(clPt0, clPt1);
// try to intersect with each line of the trim-polygon
std::set<float> afIntersections; // set of intersections (sorted by line parameter)
std::set<double> afIntersections; // set of intersections (sorted by line parameter)
Vector2D clTrimPt2; // second line point
for (size_t i = 0; i < ulTrimCt; i++)
{
@@ -369,14 +369,14 @@ void Polygon2D::Intersect (const Polygon2D &rclPolygon, std::list<Polygon2D> &rc
if (clLine.IntersectAndContain(clToTrimLine, clV) == true)
{
// save line parameter of intersection point
float fDist = (clV - clPt0).Length();
double fDist = (clV - clPt0).Length();
afIntersections.insert(fDist);
}
}
if (afIntersections.size() > 0) // intersections founded
{
for (std::set<float>::iterator pF = afIntersections.begin(); pF != afIntersections.end(); pF++)
for (std::set<double>::iterator pF = afIntersections.begin(); pF != afIntersections.end(); pF++)
{
// intersection point
Vector2D clPtIS = clLine.FromPos(*pF);

View File

@@ -45,7 +45,7 @@ class Polygon2D;
class BaseExport Vector2D
{
public:
float fX, fY;
double fX, fY;
inline Vector2D (void);
inline Vector2D (float x, float y);
@@ -53,19 +53,19 @@ public:
inline Vector2D (const Vector2D &rclVct);
// methods
inline float Length (void) const;
inline double Length (void) const;
// operators
inline Vector2D& operator= (const Vector2D &rclVct);
inline float operator* (const Vector2D &rclVct) const;
inline double operator* (const Vector2D &rclVct) const;
inline bool operator== (const Vector2D &rclVct) const;
inline Vector2D operator+ (const Vector2D &rclVct) const;
inline Vector2D operator- (const Vector2D &rclVct) const;
inline void Set (float fPX, float fPY);
inline void Scale (float fS);
inline void Set (double fPX, double fPY);
inline void Scale (double fS);
inline void Normalize (void);
float GetAngle (const Vector2D &rclVect) const;
double GetAngle (const Vector2D &rclVect) const;
void ProjToLine (const Vector2D &rclPt, const Vector2D &rclLine);
};
@@ -77,11 +77,11 @@ public:
class BaseExport BoundBox2D
{
public:
float fMinX, fMinY, fMaxX, fMaxY;
double fMinX, fMinY, fMaxX, fMaxY;
inline BoundBox2D (void);
inline BoundBox2D (const BoundBox2D &rclBB);
inline BoundBox2D (float fX1, float fY1, float fX2, float fY2);
inline BoundBox2D (double fX1, double fY1, double fX2, double fY2);
inline bool IsValid (void);
// operators
@@ -92,7 +92,7 @@ public:
bool operator|| (const Polygon2D &rclPoly) const;
inline void operator &= (const Vector2D &rclVct);
void SetVoid (void) { fMinX = fMinY = FLOAT_MAX; fMaxX = fMaxY = -FLOAT_MAX; }
void SetVoid (void) { fMinX = fMinY = DOUBLE_MAX; fMaxX = fMaxY = -DOUBLE_MAX; }
// misc
bool Contains (const Vector2D &rclV) const;
@@ -113,7 +113,7 @@ public:
inline Line2D (const Vector2D &rclV1, const Vector2D &rclV2);
// methods
inline float Length (void) const;
inline double Length (void) const;
BoundBox2D CalcBoundBox (void) const;
// operators
@@ -124,7 +124,7 @@ public:
inline bool Contains (const Vector2D &rclV) const;
bool Intersect (const Line2D& rclLine, Vector2D &rclV) const;
bool IntersectAndContain (const Line2D& rclLine, Vector2D &rclV) const;
Vector2D FromPos (float fDistance) const;
Vector2D FromPos (double fDistance) const;
};
/** Polygon2D ********************************************/
@@ -162,14 +162,14 @@ private:
inline void BoundBox2D::operator &= (const Vector2D &rclVct)
{
fMinX = std::min<float>(fMinX, rclVct.fX);
fMinY = std::min<float>(fMinY, rclVct.fY);
fMaxX = std::max<float>(fMaxX, rclVct.fX);
fMaxY = std::max<float>(fMaxY, rclVct.fY);
fMinX = std::min<double>(fMinX, rclVct.fX);
fMinY = std::min<double>(fMinY, rclVct.fY);
fMaxX = std::max<double>(fMaxX, rclVct.fX);
fMaxY = std::max<double>(fMaxY, rclVct.fY);
}
inline Vector2D::Vector2D (void)
: fX(0.0f), fY(0.0f)
: fX(0.0), fY(0.0)
{
}
@@ -179,8 +179,8 @@ inline Vector2D::Vector2D (float x, float y)
}
inline Vector2D::Vector2D (double x, double y)
: fX(float(x)),
fY(float(y))
: fX(x),
fY(y)
{
}
@@ -189,9 +189,9 @@ inline Vector2D::Vector2D (const Vector2D &rclVct)
{
}
inline float Vector2D::Length (void) const
inline double Vector2D::Length (void) const
{
return (float)sqrt ((fX * fX) + (fY * fY));
return sqrt ((fX * fX) + (fY * fY));
}
inline Vector2D& Vector2D::operator= (const Vector2D &rclVct)
@@ -216,12 +216,12 @@ inline Vector2D Vector2D::operator- (const Vector2D &rclVct) const
return Vector2D(fX - rclVct.fX, fY - rclVct.fY);
}
inline float Vector2D::operator* (const Vector2D &rclVct) const
inline double Vector2D::operator* (const Vector2D &rclVct) const
{
return (fX * rclVct.fX) + (fY * rclVct.fY);
}
inline void Vector2D::Scale (float fS)
inline void Vector2D::Scale (double fS)
{
fX *= fS;
fY *= fS;
@@ -229,7 +229,7 @@ inline void Vector2D::Scale (float fS)
inline void Vector2D::Normalize (void)
{
float fLen = Length();
double fLen = Length();
if (fLen != 0.0f)
{
fX /= fLen;
@@ -237,7 +237,7 @@ inline void Vector2D::Normalize (void)
}
}
inline void Vector2D::Set (float fPX, float fPY)
inline void Vector2D::Set (double fPX, double fPY)
{
fX = fPX;
fY = fPY;
@@ -304,7 +304,7 @@ inline Line2D::Line2D (const Vector2D &rclV1, const Vector2D &rclV2)
{
}
inline float Line2D::Length (void) const
inline double Line2D::Length (void) const
{
return (clV2 - clV1).Length ();
}
@@ -328,8 +328,8 @@ inline bool Line2D::Contains (const Vector2D &rclV) const
inline BoundBox2D::BoundBox2D (void)
{
fMinX = fMinY = FLOAT_MAX;
fMaxX = fMaxY = - FLOAT_MAX;
fMinX = fMinY = DOUBLE_MAX;
fMaxX = fMaxY = - DOUBLE_MAX;
}
inline BoundBox2D::BoundBox2D (const BoundBox2D &rclBB)
@@ -340,12 +340,12 @@ inline BoundBox2D::BoundBox2D (const BoundBox2D &rclBB)
{
}
inline BoundBox2D::BoundBox2D (float fX1, float fY1, float fX2, float fY2)
inline BoundBox2D::BoundBox2D (double fX1, double fY1, double fX2, double fY2)
{
fMinX = std::min<float>( fX1, fX2 );
fMaxX = std::max<float>( fX1, fX2 );
fMinY = std::min<float>( fY1, fY2 );
fMaxY = std::max<float>( fY1, fY2 );
fMinX = std::min<double>( fX1, fX2 );
fMaxX = std::max<double>( fX1, fX2 );
fMinY = std::min<double>( fY1, fY2 );
fMaxY = std::max<double>( fY1, fY2 );
}
inline bool BoundBox2D::IsValid (void)

View File

@@ -30,7 +30,7 @@
#include "DlgDisplayPropertiesImp.h"
#include "DlgMaterialPropertiesImp.h"
#include "DockWindowManager.h"
#include "DockWindowManager.h"
#include "View3DInventorViewer.h"
#include "View3DInventor.h"
#include "Command.h"
@@ -84,14 +84,14 @@ DlgDisplayPropertiesImp::DlgDisplayPropertiesImp( QWidget* parent, Qt::WFlags fl
setLineWidth(views);
setTransparency(views);
setLineTransparency(views);
// embed this dialog into a dockable widget container
Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance();
QDockWidget* dw = pDockMgr->addDockWindow("Display properties", this, Qt::AllDockWidgetAreas);
dw->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable);
dw->setAllowedAreas(Qt::DockWidgetAreas());
dw->setFloating(true);
dw->show();
// embed this dialog into a dockable widget container
Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance();
QDockWidget* dw = pDockMgr->addDockWindow("Display properties", this, Qt::AllDockWidgetAreas);
dw->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable);
dw->setAllowedAreas(Qt::DockWidgetAreas());
dw->setFloating(true);
dw->show();
Gui::Selection().Attach(this);
@@ -189,7 +189,7 @@ void DlgDisplayPropertiesImp::slotChangedObject(const Gui::ViewProvider& obj,
}
}
else if (prop.getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
float value = static_cast<const App::PropertyFloat&>(prop).getValue();
double value = static_cast<const App::PropertyFloat&>(prop).getValue();
if (prop_name == "PointSize") {
bool blocked = spinPointSize->blockSignals(true);
spinPointSize->setValue((int)value);
@@ -203,17 +203,17 @@ void DlgDisplayPropertiesImp::slotChangedObject(const Gui::ViewProvider& obj,
}
}
}
/**
* Destroys the dock window this object is embedded into without destroying itself.
*/
void DlgDisplayPropertiesImp::reject()
{
// closes the dock window
Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance();
pDockMgr->removeDockWindow(this);
QDialog::reject();
}
/**
* Destroys the dock window this object is embedded into without destroying itself.
*/
void DlgDisplayPropertiesImp::reject()
{
// closes the dock window
Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance();
pDockMgr->removeDockWindow(this);
QDialog::reject();
}
/**
* Opens a dialog that allows to modify the 'ShapeMaterial' property of all selected view providers.
@@ -325,7 +325,7 @@ void DlgDisplayPropertiesImp::on_spinPointSize_valueChanged(int pointsize)
App::Property* prop = (*It)->getPropertyByName("PointSize");
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
App::PropertyFloat* PointSize = (App::PropertyFloat*)prop;
PointSize->setValue((float)pointsize);
PointSize->setValue((double)pointsize);
}
}
}
@@ -340,7 +340,7 @@ void DlgDisplayPropertiesImp::on_spinLineWidth_valueChanged(int linewidth)
App::Property* prop = (*It)->getPropertyByName("LineWidth");
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
App::PropertyFloat* LineWidth = (App::PropertyFloat*)prop;
LineWidth->setValue((float)linewidth);
LineWidth->setValue((double)linewidth);
}
}
}
@@ -373,75 +373,75 @@ void DlgDisplayPropertiesImp::on_spinLineTransparency_valueChanged(int transpare
void DlgDisplayPropertiesImp::setDisplayModes(const std::vector<Gui::ViewProvider*>& views)
{
QStringList commonModes, modes;
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
App::Property* prop = (*it)->getPropertyByName("DisplayMode");
QStringList commonModes, modes;
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
App::Property* prop = (*it)->getPropertyByName("DisplayMode");
if (prop && prop->getTypeId() == App::PropertyEnumeration::getClassTypeId()) {
App::PropertyEnumeration* display = static_cast<App::PropertyEnumeration*>(prop);
if (!display->getEnums()) return;
const std::vector<std::string>& value = display->getEnumVector();
if (it == views.begin()) {
for (std::vector<std::string>::const_iterator jt = value.begin(); jt != value.end(); ++jt)
commonModes << QLatin1String(jt->c_str());
}
else {
for (std::vector<std::string>::const_iterator jt = value.begin(); jt != value.end(); ++jt) {
if (commonModes.contains(QLatin1String(jt->c_str())))
modes << QLatin1String(jt->c_str());
}
commonModes = modes;
modes.clear();
}
}
}
changeMode->clear();
changeMode->addItems(commonModes);
changeMode->setDisabled(commonModes.isEmpty());
// find the display mode to activate
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
App::Property* prop = (*it)->getPropertyByName("DisplayMode");
App::PropertyEnumeration* display = static_cast<App::PropertyEnumeration*>(prop);
if (!display->getEnums()) return;
const std::vector<std::string>& value = display->getEnumVector();
if (it == views.begin()) {
for (std::vector<std::string>::const_iterator jt = value.begin(); jt != value.end(); ++jt)
commonModes << QLatin1String(jt->c_str());
}
else {
for (std::vector<std::string>::const_iterator jt = value.begin(); jt != value.end(); ++jt) {
if (commonModes.contains(QLatin1String(jt->c_str())))
modes << QLatin1String(jt->c_str());
}
commonModes = modes;
modes.clear();
}
}
}
changeMode->clear();
changeMode->addItems(commonModes);
changeMode->setDisabled(commonModes.isEmpty());
// find the display mode to activate
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
App::Property* prop = (*it)->getPropertyByName("DisplayMode");
if (prop && prop->getTypeId() == App::PropertyEnumeration::getClassTypeId()) {
App::PropertyEnumeration* display = static_cast<App::PropertyEnumeration*>(prop);
QString activeMode = QString::fromAscii(display->getValueAsString());
int index = changeMode->findText(activeMode);
if (index != -1) {
changeMode->setCurrentIndex(index);
break;
}
}
}
App::PropertyEnumeration* display = static_cast<App::PropertyEnumeration*>(prop);
QString activeMode = QString::fromAscii(display->getValueAsString());
int index = changeMode->findText(activeMode);
if (index != -1) {
changeMode->setCurrentIndex(index);
break;
}
}
}
}
void DlgDisplayPropertiesImp::setMaterial(const std::vector<Gui::ViewProvider*>& views)
{
bool material = false;
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
App::Property* prop = (*it)->getPropertyByName("ShapeMaterial");
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
App::Property* prop = (*it)->getPropertyByName("ShapeMaterial");
if (prop && prop->getTypeId() == App::PropertyMaterial::getClassTypeId()) {
material = true;
break;
}
}
changeMaterial->setEnabled(material);
buttonUserDefinedMaterial->setEnabled(material);
}
changeMaterial->setEnabled(material);
buttonUserDefinedMaterial->setEnabled(material);
}
void DlgDisplayPropertiesImp::setColorPlot(const std::vector<Gui::ViewProvider*>& views)
{
bool material = false;
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
App::Property* prop = (*it)->getPropertyByName("TextureMaterial");
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
App::Property* prop = (*it)->getPropertyByName("TextureMaterial");
if (prop && prop->getTypeId() == App::PropertyMaterial::getClassTypeId()) {
material = true;
break;
}
}
buttonColorPlot->setEnabled(material);
}
buttonColorPlot->setEnabled(material);
}
void DlgDisplayPropertiesImp::fillupMaterials()
@@ -478,8 +478,8 @@ void DlgDisplayPropertiesImp::fillupMaterials()
void DlgDisplayPropertiesImp::setShapeColor(const std::vector<Gui::ViewProvider*>& views)
{
bool shapeColor = false;
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
App::Property* prop = (*it)->getPropertyByName("ShapeColor");
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
App::Property* prop = (*it)->getPropertyByName("ShapeColor");
if (prop && prop->getTypeId() == App::PropertyColor::getClassTypeId()) {
App::Color c = static_cast<App::PropertyColor*>(prop)->getValue();
QColor shape;
@@ -490,9 +490,9 @@ void DlgDisplayPropertiesImp::setShapeColor(const std::vector<Gui::ViewProvider*
shapeColor = true;
break;
}
}
buttonColor->setEnabled(shapeColor);
}
buttonColor->setEnabled(shapeColor);
}
void DlgDisplayPropertiesImp::setLineColor(const std::vector<Gui::ViewProvider*>& views)
@@ -518,8 +518,8 @@ void DlgDisplayPropertiesImp::setLineColor(const std::vector<Gui::ViewProvider*>
void DlgDisplayPropertiesImp::setPointSize(const std::vector<Gui::ViewProvider*>& views)
{
bool pointSize = false;
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
App::Property* prop = (*it)->getPropertyByName("PointSize");
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
App::Property* prop = (*it)->getPropertyByName("PointSize");
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
bool blocked = spinPointSize->blockSignals(true);
spinPointSize->setValue((int)static_cast<App::PropertyFloat*>(prop)->getValue());
@@ -527,16 +527,16 @@ void DlgDisplayPropertiesImp::setPointSize(const std::vector<Gui::ViewProvider*>
pointSize = true;
break;
}
}
spinPointSize->setEnabled(pointSize);
}
spinPointSize->setEnabled(pointSize);
}
void DlgDisplayPropertiesImp::setLineWidth(const std::vector<Gui::ViewProvider*>& views)
{
bool lineWidth = false;
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
App::Property* prop = (*it)->getPropertyByName("LineWidth");
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
App::Property* prop = (*it)->getPropertyByName("LineWidth");
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyFloat::getClassTypeId())) {
bool blocked = spinLineWidth->blockSignals(true);
spinLineWidth->setValue((int)static_cast<App::PropertyFloat*>(prop)->getValue());
@@ -544,16 +544,16 @@ void DlgDisplayPropertiesImp::setLineWidth(const std::vector<Gui::ViewProvider*>
lineWidth = true;
break;
}
}
spinLineWidth->setEnabled(lineWidth);
}
spinLineWidth->setEnabled(lineWidth);
}
void DlgDisplayPropertiesImp::setTransparency(const std::vector<Gui::ViewProvider*>& views)
{
bool transparency = false;
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
App::Property* prop = (*it)->getPropertyByName("Transparency");
for (std::vector<Gui::ViewProvider*>::const_iterator it = views.begin(); it != views.end(); ++it) {
App::Property* prop = (*it)->getPropertyByName("Transparency");
if (prop && prop->getTypeId().isDerivedFrom(App::PropertyInteger::getClassTypeId())) {
bool blocked = spinTransparency->blockSignals(true);
spinTransparency->setValue(static_cast<App::PropertyInteger*>(prop)->getValue());
@@ -565,10 +565,10 @@ void DlgDisplayPropertiesImp::setTransparency(const std::vector<Gui::ViewProvide
transparency = true;
break;
}
}
spinTransparency->setEnabled(transparency);
horizontalSlider->setEnabled(transparency);
}
spinTransparency->setEnabled(transparency);
horizontalSlider->setEnabled(transparency);
}
void DlgDisplayPropertiesImp::setLineTransparency(const std::vector<Gui::ViewProvider*>& views)

View File

@@ -225,7 +225,7 @@ void ViewProviderAnnotation::updateData(const App::Property* prop)
}
else if (prop->getTypeId() == App::PropertyVector::getClassTypeId() &&
strcmp(prop->getName(),"Position") == 0) {
Base::Vector3f v = static_cast<const App::PropertyVector*>(prop)->getValue();
Base::Vector3d v = static_cast<const App::PropertyVector*>(prop)->getValue();
pTranslation->translation.setValue(v.x,v.y,v.z);
}
@@ -348,12 +348,12 @@ void ViewProviderAnnotationLabel::updateData(const App::Property* prop)
}
else if (prop->getTypeId() == App::PropertyVector::getClassTypeId() &&
strcmp(prop->getName(),"BasePosition") == 0) {
Base::Vector3f v = static_cast<const App::PropertyVector*>(prop)->getValue();
Base::Vector3d v = static_cast<const App::PropertyVector*>(prop)->getValue();
pBaseTranslation->translation.setValue(v.x,v.y,v.z);
}
else if (prop->getTypeId() == App::PropertyVector::getClassTypeId() &&
strcmp(prop->getName(),"TextPosition") == 0) {
Base::Vector3f v = static_cast<const App::PropertyVector*>(prop)->getValue();
Base::Vector3d v = static_cast<const App::PropertyVector*>(prop)->getValue();
pCoords->point.set1Value(1, SbVec3f(v.x,v.y,v.z));
pTextTranslation->translation.setValue(v.x,v.y,v.z);
}

View File

@@ -196,11 +196,11 @@ void ViewProviderMeasureDistance::updateData(const App::Property* prop)
if (prop->getTypeId() == App::PropertyVector::getClassTypeId() ||
prop == &Mirror || prop == &DistFactor) {
if (strcmp(prop->getName(),"P1") == 0) {
Base::Vector3f v = static_cast<const App::PropertyVector*>(prop)->getValue();
Base::Vector3d v = static_cast<const App::PropertyVector*>(prop)->getValue();
pCoords->point.set1Value(0, SbVec3f(v.x,v.y,v.z));
}
else if (strcmp(prop->getName(),"P2") == 0) {
Base::Vector3f v = static_cast<const App::PropertyVector*>(prop)->getValue();
Base::Vector3d v = static_cast<const App::PropertyVector*>(prop)->getValue();
pCoords->point.set1Value(1, SbVec3f(v.x,v.y,v.z));
}
@@ -278,8 +278,8 @@ void PointMarker::customEvent(QEvent* e)
App::MeasureDistance* md = static_cast<App::MeasureDistance*>(obj);
const SbVec3f& pt1 = vp->pCoords->point[0];
const SbVec3f& pt2 = vp->pCoords->point[1];
md->P1.setValue(Base::Vector3f(pt1[0],pt1[1],pt1[2]));
md->P2.setValue(Base::Vector3f(pt2[0],pt2[1],pt2[2]));
md->P1.setValue(Base::Vector3d(pt1[0],pt1[1],pt1[2]));
md->P2.setValue(Base::Vector3d(pt2[0],pt2[1],pt2[2]));
std::stringstream s;
s.precision(3);
s.setf(std::ios::fixed | std::ios::showpoint);

View File

@@ -877,15 +877,15 @@ QVariant PropertyVectorItem::value(const App::Property* prop) const
{
assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyVector::getClassTypeId()));
const Base::Vector3f& value = static_cast<const App::PropertyVector*>(prop)->getValue();
return QVariant::fromValue<Base::Vector3f>(value);
const Base::Vector3d& value = static_cast<const App::PropertyVector*>(prop)->getValue();
return QVariant::fromValue<Base::Vector3d>(value);
}
void PropertyVectorItem::setValue(const QVariant& value)
{
if (!value.canConvert<Base::Vector3f>())
if (!value.canConvert<Base::Vector3d>())
return;
const Base::Vector3f& val = value.value<Base::Vector3f>();
const Base::Vector3d& val = value.value<Base::Vector3d>();
QString data = QString::fromAscii("(%1, %2, %3)")
.arg(val.x,0,'f',decimals())
.arg(val.y,0,'f',decimals())
@@ -920,32 +920,32 @@ QVariant PropertyVectorItem::editorData(QWidget *editor) const
double PropertyVectorItem::x() const
{
return data(1,Qt::EditRole).value<Base::Vector3f>().x;
return data(1,Qt::EditRole).value<Base::Vector3d>().x;
}
void PropertyVectorItem::setX(double x)
{
setData(QVariant::fromValue(Base::Vector3f(x, y(), z())));
setData(QVariant::fromValue(Base::Vector3d(x, y(), z())));
}
double PropertyVectorItem::y() const
{
return data(1,Qt::EditRole).value<Base::Vector3f>().y;
return data(1,Qt::EditRole).value<Base::Vector3d>().y;
}
void PropertyVectorItem::setY(double y)
{
setData(QVariant::fromValue(Base::Vector3f(x(), y, z())));
setData(QVariant::fromValue(Base::Vector3d(x(), y, z())));
}
double PropertyVectorItem::z() const
{
return data(1,Qt::EditRole).value<Base::Vector3f>().z;
return data(1,Qt::EditRole).value<Base::Vector3d>().z;
}
void PropertyVectorItem::setZ(double z)
{
setData(QVariant::fromValue(Base::Vector3f(x(), y(), z)));
setData(QVariant::fromValue(Base::Vector3d(x(), y(), z)));
}
// ---------------------------------------------------------------

View File

@@ -83,6 +83,7 @@ bool PropertyModel::setData(const QModelIndex& index, const QVariant & value, in
if (data.type() == QVariant::Double && value.type() == QVariant::Double) {
// since we store some properties as floats we get some round-off
// errors here. Thus, we use an epsilon here.
// NOTE: Since 0.14 PropertyFloat uses double precision, so this is maybe unnecessary now?
double d = data.toDouble();
double v = value.toDouble();
if (fabs(d-v) > FLT_EPSILON)

View File

@@ -354,7 +354,7 @@ static PyObject * best_fit_coarse(PyObject *self, PyObject *args)
static PyObject * offset(PyObject *self,PyObject *args)
{
float offset;
double offset;
PyObject *pcObj;
if (!PyArg_ParseTuple(args, "O!f",&(TopoShapePy::Type), &pcObj,&offset ))
return NULL;

View File

@@ -50,7 +50,7 @@ project(PyObject *self, PyObject *args)
if (pcObjDir)
Vector = *static_cast<Base::VectorPy*>(pcObjDir)->getVectorPtr();
ProjectionAlgos Alg(pShape->getTopoShapePtr()->_Shape,Base::Vector3f((float)Vector.x,(float)Vector.y,(float)Vector.z));
ProjectionAlgos Alg(pShape->getTopoShapePtr()->_Shape,Vector);
Py::List list;
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.V)) , true));
@@ -79,7 +79,7 @@ projectEx(PyObject *self, PyObject *args)
if (pcObjDir)
Vector = *static_cast<Base::VectorPy*>(pcObjDir)->getVectorPtr();
ProjectionAlgos Alg(pShape->getTopoShapePtr()->_Shape,Base::Vector3f((float)Vector.x,(float)Vector.y,(float)Vector.z));
ProjectionAlgos Alg(pShape->getTopoShapePtr()->_Shape,Vector);
Py::List list;
list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.V)) , true));
@@ -116,7 +116,7 @@ projectToSVG(PyObject *self, PyObject *args)
Base::Vector3d Vector(0,0,1);
if (pcObjDir)
Vector = static_cast<Base::VectorPy*>(pcObjDir)->value();
ProjectionAlgos Alg(pShape->getTopoShapePtr()->_Shape,Base::Vector3f((float)Vector.x,(float)Vector.y,(float)Vector.z));
ProjectionAlgos Alg(pShape->getTopoShapePtr()->_Shape,Vector);
bool hidden = false;
if (type && std::string(type) == "ShowHiddenLines")
@@ -146,7 +146,7 @@ projectToDXF(PyObject *self, PyObject *args)
Base::Vector3d Vector(0,0,1);
if (pcObjDir)
Vector = static_cast<Base::VectorPy*>(pcObjDir)->value();
ProjectionAlgos Alg(pShape->getTopoShapePtr()->_Shape,Base::Vector3f((float)Vector.x,(float)Vector.y,(float)Vector.z));
ProjectionAlgos Alg(pShape->getTopoShapePtr()->_Shape,Vector);
bool hidden = false;
if (type && std::string(type) == "ShowHiddenLines")

View File

@@ -50,7 +50,7 @@ FeatureProjection::FeatureProjection()
{
static const char *group = "Projection";
ADD_PROPERTY_TYPE(Source ,(0),group,App::Prop_None,"Shape to project");
ADD_PROPERTY_TYPE(Direction ,(Base::Vector3f(0,0,1)),group,App::Prop_None,"Projection direction");
ADD_PROPERTY_TYPE(Direction ,(Base::Vector3d(0,0,1)),group,App::Prop_None,"Projection direction");
ADD_PROPERTY_TYPE(VCompound ,(true),group,App::Prop_None,"Projection parameter");
ADD_PROPERTY_TYPE(Rg1LineVCompound ,(true),group,App::Prop_None,"Projection parameter");
ADD_PROPERTY_TYPE(RgNLineVCompound ,(true),group,App::Prop_None,"Projection parameter");
@@ -79,7 +79,7 @@ App::DocumentObjectExecReturn *FeatureProjection::execute(void)
return new App::DocumentObjectExecReturn("Linked shape object is empty");
try {
const Base::Vector3f& dir = Direction.getValue();
const Base::Vector3d& dir = Direction.getValue();
Drawing::ProjectionAlgos alg(shape, dir);
TopoDS_Compound comp;

View File

@@ -70,7 +70,7 @@ using namespace std;
// FeatureViewPart
//===========================================================================
App::PropertyFloatConstraint::Constraints FeatureViewPart::floatRange = {0.01f,5.0f,0.05f};
App::PropertyFloatConstraint::Constraints FeatureViewPart::floatRange = {0.01,5.0,0.05};
PROPERTY_SOURCE(Drawing::FeatureViewPart, Drawing::FeatureView)
@@ -84,8 +84,8 @@ FeatureViewPart::FeatureViewPart(void)
ADD_PROPERTY_TYPE(Source ,(0),group,App::Prop_None,"Shape to view");
ADD_PROPERTY_TYPE(ShowHiddenLines ,(false),group,App::Prop_None,"Control the appearance of the dashed hidden lines");
ADD_PROPERTY_TYPE(ShowSmoothLines ,(false),group,App::Prop_None,"Control the appearance of the smooth lines");
ADD_PROPERTY_TYPE(LineWidth,(0.35f),vgroup,App::Prop_None,"The thickness of the resulting lines");
ADD_PROPERTY_TYPE(Tolerance,(0.05f),vgroup,App::Prop_None,"The tessellation tolerance");
ADD_PROPERTY_TYPE(LineWidth,(0.35),vgroup,App::Prop_None,"The thickness of the resulting lines");
ADD_PROPERTY_TYPE(Tolerance,(0.05),vgroup,App::Prop_None,"The tessellation tolerance");
Tolerance.setConstraints(&floatRange);
}
@@ -188,7 +188,7 @@ App::DocumentObjectExecReturn *FeatureViewPart::execute(void)
TopoDS_Shape shape = static_cast<Part::Feature*>(link)->Shape.getShape()._Shape;
if (shape.IsNull())
return new App::DocumentObjectExecReturn("Linked shape object is empty");
Base::Vector3f Dir = Direction.getValue();
Base::Vector3d Dir = Direction.getValue();
bool hidden = ShowHiddenLines.getValue();
bool smooth = ShowSmoothLines.getValue();

View File

@@ -90,7 +90,7 @@ using namespace std;
ProjectionAlgos::ProjectionAlgos(const TopoDS_Shape &Input, const Base::Vector3f &Dir)
ProjectionAlgos::ProjectionAlgos(const TopoDS_Shape &Input, const Base::Vector3d &Dir)
: Input(Input), Direction(Dir)
{
execute();

View File

@@ -39,7 +39,7 @@ class DrawingExport ProjectionAlgos
{
public:
/// Constructor
ProjectionAlgos(const TopoDS_Shape &Input,const Base::Vector3f &Dir);
ProjectionAlgos(const TopoDS_Shape &Input,const Base::Vector3d &Dir);
virtual ~ProjectionAlgos();
void execute(void);
@@ -56,7 +56,7 @@ public:
const TopoDS_Shape &Input;
const Base::Vector3f &Direction;
const Base::Vector3d &Direction;
TopoDS_Shape V ;// hard edge visibly
TopoDS_Shape V1;// Smoth edges visibly

View File

@@ -159,7 +159,7 @@ exporter(PyObject *self, PyObject *args)
}
TopoDS_Shape shape = static_cast<Part::Feature*>(link)->Shape.getShape()._Shape;
if (!shape.IsNull()) {
Base::Vector3f dir = view->Direction.getValue();
Base::Vector3d dir = view->Direction.getValue();
bool hidden = view->ShowHiddenLines.getValue();
bool smooth = view->ShowSmoothLines.getValue();
Drawing::ProjectionAlgos::ExtractionType type = Drawing::ProjectionAlgos::Plain;

View File

@@ -68,7 +68,7 @@ PROPERTY_SOURCE(Fem::Constraint, App::DocumentObject);
Constraint::Constraint()
{
ADD_PROPERTY_TYPE(References,(0,0),"Constraint",(App::PropertyType)(App::Prop_None),"Elements where the constraint is applied");
ADD_PROPERTY_TYPE(NormalDirection,(Base::Vector3f(0,0,1)),"Constraint",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),"Normal direction pointing outside of solid");
ADD_PROPERTY_TYPE(NormalDirection,(Base::Vector3d(0,0,1)),"Constraint",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),"Normal direction pointing outside of solid");
}
Constraint::~Constraint()
@@ -129,7 +129,7 @@ void Constraint::onDocumentRestored()
App::DocumentObject::onDocumentRestored();
}
const bool Constraint::getPoints(std::vector<Base::Vector3f> &points, std::vector<Base::Vector3f> &normals) const
const bool Constraint::getPoints(std::vector<Base::Vector3d> &points, std::vector<Base::Vector3d> &normals) const
{
std::vector<App::DocumentObject*> Objects = References.getValues();
std::vector<std::string> SubElements = References.getSubValues();
@@ -148,7 +148,7 @@ const bool Constraint::getPoints(std::vector<Base::Vector3f> &points, std::vecto
if (sh.ShapeType() == TopAbs_VERTEX) {
const TopoDS_Vertex& vertex = TopoDS::Vertex(sh);
gp_Pnt p = BRep_Tool::Pnt(vertex);
points.push_back(Base::Vector3f(p.X(), p.Y(), p.Z()));
points.push_back(Base::Vector3d(p.X(), p.Y(), p.Z()));
normals.push_back(NormalDirection.getValue());
} else if (sh.ShapeType() == TopAbs_EDGE) {
BRepAdaptor_Curve curve(TopoDS::Edge(sh));
@@ -166,7 +166,7 @@ const bool Constraint::getPoints(std::vector<Base::Vector3f> &points, std::vecto
double step = (lp - fp) / steps;
for (int i = 0; i < steps + 1; i++) {
gp_Pnt p = curve.Value(i * step);
points.push_back(Base::Vector3f(p.X(), p.Y(), p.Z()));
points.push_back(Base::Vector3d(p.X(), p.Y(), p.Z()));
normals.push_back(NormalDirection.getValue());
}
} else if (sh.ShapeType() == TopAbs_FACE) {
@@ -212,10 +212,10 @@ const bool Constraint::getPoints(std::vector<Base::Vector3f> &points, std::vecto
gp_Pnt p = surface.Value(u, v);
BRepClass_FaceClassifier classifier(face, p, Precision::Confusion());
if (classifier.State() != TopAbs_OUT) {
points.push_back(Base::Vector3f(p.X(), p.Y(), p.Z()));
points.push_back(Base::Vector3d(p.X(), p.Y(), p.Z()));
props.Normal(u, v,center,normal);
normal.Normalize();
normals.push_back(Base::Vector3f(normal.X(), normal.Y(), normal.Z()));
normals.push_back(Base::Vector3d(normal.X(), normal.Y(), normal.Z()));
}
}
}
@@ -225,7 +225,7 @@ const bool Constraint::getPoints(std::vector<Base::Vector3f> &points, std::vecto
return true;
}
const bool Constraint::getCylinder(float& radius, float& height, Base::Vector3f& base, Base::Vector3f& axis) const
const bool Constraint::getCylinder(double &radius, double &height, Base::Vector3d& base, Base::Vector3d& axis) const
{
std::vector<App::DocumentObject*> Objects = References.getValues();
std::vector<std::string> SubElements = References.getSubValues();
@@ -247,21 +247,21 @@ const bool Constraint::getCylinder(float& radius, float& height, Base::Vector3f&
radius = cyl.Radius();
gp_Pnt b = cyl.Location();
base = Base::Vector3f(b.X(), b.Y(), b.Z());
base = Base::Vector3d(b.X(), b.Y(), b.Z());
gp_Dir dir = cyl.Axis().Direction();
axis = Base::Vector3f(dir.X(), dir.Y(), dir.Z());
axis = Base::Vector3d(dir.X(), dir.Y(), dir.Z());
return true;
}
Base::Vector3f Constraint::getBasePoint(const Base::Vector3f& base, const Base::Vector3f& axis,
const App::PropertyLinkSub& location, const float& dist)
Base::Vector3d Constraint::getBasePoint(const Base::Vector3d& base, const Base::Vector3d& axis,
const App::PropertyLinkSub& location, const double& dist)
{
// Get the point specified by Location and Distance
App::DocumentObject* objLoc = location.getValue();
std::vector<std::string> names = location.getSubValues();
if (names.size() == 0)
return Base::Vector3f(0,0,0);
return Base::Vector3d(0,0,0);
std::string subName = names.front();
Part::Feature* featLoc = static_cast<Part::Feature*>(objLoc);
TopoDS_Shape shloc = featLoc->Shape.getShape().getSubShape(subName.c_str());
@@ -285,7 +285,7 @@ Base::Vector3f Constraint::getBasePoint(const Base::Vector3f& base, const Base::
gp_Pnt cylbase(base.x, base.y, base.z);
GeomAPI_ProjectPointOnSurf proj(cylbase, pln);
if (!proj.IsDone())
return Base::Vector3f(0,0,0);
return Base::Vector3d(0,0,0);
gp_Pnt projPnt = proj.NearestPoint();
if ((fabs(dist) > Precision::Confusion()) && (projPnt.IsEqual(cylbase, Precision::Confusion()) == Standard_False))
@@ -296,17 +296,17 @@ Base::Vector3f Constraint::getBasePoint(const Base::Vector3f& base, const Base::
Handle_Geom_Curve crv = new Geom_Line(cylbase, cylaxis);
GeomAPI_IntCS intersector(crv, plnt);
if (!intersector.IsDone())
return Base::Vector3f(0,0,0);
return Base::Vector3d(0,0,0);
gp_Pnt inter = intersector.Point(1);
return Base::Vector3f(inter.X(), inter.Y(), inter.Z());
return Base::Vector3d(inter.X(), inter.Y(), inter.Z());
}
const Base::Vector3f Constraint::getDirection(const App::PropertyLinkSub &direction)
const Base::Vector3d Constraint::getDirection(const App::PropertyLinkSub &direction)
{
App::DocumentObject* obj = direction.getValue();
std::vector<std::string> names = direction.getSubValues();
if (names.size() == 0)
return Base::Vector3f(0,0,0);
return Base::Vector3d(0,0,0);
std::string subName = names.front();
Part::Feature* feat = static_cast<Part::Feature*>(obj);
TopoDS_Shape sh = feat->Shape.getShape().getSubShape(subName.c_str());
@@ -317,18 +317,18 @@ const Base::Vector3f Constraint::getDirection(const App::PropertyLinkSub &direct
if (surface.GetType() == GeomAbs_Plane) {
dir = surface.Plane().Axis().Direction();
} else {
return Base::Vector3f(0,0,0); // "Direction must be a planar face or linear edge"
return Base::Vector3d(0,0,0); // "Direction must be a planar face or linear edge"
}
} else if (sh.ShapeType() == TopAbs_EDGE) {
BRepAdaptor_Curve line(TopoDS::Edge(sh));
if (line.GetType() == GeomAbs_Line) {
dir = line.Line().Direction();
} else {
return Base::Vector3f(0,0,0); // "Direction must be a planar face or linear edge"
return Base::Vector3d(0,0,0); // "Direction must be a planar face or linear edge"
}
}
Base::Vector3f the_direction(dir.X(), dir.Y(), dir.Z());
Base::Vector3d the_direction(dir.X(), dir.Y(), dir.Z());
the_direction.Normalize();
return the_direction;
}

View File

@@ -59,11 +59,11 @@ protected:
protected:
/// Calculate the points where symbols should be drawn
const bool getPoints(std::vector<Base::Vector3f>& points, std::vector<Base::Vector3f>& normals) const;
const bool getCylinder(float& radius, float& height, Base::Vector3f& base, Base::Vector3f& axis) const;
Base::Vector3f getBasePoint(const Base::Vector3f& base, const Base::Vector3f& axis,
const App::PropertyLinkSub &location, const float& dist);
const Base::Vector3f getDirection(const App::PropertyLinkSub &direction);
const bool getPoints(std::vector<Base::Vector3d>& points, std::vector<Base::Vector3d>& normals) const;
const bool getCylinder(double& radius, double& height, Base::Vector3d& base, Base::Vector3d& axis) const;
Base::Vector3d getBasePoint(const Base::Vector3d& base, const Base::Vector3d& axis,
const App::PropertyLinkSub &location, const double& dist);
const Base::Vector3d getDirection(const App::PropertyLinkSub &direction);
};

View File

@@ -50,9 +50,9 @@ ConstraintBearing::ConstraintBearing()
ADD_PROPERTY(AxialFree,(0));
ADD_PROPERTY(Radius,(0.0));
ADD_PROPERTY(Height,(0.0));
ADD_PROPERTY_TYPE(BasePoint,(Base::Vector3f(0,0,0)),"ConstraintBearing",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
ADD_PROPERTY_TYPE(BasePoint,(Base::Vector3d(0,0,0)),"ConstraintBearing",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Base point of cylindrical bearing seat");
ADD_PROPERTY_TYPE(Axis,(Base::Vector3f(0,1,0)),"ConstraintBearing",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
ADD_PROPERTY_TYPE(Axis,(Base::Vector3d(0,1,0)),"ConstraintBearing",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Axis of bearing seat");
}
@@ -70,8 +70,8 @@ void ConstraintBearing::onChanged(const App::Property* prop)
if (prop == &References) {
// Find data of cylinder
float radius, height;
Base::Vector3f base, axis;
double radius, height;
Base::Vector3d base, axis;
if (!getCylinder(radius, height, base, axis))
return;
Radius.setValue(radius);
@@ -106,8 +106,8 @@ void ConstraintBearing::onChanged(const App::Property* prop)
}
}
float radius, height;
Base::Vector3f base, axis;
double radius, height;
Base::Vector3d base, axis;
if (!getCylinder(radius, height, base, axis))
return;
base = getBasePoint(base + axis * height/2, axis, Location, Dist.getValue());

View File

@@ -53,12 +53,12 @@ PROPERTY_SOURCE(Fem::ConstraintFixed, Fem::Constraint);
ConstraintFixed::ConstraintFixed()
{
ADD_PROPERTY_TYPE(Points,(Base::Vector3f()),"ConstraintFixed",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintFixed",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Points where symbols are drawn");
ADD_PROPERTY_TYPE(Normals,(Base::Vector3f()),"ConstraintFixed",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
ADD_PROPERTY_TYPE(Normals,(Base::Vector3d()),"ConstraintFixed",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Normals where symbols are drawn");
Points.setValues(std::vector<Base::Vector3f>());
Normals.setValues(std::vector<Base::Vector3f>());
Points.setValues(std::vector<Base::Vector3d>());
Normals.setValues(std::vector<Base::Vector3d>());
}
App::DocumentObjectExecReturn *ConstraintFixed::execute(void)
@@ -73,8 +73,8 @@ void ConstraintFixed::onChanged(const App::Property* prop)
Constraint::onChanged(prop);
if (prop == &References) {
std::vector<Base::Vector3f> points;
std::vector<Base::Vector3f> normals;
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
if (getPoints(points, normals)) {
Points.setValues(points);
Normals.setValues(normals);

View File

@@ -48,12 +48,12 @@ ConstraintForce::ConstraintForce()
ADD_PROPERTY_TYPE(Direction,(0),"ConstraintForce",(App::PropertyType)(App::Prop_None),
"Element giving direction of constraint");
ADD_PROPERTY(Reversed,(0));
ADD_PROPERTY_TYPE(Points,(Base::Vector3f()),"ConstraintForce",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
ADD_PROPERTY_TYPE(Points,(Base::Vector3d()),"ConstraintForce",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Points where arrows are drawn");
ADD_PROPERTY_TYPE(DirectionVector,(Base::Vector3f(0,0,1)),"ConstraintForce",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
ADD_PROPERTY_TYPE(DirectionVector,(Base::Vector3d(0,0,1)),"ConstraintForce",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Direction of arrows");
naturalDirectionVector = Base::Vector3f(0,0,1);
Points.setValues(std::vector<Base::Vector3f>());
naturalDirectionVector = Base::Vector3d(0,0,1);
Points.setValues(std::vector<Base::Vector3d>());
}
App::DocumentObjectExecReturn *ConstraintForce::execute(void)
@@ -68,14 +68,14 @@ void ConstraintForce::onChanged(const App::Property* prop)
Constraint::onChanged(prop);
if (prop == &References) {
std::vector<Base::Vector3f> points;
std::vector<Base::Vector3f> normals;
std::vector<Base::Vector3d> points;
std::vector<Base::Vector3d> normals;
if (getPoints(points, normals)) {
Points.setValues(points); // We don't use the normals because all arrows should have the same direction
Points.touch(); // This triggers ViewProvider::updateData()
}
} else if (prop == &Direction) {
Base::Vector3f direction = getDirection(Direction);
Base::Vector3d direction = getDirection(Direction);
if (direction.Length() < Precision::Confusion())
return;
naturalDirectionVector = direction;

View File

@@ -60,7 +60,7 @@ protected:
virtual void onChanged(const App::Property* prop);
private:
Base::Vector3f naturalDirectionVector;
Base::Vector3d naturalDirectionVector;
};
} //namespace Fem

View File

@@ -50,9 +50,9 @@ ConstraintGear::ConstraintGear()
ADD_PROPERTY_TYPE(Direction,(0),"ConstraintGear",(App::PropertyType)(App::Prop_None),
"Element giving direction of gear force");
ADD_PROPERTY(Reversed,(0));
ADD_PROPERTY_TYPE(DirectionVector,(Base::Vector3f(1,1,1).Normalize()),"ConstraintGear",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
ADD_PROPERTY_TYPE(DirectionVector,(Base::Vector3d(1,1,1).Normalize()),"ConstraintGear",App::PropertyType(App::Prop_ReadOnly|App::Prop_Output),
"Direction of gear force");
naturalDirectionVector = Base::Vector3f(1,1,1).Normalize();
naturalDirectionVector = Base::Vector3d(1,1,1).Normalize();
}
App::DocumentObjectExecReturn *ConstraintGear::execute(void)
@@ -65,7 +65,7 @@ void ConstraintGear::onChanged(const App::Property* prop)
ConstraintBearing::onChanged(prop);
if (prop == &Direction) {
Base::Vector3f direction = getDirection(Direction);
Base::Vector3d direction = getDirection(Direction);
if (direction.Length() < Precision::Confusion())
return;
naturalDirectionVector = direction;

View File

@@ -61,7 +61,7 @@ protected:
virtual void onChanged(const App::Property* prop);
private:
Base::Vector3f naturalDirectionVector;
Base::Vector3d naturalDirectionVector;
};
} //namespace Fem

View File

@@ -225,7 +225,7 @@ void TaskFemConstraintBearing::onSelectionChanged(const Gui::SelectionChanges& m
void TaskFemConstraintBearing::onDistanceChanged(double l)
{
Fem::ConstraintBearing* pcConstraint = static_cast<Fem::ConstraintBearing*>(ConstraintView->getObject());
pcConstraint->Dist.setValue((float)l);
pcConstraint->Dist.setValue(l);
}
void TaskFemConstraintBearing::onReferenceDeleted() {

View File

@@ -232,7 +232,7 @@ void TaskFemConstraintForce::onSelectionChanged(const Gui::SelectionChanges& msg
void TaskFemConstraintForce::onForceChanged(double f)
{
Fem::ConstraintForce* pcConstraint = static_cast<Fem::ConstraintForce*>(ConstraintView->getObject());
pcConstraint->Force.setValue((float)f);
pcConstraint->Force.setValue(f);
}
void TaskFemConstraintForce::onReferenceDeleted() {

View File

@@ -177,19 +177,19 @@ void TaskFemConstraintGear::onSelectionChanged(const Gui::SelectionChanges& msg)
void TaskFemConstraintGear::onDiameterChanged(double l)
{
Fem::ConstraintGear* pcConstraint = static_cast<Fem::ConstraintGear*>(ConstraintView->getObject());
pcConstraint->Diameter.setValue((float)l);
pcConstraint->Diameter.setValue(l);
}
void TaskFemConstraintGear::onForceChanged(double f)
{
Fem::ConstraintGear* pcConstraint = static_cast<Fem::ConstraintGear*>(ConstraintView->getObject());
pcConstraint->Force.setValue((float)f);
pcConstraint->Force.setValue(f);
}
void TaskFemConstraintGear::onForceAngleChanged(double a)
{
Fem::ConstraintGear* pcConstraint = static_cast<Fem::ConstraintGear*>(ConstraintView->getObject());
pcConstraint->ForceAngle.setValue((float)a);
pcConstraint->ForceAngle.setValue(a);
}
void TaskFemConstraintGear::onButtonDirection(const bool pressed) {

View File

@@ -109,19 +109,19 @@ TaskFemConstraintPulley::TaskFemConstraintPulley(ViewProviderFemConstraintPulley
void TaskFemConstraintPulley::onOtherDiameterChanged(double l)
{
Fem::ConstraintPulley* pcConstraint = static_cast<Fem::ConstraintPulley*>(ConstraintView->getObject());
pcConstraint->OtherDiameter.setValue((float)l);
pcConstraint->OtherDiameter.setValue(l);
}
void TaskFemConstraintPulley::onCenterDistanceChanged(double l)
{
Fem::ConstraintPulley* pcConstraint = static_cast<Fem::ConstraintPulley*>(ConstraintView->getObject());
pcConstraint->CenterDistance.setValue((float)l);
pcConstraint->CenterDistance.setValue(l);
}
void TaskFemConstraintPulley::onTensionForceChanged(double force)
{
Fem::ConstraintPulley* pcConstraint = static_cast<Fem::ConstraintPulley*>(ConstraintView->getObject());
pcConstraint->TensionForce.setValue((float)force);
pcConstraint->TensionForce.setValue(force);
}
void TaskFemConstraintPulley::onCheckIsDriven(const bool pressed)

View File

@@ -118,9 +118,9 @@ void ViewProviderFemConstraintBearing::updateData(const App::Property* prop)
pShapeSep->removeAllChildren();
// This should always point outside of the cylinder
Base::Vector3f normal = pcConstraint->NormalDirection.getValue();
Base::Vector3f base = pcConstraint->BasePoint.getValue();
float radius = pcConstraint->Radius.getValue();
Base::Vector3d normal = pcConstraint->NormalDirection.getValue();
Base::Vector3d base = pcConstraint->BasePoint.getValue();
double radius = pcConstraint->Radius.getValue();
base = base + radius * normal;
SbVec3f b(base.x, base.y, base.z);
@@ -132,9 +132,9 @@ void ViewProviderFemConstraintBearing::updateData(const App::Property* prop)
} else if (strcmp(prop->getName(),"AxialFree") == 0) {
if (pShapeSep->getNumChildren() > 0) {
// Change the symbol
Base::Vector3f normal = pcConstraint->NormalDirection.getValue();
Base::Vector3f base = pcConstraint->BasePoint.getValue();
float radius = pcConstraint->Radius.getValue();
Base::Vector3d normal = pcConstraint->NormalDirection.getValue();
Base::Vector3d base = pcConstraint->BasePoint.getValue();
double radius = pcConstraint->Radius.getValue();
base = base + radius * normal;
SbVec3f b(base.x, base.y, base.z);

View File

@@ -131,16 +131,16 @@ void ViewProviderFemConstraintFixed::updateData(const App::Property* prop)
// Note: Points and Normals are always updated together
pShapeSep->removeAllChildren();
const std::vector<Base::Vector3f>& points = pcConstraint->Points.getValues();
const std::vector<Base::Vector3f>& normals = pcConstraint->Normals.getValues();
std::vector<Base::Vector3f>::const_iterator n = normals.begin();
const std::vector<Base::Vector3d>& points = pcConstraint->Points.getValues();
const std::vector<Base::Vector3d>& normals = pcConstraint->Normals.getValues();
std::vector<Base::Vector3d>::const_iterator n = normals.begin();
/*
SoMultipleCopy* cp = static_cast<SoMultipleCopy*>(pShapeSep->getChild(0));
cp->matrix.setNum(points.size());
int idx = 0;
*/
for (std::vector<Base::Vector3f>::const_iterator p = points.begin(); p != points.end(); p++) {
for (std::vector<Base::Vector3d>::const_iterator p = points.begin(); p != points.end(); p++) {
SbVec3f base(p->x, p->y, p->z);
SbVec3f dir(n->x, n->y, n->z);
SbRotation rot(SbVec3f(0,-1,0), dir);

View File

@@ -132,24 +132,24 @@ void ViewProviderFemConstraintForce::updateData(const App::Property* prop)
pShapeSep->removeAllChildren();
// This should always point outside of the solid
Base::Vector3f normal = pcConstraint->NormalDirection.getValue();
Base::Vector3d normal = pcConstraint->NormalDirection.getValue();
// Get default direction (on first call to method)
Base::Vector3f forceDirection = pcConstraint->DirectionVector.getValue();
Base::Vector3d forceDirection = pcConstraint->DirectionVector.getValue();
if (forceDirection.Length() < Precision::Confusion())
forceDirection = normal;
SbVec3f dir(forceDirection.x, forceDirection.y, forceDirection.z);
SbRotation rot(SbVec3f(0,1,0), dir);
const std::vector<Base::Vector3f>& points = pcConstraint->Points.getValues();
const std::vector<Base::Vector3d>& points = pcConstraint->Points.getValues();
/*
SoMultipleCopy* cp = static_cast<SoMultipleCopy*>(pShapeSep->getChild(0));
cp->matrix.setNum(points.size());
int idx = 0;*/
for (std::vector<Base::Vector3f>::const_iterator p = points.begin(); p != points.end(); p++) {
for (std::vector<Base::Vector3d>::const_iterator p = points.begin(); p != points.end(); p++) {
SbVec3f base(p->x, p->y, p->z);
if (forceDirection.GetAngle(normal) < M_PI_2) // Move arrow so it doesn't disappear inside the solid
base = base + dir * ARROWLENGTH;
@@ -166,15 +166,15 @@ void ViewProviderFemConstraintForce::updateData(const App::Property* prop)
}
} else if (strcmp(prop->getName(),"DirectionVector") == 0) { // Note: "Reversed" also triggers "DirectionVector"
// Re-orient all arrows
Base::Vector3f normal = pcConstraint->NormalDirection.getValue();
Base::Vector3f forceDirection = pcConstraint->DirectionVector.getValue();
Base::Vector3d normal = pcConstraint->NormalDirection.getValue();
Base::Vector3d forceDirection = pcConstraint->DirectionVector.getValue();
if (forceDirection.Length() < Precision::Confusion())
forceDirection = normal;
SbVec3f dir(forceDirection.x, forceDirection.y, forceDirection.z);
SbRotation rot(SbVec3f(0,1,0), dir);
const std::vector<Base::Vector3f>& points = pcConstraint->Points.getValues();
const std::vector<Base::Vector3d>& points = pcConstraint->Points.getValues();
/*
SoMultipleCopy* cp = static_cast<SoMultipleCopy*>(pShapeSep->getChild(0));
@@ -182,7 +182,7 @@ void ViewProviderFemConstraintForce::updateData(const App::Property* prop)
*/
int idx = 0;
for (std::vector<Base::Vector3f>::const_iterator p = points.begin(); p != points.end(); p++) {
for (std::vector<Base::Vector3d>::const_iterator p = points.begin(); p != points.end(); p++) {
SbVec3f base(p->x, p->y, p->z);
if (forceDirection.GetAngle(normal) < M_PI_2)
base = base + dir * ARROWLENGTH;

View File

@@ -114,16 +114,16 @@ void ViewProviderFemConstraintGear::updateData(const App::Property* prop)
// Remove and recreate the symbol
pShapeSep->removeAllChildren();
Base::Vector3f base = pcConstraint->BasePoint.getValue();
Base::Vector3f axis = pcConstraint->Axis.getValue();
Base::Vector3f direction = pcConstraint->DirectionVector.getValue();
Base::Vector3d base = pcConstraint->BasePoint.getValue();
Base::Vector3d axis = pcConstraint->Axis.getValue();
Base::Vector3d direction = pcConstraint->DirectionVector.getValue();
if (direction.Length() < Precision::Confusion())
direction = Base::Vector3f(0,1,0);
float radius = pcConstraint->Radius.getValue();
float dia = pcConstraint->Diameter.getValue();
direction = Base::Vector3d(0,1,0);
double radius = pcConstraint->Radius.getValue();
double dia = pcConstraint->Diameter.getValue();
if (dia < 2 * radius)
dia = 2 * radius;
float angle = pcConstraint->ForceAngle.getValue() / 180 * M_PI;
double angle = pcConstraint->ForceAngle.getValue() / 180 * M_PI;
SbVec3f b(base.x, base.y, base.z);
SbVec3f ax(axis.x, axis.y, axis.z);
@@ -138,15 +138,15 @@ void ViewProviderFemConstraintGear::updateData(const App::Property* prop)
} else if (strcmp(prop->getName(),"Diameter") == 0) {
if (pShapeSep->getNumChildren() > 0) {
// Change the symbol
Base::Vector3f axis = pcConstraint->Axis.getValue();
Base::Vector3f direction = pcConstraint->DirectionVector.getValue();
Base::Vector3d axis = pcConstraint->Axis.getValue();
Base::Vector3d direction = pcConstraint->DirectionVector.getValue();
if (direction.Length() < Precision::Confusion())
direction = Base::Vector3f(0,1,0);
float dia = pcConstraint->Diameter.getValue();
float radius = pcConstraint->Radius.getValue();
direction = Base::Vector3d(0,1,0);
double dia = pcConstraint->Diameter.getValue();
double radius = pcConstraint->Radius.getValue();
if (dia < 2 * radius)
dia = 2 * radius;
float angle = pcConstraint->ForceAngle.getValue() / 180 * M_PI;
double angle = pcConstraint->ForceAngle.getValue() / 180 * M_PI;
SbVec3f ax(axis.x, axis.y, axis.z);
SbVec3f dir(direction.x, direction.y, direction.z);
@@ -161,12 +161,12 @@ void ViewProviderFemConstraintGear::updateData(const App::Property* prop)
// Note: "Reversed" also triggers "DirectionVector"
if (pShapeSep->getNumChildren() > 0) {
// Re-orient the symbol
Base::Vector3f axis = pcConstraint->Axis.getValue();
Base::Vector3f direction = pcConstraint->DirectionVector.getValue();
Base::Vector3d axis = pcConstraint->Axis.getValue();
Base::Vector3d direction = pcConstraint->DirectionVector.getValue();
if (direction.Length() < Precision::Confusion())
direction = Base::Vector3f(0,1,0);
float dia = pcConstraint->Diameter.getValue();
float angle = pcConstraint->ForceAngle.getValue() / 180 * M_PI;
direction = Base::Vector3d(0,1,0);
double dia = pcConstraint->Diameter.getValue();
double angle = pcConstraint->ForceAngle.getValue() / 180 * M_PI;
SbVec3f ax(axis.x, axis.y, axis.z);
SbVec3f dir(direction.x, direction.y, direction.z);

View File

@@ -114,17 +114,17 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop)
pShapeSep->removeAllChildren();
// This should always point outside of the cylinder
Base::Vector3f base = pcConstraint->BasePoint.getValue();
Base::Vector3f axis = pcConstraint->Axis.getValue();
float radius = pcConstraint->Radius.getValue();
float dia = pcConstraint->Diameter.getValue();
Base::Vector3d base = pcConstraint->BasePoint.getValue();
Base::Vector3d axis = pcConstraint->Axis.getValue();
double radius = pcConstraint->Radius.getValue();
double dia = pcConstraint->Diameter.getValue();
if (dia < 2 * radius)
dia = 2 * radius;
float forceAngle = pcConstraint->ForceAngle.getValue() / 180 * M_PI;
float beltAngle = pcConstraint->BeltAngle.getValue();
double forceAngle = pcConstraint->ForceAngle.getValue() / 180 * M_PI;
double beltAngle = pcConstraint->BeltAngle.getValue();
double rat1 = 0.8, rat2 = 0.2;
float f1 = pcConstraint->BeltForce1.getValue();
float f2 = pcConstraint->BeltForce2.getValue();
double f1 = pcConstraint->BeltForce1.getValue();
double f2 = pcConstraint->BeltForce2.getValue();
if (f1+f2 > Precision::Confusion()) {
rat1 = f1 / (f1+f2);
rat2 = f2 / (f1+f2);
@@ -151,15 +151,15 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop)
} else if (strcmp(prop->getName(),"Diameter") == 0) {
if (pShapeSep->getNumChildren() > 0) {
// Change the symbol
float radius = pcConstraint->Radius.getValue();
float dia = pcConstraint->Diameter.getValue();
double radius = pcConstraint->Radius.getValue();
double dia = pcConstraint->Diameter.getValue();
if (dia < 2 * radius)
dia = 2 * radius;
float forceAngle = pcConstraint->ForceAngle.getValue() / 180 * M_PI;
float beltAngle = pcConstraint->BeltAngle.getValue();
double forceAngle = pcConstraint->ForceAngle.getValue() / 180 * M_PI;
double beltAngle = pcConstraint->BeltAngle.getValue();
double rat1 = 0.8, rat2 = 0.2;
float f1 = pcConstraint->BeltForce1.getValue();
float f2 = pcConstraint->BeltForce2.getValue();
double f1 = pcConstraint->BeltForce1.getValue();
double f2 = pcConstraint->BeltForce2.getValue();
if (f1+f2 > Precision::Confusion()) {
rat1 = f1 / (f1+f2);
rat2 = f2 / (f1+f2);
@@ -182,12 +182,12 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop)
}
} else if ((strcmp(prop->getName(), "ForceAngle") == 0) || (strcmp(prop->getName(), "BeltAngle") == 0)) {
if (pShapeSep->getNumChildren() > 0) {
float radius = pcConstraint->Radius.getValue();
float dia = pcConstraint->Diameter.getValue();
double radius = pcConstraint->Radius.getValue();
double dia = pcConstraint->Diameter.getValue();
if (dia < 2 * radius)
dia = 2 * radius;
float forceAngle = pcConstraint->ForceAngle.getValue() / 180 * M_PI;
float beltAngle = pcConstraint->BeltAngle.getValue();
double forceAngle = pcConstraint->ForceAngle.getValue() / 180 * M_PI;
double beltAngle = pcConstraint->BeltAngle.getValue();
const SoSeparator* sep = static_cast<SoSeparator*>(pShapeSep->getChild(3));
updatePlacement(sep, 0, SbVec3f(dia/2 * sin(forceAngle+beltAngle), 0, dia/2 * cos(forceAngle+beltAngle)),
@@ -198,13 +198,13 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop)
}
} else if ((strcmp(prop->getName(), "BeltForce1") == 0) || (strcmp(prop->getName(), "BeltForce2") == 0)) {
if (pShapeSep->getNumChildren() > 0) {
float radius = pcConstraint->Radius.getValue();
float dia = pcConstraint->Diameter.getValue();
double radius = pcConstraint->Radius.getValue();
double dia = pcConstraint->Diameter.getValue();
if (dia < 2 * radius)
dia = 2 * radius;
double rat1 = 0.8, rat2 = 0.2;
float f1 = pcConstraint->BeltForce1.getValue();
float f2 = pcConstraint->BeltForce2.getValue();
double f1 = pcConstraint->BeltForce1.getValue();
double f2 = pcConstraint->BeltForce2.getValue();
if (f1+f2 > Precision::Confusion()) {
rat1 = f1 / (f1+f2);
rat2 = f2 / (f1+f2);

View File

@@ -162,7 +162,7 @@ bool FemFace::isSameFace (FemFace &face)
PROPERTY_SOURCE(FemGui::ViewProviderFemMesh, Gui::ViewProviderGeometryObject)
App::PropertyFloatConstraint::Constraints ViewProviderFemMesh::floatRange = {1.0f,64.0f,1.0f};
App::PropertyFloatConstraint::Constraints ViewProviderFemMesh::floatRange = {1.0,64.0,1.0};
ViewProviderFemMesh::ViewProviderFemMesh()
{
@@ -455,8 +455,8 @@ std::vector<Base::Vector3d> ViewProviderFemMesh::getSelectionShape(const char* E
return std::vector<Base::Vector3d>();
}
void ViewProviderFemMesh::setHighlightNodes(const std::set<long>& HighlightedNodes)
{
void ViewProviderFemMesh::setHighlightNodes(const std::set<long>& HighlightedNodes)
{
if(HighlightedNodes.size()){
const Fem::PropertyFemMesh* mesh = &(dynamic_cast<Fem::FemMeshObject*>(this->pcObject)->FemMesh);
@@ -475,11 +475,11 @@ void ViewProviderFemMesh::setHighlightNodes(const std::set<long>& HighlightedNod
pcAnoCoords->point.setNum(0);
}
}
void ViewProviderFemMesh::resetHighlightNodes(void)
{
pcAnoCoords->point.setNum(0);
}
}
void ViewProviderFemMesh::resetHighlightNodes(void)
{
pcAnoCoords->point.setNum(0);
}
PyObject * ViewProviderFemMesh::getPyObject()
{

View File

@@ -575,7 +575,7 @@ App::DocumentObjectExecReturn* Feature::execute(void)
str << "Inspecting " << this->Label.getValue() << "...";
Base::SequencerLauncher seq(str.str().c_str(), count);
std::vector<float> vals(count);
std::vector<double> vals(count);
for (unsigned long index = 0; index < count; index++) {
Base::Vector3f pnt = actual->getPoint(index);
@@ -599,7 +599,7 @@ App::DocumentObjectExecReturn* Feature::execute(void)
float fRMS = 0;
int countRMS = 0;
for (std::vector<float>::iterator it = vals.begin(); it != vals.end(); ++it) {
for (std::vector<double>::iterator it = vals.begin(); it != vals.end(); ++it) {
if (fabs(*it) < FLT_MAX) {
fRMS += (*it) * (*it);
countRMS++;

View File

@@ -294,7 +294,7 @@ void ViewProviderInspection::setDistances()
}
// distance values
const std::vector<float>& fValues = ((App::PropertyFloatList*)pDistances)->getValues();
const std::vector<double>& fValues = ((App::PropertyFloatList*)pDistances)->getValues();
if ((int)fValues.size() != this->pcCoords->point.getNum()) {
pcMatBinding->value = SoMaterialBinding::OVERALL;
return;
@@ -309,7 +309,7 @@ void ViewProviderInspection::setDistances()
float * tran = pcColorMat->transparency.startEditing();
unsigned long j=0;
for (std::vector<float>::const_iterator jt = fValues.begin(); jt != fValues.end(); ++jt, j++) {
for (std::vector<double>::const_iterator jt = fValues.begin(); jt != fValues.end(); ++jt, j++) {
App::Color col = pcColorBar->getColor(*jt);
cols[j] = SbColor(col.r, col.g, col.b);
if (pcColorBar->isVisible(*jt))

View File

@@ -93,8 +93,8 @@ App::DocumentObjectExecReturn *SegmentByMesh::execute(void)
// the clipping plane
Base::Vector3f cBase, cNormal;
cBase = Base.getValue();
cNormal = Normal.getValue();
cBase = Base::convertTo<Base::Vector3f>(Base.getValue());
cNormal = Base::convertTo<Base::Vector3f>(Normal.getValue());
const MeshKernel& rMeshKernel = kernel->getValue().getKernel();

View File

@@ -55,9 +55,9 @@ PROPERTY_SOURCE(Part::Extrusion, Part::Feature)
Extrusion::Extrusion()
{
ADD_PROPERTY(Base,(0));
ADD_PROPERTY(Dir,(Base::Vector3f(0.0f,0.0f,1.0f)));
ADD_PROPERTY(Dir,(Base::Vector3d(0.0,0.0,1.0)));
ADD_PROPERTY(Solid,(false));
ADD_PROPERTY(TaperAngle,(0.0f));
ADD_PROPERTY(TaperAngle,(0.0));
}
short Extrusion::mustExecute() const
@@ -79,9 +79,9 @@ App::DocumentObjectExecReturn *Extrusion::execute(void)
return new App::DocumentObjectExecReturn("Linked object is not a Part object");
Part::Feature *base = static_cast<Part::Feature*>(Base.getValue());
Base::Vector3f v = Dir.getValue();
Base::Vector3d v = Dir.getValue();
gp_Vec vec(v.x,v.y,v.z);
float taperAngle = TaperAngle.getValue();
double taperAngle = TaperAngle.getValue();
bool makeSolid = Solid.getValue();
try {

View File

@@ -42,8 +42,8 @@ PROPERTY_SOURCE(Part::Mirroring, Part::Feature)
Mirroring::Mirroring()
{
ADD_PROPERTY(Source,(0));
ADD_PROPERTY_TYPE(Base,(Base::Vector3f()),"Plane",App::Prop_None,"The base point of the plane");
ADD_PROPERTY_TYPE(Normal,(Base::Vector3f(0,0,1)),"Plane",App::Prop_None,"The normal of the plane");
ADD_PROPERTY_TYPE(Base,(Base::Vector3d()),"Plane",App::Prop_None,"The base point of the plane");
ADD_PROPERTY_TYPE(Normal,(Base::Vector3d(0,0,1)),"Plane",App::Prop_None,"The normal of the plane");
}
short Mirroring::mustExecute() const
@@ -80,8 +80,8 @@ App::DocumentObjectExecReturn *Mirroring::execute(void)
if (!link->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
return new App::DocumentObjectExecReturn("Linked object is not a Part object");
Part::Feature *source = static_cast<Part::Feature*>(link);
Base::Vector3f base = Base.getValue();
Base::Vector3f norm = Normal.getValue();
Base::Vector3d base = Base.getValue();
Base::Vector3d norm = Normal.getValue();
try {
const TopoDS_Shape& shape = source->Shape.getValue();

View File

@@ -182,8 +182,8 @@ void Box::Restore(Base::XMLReader &reader)
}
// for 0.8 releases
else if (location_axis) {
Base::Vector3f d = Axis.getValue();
Base::Vector3f p = Location.getValue();
Base::Vector3d d = Axis.getValue();
Base::Vector3d p = Location.getValue();
Base::Rotation rot(Base::Vector3d(0.0,0.0,1.0),
Base::Vector3d(d.x,d.y,d.z));
plm.setRotation(rot);

View File

@@ -37,7 +37,7 @@ PROPERTY_SOURCE(Part::Polygon, Part::Feature)
Part::Polygon::Polygon()
{
ADD_PROPERTY(Nodes,(Base::Vector3f()));
ADD_PROPERTY(Nodes,(Base::Vector3d()));
ADD_PROPERTY(Close,(false));
}
@@ -55,9 +55,9 @@ short Part::Polygon::mustExecute() const
App::DocumentObjectExecReturn *Part::Polygon::execute(void)
{
BRepBuilderAPI_MakePolygon poly;
const std::vector<Base::Vector3f> nodes = Nodes.getValues();
const std::vector<Base::Vector3d> nodes = Nodes.getValues();
for (std::vector<Base::Vector3f>::const_iterator it = nodes.begin(); it != nodes.end(); ++it) {
for (std::vector<Base::Vector3d>::const_iterator it = nodes.begin(); it != nodes.end(); ++it) {
gp_Pnt pnt(it->x, it->y, it->z);
poly.Add(pnt);
}

View File

@@ -32,16 +32,16 @@
using namespace Part;
App::PropertyFloatConstraint::Constraints Revolution::angleRangeU = {-360.0f,360.0f,1.0f};
App::PropertyFloatConstraint::Constraints Revolution::angleRangeU = {-360.0,360.0,1.0};
PROPERTY_SOURCE(Part::Revolution, Part::Feature)
Revolution::Revolution()
{
ADD_PROPERTY(Source,(0));
ADD_PROPERTY(Base,(Base::Vector3f(0.0f,0.0f,0.0f)));
ADD_PROPERTY(Axis,(Base::Vector3f(0.0f,0.0f,1.0f)));
ADD_PROPERTY(Angle,(360.0f));
ADD_PROPERTY(Base,(Base::Vector3d(0.0,0.0,0.0)));
ADD_PROPERTY(Axis,(Base::Vector3d(0.0,0.0,1.0)));
ADD_PROPERTY(Angle,(360.0));
Angle.setConstraints(&angleRangeU);
}
@@ -64,8 +64,8 @@ App::DocumentObjectExecReturn *Revolution::execute(void)
return new App::DocumentObjectExecReturn("Linked object is not a Part object");
Part::Feature *base = static_cast<Part::Feature*>(Source.getValue());
Base::Vector3f b = Base.getValue();
Base::Vector3f v = Axis.getValue();
Base::Vector3d b = Base.getValue();
Base::Vector3d v = Axis.getValue();
gp_Pnt pnt(b.x,b.y,b.z);
gp_Dir dir(v.x,v.y,v.z);

View File

@@ -79,7 +79,7 @@ PyObject* ParabolaPy::compute(PyObject *args)
}
Base::Matrix4D m;
Base::Vector3f v;
Base::Vector3d v;
m[0][0] = v1.y * v1.y;
m[0][1] = v1.y;
m[0][2] = 1;

View File

@@ -70,11 +70,11 @@
namespace Part {
const App::PropertyFloatConstraint::Constraints floatRange = {0.0f,FLT_MAX,0.1f};
const App::PropertyFloatConstraint::Constraints apexRange = {0.0f,90.0f,0.1f};
const App::PropertyFloatConstraint::Constraints angleRangeU = {0.0f,360.0f,1.0f};
const App::PropertyFloatConstraint::Constraints angleRangeV = {-90.0f,90.0f,1.0f};
const App::PropertyFloatConstraint::Constraints torusRangeV = {-180.0f,180.0f,1.0f};
const App::PropertyFloatConstraint::Constraints floatRange = {0.0,FLT_MAX,0.1};
const App::PropertyFloatConstraint::Constraints apexRange = {0.0,90.0,0.1};
const App::PropertyFloatConstraint::Constraints angleRangeU = {0.0,360.0,1.0};
const App::PropertyFloatConstraint::Constraints angleRangeV = {-90.0,90.0,1.0};
const App::PropertyFloatConstraint::Constraints torusRangeV = {-180.0,180.0,1.0};
}
using namespace Part;
@@ -166,69 +166,69 @@ void Vertex::onChanged(const App::Property* prop)
Part::Feature::onChanged(prop);
}
PROPERTY_SOURCE(Part::Line, Part::Primitive)
Line::Line()
{
ADD_PROPERTY_TYPE(X1,(0.0f),"Vertex 1 - Start",App::Prop_None,"X value of the start vertex");
ADD_PROPERTY_TYPE(Y1,(0.0f),"Vertex 1 - Start",App::Prop_None,"Y value of the Start vertex");
ADD_PROPERTY_TYPE(Z1,(0.0f),"Vertex 1 - Start",App::Prop_None,"Z value of the Start vertex");
ADD_PROPERTY_TYPE(X2,(0.0f),"Vertex 2 - Finish",App::Prop_None,"X value of the finish vertex");
ADD_PROPERTY_TYPE(Y2,(0.0f),"Vertex 2 - Finish",App::Prop_None,"Y value of the finish vertex");
ADD_PROPERTY_TYPE(Z2,(1.0f),"Vertex 2 - Finish",App::Prop_None,"Z value of the finish vertex");
}
Line::~Line()
{
}
short Line::mustExecute() const
{
if (X1.isTouched() ||
Y1.isTouched() ||
Z1.isTouched() ||
X2.isTouched() ||
Y2.isTouched() ||
Z2.isTouched())
return 1;
return Part::Feature::mustExecute();
}
App::DocumentObjectExecReturn *Line::execute(void)
{
gp_Pnt point1;
point1.SetX(this->X1.getValue());
point1.SetY(this->Y1.getValue());
point1.SetZ(this->Z1.getValue());
gp_Pnt point2;
point2.SetX(this->X2.getValue());
point2.SetY(this->Y2.getValue());
point2.SetZ(this->Z2.getValue());
BRepBuilderAPI_MakeEdge mkEdge(point1, point2);
if (!mkEdge.IsDone())
return new App::DocumentObjectExecReturn("Failed to create edge");
const TopoDS_Edge& edge = mkEdge.Edge();
this->Shape.setValue(edge);
return App::DocumentObject::StdReturn;
}
void Line::onChanged(const App::Property* prop)
{
if (!isRestoring()) {
if (prop == &X1 || prop == &Y1 || prop == &Z1 || prop == &X2 || prop == &Y2 || prop == &Z2){
try {
App::DocumentObjectExecReturn *ret = recompute();
delete ret;
}
catch (...) {
}
}
}
Part::Feature::onChanged(prop);
}
PROPERTY_SOURCE(Part::Line, Part::Primitive)
Line::Line()
{
ADD_PROPERTY_TYPE(X1,(0.0f),"Vertex 1 - Start",App::Prop_None,"X value of the start vertex");
ADD_PROPERTY_TYPE(Y1,(0.0f),"Vertex 1 - Start",App::Prop_None,"Y value of the Start vertex");
ADD_PROPERTY_TYPE(Z1,(0.0f),"Vertex 1 - Start",App::Prop_None,"Z value of the Start vertex");
ADD_PROPERTY_TYPE(X2,(0.0f),"Vertex 2 - Finish",App::Prop_None,"X value of the finish vertex");
ADD_PROPERTY_TYPE(Y2,(0.0f),"Vertex 2 - Finish",App::Prop_None,"Y value of the finish vertex");
ADD_PROPERTY_TYPE(Z2,(1.0f),"Vertex 2 - Finish",App::Prop_None,"Z value of the finish vertex");
}
Line::~Line()
{
}
short Line::mustExecute() const
{
if (X1.isTouched() ||
Y1.isTouched() ||
Z1.isTouched() ||
X2.isTouched() ||
Y2.isTouched() ||
Z2.isTouched())
return 1;
return Part::Feature::mustExecute();
}
App::DocumentObjectExecReturn *Line::execute(void)
{
gp_Pnt point1;
point1.SetX(this->X1.getValue());
point1.SetY(this->Y1.getValue());
point1.SetZ(this->Z1.getValue());
gp_Pnt point2;
point2.SetX(this->X2.getValue());
point2.SetY(this->Y2.getValue());
point2.SetZ(this->Z2.getValue());
BRepBuilderAPI_MakeEdge mkEdge(point1, point2);
if (!mkEdge.IsDone())
return new App::DocumentObjectExecReturn("Failed to create edge");
const TopoDS_Edge& edge = mkEdge.Edge();
this->Shape.setValue(edge);
return App::DocumentObject::StdReturn;
}
void Line::onChanged(const App::Property* prop)
{
if (!isRestoring()) {
if (prop == &X1 || prop == &Y1 || prop == &Z1 || prop == &X2 || prop == &Y2 || prop == &Z2){
try {
App::DocumentObjectExecReturn *ret = recompute();
delete ret;
}
catch (...) {
}
}
}
Part::Feature::onChanged(prop);
}
PROPERTY_SOURCE(Part::Plane, Part::Primitive)

View File

@@ -22,32 +22,32 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <BRep_Builder.hxx>
# include <BRep_Tool.hxx>
# include <BRepCheck_Analyzer.hxx>
# include <BRepTools.hxx>
# include <BRepBuilderAPI_MakeFace.hxx>
# include <ShapeAnalysis.hxx>
# include <BRepAdaptor_Surface.hxx>
# include <BRepLProp_SLProps.hxx>
# include <BRepOffsetAPI_MakeOffset.hxx>
#ifndef _PreComp_
# include <BRep_Builder.hxx>
# include <BRep_Tool.hxx>
# include <BRepCheck_Analyzer.hxx>
# include <BRepTools.hxx>
# include <BRepBuilderAPI_MakeFace.hxx>
# include <ShapeAnalysis.hxx>
# include <BRepAdaptor_Surface.hxx>
# include <BRepLProp_SLProps.hxx>
# include <BRepOffsetAPI_MakeOffset.hxx>
# include <Geom_BezierSurface.hxx>
# include <Geom_BSplineSurface.hxx>
# include <Geom_Plane.hxx>
# include <Geom_CylindricalSurface.hxx>
# include <Geom_ConicalSurface.hxx>
# include <Geom_RectangularTrimmedSurface.hxx>
# include <Geom_Plane.hxx>
# include <Geom_CylindricalSurface.hxx>
# include <Geom_ConicalSurface.hxx>
# include <Geom_RectangularTrimmedSurface.hxx>
# include <Geom_SphericalSurface.hxx>
# include <Geom_ToroidalSurface.hxx>
# include <Handle_Geom_Surface.hxx>
# include <TopoDS.hxx>
# include <TopoDS_Face.hxx>
# include <TopoDS_Wire.hxx>
# include <gp_Pnt2d.hxx>
# include <gp_Pln.hxx>
# include <gp_Cylinder.hxx>
# include <gp_Cone.hxx>
# include <TopoDS_Face.hxx>
# include <TopoDS_Wire.hxx>
# include <gp_Pnt2d.hxx>
# include <gp_Pln.hxx>
# include <gp_Cylinder.hxx>
# include <gp_Cone.hxx>
# include <gp_Sphere.hxx>
# include <gp_Torus.hxx>
# include <Standard_Version.hxx>
@@ -55,7 +55,7 @@
# include <ShapeFix_Wire.hxx>
# include <TopExp_Explorer.hxx>
# include <TopTools_IndexedMapOfShape.hxx>
#endif
#endif
#include <BRepTopAdaptor_FClass2d.hxx>
#include <BRepPrimAPI_MakeHalfSpace.hxx>
@@ -106,7 +106,7 @@ PyObject *TopoShapeFacePy::PyMake(struct _typeobject *, PyObject *, PyObject *)
int TopoShapeFacePy::PyInit(PyObject* args, PyObject* /*kwd*/)
{
PyObject *pW;
if (PyArg_ParseTuple(args, "O!", &(Part::TopoShapePy::Type), &pW)) {
if (PyArg_ParseTuple(args, "O!", &(Part::TopoShapePy::Type), &pW)) {
try {
const TopoDS_Shape& sh = static_cast<Part::TopoShapePy*>(pW)->getTopoShapePtr()->_Shape;
if (sh.IsNull()) {
@@ -122,17 +122,17 @@ int TopoShapeFacePy::PyInit(PyObject* args, PyObject* /*kwd*/)
}
getTopoShapePtr()->_Shape = mkFace.Face();
return 0;
}
}
else if (sh.ShapeType() == TopAbs_FACE) {
getTopoShapePtr()->_Shape = sh;
return 0;
}
}
catch (Standard_Failure) {
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PyExc_Exception, e->GetMessageString());
PyErr_SetString(PyExc_Exception, e->GetMessageString());
return -1;
}
}
}
PyErr_Clear();
@@ -247,7 +247,7 @@ int TopoShapeFacePy::PyInit(PyObject* args, PyObject* /*kwd*/)
PyObject* TopoShapeFacePy::makeOffset(PyObject *args)
{
float dist;
double dist;
if (!PyArg_ParseTuple(args, "f",&dist))
return 0;
const TopoDS_Face& f = TopoDS::Face(getTopoShapePtr()->_Shape);

View File

@@ -23,10 +23,10 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <gp_Pnt.hxx>
# include <gp_Ax1.hxx>
# include <BRep_Tool.hxx>
#ifndef _PreComp_
# include <gp_Pnt.hxx>
# include <gp_Ax1.hxx>
# include <BRep_Tool.hxx>
# include <TopoDS.hxx>
# include <TopoDS_Vertex.hxx>
# include <BRep_Builder.hxx>
@@ -84,9 +84,9 @@ int TopoShapeVertexPy::PyInit(PyObject* args, PyObject* /*kwd*/)
if (PyArg_ParseTuple(args,"O!",&(PyTuple_Type), &object)) {
try {
Py::Tuple tuple(object);
x = (float)Py::Float(tuple.getItem(0));
y = (float)Py::Float(tuple.getItem(1));
z = (float)Py::Float(tuple.getItem(2));
x = Py::Float(tuple.getItem(0));
y = Py::Float(tuple.getItem(1));
z = Py::Float(tuple.getItem(2));
success = true;
}
catch (const Py::Exception&) {

View File

@@ -209,7 +209,7 @@ PyObject* TopoShapeWirePy::fixWire(PyObject *args)
PyObject* TopoShapeWirePy::makeOffset(PyObject *args)
{
float dist;
double dist;
if (!PyArg_ParseTuple(args, "f",&dist))
return 0;
const TopoDS_Wire& w = TopoDS::Wire(getTopoShapePtr()->_Shape);

View File

@@ -90,7 +90,7 @@ Part::Offset* OffsetWidget::getObject() const
void OffsetWidget::on_spinOffset_valueChanged(double val)
{
d->offset->Value.setValue((float)val);
d->offset->Value.setValue(val);
if (d->ui.updateView->isChecked())
d->offset->getDocument()->recomputeFeature(d->offset);
}
@@ -104,7 +104,7 @@ void OffsetWidget::on_modeType_activated(int val)
void OffsetWidget::on_joinType_activated(int val)
{
d->offset->Join.setValue((float)val);
d->offset->Join.setValue((long)val);
if (d->ui.updateView->isChecked())
d->offset->getDocument()->recomputeFeature(d->offset);
}

View File

@@ -114,7 +114,7 @@ Part::Thickness* ThicknessWidget::getObject() const
void ThicknessWidget::on_spinOffset_valueChanged(double val)
{
d->thickness->Value.setValue((float)val);
d->thickness->Value.setValue(val);
if (d->ui.updateView->isChecked())
d->thickness->getDocument()->recomputeFeature(d->thickness);
}
@@ -128,7 +128,7 @@ void ThicknessWidget::on_modeType_activated(int val)
void ThicknessWidget::on_joinType_activated(int val)
{
d->thickness->Join.setValue((float)val);
d->thickness->Join.setValue((long)val);
if (d->ui.updateView->isChecked())
d->thickness->getDocument()->recomputeFeature(d->thickness);
}

View File

@@ -55,8 +55,8 @@
# include <TopTools_IndexedMapOfShape.hxx>
# include <Poly_PolygonOnTriangulation.hxx>
# include <TColStd_Array1OfInteger.hxx>
# include <TopTools_ListOfShape.hxx>
# include <Inventor/SoPickedPoint.h>
# include <TopTools_ListOfShape.hxx>
# include <Inventor/SoPickedPoint.h>
# include <Inventor/events/SoMouseButtonEvent.h>
# include <Inventor/nodes/SoCoordinate3.h>
# include <Inventor/nodes/SoDrawStyle.h>
@@ -164,8 +164,8 @@ PROPERTY_SOURCE(PartGui::ViewProviderPartBase, Gui::ViewProviderGeometryObject)
//**************************************************************************
// Construction/Destruction
App::PropertyFloatConstraint::Constraints ViewProviderPartBase::floatRange = {1.0f,64.0f,1.0f};
const char* ViewProviderPartBase::LightingEnums[]= {"One side","Two side",NULL};
App::PropertyFloatConstraint::Constraints ViewProviderPartBase::floatRange = {1.0,64.0,1.0};
const char* ViewProviderPartBase::LightingEnums[]= {"One side","Two side",NULL};
ViewProviderPartBase::ViewProviderPartBase() : pcControlPoints(0)
{
@@ -185,8 +185,8 @@ ViewProviderPartBase::ViewProviderPartBase() : pcControlPoints(0)
PointSize.setConstraints(&floatRange);
ADD_PROPERTY(PointSize,(2.0f));
ADD_PROPERTY(ControlPoints,(false));
ADD_PROPERTY(Lighting,(1));
Lighting.setEnums(LightingEnums);
ADD_PROPERTY(Lighting,(1));
Lighting.setEnums(LightingEnums);
EdgeRoot = new SoSeparator();
EdgeRoot->ref();
@@ -211,11 +211,11 @@ ViewProviderPartBase::ViewProviderPartBase() : pcControlPoints(0)
pcPointStyle->ref();
pcPointStyle->style = SoDrawStyle::POINTS;
pcPointStyle->pointSize = PointSize.getValue();
pShapeHints = new SoShapeHints;
pShapeHints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
pShapeHints->ref();
Lighting.touch();
pShapeHints = new SoShapeHints;
pShapeHints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
pShapeHints->ref();
Lighting.touch();
sPixmap = "Tree_Part";
loadParameter();
@@ -230,7 +230,7 @@ ViewProviderPartBase::~ViewProviderPartBase()
pcPointMaterial->unref();
pcLineStyle->unref();
pcPointStyle->unref();
pShapeHints->unref();
pShapeHints->unref();
}
void ViewProviderPartBase::onChanged(const App::Property* prop)
@@ -280,12 +280,12 @@ void ViewProviderPartBase::onChanged(const App::Property* prop)
App::Property* shape = obj->getPropertyByName("Shape");
showControlPoints(ControlPoints.getValue(), shape);
}
else if (prop == &Lighting) {
if (Lighting.getValue() == 0)
pShapeHints->vertexOrdering = SoShapeHints::UNKNOWN_ORDERING;
else
pShapeHints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
}
else if (prop == &Lighting) {
if (Lighting.getValue() == 0)
pShapeHints->vertexOrdering = SoShapeHints::UNKNOWN_ORDERING;
else
pShapeHints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
}
else {
ViewProviderGeometryObject::onChanged(prop);
}
@@ -361,7 +361,7 @@ std::vector<std::string> ViewProviderPartBase::getDisplayModes(void) const
return StrList;
}
void ViewProviderPartBase::shapeInfoCallback(void * ud, SoEventCallback * n)
{
const SoMouseButtonEvent * mbe = (SoMouseButtonEvent *)n->getEvent();
@@ -916,7 +916,7 @@ void ViewProviderPartBase::showControlPoints(bool show, const App::Property* pro
{
if (!pcControlPoints && show) {
pcControlPoints = new SoSwitch();
pcRoot->addChild(pcControlPoints);
pcRoot->addChild(pcControlPoints);
}
if (pcControlPoints) {
@@ -1167,12 +1167,12 @@ void ViewProviderEllipsoid::updateData(const App::Property* prop)
return;
App::DocumentObject* object = this->getObject();
if (object && object->isDerivedFrom(Part::Ellipsoid::getClassTypeId())) {
float angle1 = static_cast<Part::Ellipsoid*>(object)->Angle1.getValue();
float angle2 = static_cast<Part::Ellipsoid*>(object)->Angle2.getValue();
float angle3 = static_cast<Part::Ellipsoid*>(object)->Angle3.getValue();
double angle1 = static_cast<Part::Ellipsoid*>(object)->Angle1.getValue();
double angle2 = static_cast<Part::Ellipsoid*>(object)->Angle2.getValue();
double angle3 = static_cast<Part::Ellipsoid*>(object)->Angle3.getValue();
float radius1 = static_cast<Part::Ellipsoid*>(object)->Radius1.getValue();
float radius2 = static_cast<Part::Ellipsoid*>(object)->Radius2.getValue();
if (angle1 == -90.0f && angle2 == 90.0f && angle3 == 360.0f) {
if (angle1 == -90.0 && angle2 == 90.0 && angle3 == 360.0) {
float scale = radius1/radius2;
pScaling->scaleFactor.setValue(1,1,scale);
pSphere->radius.setValue(radius2);

View File

@@ -117,8 +117,8 @@ PROPERTY_SOURCE(PartGui::ViewProviderPartExt, Gui::ViewProviderGeometryObject)
//**************************************************************************
// Construction/Destruction
App::PropertyFloatConstraint::Constraints ViewProviderPartExt::sizeRange = {1.0f,64.0f,1.0f};
App::PropertyFloatConstraint::Constraints ViewProviderPartExt::tessRange = {0.0001f,100.0f,0.01f};
App::PropertyFloatConstraint::Constraints ViewProviderPartExt::sizeRange = {1.0,64.0,1.0};
App::PropertyFloatConstraint::Constraints ViewProviderPartExt::tessRange = {0.0001,100.0,0.01};
const char* ViewProviderPartExt::LightingEnums[]= {"One side","Two side",NULL};
const char* ViewProviderPartExt::DrawStyleEnums[]= {"Solid","Dashed","Dotted","Dashdot",NULL};

View File

@@ -86,11 +86,10 @@ bool ViewProviderMirror::setEdit(int ModNum)
Part::Mirroring* mf = static_cast<Part::Mirroring*>(getObject());
Base::BoundBox3d bbox = mf->Shape.getBoundingBox();
float len = (float)bbox.CalcDiagonalLength();
Base::Vector3f base = mf->Base.getValue();
Base::Vector3f norm = mf->Normal.getValue();
Base::Vector3d base = mf->Base.getValue();
Base::Vector3d norm = mf->Normal.getValue();
Base::Vector3d cent = bbox.CalcCenter();
Base::Vector3f cbox((float)cent.x,(float)cent.y,(float)cent.z);
base = cbox.ProjToPlane(base, norm);
base = cent.ProjToPlane(base, norm);
// setup the graph for editing the mirror plane
SoTransform* trans = new SoTransform;

View File

@@ -55,8 +55,8 @@ PROPERTY_SOURCE(PartDesign::Groove, PartDesign::Subtractive)
Groove::Groove()
{
ADD_PROPERTY_TYPE(Base,(Base::Vector3f(0.0f,0.0f,0.0f)),"Groove", App::Prop_ReadOnly, "Base");
ADD_PROPERTY_TYPE(Axis,(Base::Vector3f(0.0f,1.0f,0.0f)),"Groove", App::Prop_ReadOnly, "Axis");
ADD_PROPERTY_TYPE(Base,(Base::Vector3d(0.0f,0.0f,0.0f)),"Groove", App::Prop_ReadOnly, "Base");
ADD_PROPERTY_TYPE(Axis,(Base::Vector3d(0.0f,1.0f,0.0f)),"Groove", App::Prop_ReadOnly, "Axis");
ADD_PROPERTY_TYPE(Angle,(360.0),"Groove", App::Prop_None, "Angle");
ADD_PROPERTY_TYPE(ReferenceAxis,(0),"Groove",(App::PropertyType)(App::Prop_None),"Reference axis of Groove");
}
@@ -99,9 +99,9 @@ App::DocumentObjectExecReturn *Groove::execute(void)
updateAxis();
// get revolve axis
Base::Vector3f b = Base.getValue();
Base::Vector3d b = Base.getValue();
gp_Pnt pnt(b.x,b.y,b.z);
Base::Vector3f v = Axis.getValue();
Base::Vector3d v = Axis.getValue();
gp_Dir dir(v.x,v.y,v.z);
try {
@@ -178,28 +178,26 @@ bool Groove::suggestReversed(void)
std::vector<TopoDS_Wire> wires = getSketchWires();
TopoDS_Shape sketchshape = makeFace(wires);
Base::Vector3f b = Base.getValue();
Base::Vector3f v = Axis.getValue();
Base::Vector3d b = Base.getValue();
Base::Vector3d v = Axis.getValue();
// get centre of gravity of the sketch face
GProp_GProps props;
BRepGProp::SurfaceProperties(sketchshape, props);
gp_Pnt cog = props.CentreOfMass();
Base::Vector3f p_cog(cog.X(), cog.Y(), cog.Z());
Base::Vector3d p_cog(cog.X(), cog.Y(), cog.Z());
// get direction to cog from its projection on the revolve axis
Base::Vector3f perp_dir = p_cog - p_cog.Perpendicular(b, v);
Base::Vector3d perp_dir = p_cog - p_cog.Perpendicular(b, v);
// get cross product of projection direction with revolve axis direction
Base::Vector3f cross = v % perp_dir;
Base::Vector3d cross = v % perp_dir;
// get sketch vector pointing away from support material
Base::Placement SketchPos = sketch->Placement.getValue();
Base::Rotation SketchOrientation = SketchPos.getRotation();
Base::Vector3d SketchNormal(0,0,1);
SketchOrientation.multVec(SketchNormal,SketchNormal);
// simply convert double to float
Base::Vector3f norm(SketchNormal.x, SketchNormal.y, SketchNormal.z);
// return true if the angle between norm and cross is acute
return norm * cross > 0.f;
return SketchNormal * cross > 0.f;
}
catch (...) {
return Reversed.getValue();

View File

@@ -55,8 +55,8 @@ PROPERTY_SOURCE(PartDesign::Revolution, PartDesign::Additive)
Revolution::Revolution()
{
ADD_PROPERTY_TYPE(Base,(Base::Vector3f(0.0f,0.0f,0.0f)),"Revolution", App::Prop_ReadOnly, "Base");
ADD_PROPERTY_TYPE(Axis,(Base::Vector3f(0.0f,1.0f,0.0f)),"Revolution", App::Prop_ReadOnly, "Axis");
ADD_PROPERTY_TYPE(Base,(Base::Vector3d(0.0f,0.0f,0.0f)),"Revolution", App::Prop_ReadOnly, "Base");
ADD_PROPERTY_TYPE(Axis,(Base::Vector3d(0.0f,1.0f,0.0f)),"Revolution", App::Prop_ReadOnly, "Axis");
ADD_PROPERTY_TYPE(Angle,(360.0),"Revolution", App::Prop_None, "Angle");
ADD_PROPERTY_TYPE(ReferenceAxis,(0),"Revolution",(App::Prop_None),"Reference axis of revolution");
}
@@ -105,9 +105,9 @@ App::DocumentObjectExecReturn *Revolution::execute(void)
updateAxis();
// get revolve axis
Base::Vector3f b = Base.getValue();
Base::Vector3d b = Base.getValue();
gp_Pnt pnt(b.x,b.y,b.z);
Base::Vector3f v = Axis.getValue();
Base::Vector3d v = Axis.getValue();
gp_Dir dir(v.x,v.y,v.z);
try {
@@ -183,25 +183,25 @@ bool Revolution::suggestReversed(void)
std::vector<TopoDS_Wire> wires = getSketchWires();
TopoDS_Shape sketchshape = makeFace(wires);
Base::Vector3f b = Base.getValue();
Base::Vector3f v = Axis.getValue();
Base::Vector3d b = Base.getValue();
Base::Vector3d v = Axis.getValue();
// get centre of gravity of the sketch face
GProp_GProps props;
BRepGProp::SurfaceProperties(sketchshape, props);
gp_Pnt cog = props.CentreOfMass();
Base::Vector3f p_cog(cog.X(), cog.Y(), cog.Z());
Base::Vector3d p_cog(cog.X(), cog.Y(), cog.Z());
// get direction to cog from its projection on the revolve axis
Base::Vector3f perp_dir = p_cog - p_cog.Perpendicular(b, v);
Base::Vector3d perp_dir = p_cog - p_cog.Perpendicular(b, v);
// get cross product of projection direction with revolve axis direction
Base::Vector3f cross = v % perp_dir;
Base::Vector3d cross = v % perp_dir;
// get sketch vector pointing away from support material
Base::Placement SketchPos = sketch->Placement.getValue();
Base::Rotation SketchOrientation = SketchPos.getRotation();
Base::Vector3d SketchNormal(0,0,1);
SketchOrientation.multVec(SketchNormal,SketchNormal);
// simply convert double to float
Base::Vector3f norm(SketchNormal.x, SketchNormal.y, SketchNormal.z);
Base::Vector3d norm(SketchNormal.x, SketchNormal.y, SketchNormal.z);
// return true if the angle between norm and cross is obtuse
return norm * cross < 0.f;

View File

@@ -48,6 +48,7 @@ TYPESYSTEM_SOURCE(Points::PropertyCurvatureList , App::PropertyLists);
void PropertyGreyValueList::removeIndices( const std::vector<unsigned long>& uIndices )
{
#if 0
// We need a sorted array
std::vector<unsigned long> uSortedInds = uIndices;
std::sort(uSortedInds.begin(), uSortedInds.end());
@@ -73,6 +74,7 @@ void PropertyGreyValueList::removeIndices( const std::vector<unsigned long>& uIn
}
setValues(remainValue);
#endif
}
void PropertyNormalList::transform(const Base::Matrix4D &mat)
@@ -109,17 +111,17 @@ void PropertyNormalList::removeIndices( const std::vector<unsigned long>& uIndic
std::vector<unsigned long> uSortedInds = uIndices;
std::sort(uSortedInds.begin(), uSortedInds.end());
const std::vector<Base::Vector3f>& rValueList = getValues();
const std::vector<Base::Vector3d>& rValueList = getValues();
assert( uSortedInds.size() <= rValueList.size() );
if ( uSortedInds.size() > rValueList.size() )
return;
std::vector<Base::Vector3f> remainValue;
std::vector<Base::Vector3d> remainValue;
remainValue.reserve(rValueList.size() - uSortedInds.size());
std::vector<unsigned long>::iterator pos = uSortedInds.begin();
for ( std::vector<Base::Vector3f>::const_iterator it = rValueList.begin(); it != rValueList.end(); ++it ) {
for ( std::vector<Base::Vector3d>::const_iterator it = rValueList.begin(); it != rValueList.end(); ++it ) {
unsigned long index = it - rValueList.begin();
if (pos == uSortedInds.end())
remainValue.push_back( *it );

View File

@@ -125,14 +125,14 @@ void ViewProviderPoints::setVertexColorMode(App::PropertyColorList* pcProperty)
void ViewProviderPoints::setVertexGreyvalueMode(Points::PropertyGreyValueList* pcProperty)
{
const std::vector<float>& val = pcProperty->getValues();
const std::vector<double>& val = pcProperty->getValues();
unsigned long i=0;
pcColorMat->enableNotify(false);
pcColorMat->diffuseColor.deleteValues(0);
pcColorMat->diffuseColor.setNum(val.size());
for ( std::vector<float>::const_iterator it = val.begin(); it != val.end(); ++it ) {
for ( std::vector<double>::const_iterator it = val.begin(); it != val.end(); ++it ) {
pcColorMat->diffuseColor.set1Value(i++, SbColor(*it, *it, *it));
}
@@ -142,14 +142,14 @@ void ViewProviderPoints::setVertexGreyvalueMode(Points::PropertyGreyValueList* p
void ViewProviderPoints::setVertexNormalMode(Points::PropertyNormalList* pcProperty)
{
const std::vector<Base::Vector3f>& val = pcProperty->getValues();
const std::vector<Base::Vector3d>& val = pcProperty->getValues();
unsigned long i=0;
pcPointsNormal->enableNotify(false);
pcPointsNormal->vector.deleteValues(0);
pcPointsNormal->vector.setNum(val.size());
for ( std::vector<Base::Vector3f>::const_iterator it = val.begin(); it != val.end(); ++it ) {
for ( std::vector<Base::Vector3d>::const_iterator it = val.begin(); it != val.end(); ++it ) {
pcPointsNormal->vector.set1Value(i++, it->x, it->y, it->z);
}