From efc29e44222920c3f8cad2206a0044c83022c86b Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 23 Mar 2013 15:12:04 +0100 Subject: [PATCH 01/17] Move from float to double --- src/App/Annotation.cpp | 6 +- src/App/MeasureDistance.cpp | 6 +- src/App/PropertyGeo.cpp | 82 +++++++++---------- src/App/PropertyGeo.h | 24 +++--- src/App/PropertyStandard.cpp | 32 ++++---- src/App/PropertyStandard.h | 22 ++--- src/Gui/ViewProviderAnnotation.cpp | 6 +- src/Gui/ViewProviderMeasureDistance.cpp | 8 +- src/Gui/propertyeditor/PropertyItem.cpp | 6 +- src/Mod/Drawing/App/AppDrawingPy.cpp | 8 +- src/Mod/Drawing/App/FeatureProjection.cpp | 4 +- src/Mod/Drawing/App/FeatureViewPart.cpp | 2 +- src/Mod/Drawing/App/ProjectionAlgos.cpp | 2 +- src/Mod/Drawing/App/ProjectionAlgos.h | 4 +- src/Mod/Drawing/Gui/AppDrawingGuiPy.cpp | 2 +- src/Mod/Fem/App/FemConstraint.cpp | 38 ++++----- src/Mod/Fem/App/FemConstraint.h | 8 +- src/Mod/Fem/App/FemConstraintBearing.cpp | 8 +- src/Mod/Fem/App/FemConstraintFixed.cpp | 12 +-- src/Mod/Fem/App/FemConstraintForce.cpp | 14 ++-- src/Mod/Fem/App/FemConstraintForce.h | 2 +- src/Mod/Fem/App/FemConstraintGear.cpp | 6 +- src/Mod/Fem/App/FemConstraintGear.h | 2 +- .../Gui/ViewProviderFemConstraintBearing.cpp | 12 +-- .../Gui/ViewProviderFemConstraintFixed.cpp | 8 +- .../Gui/ViewProviderFemConstraintForce.cpp | 16 ++-- .../Fem/Gui/ViewProviderFemConstraintGear.cpp | 20 ++--- .../Gui/ViewProviderFemConstraintPulley.cpp | 4 +- src/Mod/Inspection/App/InspectionFeature.cpp | 4 +- .../Inspection/Gui/ViewProviderInspection.cpp | 4 +- src/Mod/Mesh/App/FeatureMeshSegmentByMesh.cpp | 4 +- src/Mod/Part/App/FeatureExtrusion.cpp | 6 +- src/Mod/Part/App/FeatureMirroring.cpp | 8 +- src/Mod/Part/App/FeaturePartBox.cpp | 4 +- src/Mod/Part/App/FeaturePartPolygon.cpp | 6 +- src/Mod/Part/App/FeatureRevolution.cpp | 10 +-- src/Mod/Part/Gui/ViewProviderMirror.cpp | 7 +- src/Mod/PartDesign/App/FeatureGroove.cpp | 22 +++-- src/Mod/PartDesign/App/FeatureRevolution.cpp | 20 ++--- src/Mod/Points/App/Properties.cpp | 8 +- src/Mod/Points/Gui/ViewProvider.cpp | 8 +- 41 files changed, 236 insertions(+), 239 deletions(-) diff --git a/src/App/Annotation.cpp b/src/App/Annotation.cpp index 368bc7420..37a780068 100644 --- a/src/App/Annotation.cpp +++ b/src/App/Annotation.cpp @@ -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() diff --git a/src/App/MeasureDistance.cpp b/src/App/MeasureDistance.cpp index 13d36bcd7..8314df865 100644 --- a/src/App/MeasureDistance.cpp +++ b/src/App/MeasureDistance.cpp @@ -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"); } diff --git a/src/App/PropertyGeo.cpp b/src/App/PropertyGeo.cpp index 5a1adb114..9dfc4dd70 100644 --- a/src/App/PropertyGeo.cpp +++ b/src/App/PropertyGeo.cpp @@ -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(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::Exception("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::Exception("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::Exception("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(_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& values) +void PropertyVectorList::setValues(const std::vector& 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 values; + std::vector values; values.resize(nSize); for (Py_ssize_t i=0; i(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::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) { + for (std::vector::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 values(uCt); - for (std::vector::iterator it = values.begin(); it != values.end(); ++it) { + std::vector values(uCt); + for (std::vector::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(_lValueList.size() * sizeof(Base::Vector3f)); + return static_cast(_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(); } diff --git a/src/App/PropertyGeo.h b/src/App/PropertyGeo.h index f8f839b47..9aa9ac178 100644 --- a/src/App/PropertyGeo.h +++ b/src/App/PropertyGeo.h @@ -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& values); + void setValues (const std::vector& values); - const std::vector &getValues(void) const { + const std::vector &getValues(void) const { return _lValueList; } @@ -155,7 +155,7 @@ public: virtual unsigned int getMemSize (void) const; private: - std::vector _lValueList; + std::vector _lValueList; }; /** Vector properties diff --git a/src/App/PropertyStandard.cpp b/src/App/PropertyStandard.cpp index f777c8d2b..724788c01 100644 --- a/src/App/PropertyStandard.cpp +++ b/src/App/PropertyStandard.cpp @@ -873,14 +873,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; } @@ -894,12 +894,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 { @@ -919,7 +919,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 @@ -971,7 +971,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; @@ -984,7 +984,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; @@ -1037,7 +1037,7 @@ int PropertyFloatList::getSize(void) const return static_cast(_lValueList.size()); } -void PropertyFloatList::setValue(float lValue) +void PropertyFloatList::setValue(double lValue) { aboutToSetValue(); _lValueList.resize(1); @@ -1045,7 +1045,7 @@ void PropertyFloatList::setValue(float lValue) hasSetValue(); } -void PropertyFloatList::setValues(const std::vector& values) +void PropertyFloatList::setValues(const std::vector& values) { aboutToSetValue(); _lValueList = values; @@ -1064,7 +1064,7 @@ void PropertyFloatList::setPyObject(PyObject *value) { if (PyList_Check(value)) { Py_ssize_t nSize = PyList_Size(value); - std::vector values; + std::vector values; values.resize(nSize); for (Py_ssize_t i=0; i::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) { + for (std::vector::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) { str << *it; } } @@ -1132,8 +1132,8 @@ void PropertyFloatList::RestoreDocFile(Base::Reader &reader) Base::InputStream str(reader); uint32_t uCt=0; str >> uCt; - std::vector values(uCt); - for (std::vector::iterator it = values.begin(); it != values.end(); ++it) { + std::vector values(uCt); + for (std::vector::iterator it = values.begin(); it != values.end(); ++it) { str >> *it; } setValues(values); @@ -1155,7 +1155,7 @@ void PropertyFloatList::Paste(const Property &from) unsigned int PropertyFloatList::getMemSize (void) const { - return static_cast(_lValueList.size() * sizeof(float)); + return static_cast(_lValueList.size() * sizeof(double)); } //************************************************************************** diff --git a/src/App/PropertyStandard.h b/src/App/PropertyStandard.h index e611dd070..c26688258 100644 --- a/src/App/PropertyStandard.h +++ b/src/App/PropertyStandard.h @@ -424,8 +424,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"; } @@ -438,10 +438,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 @@ -472,7 +472,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 @@ -519,16 +519,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& values); + void set1Value (const int idx, double value){_lValueList.operator[] (idx) = value;} + void setValues (const std::vector& values); - const std::vector &getValues(void) const{return _lValueList;} + const std::vector &getValues(void) const{return _lValueList;} virtual PyObject *getPyObject(void); virtual void setPyObject(PyObject *); @@ -544,7 +544,7 @@ public: virtual unsigned int getMemSize (void) const; private: - std::vector _lValueList; + std::vector _lValueList; }; diff --git a/src/Gui/ViewProviderAnnotation.cpp b/src/Gui/ViewProviderAnnotation.cpp index 5224277d2..e0d98f3da 100644 --- a/src/Gui/ViewProviderAnnotation.cpp +++ b/src/Gui/ViewProviderAnnotation.cpp @@ -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(prop)->getValue(); + Base::Vector3d v = static_cast(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(prop)->getValue(); + Base::Vector3d v = static_cast(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(prop)->getValue(); + Base::Vector3d v = static_cast(prop)->getValue(); pCoords->point.set1Value(1, SbVec3f(v.x,v.y,v.z)); pTextTranslation->translation.setValue(v.x,v.y,v.z); } diff --git a/src/Gui/ViewProviderMeasureDistance.cpp b/src/Gui/ViewProviderMeasureDistance.cpp index 490cbb864..f1217989a 100644 --- a/src/Gui/ViewProviderMeasureDistance.cpp +++ b/src/Gui/ViewProviderMeasureDistance.cpp @@ -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(prop)->getValue(); + Base::Vector3d v = static_cast(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(prop)->getValue(); + Base::Vector3d v = static_cast(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(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); diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index 65b22e03c..b57e8e6a9 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -876,15 +876,15 @@ QVariant PropertyVectorItem::value(const App::Property* prop) const { assert(prop && prop->getTypeId().isDerivedFrom(App::PropertyVector::getClassTypeId())); - const Base::Vector3f& value = static_cast(prop)->getValue(); - return QVariant::fromValue(value); + const Base::Vector3d& value = static_cast(prop)->getValue(); + return QVariant::fromValue(value); } void PropertyVectorItem::setValue(const QVariant& value) { if (!value.canConvert()) return; - const Base::Vector3f& val = value.value(); + const Base::Vector3d& val = value.value(); QString data = QString::fromAscii("(%1, %2, %3)") .arg(val.x,0,'f',decimals()) .arg(val.y,0,'f',decimals()) diff --git a/src/Mod/Drawing/App/AppDrawingPy.cpp b/src/Mod/Drawing/App/AppDrawingPy.cpp index 892504a72..77a1a5fdb 100644 --- a/src/Mod/Drawing/App/AppDrawingPy.cpp +++ b/src/Mod/Drawing/App/AppDrawingPy.cpp @@ -50,7 +50,7 @@ project(PyObject *self, PyObject *args) if (pcObjDir) Vector = *static_cast(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(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(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(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") diff --git a/src/Mod/Drawing/App/FeatureProjection.cpp b/src/Mod/Drawing/App/FeatureProjection.cpp index 50a8e088b..40c4a027d 100644 --- a/src/Mod/Drawing/App/FeatureProjection.cpp +++ b/src/Mod/Drawing/App/FeatureProjection.cpp @@ -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; diff --git a/src/Mod/Drawing/App/FeatureViewPart.cpp b/src/Mod/Drawing/App/FeatureViewPart.cpp index db96dc852..9a5eea4d0 100644 --- a/src/Mod/Drawing/App/FeatureViewPart.cpp +++ b/src/Mod/Drawing/App/FeatureViewPart.cpp @@ -188,7 +188,7 @@ App::DocumentObjectExecReturn *FeatureViewPart::execute(void) TopoDS_Shape shape = static_cast(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(); diff --git a/src/Mod/Drawing/App/ProjectionAlgos.cpp b/src/Mod/Drawing/App/ProjectionAlgos.cpp index 38ca1f48d..66027e911 100644 --- a/src/Mod/Drawing/App/ProjectionAlgos.cpp +++ b/src/Mod/Drawing/App/ProjectionAlgos.cpp @@ -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(); diff --git a/src/Mod/Drawing/App/ProjectionAlgos.h b/src/Mod/Drawing/App/ProjectionAlgos.h index f95d0fa1f..2bf19f30c 100644 --- a/src/Mod/Drawing/App/ProjectionAlgos.h +++ b/src/Mod/Drawing/App/ProjectionAlgos.h @@ -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 diff --git a/src/Mod/Drawing/Gui/AppDrawingGuiPy.cpp b/src/Mod/Drawing/Gui/AppDrawingGuiPy.cpp index 87addd915..1ff6170e6 100644 --- a/src/Mod/Drawing/Gui/AppDrawingGuiPy.cpp +++ b/src/Mod/Drawing/Gui/AppDrawingGuiPy.cpp @@ -159,7 +159,7 @@ exporter(PyObject *self, PyObject *args) } TopoDS_Shape shape = static_cast(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; diff --git a/src/Mod/Fem/App/FemConstraint.cpp b/src/Mod/Fem/App/FemConstraint.cpp index a8f4d955b..86f2288a5 100644 --- a/src/Mod/Fem/App/FemConstraint.cpp +++ b/src/Mod/Fem/App/FemConstraint.cpp @@ -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 &points, std::vector &normals) const +const bool Constraint::getPoints(std::vector &points, std::vector &normals) const { std::vector Objects = References.getValues(); std::vector SubElements = References.getSubValues(); @@ -148,7 +148,7 @@ const bool Constraint::getPoints(std::vector &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 &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 &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 &points, std::vecto return true; } -const bool Constraint::getCylinder(float& radius, float& height, Base::Vector3f& base, Base::Vector3f& axis) const +const bool Constraint::getCylinder(float& radius, float& height, Base::Vector3d& base, Base::Vector3d& axis) const { std::vector Objects = References.getValues(); std::vector 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, +Base::Vector3d Constraint::getBasePoint(const Base::Vector3d& base, const Base::Vector3d& axis, const App::PropertyLinkSub& location, const float& dist) { // Get the point specified by Location and Distance App::DocumentObject* objLoc = location.getValue(); std::vector 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(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 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(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; } diff --git a/src/Mod/Fem/App/FemConstraint.h b/src/Mod/Fem/App/FemConstraint.h index 157d76285..693b5be96 100644 --- a/src/Mod/Fem/App/FemConstraint.h +++ b/src/Mod/Fem/App/FemConstraint.h @@ -59,11 +59,11 @@ protected: protected: /// Calculate the points where symbols should be drawn - const bool getPoints(std::vector& points, std::vector& 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 bool getPoints(std::vector& points, std::vector& normals) const; + const bool getCylinder(float& radius, float& height, Base::Vector3d& base, Base::Vector3d& axis) const; + Base::Vector3d getBasePoint(const Base::Vector3d& base, const Base::Vector3d& axis, const App::PropertyLinkSub &location, const float& dist); - const Base::Vector3f getDirection(const App::PropertyLinkSub &direction); + const Base::Vector3d getDirection(const App::PropertyLinkSub &direction); }; diff --git a/src/Mod/Fem/App/FemConstraintBearing.cpp b/src/Mod/Fem/App/FemConstraintBearing.cpp index ed399bd02..6e3b4e63a 100644 --- a/src/Mod/Fem/App/FemConstraintBearing.cpp +++ b/src/Mod/Fem/App/FemConstraintBearing.cpp @@ -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"); } @@ -71,7 +71,7 @@ void ConstraintBearing::onChanged(const App::Property* prop) if (prop == &References) { // Find data of cylinder float radius, height; - Base::Vector3f base, axis; + Base::Vector3d base, axis; if (!getCylinder(radius, height, base, axis)) return; Radius.setValue(radius); @@ -107,7 +107,7 @@ void ConstraintBearing::onChanged(const App::Property* prop) } float radius, height; - Base::Vector3f base, axis; + Base::Vector3d base, axis; if (!getCylinder(radius, height, base, axis)) return; base = getBasePoint(base + axis * height/2, axis, Location, Dist.getValue()); diff --git a/src/Mod/Fem/App/FemConstraintFixed.cpp b/src/Mod/Fem/App/FemConstraintFixed.cpp index 762b63d89..dcd5ab33b 100644 --- a/src/Mod/Fem/App/FemConstraintFixed.cpp +++ b/src/Mod/Fem/App/FemConstraintFixed.cpp @@ -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()); - Normals.setValues(std::vector()); + Points.setValues(std::vector()); + Normals.setValues(std::vector()); } App::DocumentObjectExecReturn *ConstraintFixed::execute(void) @@ -73,8 +73,8 @@ void ConstraintFixed::onChanged(const App::Property* prop) Constraint::onChanged(prop); if (prop == &References) { - std::vector points; - std::vector normals; + std::vector points; + std::vector normals; if (getPoints(points, normals)) { Points.setValues(points); Normals.setValues(normals); diff --git a/src/Mod/Fem/App/FemConstraintForce.cpp b/src/Mod/Fem/App/FemConstraintForce.cpp index 771929d23..2f55c9c77 100644 --- a/src/Mod/Fem/App/FemConstraintForce.cpp +++ b/src/Mod/Fem/App/FemConstraintForce.cpp @@ -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()); + naturalDirectionVector = Base::Vector3d(0,0,1); + Points.setValues(std::vector()); } App::DocumentObjectExecReturn *ConstraintForce::execute(void) @@ -68,14 +68,14 @@ void ConstraintForce::onChanged(const App::Property* prop) Constraint::onChanged(prop); if (prop == &References) { - std::vector points; - std::vector normals; + std::vector points; + std::vector 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; diff --git a/src/Mod/Fem/App/FemConstraintForce.h b/src/Mod/Fem/App/FemConstraintForce.h index 1386e7d7d..9d7f2b08e 100644 --- a/src/Mod/Fem/App/FemConstraintForce.h +++ b/src/Mod/Fem/App/FemConstraintForce.h @@ -60,7 +60,7 @@ protected: virtual void onChanged(const App::Property* prop); private: - Base::Vector3f naturalDirectionVector; + Base::Vector3d naturalDirectionVector; }; } //namespace Fem diff --git a/src/Mod/Fem/App/FemConstraintGear.cpp b/src/Mod/Fem/App/FemConstraintGear.cpp index ec62a294c..f9a430652 100644 --- a/src/Mod/Fem/App/FemConstraintGear.cpp +++ b/src/Mod/Fem/App/FemConstraintGear.cpp @@ -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; diff --git a/src/Mod/Fem/App/FemConstraintGear.h b/src/Mod/Fem/App/FemConstraintGear.h index 11926f350..1e6384659 100644 --- a/src/Mod/Fem/App/FemConstraintGear.h +++ b/src/Mod/Fem/App/FemConstraintGear.h @@ -61,7 +61,7 @@ protected: virtual void onChanged(const App::Property* prop); private: - Base::Vector3f naturalDirectionVector; + Base::Vector3d naturalDirectionVector; }; } //namespace Fem diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintBearing.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintBearing.cpp index a2186df8f..c63c633be 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintBearing.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintBearing.cpp @@ -120,9 +120,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); @@ -134,9 +134,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); diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp index d82603353..47b848e23 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintFixed.cpp @@ -131,16 +131,16 @@ void ViewProviderFemConstraintFixed::updateData(const App::Property* prop) // Note: Points and Normals are always updated together pShapeSep->removeAllChildren(); - const std::vector& points = pcConstraint->Points.getValues(); - const std::vector& normals = pcConstraint->Normals.getValues(); - std::vector::const_iterator n = normals.begin(); + const std::vector& points = pcConstraint->Points.getValues(); + const std::vector& normals = pcConstraint->Normals.getValues(); + std::vector::const_iterator n = normals.begin(); /* SoMultipleCopy* cp = static_cast(pShapeSep->getChild(0)); cp->matrix.setNum(points.size()); int idx = 0; */ - for (std::vector::const_iterator p = points.begin(); p != points.end(); p++) { + for (std::vector::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); diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp index 56b49b0bd..71cdbbf6c 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintForce.cpp @@ -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& points = pcConstraint->Points.getValues(); + const std::vector& points = pcConstraint->Points.getValues(); /* SoMultipleCopy* cp = static_cast(pShapeSep->getChild(0)); cp->matrix.setNum(points.size()); int idx = 0;*/ - for (std::vector::const_iterator p = points.begin(); p != points.end(); p++) { + for (std::vector::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& points = pcConstraint->Points.getValues(); + const std::vector& points = pcConstraint->Points.getValues(); /* SoMultipleCopy* cp = static_cast(pShapeSep->getChild(0)); @@ -182,7 +182,7 @@ void ViewProviderFemConstraintForce::updateData(const App::Property* prop) */ int idx = 0; - for (std::vector::const_iterator p = points.begin(); p != points.end(); p++) { + for (std::vector::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; diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.cpp index f5df20359..fc246a006 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.cpp @@ -114,11 +114,11 @@ 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); + direction = Base::Vector3d(0,1,0); float radius = pcConstraint->Radius.getValue(); float dia = pcConstraint->Diameter.getValue(); if (dia < 2 * radius) @@ -138,10 +138,10 @@ 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); + direction = Base::Vector3d(0,1,0); float dia = pcConstraint->Diameter.getValue(); float radius = pcConstraint->Radius.getValue(); if (dia < 2 * radius) @@ -161,10 +161,10 @@ 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); + direction = Base::Vector3d(0,1,0); float dia = pcConstraint->Diameter.getValue(); float angle = pcConstraint->ForceAngle.getValue() / 180 * M_PI; diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintPulley.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintPulley.cpp index ed10aa524..100ef72d6 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintPulley.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintPulley.cpp @@ -114,8 +114,8 @@ 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(); + Base::Vector3d base = pcConstraint->BasePoint.getValue(); + Base::Vector3d axis = pcConstraint->Axis.getValue(); float radius = pcConstraint->Radius.getValue(); float dia = pcConstraint->Diameter.getValue(); if (dia < 2 * radius) diff --git a/src/Mod/Inspection/App/InspectionFeature.cpp b/src/Mod/Inspection/App/InspectionFeature.cpp index ae8c46b7b..9ff0f6e6e 100644 --- a/src/Mod/Inspection/App/InspectionFeature.cpp +++ b/src/Mod/Inspection/App/InspectionFeature.cpp @@ -575,7 +575,7 @@ App::DocumentObjectExecReturn* Feature::execute(void) str << "Inspecting " << this->Label.getValue() << "..."; Base::SequencerLauncher seq(str.str().c_str(), count); - std::vector vals(count); + std::vector 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::iterator it = vals.begin(); it != vals.end(); ++it) { + for (std::vector::iterator it = vals.begin(); it != vals.end(); ++it) { if (fabs(*it) < FLT_MAX) { fRMS += (*it) * (*it); countRMS++; diff --git a/src/Mod/Inspection/Gui/ViewProviderInspection.cpp b/src/Mod/Inspection/Gui/ViewProviderInspection.cpp index dc6f246ed..871a2bfb6 100644 --- a/src/Mod/Inspection/Gui/ViewProviderInspection.cpp +++ b/src/Mod/Inspection/Gui/ViewProviderInspection.cpp @@ -293,7 +293,7 @@ void ViewProviderInspection::setDistances() } // distance values - const std::vector& fValues = ((App::PropertyFloatList*)pDistances)->getValues(); + const std::vector& fValues = ((App::PropertyFloatList*)pDistances)->getValues(); if ((int)fValues.size() != this->pcCoords->point.getNum()) { pcMatBinding->value = SoMaterialBinding::OVERALL; return; @@ -308,7 +308,7 @@ void ViewProviderInspection::setDistances() float * tran = pcColorMat->transparency.startEditing(); unsigned long j=0; - for (std::vector::const_iterator jt = fValues.begin(); jt != fValues.end(); ++jt, j++) { + for (std::vector::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)) diff --git a/src/Mod/Mesh/App/FeatureMeshSegmentByMesh.cpp b/src/Mod/Mesh/App/FeatureMeshSegmentByMesh.cpp index a95b44bca..8e6912c29 100644 --- a/src/Mod/Mesh/App/FeatureMeshSegmentByMesh.cpp +++ b/src/Mod/Mesh/App/FeatureMeshSegmentByMesh.cpp @@ -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.getValue()); + cNormal = Base::convertTo(Normal.getValue()); const MeshKernel& rMeshKernel = kernel->getValue().getKernel(); diff --git a/src/Mod/Part/App/FeatureExtrusion.cpp b/src/Mod/Part/App/FeatureExtrusion.cpp index 6ccf14328..8f3a205c8 100644 --- a/src/Mod/Part/App/FeatureExtrusion.cpp +++ b/src/Mod/Part/App/FeatureExtrusion.cpp @@ -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.0f,0.0f,1.0f))); ADD_PROPERTY(Solid,(false)); - ADD_PROPERTY(TaperAngle,(0.0f)); + ADD_PROPERTY(TaperAngle,(0.0)); } short Extrusion::mustExecute() const @@ -79,7 +79,7 @@ App::DocumentObjectExecReturn *Extrusion::execute(void) return new App::DocumentObjectExecReturn("Linked object is not a Part object"); Part::Feature *base = static_cast(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(); bool makeSolid = Solid.getValue(); diff --git a/src/Mod/Part/App/FeatureMirroring.cpp b/src/Mod/Part/App/FeatureMirroring.cpp index 004479b61..364df4fab 100644 --- a/src/Mod/Part/App/FeatureMirroring.cpp +++ b/src/Mod/Part/App/FeatureMirroring.cpp @@ -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(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(); diff --git a/src/Mod/Part/App/FeaturePartBox.cpp b/src/Mod/Part/App/FeaturePartBox.cpp index 7e8ffcea2..12c9bf208 100644 --- a/src/Mod/Part/App/FeaturePartBox.cpp +++ b/src/Mod/Part/App/FeaturePartBox.cpp @@ -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); diff --git a/src/Mod/Part/App/FeaturePartPolygon.cpp b/src/Mod/Part/App/FeaturePartPolygon.cpp index 6cd1945b0..e85f2d4a5 100644 --- a/src/Mod/Part/App/FeaturePartPolygon.cpp +++ b/src/Mod/Part/App/FeaturePartPolygon.cpp @@ -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 nodes = Nodes.getValues(); + const std::vector nodes = Nodes.getValues(); - for (std::vector::const_iterator it = nodes.begin(); it != nodes.end(); ++it) { + for (std::vector::const_iterator it = nodes.begin(); it != nodes.end(); ++it) { gp_Pnt pnt(it->x, it->y, it->z); poly.Add(pnt); } diff --git a/src/Mod/Part/App/FeatureRevolution.cpp b/src/Mod/Part/App/FeatureRevolution.cpp index e16379bba..846d7badd 100644 --- a/src/Mod/Part/App/FeatureRevolution.cpp +++ b/src/Mod/Part/App/FeatureRevolution.cpp @@ -39,9 +39,9 @@ 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.0f,0.0f,0.0f))); + ADD_PROPERTY(Axis,(Base::Vector3d(0.0f,0.0f,1.0f))); + 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(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); diff --git a/src/Mod/Part/Gui/ViewProviderMirror.cpp b/src/Mod/Part/Gui/ViewProviderMirror.cpp index 5296fa8a3..32e6dff97 100644 --- a/src/Mod/Part/Gui/ViewProviderMirror.cpp +++ b/src/Mod/Part/Gui/ViewProviderMirror.cpp @@ -82,11 +82,10 @@ bool ViewProviderMirror::setEdit(int ModNum) Part::Mirroring* mf = static_cast(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; diff --git a/src/Mod/PartDesign/App/FeatureGroove.cpp b/src/Mod/PartDesign/App/FeatureGroove.cpp index e3344e70a..7f6a64f83 100644 --- a/src/Mod/PartDesign/App/FeatureGroove.cpp +++ b/src/Mod/PartDesign/App/FeatureGroove.cpp @@ -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 { @@ -176,28 +176,26 @@ bool Groove::suggestReversed(void) std::vector 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(); diff --git a/src/Mod/PartDesign/App/FeatureRevolution.cpp b/src/Mod/PartDesign/App/FeatureRevolution.cpp index afb3667f7..72bbfa8e3 100644 --- a/src/Mod/PartDesign/App/FeatureRevolution.cpp +++ b/src/Mod/PartDesign/App/FeatureRevolution.cpp @@ -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 { @@ -181,25 +181,25 @@ bool Revolution::suggestReversed(void) std::vector 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; diff --git a/src/Mod/Points/App/Properties.cpp b/src/Mod/Points/App/Properties.cpp index df70d1045..855633fa9 100644 --- a/src/Mod/Points/App/Properties.cpp +++ b/src/Mod/Points/App/Properties.cpp @@ -48,6 +48,7 @@ TYPESYSTEM_SOURCE(Points::PropertyCurvatureList , App::PropertyLists); void PropertyGreyValueList::removeIndices( const std::vector& uIndices ) { +#if 0 // We need a sorted array std::vector uSortedInds = uIndices; std::sort(uSortedInds.begin(), uSortedInds.end()); @@ -73,6 +74,7 @@ void PropertyGreyValueList::removeIndices( const std::vector& uIn } setValues(remainValue); +#endif } void PropertyNormalList::transform(const Base::Matrix4D &mat) @@ -109,17 +111,17 @@ void PropertyNormalList::removeIndices( const std::vector& uIndic std::vector uSortedInds = uIndices; std::sort(uSortedInds.begin(), uSortedInds.end()); - const std::vector& rValueList = getValues(); + const std::vector& rValueList = getValues(); assert( uSortedInds.size() <= rValueList.size() ); if ( uSortedInds.size() > rValueList.size() ) return; - std::vector remainValue; + std::vector remainValue; remainValue.reserve(rValueList.size() - uSortedInds.size()); std::vector::iterator pos = uSortedInds.begin(); - for ( std::vector::const_iterator it = rValueList.begin(); it != rValueList.end(); ++it ) { + for ( std::vector::const_iterator it = rValueList.begin(); it != rValueList.end(); ++it ) { unsigned long index = it - rValueList.begin(); if (pos == uSortedInds.end()) remainValue.push_back( *it ); diff --git a/src/Mod/Points/Gui/ViewProvider.cpp b/src/Mod/Points/Gui/ViewProvider.cpp index 5a43c5304..4fe161b71 100644 --- a/src/Mod/Points/Gui/ViewProvider.cpp +++ b/src/Mod/Points/Gui/ViewProvider.cpp @@ -125,14 +125,14 @@ void ViewProviderPoints::setVertexColorMode(App::PropertyColorList* pcProperty) void ViewProviderPoints::setVertexGreyvalueMode(Points::PropertyGreyValueList* pcProperty) { - const std::vector& val = pcProperty->getValues(); + const std::vector& val = pcProperty->getValues(); unsigned long i=0; pcColorMat->enableNotify(false); pcColorMat->diffuseColor.deleteValues(0); pcColorMat->diffuseColor.setNum(val.size()); - for ( std::vector::const_iterator it = val.begin(); it != val.end(); ++it ) { + for ( std::vector::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& val = pcProperty->getValues(); + const std::vector& val = pcProperty->getValues(); unsigned long i=0; pcPointsNormal->enableNotify(false); pcPointsNormal->vector.deleteValues(0); pcPointsNormal->vector.setNum(val.size()); - for ( std::vector::const_iterator it = val.begin(); it != val.end(); ++it ) { + for ( std::vector::const_iterator it = val.begin(); it != val.end(); ++it ) { pcPointsNormal->vector.set1Value(i++, it->x, it->y, it->z); } From 97d6564f51eeed4d4a81d17e95f8e0f48ae994ca Mon Sep 17 00:00:00 2001 From: jrheinlaender Date: Sat, 23 Mar 2013 20:20:16 +0430 Subject: [PATCH 02/17] Further suggestions for float -> double move --- src/App/PropertyUnits.cpp | 6 +- src/Base/Matrix.cpp | 171 +++++++++++++++++++++++++++++++++----- src/Base/Matrix.h | 7 +- src/Base/Persistence.h | 6 +- 4 files changed, 161 insertions(+), 29 deletions(-) diff --git a/src/App/PropertyUnits.cpp b/src/App/PropertyUnits.cpp index fae1df405..3a5926440 100644 --- a/src/App/PropertyUnits.cpp +++ b/src/App/PropertyUnits.cpp @@ -92,12 +92,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 "); diff --git a/src/Base/Matrix.cpp b/src/Base/Matrix.cpp index 18072b6b0..9656d3b3e 100644 --- a/src/Base/Matrix.cpp +++ b/src/Base/Matrix.cpp @@ -23,8 +23,8 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include +# include +# include # include #endif @@ -449,6 +449,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); @@ -701,8 +828,8 @@ void Matrix4D::fromString(const std::string &str) input >> dMtrx4D[i][j]; } } - -// Analyse the a transformation Matrix and describe the transformation + +// Analyse the a transformation Matrix and describe the transformation std::string Matrix4D::analyse(void) const { const double eps=1.0e-06; @@ -723,22 +850,22 @@ std::string Matrix4D::analyse(void) const } else //translation and affine { - if (dMtrx4D[0][1] == 0.0 && dMtrx4D[0][2] == 0.0 && - dMtrx4D[1][0] == 0.0 && dMtrx4D[1][2] == 0.0 && + if (dMtrx4D[0][1] == 0.0 && dMtrx4D[0][2] == 0.0 && + dMtrx4D[1][0] == 0.0 && dMtrx4D[1][2] == 0.0 && dMtrx4D[2][0] == 0.0 && dMtrx4D[2][1] == 0.0) //scaling { - std::ostringstream stringStream; - stringStream << "Scale [" << dMtrx4D[0][0] << ", " << + std::ostringstream stringStream; + stringStream << "Scale [" << dMtrx4D[0][0] << ", " << dMtrx4D[1][1] << ", " << dMtrx4D[2][2] << "]"; - text = stringStream.str(); + text = stringStream.str(); } else { Base::Matrix4D sub; - sub[0][0] = dMtrx4D[0][0]; sub[0][1] = dMtrx4D[0][1]; - sub[0][2] = dMtrx4D[0][2]; sub[1][0] = dMtrx4D[1][0]; + sub[0][0] = dMtrx4D[0][0]; sub[0][1] = dMtrx4D[0][1]; + sub[0][2] = dMtrx4D[0][2]; sub[1][0] = dMtrx4D[1][0]; sub[1][1] = dMtrx4D[1][1]; sub[1][2] = dMtrx4D[1][2]; - sub[2][0] = dMtrx4D[2][0]; sub[2][1] = dMtrx4D[2][1]; + sub[2][0] = dMtrx4D[2][0]; sub[2][1] = dMtrx4D[2][1]; sub[2][2] = dMtrx4D[2][2]; Base::Matrix4D trp = sub; @@ -771,23 +898,23 @@ std::string Matrix4D::analyse(void) const } else //scaling with rotation { - std::ostringstream stringStream; - stringStream << "Scale and Rotate "; + std::ostringstream stringStream; + stringStream << "Scale and Rotate "; if (determinant<0.0 ) - stringStream << "and Invert "; - stringStream << "[ " << - sqrt(trp[0][0]) << ", " << sqrt(trp[1][1]) << ", " << + stringStream << "and Invert "; + stringStream << "[ " << + sqrt(trp[0][0]) << ", " << sqrt(trp[1][1]) << ", " << sqrt(trp[2][2]) << "]"; - text = stringStream.str(); + text = stringStream.str(); } } } else { - std::ostringstream stringStream; - stringStream << "Affine with det= " << + std::ostringstream stringStream; + stringStream << "Affine with det= " << determinant; - text = stringStream.str(); + text = stringStream.str(); } } } @@ -795,4 +922,4 @@ std::string Matrix4D::analyse(void) const text += " with Translation"; } return text; -} +} diff --git a/src/Base/Matrix.h b/src/Base/Matrix.h index 36444c667..99e18bd2b 100644 --- a/src/Base/Matrix.h +++ b/src/Base/Matrix.h @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include "Vector3D.h" @@ -108,12 +108,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); @@ -131,6 +135,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); diff --git a/src/Base/Persistence.h b/src/Base/Persistence.h index 0ca3fb3e3..f05315653 100644 --- a/src/Base/Persistence.h +++ b/src/Base/Persistence.h @@ -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 */ From c3bd10430bf75410f0d35581966c113861ffc430 Mon Sep 17 00:00:00 2001 From: jrheinlaender Date: Sun, 24 Mar 2013 19:10:29 +0430 Subject: [PATCH 03/17] Moved Tools2D from float to double --- src/Base/Tools2D.cpp | 48 ++++++++++++++++----------------- src/Base/Tools2D.h | 64 ++++++++++++++++++++++---------------------- 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/src/Base/Tools2D.cpp b/src/Base/Tools2D.cpp index 978b8cb46..8af9f88b4 100644 --- a/src/Base/Tools2D.cpp +++ b/src/Base/Tools2D.cpp @@ -23,7 +23,7 @@ #include "PreCompiled.h" -#ifndef _PreComp_ +#ifndef _PreComp_ # include # include #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 (clV1.fX, clV2.fX); - clBB.fMinY = std::min (clV1.fY, clV2.fY); - clBB.fMaxX = std::max (clV1.fX, clV2.fX); - clBB.fMaxY = std::max (clV1.fY, clV2.fY); + clBB.fMinX = std::min (clV1.fX, clV2.fX); + clBB.fMinY = std::min (clV1.fY, clV2.fY); + clBB.fMaxX = std::max (clV1.fX, clV2.fX); + clBB.fMaxY = std::max (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 (clBB.fMinX, _aclVct[i].fX); - clBB.fMinY = std::min (clBB.fMinY, _aclVct[i].fY); - clBB.fMaxX = std::max (clBB.fMaxX, _aclVct[i].fX); - clBB.fMaxY = std::max (clBB.fMaxY, _aclVct[i].fY); + clBB.fMinX = std::min (clBB.fMinX, _aclVct[i].fX); + clBB.fMinY = std::min (clBB.fMinY, _aclVct[i].fY); + clBB.fMaxX = std::max (clBB.fMaxX, _aclVct[i].fX); + clBB.fMaxY = std::max (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 &rc Line2D clLine(clPt0, clPt1); // try to intersect with each line of the trim-polygon - std::set afIntersections; // set of intersections (sorted by line parameter) + std::set 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 &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::iterator pF = afIntersections.begin(); pF != afIntersections.end(); pF++) + for (std::set::iterator pF = afIntersections.begin(); pF != afIntersections.end(); pF++) { // intersection point Vector2D clPtIS = clLine.FromPos(*pF); diff --git a/src/Base/Tools2D.h b/src/Base/Tools2D.h index 84c1c0bcd..527793392 100644 --- a/src/Base/Tools2D.h +++ b/src/Base/Tools2D.h @@ -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(fMinX, rclVct.fX); - fMinY = std::min(fMinY, rclVct.fY); - fMaxX = std::max(fMaxX, rclVct.fX); - fMaxY = std::max(fMaxY, rclVct.fY); + fMinX = std::min(fMinX, rclVct.fX); + fMinY = std::min(fMinY, rclVct.fY); + fMaxX = std::max(fMaxX, rclVct.fX); + fMaxY = std::max(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( fX1, fX2 ); - fMaxX = std::max( fX1, fX2 ); - fMinY = std::min( fY1, fY2 ); - fMaxY = std::max( fY1, fY2 ); + fMinX = std::min( fX1, fX2 ); + fMaxX = std::max( fX1, fX2 ); + fMinY = std::min( fY1, fY2 ); + fMaxY = std::max( fY1, fY2 ); } inline bool BoundBox2D::IsValid (void) From bcdc353375d2ff0e20dcea13b07085e7e3bd8ed7 Mon Sep 17 00:00:00 2001 From: jrheinlaender Date: Sun, 24 Mar 2013 19:59:43 +0430 Subject: [PATCH 04/17] More suggestions for float->double move from Gui subdirectory --- src/Gui/DlgDisplayPropertiesImp.cpp | 186 +++++++++++------------ src/Gui/propertyeditor/PropertyItem.cpp | 14 +- src/Gui/propertyeditor/PropertyModel.cpp | 1 + 3 files changed, 101 insertions(+), 100 deletions(-) diff --git a/src/Gui/DlgDisplayPropertiesImp.cpp b/src/Gui/DlgDisplayPropertiesImp.cpp index 356eae44e..7493bddf5 100644 --- a/src/Gui/DlgDisplayPropertiesImp.cpp +++ b/src/Gui/DlgDisplayPropertiesImp.cpp @@ -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(prop).getValue(); + double value = static_cast(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& views) { - QStringList commonModes, modes; - for (std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { - App::Property* prop = (*it)->getPropertyByName("DisplayMode"); + QStringList commonModes, modes; + for (std::vector::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(prop); - if (!display->getEnums()) return; - const std::vector& value = display->getEnumVector(); - if (it == views.begin()) { - for (std::vector::const_iterator jt = value.begin(); jt != value.end(); ++jt) - commonModes << QLatin1String(jt->c_str()); - } - else { - for (std::vector::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::const_iterator it = views.begin(); it != views.end(); ++it) { - App::Property* prop = (*it)->getPropertyByName("DisplayMode"); + App::PropertyEnumeration* display = static_cast(prop); + if (!display->getEnums()) return; + const std::vector& value = display->getEnumVector(); + if (it == views.begin()) { + for (std::vector::const_iterator jt = value.begin(); jt != value.end(); ++jt) + commonModes << QLatin1String(jt->c_str()); + } + else { + for (std::vector::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::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(prop); - QString activeMode = QString::fromAscii(display->getValueAsString()); - int index = changeMode->findText(activeMode); - if (index != -1) { - changeMode->setCurrentIndex(index); - break; - } - } - } + App::PropertyEnumeration* display = static_cast(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& views) { bool material = false; - for (std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { - App::Property* prop = (*it)->getPropertyByName("ShapeMaterial"); + for (std::vector::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& views) { bool material = false; - for (std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { - App::Property* prop = (*it)->getPropertyByName("TextureMaterial"); + for (std::vector::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& views) { bool shapeColor = false; - for (std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { - App::Property* prop = (*it)->getPropertyByName("ShapeColor"); + for (std::vector::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(prop)->getValue(); QColor shape; @@ -490,9 +490,9 @@ void DlgDisplayPropertiesImp::setShapeColor(const std::vectorsetEnabled(shapeColor); + } + + buttonColor->setEnabled(shapeColor); } void DlgDisplayPropertiesImp::setLineColor(const std::vector& views) @@ -518,8 +518,8 @@ void DlgDisplayPropertiesImp::setLineColor(const std::vector void DlgDisplayPropertiesImp::setPointSize(const std::vector& views) { bool pointSize = false; - for (std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { - App::Property* prop = (*it)->getPropertyByName("PointSize"); + for (std::vector::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(prop)->getValue()); @@ -527,16 +527,16 @@ void DlgDisplayPropertiesImp::setPointSize(const std::vector pointSize = true; break; } - } - - spinPointSize->setEnabled(pointSize); + } + + spinPointSize->setEnabled(pointSize); } void DlgDisplayPropertiesImp::setLineWidth(const std::vector& views) { bool lineWidth = false; - for (std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { - App::Property* prop = (*it)->getPropertyByName("LineWidth"); + for (std::vector::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(prop)->getValue()); @@ -544,16 +544,16 @@ void DlgDisplayPropertiesImp::setLineWidth(const std::vector lineWidth = true; break; } - } - - spinLineWidth->setEnabled(lineWidth); + } + + spinLineWidth->setEnabled(lineWidth); } void DlgDisplayPropertiesImp::setTransparency(const std::vector& views) { bool transparency = false; - for (std::vector::const_iterator it = views.begin(); it != views.end(); ++it) { - App::Property* prop = (*it)->getPropertyByName("Transparency"); + for (std::vector::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(prop)->getValue()); @@ -565,10 +565,10 @@ void DlgDisplayPropertiesImp::setTransparency(const std::vectorsetEnabled(transparency); - horizontalSlider->setEnabled(transparency); + } + + spinTransparency->setEnabled(transparency); + horizontalSlider->setEnabled(transparency); } void DlgDisplayPropertiesImp::setLineTransparency(const std::vector& views) diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index b57e8e6a9..c5d8cb9b9 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -882,7 +882,7 @@ QVariant PropertyVectorItem::value(const App::Property* prop) const void PropertyVectorItem::setValue(const QVariant& value) { - if (!value.canConvert()) + if (!value.canConvert()) return; const Base::Vector3d& val = value.value(); QString data = QString::fromAscii("(%1, %2, %3)") @@ -919,32 +919,32 @@ QVariant PropertyVectorItem::editorData(QWidget *editor) const double PropertyVectorItem::x() const { - return data(1,Qt::EditRole).value().x; + return data(1,Qt::EditRole).value().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().y; + return data(1,Qt::EditRole).value().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().z; + return data(1,Qt::EditRole).value().z; } void PropertyVectorItem::setZ(double z) { - setData(QVariant::fromValue(Base::Vector3f(x(), y(), z))); + setData(QVariant::fromValue(Base::Vector3d(x(), y(), z))); } // --------------------------------------------------------------- diff --git a/src/Gui/propertyeditor/PropertyModel.cpp b/src/Gui/propertyeditor/PropertyModel.cpp index 960ae6448..05c9e06a5 100644 --- a/src/Gui/propertyeditor/PropertyModel.cpp +++ b/src/Gui/propertyeditor/PropertyModel.cpp @@ -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) From 39b2b731f8822fbee493be6f720454d660d0a365 Mon Sep 17 00:00:00 2001 From: jrheinlaender Date: Mon, 25 Mar 2013 15:32:05 +0430 Subject: [PATCH 05/17] Changes to FEM constraint visuals for float->double move --- src/Mod/Fem/App/FemConstraint.cpp | 4 +- src/Mod/Fem/App/FemConstraint.h | 4 +- src/Mod/Fem/App/FemConstraintBearing.cpp | 4 +- src/Mod/Fem/Gui/TaskFemConstraintBearing.cpp | 2 +- src/Mod/Fem/Gui/TaskFemConstraintForce.cpp | 2 +- src/Mod/Fem/Gui/TaskFemConstraintGear.cpp | 6 +-- src/Mod/Fem/Gui/TaskFemConstraintPulley.cpp | 6 +-- .../Fem/Gui/ViewProviderFemConstraintGear.cpp | 16 ++++---- .../Gui/ViewProviderFemConstraintPulley.cpp | 40 +++++++++---------- 9 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/Mod/Fem/App/FemConstraint.cpp b/src/Mod/Fem/App/FemConstraint.cpp index 86f2288a5..ea180d645 100644 --- a/src/Mod/Fem/App/FemConstraint.cpp +++ b/src/Mod/Fem/App/FemConstraint.cpp @@ -225,7 +225,7 @@ const bool Constraint::getPoints(std::vector &points, std::vecto return true; } -const bool Constraint::getCylinder(float& radius, float& height, Base::Vector3d& base, Base::Vector3d& axis) const +const bool Constraint::getCylinder(double &radius, double &height, Base::Vector3d& base, Base::Vector3d& axis) const { std::vector Objects = References.getValues(); std::vector SubElements = References.getSubValues(); @@ -255,7 +255,7 @@ const bool Constraint::getCylinder(float& radius, float& height, Base::Vector3d& } Base::Vector3d Constraint::getBasePoint(const Base::Vector3d& base, const Base::Vector3d& axis, - const App::PropertyLinkSub& location, const float& dist) + const App::PropertyLinkSub& location, const double& dist) { // Get the point specified by Location and Distance App::DocumentObject* objLoc = location.getValue(); diff --git a/src/Mod/Fem/App/FemConstraint.h b/src/Mod/Fem/App/FemConstraint.h index 693b5be96..a0ba40911 100644 --- a/src/Mod/Fem/App/FemConstraint.h +++ b/src/Mod/Fem/App/FemConstraint.h @@ -60,9 +60,9 @@ protected: protected: /// Calculate the points where symbols should be drawn const bool getPoints(std::vector& points, std::vector& normals) const; - const bool getCylinder(float& radius, float& height, Base::Vector3d& base, Base::Vector3d& axis) 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 float& dist); + const App::PropertyLinkSub &location, const double& dist); const Base::Vector3d getDirection(const App::PropertyLinkSub &direction); }; diff --git a/src/Mod/Fem/App/FemConstraintBearing.cpp b/src/Mod/Fem/App/FemConstraintBearing.cpp index 6e3b4e63a..5eab9e8b5 100644 --- a/src/Mod/Fem/App/FemConstraintBearing.cpp +++ b/src/Mod/Fem/App/FemConstraintBearing.cpp @@ -70,7 +70,7 @@ void ConstraintBearing::onChanged(const App::Property* prop) if (prop == &References) { // Find data of cylinder - float radius, height; + double radius, height; Base::Vector3d base, axis; if (!getCylinder(radius, height, base, axis)) return; @@ -106,7 +106,7 @@ void ConstraintBearing::onChanged(const App::Property* prop) } } - float radius, height; + double radius, height; Base::Vector3d base, axis; if (!getCylinder(radius, height, base, axis)) return; diff --git a/src/Mod/Fem/Gui/TaskFemConstraintBearing.cpp b/src/Mod/Fem/Gui/TaskFemConstraintBearing.cpp index cf98b3003..ba15669b6 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintBearing.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintBearing.cpp @@ -225,7 +225,7 @@ void TaskFemConstraintBearing::onSelectionChanged(const Gui::SelectionChanges& m void TaskFemConstraintBearing::onDistanceChanged(double l) { Fem::ConstraintBearing* pcConstraint = static_cast(ConstraintView->getObject()); - pcConstraint->Dist.setValue((float)l); + pcConstraint->Dist.setValue(l); } void TaskFemConstraintBearing::onReferenceDeleted() { diff --git a/src/Mod/Fem/Gui/TaskFemConstraintForce.cpp b/src/Mod/Fem/Gui/TaskFemConstraintForce.cpp index 8a51a99e4..5d58026d8 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintForce.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintForce.cpp @@ -232,7 +232,7 @@ void TaskFemConstraintForce::onSelectionChanged(const Gui::SelectionChanges& msg void TaskFemConstraintForce::onForceChanged(double f) { Fem::ConstraintForce* pcConstraint = static_cast(ConstraintView->getObject()); - pcConstraint->Force.setValue((float)f); + pcConstraint->Force.setValue(f); } void TaskFemConstraintForce::onReferenceDeleted() { diff --git a/src/Mod/Fem/Gui/TaskFemConstraintGear.cpp b/src/Mod/Fem/Gui/TaskFemConstraintGear.cpp index 4f4f3adf9..ad36e01d3 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintGear.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintGear.cpp @@ -177,19 +177,19 @@ void TaskFemConstraintGear::onSelectionChanged(const Gui::SelectionChanges& msg) void TaskFemConstraintGear::onDiameterChanged(double l) { Fem::ConstraintGear* pcConstraint = static_cast(ConstraintView->getObject()); - pcConstraint->Diameter.setValue((float)l); + pcConstraint->Diameter.setValue(l); } void TaskFemConstraintGear::onForceChanged(double f) { Fem::ConstraintGear* pcConstraint = static_cast(ConstraintView->getObject()); - pcConstraint->Force.setValue((float)f); + pcConstraint->Force.setValue(f); } void TaskFemConstraintGear::onForceAngleChanged(double a) { Fem::ConstraintGear* pcConstraint = static_cast(ConstraintView->getObject()); - pcConstraint->ForceAngle.setValue((float)a); + pcConstraint->ForceAngle.setValue(a); } void TaskFemConstraintGear::onButtonDirection(const bool pressed) { diff --git a/src/Mod/Fem/Gui/TaskFemConstraintPulley.cpp b/src/Mod/Fem/Gui/TaskFemConstraintPulley.cpp index e6d7c55ce..365ba9490 100644 --- a/src/Mod/Fem/Gui/TaskFemConstraintPulley.cpp +++ b/src/Mod/Fem/Gui/TaskFemConstraintPulley.cpp @@ -109,19 +109,19 @@ TaskFemConstraintPulley::TaskFemConstraintPulley(ViewProviderFemConstraintPulley void TaskFemConstraintPulley::onOtherDiameterChanged(double l) { Fem::ConstraintPulley* pcConstraint = static_cast(ConstraintView->getObject()); - pcConstraint->OtherDiameter.setValue((float)l); + pcConstraint->OtherDiameter.setValue(l); } void TaskFemConstraintPulley::onCenterDistanceChanged(double l) { Fem::ConstraintPulley* pcConstraint = static_cast(ConstraintView->getObject()); - pcConstraint->CenterDistance.setValue((float)l); + pcConstraint->CenterDistance.setValue(l); } void TaskFemConstraintPulley::onTensionForceChanged(double force) { Fem::ConstraintPulley* pcConstraint = static_cast(ConstraintView->getObject()); - pcConstraint->TensionForce.setValue((float)force); + pcConstraint->TensionForce.setValue(force); } void TaskFemConstraintPulley::onCheckIsDriven(const bool pressed) diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.cpp index fc246a006..8ae1e7bcf 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintGear.cpp @@ -119,11 +119,11 @@ void ViewProviderFemConstraintGear::updateData(const App::Property* prop) Base::Vector3d direction = pcConstraint->DirectionVector.getValue(); if (direction.Length() < Precision::Confusion()) direction = Base::Vector3d(0,1,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 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); @@ -142,11 +142,11 @@ void ViewProviderFemConstraintGear::updateData(const App::Property* prop) Base::Vector3d direction = pcConstraint->DirectionVector.getValue(); if (direction.Length() < Precision::Confusion()) direction = Base::Vector3d(0,1,0); - float dia = pcConstraint->Diameter.getValue(); - float radius = pcConstraint->Radius.getValue(); + 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); @@ -165,8 +165,8 @@ void ViewProviderFemConstraintGear::updateData(const App::Property* prop) Base::Vector3d direction = pcConstraint->DirectionVector.getValue(); if (direction.Length() < Precision::Confusion()) direction = Base::Vector3d(0,1,0); - float dia = pcConstraint->Diameter.getValue(); - float angle = pcConstraint->ForceAngle.getValue() / 180 * M_PI; + 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); diff --git a/src/Mod/Fem/Gui/ViewProviderFemConstraintPulley.cpp b/src/Mod/Fem/Gui/ViewProviderFemConstraintPulley.cpp index 100ef72d6..5f5401c9a 100644 --- a/src/Mod/Fem/Gui/ViewProviderFemConstraintPulley.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemConstraintPulley.cpp @@ -116,15 +116,15 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop) // This should always point outside of the cylinder Base::Vector3d base = pcConstraint->BasePoint.getValue(); Base::Vector3d axis = pcConstraint->Axis.getValue(); - 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); @@ -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(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); From 67a518083d31645050ff75970167fc83197cfcb4 Mon Sep 17 00:00:00 2001 From: jrheinlaender Date: Mon, 25 Mar 2013 15:33:12 +0430 Subject: [PATCH 06/17] Suggested changes for float -> double move --- src/Mod/Cam/App/AppCamPy.cpp | 2 +- src/Mod/Drawing/App/FeatureViewPart.cpp | 6 +++--- src/Mod/Fem/Gui/ViewProviderFemMesh.cpp | 16 ++++++++-------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Mod/Cam/App/AppCamPy.cpp b/src/Mod/Cam/App/AppCamPy.cpp index 4732881c0..7ed919260 100644 --- a/src/Mod/Cam/App/AppCamPy.cpp +++ b/src/Mod/Cam/App/AppCamPy.cpp @@ -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; diff --git a/src/Mod/Drawing/App/FeatureViewPart.cpp b/src/Mod/Drawing/App/FeatureViewPart.cpp index 9a5eea4d0..1c99ff63d 100644 --- a/src/Mod/Drawing/App/FeatureViewPart.cpp +++ b/src/Mod/Drawing/App/FeatureViewPart.cpp @@ -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); } diff --git a/src/Mod/Fem/Gui/ViewProviderFemMesh.cpp b/src/Mod/Fem/Gui/ViewProviderFemMesh.cpp index bb209ba7a..ff7491fe1 100755 --- a/src/Mod/Fem/Gui/ViewProviderFemMesh.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemMesh.cpp @@ -160,7 +160,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() { @@ -445,8 +445,8 @@ std::vector ViewProviderFemMesh::getSelectionShape(const char* E return std::vector(); } -void ViewProviderFemMesh::setHighlightNodes(const std::set& HighlightedNodes) -{ +void ViewProviderFemMesh::setHighlightNodes(const std::set& HighlightedNodes) +{ if(HighlightedNodes.size()){ const Fem::PropertyFemMesh* mesh = &(dynamic_cast(this->pcObject)->FemMesh); @@ -465,11 +465,11 @@ void ViewProviderFemMesh::setHighlightNodes(const std::set& HighlightedNod pcAnoCoords->point.setNum(0); } -} -void ViewProviderFemMesh::resetHighlightNodes(void) -{ - pcAnoCoords->point.setNum(0); -} +} +void ViewProviderFemMesh::resetHighlightNodes(void) +{ + pcAnoCoords->point.setNum(0); +} // ---------------------------------------------------------------------------- From 4c0781a555df99ebba2c7738f45a7aa31fea9401 Mon Sep 17 00:00:00 2001 From: jrheinlaender Date: Mon, 25 Mar 2013 17:15:21 +0430 Subject: [PATCH 07/17] Suggestions for Part module moving float -> double --- src/Mod/Part/App/FeatureExtrusion.cpp | 4 +- src/Mod/Part/App/FeatureRevolution.cpp | 6 +- src/Mod/Part/App/ParabolaPyImp.cpp | 2 +- src/Mod/Part/App/PrimitiveFeature.cpp | 136 +++++++++++----------- src/Mod/Part/App/TopoShapeFacePyImp.cpp | 50 ++++---- src/Mod/Part/App/TopoShapeVertexPyImp.cpp | 14 +-- src/Mod/Part/App/TopoShapeWirePyImp.cpp | 2 +- src/Mod/Part/Gui/TaskOffset.cpp | 4 +- src/Mod/Part/Gui/TaskThickness.cpp | 4 +- src/Mod/Part/Gui/ViewProvider.cpp | 48 ++++---- src/Mod/Part/Gui/ViewProviderExt.cpp | 4 +- 11 files changed, 137 insertions(+), 137 deletions(-) diff --git a/src/Mod/Part/App/FeatureExtrusion.cpp b/src/Mod/Part/App/FeatureExtrusion.cpp index 8f3a205c8..7c4605a8a 100644 --- a/src/Mod/Part/App/FeatureExtrusion.cpp +++ b/src/Mod/Part/App/FeatureExtrusion.cpp @@ -55,7 +55,7 @@ PROPERTY_SOURCE(Part::Extrusion, Part::Feature) Extrusion::Extrusion() { ADD_PROPERTY(Base,(0)); - ADD_PROPERTY(Dir,(Base::Vector3d(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.0)); } @@ -81,7 +81,7 @@ App::DocumentObjectExecReturn *Extrusion::execute(void) 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 { diff --git a/src/Mod/Part/App/FeatureRevolution.cpp b/src/Mod/Part/App/FeatureRevolution.cpp index 846d7badd..ddb96db07 100644 --- a/src/Mod/Part/App/FeatureRevolution.cpp +++ b/src/Mod/Part/App/FeatureRevolution.cpp @@ -32,15 +32,15 @@ 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::Vector3d(0.0f,0.0f,0.0f))); - ADD_PROPERTY(Axis,(Base::Vector3d(0.0f,0.0f,1.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); } diff --git a/src/Mod/Part/App/ParabolaPyImp.cpp b/src/Mod/Part/App/ParabolaPyImp.cpp index 191df05f4..14adc3ef0 100644 --- a/src/Mod/Part/App/ParabolaPyImp.cpp +++ b/src/Mod/Part/App/ParabolaPyImp.cpp @@ -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; diff --git a/src/Mod/Part/App/PrimitiveFeature.cpp b/src/Mod/Part/App/PrimitiveFeature.cpp index c2e818a52..2bd0cd618 100644 --- a/src/Mod/Part/App/PrimitiveFeature.cpp +++ b/src/Mod/Part/App/PrimitiveFeature.cpp @@ -68,11 +68,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; @@ -164,69 +164,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) diff --git a/src/Mod/Part/App/TopoShapeFacePyImp.cpp b/src/Mod/Part/App/TopoShapeFacePyImp.cpp index b0460a580..7bb261dbe 100644 --- a/src/Mod/Part/App/TopoShapeFacePyImp.cpp +++ b/src/Mod/Part/App/TopoShapeFacePyImp.cpp @@ -22,34 +22,34 @@ #include "PreCompiled.h" -#ifndef _PreComp_ -# include -# include -# include -# include -# include -# include -# include -# include +#ifndef _PreComp_ +# include +# include +# include +# include +# include +# include +# include +# include # include # include -# include -# include -# include +# include +# include +# include # include # include # include # include -# include -# include -# include -# include -# include -# include +# include +# include +# include +# include +# include +# include # include # include # include -#endif +#endif #include #include @@ -100,7 +100,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(pW)->getTopoShapePtr()->_Shape; if (sh.IsNull()) { @@ -116,17 +116,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(); @@ -241,7 +241,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); diff --git a/src/Mod/Part/App/TopoShapeVertexPyImp.cpp b/src/Mod/Part/App/TopoShapeVertexPyImp.cpp index 013a5167c..9be1003bf 100644 --- a/src/Mod/Part/App/TopoShapeVertexPyImp.cpp +++ b/src/Mod/Part/App/TopoShapeVertexPyImp.cpp @@ -23,10 +23,10 @@ #include "PreCompiled.h" -#ifndef _PreComp_ -# include -# include -# include +#ifndef _PreComp_ +# include +# include +# include # include # include # include @@ -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&) { diff --git a/src/Mod/Part/App/TopoShapeWirePyImp.cpp b/src/Mod/Part/App/TopoShapeWirePyImp.cpp index 0011e2198..3ed758c14 100644 --- a/src/Mod/Part/App/TopoShapeWirePyImp.cpp +++ b/src/Mod/Part/App/TopoShapeWirePyImp.cpp @@ -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); diff --git a/src/Mod/Part/Gui/TaskOffset.cpp b/src/Mod/Part/Gui/TaskOffset.cpp index d288453f3..5da925303 100644 --- a/src/Mod/Part/Gui/TaskOffset.cpp +++ b/src/Mod/Part/Gui/TaskOffset.cpp @@ -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); } diff --git a/src/Mod/Part/Gui/TaskThickness.cpp b/src/Mod/Part/Gui/TaskThickness.cpp index 58ae38c4c..5a2370f67 100644 --- a/src/Mod/Part/Gui/TaskThickness.cpp +++ b/src/Mod/Part/Gui/TaskThickness.cpp @@ -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); } diff --git a/src/Mod/Part/Gui/ViewProvider.cpp b/src/Mod/Part/Gui/ViewProvider.cpp index ac9956fe5..3c2d57559 100644 --- a/src/Mod/Part/Gui/ViewProvider.cpp +++ b/src/Mod/Part/Gui/ViewProvider.cpp @@ -55,8 +55,8 @@ # include # include # include -# include -# include +# include +# include # include # include # include @@ -149,8 +149,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) { @@ -170,8 +170,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(); @@ -196,11 +196,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(); @@ -215,7 +215,7 @@ ViewProviderPartBase::~ViewProviderPartBase() pcPointMaterial->unref(); pcLineStyle->unref(); pcPointStyle->unref(); - pShapeHints->unref(); + pShapeHints->unref(); } void ViewProviderPartBase::onChanged(const App::Property* prop) @@ -265,12 +265,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); } @@ -346,7 +346,7 @@ std::vector ViewProviderPartBase::getDisplayModes(void) const return StrList; } - + void ViewProviderPartBase::shapeInfoCallback(void * ud, SoEventCallback * n) { const SoMouseButtonEvent * mbe = (SoMouseButtonEvent *)n->getEvent(); @@ -901,7 +901,7 @@ void ViewProviderPartBase::showControlPoints(bool show, const App::Property* pro { if (!pcControlPoints && show) { pcControlPoints = new SoSwitch(); - pcRoot->addChild(pcControlPoints); + pcRoot->addChild(pcControlPoints); } if (pcControlPoints) { @@ -1152,12 +1152,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(object)->Angle1.getValue(); - float angle2 = static_cast(object)->Angle2.getValue(); - float angle3 = static_cast(object)->Angle3.getValue(); + double angle1 = static_cast(object)->Angle1.getValue(); + double angle2 = static_cast(object)->Angle2.getValue(); + double angle3 = static_cast(object)->Angle3.getValue(); float radius1 = static_cast(object)->Radius1.getValue(); float radius2 = static_cast(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); diff --git a/src/Mod/Part/Gui/ViewProviderExt.cpp b/src/Mod/Part/Gui/ViewProviderExt.cpp index 7dc155b08..765cd2d17 100644 --- a/src/Mod/Part/Gui/ViewProviderExt.cpp +++ b/src/Mod/Part/Gui/ViewProviderExt.cpp @@ -116,8 +116,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}; From 8df84e76c46f335f6c73ca0b77ef1eac175f0f76 Mon Sep 17 00:00:00 2001 From: jrheinlaender Date: Mon, 25 Mar 2013 17:42:29 +0430 Subject: [PATCH 08/17] PartDesign module moving float -> double --- src/Mod/PartDesign/App/FeatureChamfer.cpp | 8 ++++---- src/Mod/PartDesign/App/FeatureDraft.cpp | 6 +++--- src/Mod/PartDesign/App/FeatureFillet.cpp | 8 ++++---- src/Mod/PartDesign/App/FeatureLinearPattern.cpp | 2 +- src/Mod/PartDesign/App/FeaturePolarPattern.cpp | 4 ++-- src/Mod/PartDesign/App/FeatureRevolution.cpp | 6 +++--- src/Mod/PartDesign/Gui/TaskChamferParameters.cpp | 2 +- src/Mod/PartDesign/Gui/TaskDraftParameters.cpp | 2 +- src/Mod/PartDesign/Gui/TaskFilletParameters.cpp | 2 +- src/Mod/PartDesign/Gui/TaskGrooveParameters.cpp | 4 ++-- src/Mod/PartDesign/Gui/TaskPadParameters.cpp | 12 ++++++------ src/Mod/PartDesign/Gui/TaskPocketParameters.cpp | 10 +++++----- src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp | 4 ++-- 13 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/Mod/PartDesign/App/FeatureChamfer.cpp b/src/Mod/PartDesign/App/FeatureChamfer.cpp index 42d82b923..cd16bd306 100644 --- a/src/Mod/PartDesign/App/FeatureChamfer.cpp +++ b/src/Mod/PartDesign/App/FeatureChamfer.cpp @@ -41,12 +41,12 @@ using namespace PartDesign; PROPERTY_SOURCE(PartDesign::Chamfer, PartDesign::DressUp) - -const App::PropertyFloatConstraint::Constraints floatSize = {0.0f,FLT_MAX,0.1f}; + +const App::PropertyFloatConstraint::Constraints floatSize = {0.0,FLT_MAX,0.1}; Chamfer::Chamfer() { - ADD_PROPERTY(Size,(1.0f)); + ADD_PROPERTY(Size,(1.0)); Size.setConstraints(&floatSize); } @@ -73,7 +73,7 @@ App::DocumentObjectExecReturn *Chamfer::execute(void) if (SubVals.size() == 0) return new App::DocumentObjectExecReturn("No edges specified"); - float size = Size.getValue(); + double size = Size.getValue(); this->positionByBase(); // create an untransformed copy of the base shape diff --git a/src/Mod/PartDesign/App/FeatureDraft.cpp b/src/Mod/PartDesign/App/FeatureDraft.cpp index b2684efd3..b614afccc 100644 --- a/src/Mod/PartDesign/App/FeatureDraft.cpp +++ b/src/Mod/PartDesign/App/FeatureDraft.cpp @@ -61,11 +61,11 @@ using namespace PartDesign; PROPERTY_SOURCE(PartDesign::Draft, PartDesign::DressUp) -const App::PropertyFloatConstraint::Constraints floatAngle = {0.0f,89.99f,0.1f}; +const App::PropertyFloatConstraint::Constraints floatAngle = {0.0,89.9,0.1}; Draft::Draft() { - ADD_PROPERTY(Angle,(1.5f)); + ADD_PROPERTY(Angle,(1.5)); Angle.setConstraints(&floatAngle); ADD_PROPERTY_TYPE(NeutralPlane,(0),"Draft",(App::PropertyType)(App::Prop_None),"NeutralPlane"); ADD_PROPERTY_TYPE(PullDirection,(0),"Draft",(App::PropertyType)(App::Prop_None),"PullDirection"); @@ -104,7 +104,7 @@ App::DocumentObjectExecReturn *Draft::execute(void) return new App::DocumentObjectExecReturn("No faces specified"); // Draft angle - float angle = Angle.getValue() / 180.0 * M_PI; + double angle = Angle.getValue() / 180.0 * M_PI; // Pull direction gp_Dir pullDirection; diff --git a/src/Mod/PartDesign/App/FeatureFillet.cpp b/src/Mod/PartDesign/App/FeatureFillet.cpp index 8f9d8d3e8..7d6c1f2bb 100644 --- a/src/Mod/PartDesign/App/FeatureFillet.cpp +++ b/src/Mod/PartDesign/App/FeatureFillet.cpp @@ -39,11 +39,11 @@ using namespace PartDesign; PROPERTY_SOURCE(PartDesign::Fillet, PartDesign::DressUp) -const App::PropertyFloatConstraint::Constraints floatRadius = {0.0f,FLT_MAX,0.1f}; +const App::PropertyFloatConstraint::Constraints floatRadius = {0.0,FLT_MAX,0.1}; Fillet::Fillet() { - ADD_PROPERTY(Radius,(1.0f)); + ADD_PROPERTY(Radius,(1.0)); Radius.setConstraints(&floatRadius); } @@ -70,8 +70,8 @@ App::DocumentObjectExecReturn *Fillet::execute(void) if (SubVals.size() == 0) return new App::DocumentObjectExecReturn("No edges specified"); - float radius = Radius.getValue(); - + double radius = Radius.getValue(); + this->positionByBase(); // create an untransformed copy of the base shape Part::TopoShape baseShape(TopShape); diff --git a/src/Mod/PartDesign/App/FeatureLinearPattern.cpp b/src/Mod/PartDesign/App/FeatureLinearPattern.cpp index bcb8173f4..9841c4ccc 100644 --- a/src/Mod/PartDesign/App/FeatureLinearPattern.cpp +++ b/src/Mod/PartDesign/App/FeatureLinearPattern.cpp @@ -66,7 +66,7 @@ short LinearPattern::mustExecute() const const std::list LinearPattern::getTransformations(const std::vector) { - float distance = Length.getValue(); + double distance = Length.getValue(); if (distance < Precision::Confusion()) throw Base::Exception("Pattern length too small"); int occurrences = Occurrences.getValue(); diff --git a/src/Mod/PartDesign/App/FeaturePolarPattern.cpp b/src/Mod/PartDesign/App/FeaturePolarPattern.cpp index d9d49a046..e0906a29b 100644 --- a/src/Mod/PartDesign/App/FeaturePolarPattern.cpp +++ b/src/Mod/PartDesign/App/FeaturePolarPattern.cpp @@ -65,7 +65,7 @@ short PolarPattern::mustExecute() const const std::list PolarPattern::getTransformations(const std::vector) { - float angle = Angle.getValue(); + double angle = Angle.getValue(); if (angle < Precision::Confusion()) throw Base::Exception("Pattern angle too small"); int occurrences = Occurrences.getValue(); @@ -105,7 +105,7 @@ const std::list PolarPattern::getTransformations(const std::vectorgetAxis(AxId); } axis *= refSketch->Placement.getValue(); - axbase = gp_Pnt(axis.getBase().x, axis.getBase().y, axis.getBase().z); + axbase = gp_Pnt(axis.getBase().x, axis.getBase().y, axis.getBase().z); axdir = gp_Dir(axis.getDirection().x, axis.getDirection().y, axis.getDirection().z); } else { Part::Feature* refFeature = static_cast(refObject); diff --git a/src/Mod/PartDesign/App/FeatureRevolution.cpp b/src/Mod/PartDesign/App/FeatureRevolution.cpp index 72bbfa8e3..c0b180cc7 100644 --- a/src/Mod/PartDesign/App/FeatureRevolution.cpp +++ b/src/Mod/PartDesign/App/FeatureRevolution.cpp @@ -55,8 +55,8 @@ PROPERTY_SOURCE(PartDesign::Revolution, PartDesign::Additive) Revolution::Revolution() { - 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(Base,(Base::Vector3d(0.0,0.0,0.0)),"Revolution", App::Prop_ReadOnly, "Base"); + ADD_PROPERTY_TYPE(Axis,(Base::Vector3d(0.0,1.0,0.0)),"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"); } @@ -171,7 +171,7 @@ App::DocumentObjectExecReturn *Revolution::execute(void) return new App::DocumentObjectExecReturn(e.what()); } } - + bool Revolution::suggestReversed(void) { try { diff --git a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp index b081e5c09..24904730d 100644 --- a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp @@ -73,7 +73,7 @@ TaskChamferParameters::TaskChamferParameters(ViewProviderChamfer *ChamferView,QW void TaskChamferParameters::onLengthChanged(double len) { PartDesign::Chamfer* pcChamfer = static_cast(ChamferView->getObject()); - pcChamfer->Size.setValue((float)len); + pcChamfer->Size.setValue(len); pcChamfer->getDocument()->recomputeFeature(pcChamfer); } diff --git a/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp b/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp index 9b97971ea..20efc7e9e 100644 --- a/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp @@ -287,7 +287,7 @@ void TaskDraftParameters::showObject() void TaskDraftParameters::onAngleChanged(double angle) { PartDesign::Draft* pcDraft = static_cast(DraftView->getObject()); - pcDraft->Angle.setValue((float)angle); + pcDraft->Angle.setValue(angle); pcDraft->getDocument()->recomputeFeature(pcDraft); } diff --git a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp index 8050d8953..227e62d57 100644 --- a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp @@ -73,7 +73,7 @@ TaskFilletParameters::TaskFilletParameters(ViewProviderFillet *FilletView,QWidge void TaskFilletParameters::onLengthChanged(double len) { PartDesign::Fillet* pcFillet = static_cast(FilletView->getObject()); - pcFillet->Radius.setValue((float)len); + pcFillet->Radius.setValue(len); pcFillet->getDocument()->recomputeFeature(pcFillet); } diff --git a/src/Mod/PartDesign/Gui/TaskGrooveParameters.cpp b/src/Mod/PartDesign/Gui/TaskGrooveParameters.cpp index 8e3c1add2..07095d01c 100644 --- a/src/Mod/PartDesign/Gui/TaskGrooveParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskGrooveParameters.cpp @@ -124,7 +124,7 @@ TaskGrooveParameters::TaskGrooveParameters(ViewProviderGroove *GrooveView,QWidge void TaskGrooveParameters::onAngleChanged(double len) { PartDesign::Groove* pcGroove = static_cast(GrooveView->getObject()); - pcGroove->Angle.setValue((float)len); + pcGroove->Angle.setValue(len); if (updateView()) pcGroove->getDocument()->recomputeFeature(pcGroove); } @@ -187,7 +187,7 @@ void TaskGrooveParameters::onUpdateView(bool on) { if (on) { PartDesign::Groove* pcGroove = static_cast(GrooveView->getObject()); - pcGroove->getDocument()->recomputeFeature(pcGroove); + pcGroove->getDocument()->recomputeFeature(pcGroove); } } diff --git a/src/Mod/PartDesign/Gui/TaskPadParameters.cpp b/src/Mod/PartDesign/Gui/TaskPadParameters.cpp index e47ae2d78..f3c213a29 100644 --- a/src/Mod/PartDesign/Gui/TaskPadParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPadParameters.cpp @@ -235,7 +235,7 @@ void TaskPadParameters::onSelectionChanged(const Gui::SelectionChanges& msg) void TaskPadParameters::onLengthChanged(double len) { PartDesign::Pad* pcPad = static_cast(PadView->getObject()); - pcPad->Length.setValue((float)len); + pcPad->Length.setValue(len); if (updateView()) pcPad->getDocument()->recomputeFeature(pcPad); } @@ -260,7 +260,7 @@ void TaskPadParameters::onReversed(bool on) void TaskPadParameters::onLength2Changed(double len) { PartDesign::Pad* pcPad = static_cast(PadView->getObject()); - pcPad->Length2.setValue((float)len); + pcPad->Length2.setValue(len); if (updateView()) pcPad->getDocument()->recomputeFeature(pcPad); } @@ -412,15 +412,15 @@ void TaskPadParameters::changeEvent(QEvent *e) ui->changeMode->addItem(tr("Up to face")); ui->changeMode->addItem(tr("Two dimensions")); ui->changeMode->setCurrentIndex(index); - - QByteArray upToFace = this->getFaceName(); + + QByteArray upToFace = this->getFaceName(); int faceId = -1; bool ok = false; if (upToFace.indexOf("Face") == 0) { faceId = upToFace.remove(0,4).toInt(&ok); } - ui->lineFaceName->setText(ok ? - tr("Face") + QString::number(faceId) : + ui->lineFaceName->setText(ok ? + tr("Face") + QString::number(faceId) : tr("No face selected")); ui->doubleSpinBox->blockSignals(false); ui->doubleSpinBox2->blockSignals(false); diff --git a/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp b/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp index 152943a5a..ceb913666 100644 --- a/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp @@ -215,7 +215,7 @@ void TaskPocketParameters::onSelectionChanged(const Gui::SelectionChanges& msg) void TaskPocketParameters::onLengthChanged(double len) { PartDesign::Pocket* pcPocket = static_cast(PocketView->getObject()); - pcPocket->Length.setValue((float)len); + pcPocket->Length.setValue(len); if (updateView()) pcPocket->getDocument()->recomputeFeature(pcPocket); } @@ -374,15 +374,15 @@ void TaskPocketParameters::changeEvent(QEvent *e) ui->changeMode->addItem(tr("To first")); ui->changeMode->addItem(tr("Up to face")); ui->changeMode->setCurrentIndex(index); - - QByteArray upToFace = this->getFaceName(); + + QByteArray upToFace = this->getFaceName(); int faceId = -1; bool ok = false; if (upToFace.indexOf("Face") == 0) { faceId = upToFace.remove(0,4).toInt(&ok); } - ui->lineFaceName->setText(ok ? - tr("Face") + QString::number(faceId) : + ui->lineFaceName->setText(ok ? + tr("Face") + QString::number(faceId) : tr("No face selected")); ui->doubleSpinBox->blockSignals(false); ui->lineFaceName->blockSignals(false); diff --git a/src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp b/src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp index abbf000c4..a666fcee0 100644 --- a/src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp @@ -124,7 +124,7 @@ TaskRevolutionParameters::TaskRevolutionParameters(ViewProviderRevolution *Revol void TaskRevolutionParameters::onAngleChanged(double len) { PartDesign::Revolution* pcRevolution = static_cast(RevolutionView->getObject()); - pcRevolution->Angle.setValue((float)len); + pcRevolution->Angle.setValue(len); if (updateView()) pcRevolution->getDocument()->recomputeFeature(pcRevolution); } @@ -187,7 +187,7 @@ void TaskRevolutionParameters::onUpdateView(bool on) { if (on) { PartDesign::Revolution* pcRevolution = static_cast(RevolutionView->getObject()); - pcRevolution->getDocument()->recomputeFeature(pcRevolution); + pcRevolution->getDocument()->recomputeFeature(pcRevolution); } } From 50c9ea219d8552f809a7c7846ed8f7c3ee6c29a7 Mon Sep 17 00:00:00 2001 From: jrheinlaender Date: Mon, 25 Mar 2013 19:45:37 +0430 Subject: [PATCH 09/17] Moved Gui/InputVector,Placement,Transform from float to double --- src/Gui/InputVector.cpp | 56 +++++++++---------- src/Gui/InputVector.h | 86 +++++++++++++++--------------- src/Gui/Placement.cpp | 32 +++++------ src/Gui/Placement.h | 2 +- src/Gui/Transform.cpp | 8 +-- src/Gui/Transform.h | 2 +- src/Mod/Part/Gui/CommandSimple.cpp | 6 +-- src/Mod/Part/Gui/DlgPrimitives.cpp | 8 +-- src/Mod/Part/Gui/DlgRevolution.cpp | 8 +-- src/Mod/Part/Gui/DlgRevolution.h | 2 +- 10 files changed, 105 insertions(+), 105 deletions(-) diff --git a/src/Gui/InputVector.cpp b/src/Gui/InputVector.cpp index de8683dfc..58359f988 100644 --- a/src/Gui/InputVector.cpp +++ b/src/Gui/InputVector.cpp @@ -105,10 +105,10 @@ void LocationWidget::retranslateUi() dValue->setCurrentIndex(2); - // Vector3f declared to use with QVariant see Gui/propertyeditor/PropertyItem.h - dValue->setItemData(0, QVariant::fromValue(Base::Vector3f(1,0,0))); - dValue->setItemData(1, QVariant::fromValue(Base::Vector3f(0,1,0))); - dValue->setItemData(2, QVariant::fromValue(Base::Vector3f(0,0,1))); + // Vector3d declared to use with QVariant see Gui/propertyeditor/PropertyItem.h + dValue->setItemData(0, QVariant::fromValue(Base::Vector3d(1,0,0))); + dValue->setItemData(1, QVariant::fromValue(Base::Vector3d(0,1,0))); + dValue->setItemData(2, QVariant::fromValue(Base::Vector3d(0,0,1))); } else { dValue->setItemText(0, QApplication::translate("Gui::LocationDialog", "X")); @@ -119,21 +119,21 @@ void LocationWidget::retranslateUi() } } -Base::Vector3f LocationWidget::getPosition() const +Base::Vector3d LocationWidget::getPosition() const { - return Base::Vector3f((float)this->xValue->value(), - (float)this->yValue->value(), - (float)this->zValue->value()); + return Base::Vector3d(this->xValue->value(), + this->yValue->value(), + this->zValue->value()); } -void LocationWidget::setPosition(const Base::Vector3f& v) +void LocationWidget::setPosition(const Base::Vector3d& v) { this->xValue->setValue(v.x); this->yValue->setValue(v.y); this->zValue->setValue(v.z); } -void LocationWidget::setDirection(const Base::Vector3f& dir) +void LocationWidget::setDirection(const Base::Vector3d& dir) { if (dir.Length() < FLT_EPSILON) { return; @@ -142,8 +142,8 @@ void LocationWidget::setDirection(const Base::Vector3f& dir) // check if the user-defined direction is already there for (int i=0; icount()-1; i++) { QVariant data = dValue->itemData (i); - if (data.canConvert()) { - const Base::Vector3f val = data.value(); + if (data.canConvert()) { + const Base::Vector3d val = data.value(); if (val == dir) { dValue->setCurrentIndex(i); return; @@ -157,31 +157,31 @@ void LocationWidget::setDirection(const Base::Vector3f& dir) .arg(dir.y) .arg(dir.z); dValue->insertItem(dValue->count()-1, display, - QVariant::fromValue(dir)); + QVariant::fromValue(dir)); dValue->setCurrentIndex(dValue->count()-2); } -Base::Vector3f LocationWidget::getDirection() const +Base::Vector3d LocationWidget::getDirection() const { QVariant data = dValue->itemData (this->dValue->currentIndex()); - if (data.canConvert()) { - return data.value(); + if (data.canConvert()) { + return data.value(); } else { - return Base::Vector3f(0,0,1); + return Base::Vector3d(0,0,1); } } -Base::Vector3f LocationWidget::getUserDirection(bool* ok) const +Base::Vector3d LocationWidget::getUserDirection(bool* ok) const { Gui::Dialog::Ui_InputVector iv; QDialog dlg(const_cast(this)); iv.setupUi(&dlg); - Base::Vector3f dir; + Base::Vector3d dir; if (dlg.exec()) { - dir.x = (float)iv.vectorX->value(); - dir.y = (float)iv.vectorY->value(); - dir.z = (float)iv.vectorZ->value(); + dir.x = iv.vectorX->value(); + dir.y = iv.vectorY->value(); + dir.z = iv.vectorZ->value(); if (ok) *ok = true; } else { @@ -196,7 +196,7 @@ void LocationWidget::on_direction_activated(int index) // last item is selected to define direction by user if (index+1 == dValue->count()) { bool ok; - Base::Vector3f dir = this->getUserDirection(&ok); + Base::Vector3d dir = this->getUserDirection(&ok); if (ok) { if (dir.Length() < FLT_EPSILON) { QMessageBox::critical(this, LocationDialog::tr("Wrong direction"), @@ -220,16 +220,16 @@ LocationDialog::~LocationDialog() { } -Base::Vector3f LocationDialog::getUserDirection(bool* ok) const +Base::Vector3d LocationDialog::getUserDirection(bool* ok) const { Gui::Dialog::Ui_InputVector iv; QDialog dlg(const_cast(this)); iv.setupUi(&dlg); - Base::Vector3f dir; + Base::Vector3d dir; if (dlg.exec()) { - dir.x = (float)iv.vectorX->value(); - dir.y = (float)iv.vectorY->value(); - dir.z = (float)iv.vectorZ->value(); + dir.x = iv.vectorX->value(); + dir.y = iv.vectorY->value(); + dir.z = iv.vectorZ->value(); if (ok) *ok = true; } else { diff --git a/src/Gui/InputVector.h b/src/Gui/InputVector.h index bdb9036d9..bd9d41f99 100644 --- a/src/Gui/InputVector.h +++ b/src/Gui/InputVector.h @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include @@ -46,11 +46,11 @@ public: virtual ~LocationWidget(); QSize sizeHint() const; - Base::Vector3f getPosition() const; - void setPosition(const Base::Vector3f&); - void setDirection(const Base::Vector3f& dir); - Base::Vector3f getDirection() const; - Base::Vector3f getUserDirection(bool* ok=0) const; + Base::Vector3d getPosition() const; + void setPosition(const Base::Vector3d&); + void setDirection(const Base::Vector3d& dir); + Base::Vector3d getDirection() const; + Base::Vector3d getUserDirection(bool* ok=0) const; private Q_SLOTS: void on_direction_activated(int); @@ -90,8 +90,8 @@ private Q_SLOTS: void on_direction_activated(int); public: - virtual Base::Vector3f getDirection() const = 0; - Base::Vector3f getUserDirection(bool* ok=0) const; + virtual Base::Vector3d getDirection() const = 0; + Base::Vector3d getUserDirection(bool* ok=0) const; private: virtual void directionActivated(int) = 0; @@ -135,10 +135,10 @@ public: this->direction->setCurrentIndex(2); - // Vector3f declared to use with QVariant see Gui/propertyeditor/PropertyItem.h - this->direction->setItemData(0, QVariant::fromValue(Base::Vector3f(1,0,0))); - this->direction->setItemData(1, QVariant::fromValue(Base::Vector3f(0,1,0))); - this->direction->setItemData(2, QVariant::fromValue(Base::Vector3f(0,0,1))); + // Vector3d declared to use with QVariant see Gui/propertyeditor/PropertyItem.h + this->direction->setItemData(0, QVariant::fromValue(Base::Vector3d(1,0,0))); + this->direction->setItemData(1, QVariant::fromValue(Base::Vector3d(0,1,0))); + this->direction->setItemData(2, QVariant::fromValue(Base::Vector3d(0,0,1))); } else { this->direction->setItemText(0, QApplication::translate("Gui::LocationDialog", "X", 0, @@ -153,21 +153,21 @@ public: } } - Base::Vector3f getPosition() const + Base::Vector3d getPosition() const { - return Base::Vector3f((float)this->xPos->value(), - (float)this->yPos->value(), - (float)this->zPos->value()); + return Base::Vector3d(this->xPos->value(), + this->yPos->value(), + this->zPos->value()); } - Base::Vector3f getDirection() const + Base::Vector3d getDirection() const { QVariant data = this->direction->itemData (this->direction->currentIndex()); - if (data.canConvert()) { - return data.value(); + if (data.canConvert()) { + return data.value(); } else { - return Base::Vector3f(0,0,1); + return Base::Vector3d(0,0,1); } } @@ -188,7 +188,7 @@ private: // last item is selected to define direction by user if (index+1 == this->direction->count()) { bool ok; - Base::Vector3f dir = this->getUserDirection(&ok); + Base::Vector3d dir = this->getUserDirection(&ok); if (ok) { if (dir.Length() < FLT_EPSILON) { QMessageBox::critical(this, LocationDialog::tr("Wrong direction"), @@ -199,8 +199,8 @@ private: // check if the user-defined direction is already there for (int i=0; idirection->count()-1; i++) { QVariant data = this->direction->itemData (i); - if (data.canConvert()) { - const Base::Vector3f val = data.value(); + if (data.canConvert()) { + const Base::Vector3d val = data.value(); if (val == dir) { this->direction->setCurrentIndex(i); return; @@ -214,7 +214,7 @@ private: .arg(dir.y) .arg(dir.z); this->direction->insertItem(this->direction->count()-1, display, - QVariant::fromValue(dir)); + QVariant::fromValue(dir)); this->direction->setCurrentIndex(this->direction->count()-2); } } @@ -257,10 +257,10 @@ public: this->direction->setCurrentIndex(2); - // Vector3f declared to use with QVariant see Gui/propertyeditor/PropertyItem.h - this->direction->setItemData(0, QVariant::fromValue(Base::Vector3f(1,0,0))); - this->direction->setItemData(1, QVariant::fromValue(Base::Vector3f(0,1,0))); - this->direction->setItemData(2, QVariant::fromValue(Base::Vector3f(0,0,1))); + // Vector3d declared to use with QVariant see Gui/propertyeditor/PropertyItem.h + this->direction->setItemData(0, QVariant::fromValue(Base::Vector3d(1,0,0))); + this->direction->setItemData(1, QVariant::fromValue(Base::Vector3d(0,1,0))); + this->direction->setItemData(2, QVariant::fromValue(Base::Vector3d(0,0,1))); } else { this->direction->setItemText(0, QApplication::translate("Gui::LocationDialog", "X", 0, @@ -275,33 +275,33 @@ public: } } - void setPosition(const Base::Vector3f& v) + void setPosition(const Base::Vector3d& v) { this->xPos->setValue(v.x); this->yPos->setValue(v.y); this->zPos->setValue(v.z); } - Base::Vector3f getPosition() const + Base::Vector3d getPosition() const { - return Base::Vector3f((float)this->xPos->value(), - (float)this->yPos->value(), - (float)this->zPos->value()); + return Base::Vector3d(this->xPos->value(), + this->yPos->value(), + this->zPos->value()); } - Base::Vector3f getDirection() const + Base::Vector3d getDirection() const { QVariant data = this->direction->itemData (this->direction->currentIndex()); - if (data.canConvert()) { - return data.value(); + if (data.canConvert()) { + return data.value(); } else { - return Base::Vector3f(0,0,1); + return Base::Vector3d(0,0,1); } } public: - void setDirection(const Base::Vector3f& dir) + void setDirection(const Base::Vector3d& dir) { if (dir.Length() < FLT_EPSILON) { return; @@ -310,8 +310,8 @@ public: // check if the user-defined direction is already there for (int i=0; idirection->count()-1; i++) { QVariant data = this->direction->itemData (i); - if (data.canConvert()) { - const Base::Vector3f val = data.value(); + if (data.canConvert()) { + const Base::Vector3d val = data.value(); if (val == dir) { this->direction->setCurrentIndex(i); return; @@ -325,7 +325,7 @@ public: .arg(dir.y) .arg(dir.z); this->direction->insertItem(this->direction->count()-1, display, - QVariant::fromValue(dir)); + QVariant::fromValue(dir)); this->direction->setCurrentIndex(this->direction->count()-2); } bool directionActivated(LocationDialog* dlg, int index) @@ -333,7 +333,7 @@ public: // last item is selected to define direction by user if (index+1 == this->direction->count()) { bool ok; - Base::Vector3f dir = dlg->getUserDirection(&ok); + Base::Vector3d dir = dlg->getUserDirection(&ok); if (ok) { if (dir.Length() < FLT_EPSILON) { QMessageBox::critical(dlg, LocationDialog::tr("Wrong direction"), @@ -368,7 +368,7 @@ public: // no need to delete child widgets, Qt does it all for us } - Base::Vector3f getDirection() const + Base::Vector3d getDirection() const { return ui.getDirection(); } diff --git a/src/Gui/Placement.cpp b/src/Gui/Placement.cpp index 5697814e9..a6e2e9f0e 100644 --- a/src/Gui/Placement.cpp +++ b/src/Gui/Placement.cpp @@ -22,7 +22,7 @@ #include "PreCompiled.h" -#include +#include #include #include "Placement.h" @@ -314,7 +314,7 @@ void Placement::directionActivated(int index) } } -Base::Vector3f Placement::getDirection() const +Base::Vector3d Placement::getDirection() const { return ui->getDirection(); } @@ -343,11 +343,11 @@ void Placement::setPlacementData(const Base::Placement& p) Base::Vector3d axis; p.getRotation().getValue(axis, angle); ui->angle->setValue(angle*180.0/D_PI); - Base::Vector3f dir((float)axis.x,(float)axis.y,(float)axis.z); + Base::Vector3d dir(axis.x,axis.y,axis.z); for (int i=0; idirection->count()-1; i++) { QVariant data = ui->direction->itemData (i); - if (data.canConvert()) { - const Base::Vector3f val = data.value(); + if (data.canConvert()) { + const Base::Vector3d val = data.value(); if (val == dir) { ui->direction->setCurrentIndex(i); newitem = false; @@ -363,7 +363,7 @@ void Placement::setPlacementData(const Base::Placement& p) .arg(dir.y) .arg(dir.z); ui->direction->insertItem(ui->direction->count()-1, display, - QVariant::fromValue(dir)); + QVariant::fromValue(dir)); ui->direction->setCurrentIndex(ui->direction->count()-2); } signalMapper->blockSignals(false); @@ -386,7 +386,7 @@ Base::Placement Placement::getPlacementData() const cnt = Base::Vector3d(ui->xCnt->value(),ui->yCnt->value(),ui->zCnt->value()); if (index == 0) { - Base::Vector3f dir = getDirection(); + Base::Vector3d dir = getDirection(); rot.setValue(Base::Vector3d(dir.x,dir.y,dir.z),ui->angle->value()*D_PI/180.0); } else if (index == 1) { @@ -416,11 +416,11 @@ void Placement::changeEvent(QEvent *e) DockablePlacement::DockablePlacement(QWidget* parent, Qt::WFlags fl) : Placement(parent, fl) { - Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance(); + Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance(); QDockWidget* dw = pDockMgr->addDockWindow(QT_TR_NOOP("Placement"), this, Qt::BottomDockWidgetArea); - dw->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable); - dw->show(); + dw->setFeatures(QDockWidget::DockWidgetMovable|QDockWidget::DockWidgetFloatable); + dw->show(); } DockablePlacement::~DockablePlacement() @@ -429,17 +429,17 @@ DockablePlacement::~DockablePlacement() void DockablePlacement::accept() { - // closes the dock window - Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance(); - pDockMgr->removeDockWindow(this); + // closes the dock window + Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance(); + pDockMgr->removeDockWindow(this); Placement::accept(); } void DockablePlacement::reject() { - // closes the dock window - Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance(); - pDockMgr->removeDockWindow(this); + // closes the dock window + Gui::DockWindowManager* pDockMgr = Gui::DockWindowManager::instance(); + pDockMgr->removeDockWindow(this); Placement::reject(); } diff --git a/src/Gui/Placement.h b/src/Gui/Placement.h index 233284d1a..73fe656dd 100644 --- a/src/Gui/Placement.h +++ b/src/Gui/Placement.h @@ -50,7 +50,7 @@ public: void accept(); void reject(); - Base::Vector3f getDirection() const; + Base::Vector3d getDirection() const; void setPlacement(const Base::Placement&); Base::Placement getPlacement() const; void showDefaultButtons(bool); diff --git a/src/Gui/Transform.cpp b/src/Gui/Transform.cpp index d04cf9141..608e13e65 100644 --- a/src/Gui/Transform.cpp +++ b/src/Gui/Transform.cpp @@ -278,7 +278,7 @@ void DefaultTransformStrategy::onSelectionChanged(const Gui::SelectionChanges& m } if (!filter.empty()) { - std::set diff; + std::set diff; std::insert_iterator< std::set > biit(diff, diff.begin()); std::set_difference(update_selection.begin(), update_selection.end(), filter.begin(), filter.end(), biit); @@ -286,7 +286,7 @@ void DefaultTransformStrategy::onSelectionChanged(const Gui::SelectionChanges& m } // reset transform for all deselected objects - std::vector diff; + std::vector diff; std::back_insert_iterator< std::vector > biit(diff); std::set_difference(selection.begin(), selection.end(), update_selection.begin(), update_selection.end(), biit); @@ -408,7 +408,7 @@ void Transform::directionActivated(int index) } } -Base::Vector3f Transform::getDirection() const +Base::Vector3d Transform::getDirection() const { return ui->getDirection(); } @@ -424,7 +424,7 @@ Base::Placement Transform::getPlacementData() const cnt = Base::Vector3d(ui->xCnt->value(),ui->yCnt->value(),ui->zCnt->value()); if (index == 0) { - Base::Vector3f dir = getDirection(); + Base::Vector3d dir = getDirection(); rot.setValue(Base::Vector3d(dir.x,dir.y,dir.z),ui->angle->value()*D_PI/180.0); } else if (index == 1) { diff --git a/src/Gui/Transform.h b/src/Gui/Transform.h index d43eee0e4..042d4f691 100644 --- a/src/Gui/Transform.h +++ b/src/Gui/Transform.h @@ -79,7 +79,7 @@ public: void setTransformStrategy(TransformStrategy* ts); protected: - Base::Vector3f getDirection() const; + Base::Vector3d getDirection() const; void changeEvent(QEvent *e); public Q_SLOTS: diff --git a/src/Mod/Part/Gui/CommandSimple.cpp b/src/Mod/Part/Gui/CommandSimple.cpp index 252a3b1d0..23834e429 100644 --- a/src/Mod/Part/Gui/CommandSimple.cpp +++ b/src/Mod/Part/Gui/CommandSimple.cpp @@ -25,8 +25,8 @@ #ifndef _PreComp_ # include # include -# include -# include +# include +# include # include #endif @@ -66,7 +66,7 @@ void CmdPartSimpleCylinder::activated(int iMsg) { PartGui::DlgPartCylinderImp dlg(Gui::getMainWindow()); if (dlg.exec()== QDialog::Accepted) { - Base::Vector3f dir = dlg.getDirection(); + Base::Vector3d dir = dlg.getDirection(); openCommand("Create Part Cylinder"); doCommand(Doc,"from FreeCAD import Base"); doCommand(Doc,"import Part"); diff --git a/src/Mod/Part/Gui/DlgPrimitives.cpp b/src/Mod/Part/Gui/DlgPrimitives.cpp index 7ef822edf..daabaad51 100644 --- a/src/Mod/Part/Gui/DlgPrimitives.cpp +++ b/src/Mod/Part/Gui/DlgPrimitives.cpp @@ -641,8 +641,8 @@ void Location::pickCallback(void * ud, SoEventCallback * n) SbVec3f pnt = point->getPoint(); SbVec3f nor = point->getNormal(); Location* dlg = reinterpret_cast(ud); - dlg->ui.loc->setPosition(Base::Vector3f(pnt[0],pnt[1],pnt[2])); - dlg->ui.loc->setDirection(Base::Vector3f(nor[0],nor[1],nor[2])); + dlg->ui.loc->setPosition(Base::Vector3d(pnt[0],pnt[1],pnt[2])); + dlg->ui.loc->setDirection(Base::Vector3d(nor[0],nor[1],nor[2])); n->setHandled(); } } @@ -664,7 +664,7 @@ void Location::pickCallback(void * ud, SoEventCallback * n) QString Location::toPlacement() const { - Base::Vector3f d = ui.loc->getDirection(); + Base::Vector3d d = ui.loc->getDirection(); gp_Dir dir = gp_Dir(d.x,d.y,d.z); gp_Pnt pnt = gp_Pnt(0.0,0.0,0.0); gp_Ax3 ax3; @@ -707,7 +707,7 @@ QString Location::toPlacement() const Trf.GetRotation(theAxis,theAngle); Base::Rotation rot(Base::convertTo(theAxis), theAngle); - Base::Vector3f loc = ui.loc->getPosition(); + Base::Vector3d loc = ui.loc->getPosition(); return QString::fromAscii("Base.Placement(Base.Vector(%1,%2,%3),Base.Rotation(%4,%5,%6,%7))") .arg(loc.x,0,'f',2) diff --git a/src/Mod/Part/Gui/DlgRevolution.cpp b/src/Mod/Part/Gui/DlgRevolution.cpp index d0a04668d..221fdcb60 100644 --- a/src/Mod/Part/Gui/DlgRevolution.cpp +++ b/src/Mod/Part/Gui/DlgRevolution.cpp @@ -121,7 +121,7 @@ void DlgRevolution::directionActivated(int index) ui->directionActivated(this, index); } -Base::Vector3f DlgRevolution::getDirection() const +Base::Vector3d DlgRevolution::getDirection() const { return ui->getDirection(); } @@ -180,7 +180,7 @@ void DlgRevolution::accept() shape = (*it)->data(0, Qt::UserRole).toString(); type = QString::fromAscii("Part::Revolution"); name = QString::fromAscii(activeDoc->getUniqueObjectName("Revolve").c_str()); - Base::Vector3f axis = this->getDirection(); + Base::Vector3d axis = this->getDirection(); QString code = QString::fromAscii( "FreeCAD.ActiveDocument.addObject(\"%1\",\"%2\")\n" @@ -222,8 +222,8 @@ void DlgRevolution::onSelectionChanged(const Gui::SelectionChanges& msg) { if (msg.Type == Gui::SelectionChanges::AddSelection) { if (filter && filter->canSelect) { - ui->setPosition (Base::convertTo(filter->loc)); - ui->setDirection(Base::convertTo(filter->dir)); + ui->setPosition (Base::convertTo(filter->loc)); + ui->setDirection(Base::convertTo(filter->dir)); } } } diff --git a/src/Mod/Part/Gui/DlgRevolution.h b/src/Mod/Part/Gui/DlgRevolution.h index 8e4ebba50..7f3d648b8 100644 --- a/src/Mod/Part/Gui/DlgRevolution.h +++ b/src/Mod/Part/Gui/DlgRevolution.h @@ -40,7 +40,7 @@ public: ~DlgRevolution(); void accept(); - Base::Vector3f getDirection() const; + Base::Vector3d getDirection() const; protected: void changeEvent(QEvent *e); From f6b53e6b57026ac6b32ad85bbd5f496787487fb7 Mon Sep 17 00:00:00 2001 From: jrheinlaender Date: Mon, 25 Mar 2013 20:37:59 +0430 Subject: [PATCH 10/17] Moved Sketcher from float to double --- src/Mod/Sketcher/Gui/CommandCreateGeo.cpp | 80 +++++++++++----------- src/Mod/Sketcher/Gui/DrawSketchHandler.cpp | 10 +-- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp index 3a133118f..1b3328c2a 100644 --- a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp +++ b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp @@ -326,7 +326,7 @@ public: EditCurve[1] = Base::Vector2D(onSketchPos.fX ,EditCurve[0].fY); EditCurve[3] = Base::Vector2D(EditCurve[0].fX,onSketchPos.fY); sketchgui->drawEdit(EditCurve); - if (seekAutoConstraint(sugConstr2, onSketchPos, Base::Vector2D(0.f,0.f))) { + if (seekAutoConstraint(sugConstr2, onSketchPos, Base::Vector2D(0.0,0.0))) { renderSuggestConstraintsCursor(sugConstr2); return; } @@ -663,17 +663,17 @@ public: else if (TransitionMode == TRANSITION_MODE_Perpendicular_R) Tangent = Base::Vector2D(dirVec.y,-dirVec.x); - float theta = Tangent.GetAngle(onSketchPos - EditCurve[0]); + double theta = Tangent.GetAngle(onSketchPos - EditCurve[0]); arcRadius = (onSketchPos - EditCurve[0]).Length()/(2.0*sin(theta)); // At this point we need a unit normal vector pointing torwards // the center of the arc we are drawing. Derivation of the formula // used here can be found at http://people.richland.edu/james/lecture/m116/matrices/area.html - float x1 = EditCurve[0].fX; - float y1 = EditCurve[0].fY; - float x2 = x1 + Tangent.fX; - float y2 = y1 + Tangent.fY; - float x3 = onSketchPos.fX; - float y3 = onSketchPos.fY; + double x1 = EditCurve[0].fX; + double y1 = EditCurve[0].fY; + double x2 = x1 + Tangent.fX; + double y2 = y1 + Tangent.fY; + double x3 = onSketchPos.fX; + double y3 = onSketchPos.fY; if ((x2*y3-x3*y2)-(x1*y3-x3*y1)+(x1*y2-x2*y1) > 0) arcRadius *= -1; if (boost::math::isnan(arcRadius) || boost::math::isinf(arcRadius)) @@ -681,26 +681,26 @@ public: CenterPoint = EditCurve[0] + Base::Vector2D(arcRadius * Tangent.fY, -arcRadius * Tangent.fX); - float rx = EditCurve[0].fX - CenterPoint.fX; - float ry = EditCurve[0].fY - CenterPoint.fY; + double rx = EditCurve[0].fX - CenterPoint.fX; + double ry = EditCurve[0].fY - CenterPoint.fY; startAngle = atan2(ry,rx); - float rxe = onSketchPos.fX - CenterPoint.fX; - float rye = onSketchPos.fY - CenterPoint.fY; - float arcAngle = atan2(-rxe*ry + rye*rx, rxe*rx + rye*ry); + double rxe = onSketchPos.fX - CenterPoint.fX; + double rye = onSketchPos.fY - CenterPoint.fY; + double arcAngle = atan2(-rxe*ry + rye*rx, rxe*rx + rye*ry); if (boost::math::isnan(arcAngle) || boost::math::isinf(arcAngle)) arcAngle = 0.f; if (arcRadius >= 0 && arcAngle > 0) - arcAngle -= (float) 2*M_PI; + arcAngle -= 2*M_PI; if (arcRadius < 0 && arcAngle < 0) - arcAngle += (float) 2*M_PI; + arcAngle += 2*M_PI; endAngle = startAngle + arcAngle; for (int i=1; i <= 29; i++) { - float angle = i*arcAngle/29.0; - float dx = rx * cos(angle) - ry * sin(angle); - float dy = rx * sin(angle) + ry * cos(angle); + double angle = i*arcAngle/29.0; + double dx = rx * cos(angle) - ry * sin(angle); + double dy = rx * sin(angle) + ry * cos(angle); EditCurve[i] = Base::Vector2D(CenterPoint.fX + dx, CenterPoint.fY + dy); } @@ -915,7 +915,7 @@ protected: Base::Vector2D CenterPoint; Base::Vector3d dirVec; - float startAngle, endAngle, arcRadius; + double startAngle, endAngle, arcRadius; void updateTransitionData(int GeoId, Sketcher::PointPos PosId) { @@ -1044,12 +1044,12 @@ public: } } else if (Mode==STATUS_SEEK_Second) { - float dx_ = onSketchPos.fX - EditCurve[0].fX; - float dy_ = onSketchPos.fY - EditCurve[0].fY; + double dx_ = onSketchPos.fX - EditCurve[0].fX; + double dy_ = onSketchPos.fY - EditCurve[0].fY; for (int i=0; i < 16; i++) { - float angle = i*M_PI/16.0; - float dx = dx_ * cos(angle) + dy_ * sin(angle); - float dy = -dx_ * sin(angle) + dy_ * cos(angle); + double angle = i*M_PI/16.0; + double dx = dx_ * cos(angle) + dy_ * sin(angle); + double dy = -dx_ * sin(angle) + dy_ * cos(angle); EditCurve[1+i] = Base::Vector2D(EditCurve[0].fX + dx, EditCurve[0].fY + dy); EditCurve[17+i] = Base::Vector2D(EditCurve[0].fX - dx, EditCurve[0].fY - dy); } @@ -1070,14 +1070,14 @@ public: } } else if (Mode==STATUS_SEEK_Third) { - float angle1 = atan2(onSketchPos.fY - CenterPoint.fY, + double angle1 = atan2(onSketchPos.fY - CenterPoint.fY, onSketchPos.fX - CenterPoint.fX) - startAngle; - float angle2 = angle1 + (angle1 < 0. ? 2 : -2) * M_PI ; + double angle2 = angle1 + (angle1 < 0. ? 2 : -2) * M_PI ; arcAngle = abs(angle1-arcAngle) < abs(angle2-arcAngle) ? angle1 : angle2; for (int i=1; i <= 29; i++) { - float angle = i*arcAngle/29.0; - float dx = rx * cos(angle) - ry * sin(angle); - float dy = rx * sin(angle) + ry * cos(angle); + double angle = i*arcAngle/29.0; + double dx = rx * cos(angle) - ry * sin(angle); + double dy = rx * sin(angle) + ry * cos(angle); EditCurve[i] = Base::Vector2D(CenterPoint.fX + dx, CenterPoint.fY + dy); } @@ -1089,7 +1089,7 @@ public: setPositionText(onSketchPos, text); sketchgui->drawEdit(EditCurve); - if (seekAutoConstraint(sugConstr3, onSketchPos, Base::Vector2D(0.f,0.f))) { + if (seekAutoConstraint(sugConstr3, onSketchPos, Base::Vector2D(0.0,0.0))) { renderSuggestConstraintsCursor(sugConstr3); return; } @@ -1118,9 +1118,9 @@ public: } else { EditCurve.resize(30); - float angle1 = atan2(onSketchPos.fY - CenterPoint.fY, + double angle1 = atan2(onSketchPos.fY - CenterPoint.fY, onSketchPos.fX - CenterPoint.fX) - startAngle; - float angle2 = angle1 + (angle1 < 0. ? 2 : -2) * M_PI ; + double angle2 = angle1 + (angle1 < 0. ? 2 : -2) * M_PI ; arcAngle = abs(angle1-arcAngle) < abs(angle2-arcAngle) ? angle1 : angle2; if (arcAngle > 0) endAngle = startAngle + arcAngle; @@ -1182,7 +1182,7 @@ protected: SelectMode Mode; std::vector EditCurve; Base::Vector2D CenterPoint; - float rx, ry, startAngle, endAngle, arcAngle; + double rx, ry, startAngle, endAngle, arcAngle; std::vector sugConstr1, sugConstr2, sugConstr3; }; @@ -1279,12 +1279,12 @@ public: } } else if (Mode==STATUS_SEEK_Second) { - float rx0 = onSketchPos.fX - EditCurve[0].fX; - float ry0 = onSketchPos.fY - EditCurve[0].fY; + double rx0 = onSketchPos.fX - EditCurve[0].fX; + double ry0 = onSketchPos.fY - EditCurve[0].fY; for (int i=0; i < 16; i++) { - float angle = i*M_PI/16.0; - float rx = rx0 * cos(angle) + ry0 * sin(angle); - float ry = -rx0 * sin(angle) + ry0 * cos(angle); + double angle = i*M_PI/16.0; + double rx = rx0 * cos(angle) + ry0 * sin(angle); + double ry = -rx0 * sin(angle) + ry0 * cos(angle); EditCurve[1+i] = Base::Vector2D(EditCurve[0].fX + rx, EditCurve[0].fY + ry); EditCurve[17+i] = Base::Vector2D(EditCurve[0].fX - rx, EditCurve[0].fY - ry); } @@ -1322,8 +1322,8 @@ public: virtual bool releaseButton(Base::Vector2D onSketchPos) { if (Mode==STATUS_Close) { - float rx = EditCurve[1].fX - EditCurve[0].fX; - float ry = EditCurve[1].fY - EditCurve[0].fY; + double rx = EditCurve[1].fX - EditCurve[0].fX; + double ry = EditCurve[1].fY - EditCurve[0].fY; unsetCursor(); resetPositionText(); Gui::Command::openCommand("Add sketch circle"); diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp index efe28b6c9..6f6098ff7 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp +++ b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp @@ -203,10 +203,10 @@ int DrawSketchHandler::seekAutoConstraint(std::vector &suggested // Find if there are tangent constraints (currently arcs and circles) // FIXME needs to consider when zooming out? - const float tangDeviation = 2.; + const double tangDeviation = 2.; int tangId = Constraint::GeoUndef; - float smlTangDist = 1e15f; + double smlTangDist = 1e15f; // Get geometry list const std::vector geomlist = sketchgui->getSketchObject()->getCompleteGeometry(); @@ -221,11 +221,11 @@ int DrawSketchHandler::seekAutoConstraint(std::vector &suggested Base::Vector3d center = circle->getCenter(); Base::Vector3d tmpPos(Pos.fX, Pos.fY, 0.f); - float radius = (float) circle->getRadius(); + double radius = circle->getRadius(); Base::Vector3d projPnt(0.f, 0.f, 0.f); projPnt = projPnt.ProjToLine(center - tmpPos, Base::Vector3d(Dir.fX, Dir.fY)); - float projDist = projPnt.Length(); + double projDist = projPnt.Length(); if ( (projDist < radius + tangDeviation ) && (projDist > radius - tangDeviation)) { // Find if nearest @@ -245,7 +245,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector &suggested Base::Vector3d tmpPos(Pos.fX, Pos.fY, 0.f); projPnt = projPnt.ProjToLine(center - tmpPos, Base::Vector3d(Dir.fX, Dir.fY)); - float projDist = projPnt.Length(); + double projDist = projPnt.Length(); if ( projDist < radius + tangDeviation && projDist > radius - tangDeviation) { double startAngle, endAngle; From d93907119d757c75cdd3a041312ca1fd70b491da Mon Sep 17 00:00:00 2001 From: jrheinlaender Date: Mon, 25 Mar 2013 20:40:41 +0430 Subject: [PATCH 11/17] more suggestions for moving float -> double --- src/Mod/Inspection/App/InspectionFeature.cpp | 10 +++++----- src/Mod/Inspection/Gui/ViewProviderInspection.cpp | 8 ++++---- src/Mod/Points/App/Properties.cpp | 6 +++--- src/Mod/Points/Gui/ViewProvider.cpp | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Mod/Inspection/App/InspectionFeature.cpp b/src/Mod/Inspection/App/InspectionFeature.cpp index 9ff0f6e6e..b0783ad43 100644 --- a/src/Mod/Inspection/App/InspectionFeature.cpp +++ b/src/Mod/Inspection/App/InspectionFeature.cpp @@ -40,8 +40,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -479,11 +479,11 @@ PROPERTY_SOURCE(Inspection::Feature, App::DocumentObject) Feature::Feature() { - ADD_PROPERTY(SearchRadius,(0.05f)); - ADD_PROPERTY(Thickness,(0.0f)); + ADD_PROPERTY(SearchRadius,(0.05)); + ADD_PROPERTY(Thickness,(0.0)); ADD_PROPERTY(Actual,(0)); ADD_PROPERTY(Nominals,(0)); - ADD_PROPERTY(Distances,(0.0f)); + ADD_PROPERTY(Distances,(0.0)); } Feature::~Feature() diff --git a/src/Mod/Inspection/Gui/ViewProviderInspection.cpp b/src/Mod/Inspection/Gui/ViewProviderInspection.cpp index 871a2bfb6..be8d258c7 100644 --- a/src/Mod/Inspection/Gui/ViewProviderInspection.cpp +++ b/src/Mod/Inspection/Gui/ViewProviderInspection.cpp @@ -35,8 +35,8 @@ #include #include #include -#include -#include +#include +#include #include #include #include @@ -63,14 +63,14 @@ using namespace InspectionGui; bool ViewProviderInspection::addflag = false; -App::PropertyFloatConstraint::Constraints ViewProviderInspection::floatRange = {1.0f,64.0f,1.0f}; +App::PropertyFloatConstraint::Constraints ViewProviderInspection::floatRange = {1.0,64.0,1.0}; PROPERTY_SOURCE(InspectionGui::ViewProviderInspection, Gui::ViewProviderDocumentObject) ViewProviderInspection::ViewProviderInspection() : search_radius(FLT_MAX) { ADD_PROPERTY_TYPE(OutsideGrayed,(false),"",(App::PropertyType) (App::Prop_Output|App::Prop_Hidden),""); - ADD_PROPERTY_TYPE(PointSize,(1.0f),"Display",(App::PropertyType) (App::Prop_None/*App::Prop_Hidden*/),""); + ADD_PROPERTY_TYPE(PointSize,(1.0),"Display",(App::PropertyType) (App::Prop_None/*App::Prop_Hidden*/),""); PointSize.setConstraints(&floatRange); pcColorRoot = new SoSeparator(); diff --git a/src/Mod/Points/App/Properties.cpp b/src/Mod/Points/App/Properties.cpp index 855633fa9..aba32ce2c 100644 --- a/src/Mod/Points/App/Properties.cpp +++ b/src/Mod/Points/App/Properties.cpp @@ -53,17 +53,17 @@ void PropertyGreyValueList::removeIndices( const std::vector& uIn std::vector uSortedInds = uIndices; std::sort(uSortedInds.begin(), uSortedInds.end()); - const std::vector& rValueList = getValues(); + const std::vector& rValueList = getValues(); assert( uSortedInds.size() <= rValueList.size() ); if ( uSortedInds.size() > rValueList.size() ) return; - std::vector remainValue; + std::vector remainValue; remainValue.reserve(rValueList.size() - uSortedInds.size()); std::vector::iterator pos = uSortedInds.begin(); - for ( std::vector::const_iterator it = rValueList.begin(); it != rValueList.end(); ++it ) { + for ( std::vector::const_iterator it = rValueList.begin(); it != rValueList.end(); ++it ) { unsigned long index = it - rValueList.begin(); if (pos == uSortedInds.end()) remainValue.push_back( *it ); diff --git a/src/Mod/Points/Gui/ViewProvider.cpp b/src/Mod/Points/Gui/ViewProvider.cpp index 4fe161b71..cbf165d1b 100644 --- a/src/Mod/Points/Gui/ViewProvider.cpp +++ b/src/Mod/Points/Gui/ViewProvider.cpp @@ -65,7 +65,7 @@ using namespace Points; PROPERTY_SOURCE(PointsGui::ViewProviderPoints, Gui::ViewProviderGeometryObject) -App::PropertyFloatConstraint::Constraints ViewProviderPoints::floatRange = {1.0f,64.0f,1.0f}; +App::PropertyFloatConstraint::Constraints ViewProviderPoints::floatRange = {1.0,64.0,1.0}; ViewProviderPoints::ViewProviderPoints() { From e233f0cb6def44a6f0c8f27c8ad994ea7bfa02d8 Mon Sep 17 00:00:00 2001 From: jrheinlaender Date: Tue, 26 Mar 2013 19:13:06 +0430 Subject: [PATCH 12/17] Mod/ReverseEngineering moved float -> double --- .../ReverseEngineering/App/ApproxSurface.cpp | 134 +++++++++--------- .../ReverseEngineering/App/ApproxSurface.h | 38 ++--- 2 files changed, 86 insertions(+), 86 deletions(-) diff --git a/src/Mod/ReverseEngineering/App/ApproxSurface.cpp b/src/Mod/ReverseEngineering/App/ApproxSurface.cpp index 0eeae2cb1..3710a59e0 100644 --- a/src/Mod/ReverseEngineering/App/ApproxSurface.cpp +++ b/src/Mod/ReverseEngineering/App/ApproxSurface.cpp @@ -486,31 +486,31 @@ void BSplineBasis::GenerateRootsAndWeights(TColStd_Array1OfReal& vRoots, TColStd } else if (iSize == 2) { - vRoots(0) = 0.57735f; vWeights(0) = 1.0f; + vRoots(0) = 0.57735; vWeights(0) = 1.0; vRoots(1) = -vRoots(0); vWeights(1) = vWeights(0); } else if (iSize == 4) { - vRoots(0) = 0.33998f; vWeights(0) = 0.65214f; - vRoots(1) = 0.86113f; vWeights(1) = 0.34785f; + vRoots(0) = 0.33998; vWeights(0) = 0.65214; + vRoots(1) = 0.86113; vWeights(1) = 0.34785; vRoots(2) = -vRoots(0); vWeights(2) = vWeights(0); vRoots(3) = -vRoots(1); vWeights(3) = vWeights(1); } else if (iSize == 6) { - vRoots(0) = 0.23861f; vWeights(0) = 0.46791f; - vRoots(1) = 0.66120f; vWeights(1) = 0.36076f; - vRoots(2) = 0.93246f; vWeights(2) = 0.17132f; + vRoots(0) = 0.23861; vWeights(0) = 0.46791; + vRoots(1) = 0.66120; vWeights(1) = 0.36076; + vRoots(2) = 0.93246; vWeights(2) = 0.17132; vRoots(3) = -vRoots(0); vWeights(3) = vWeights(0); vRoots(4) = -vRoots(1); vWeights(4) = vWeights(1); vRoots(5) = -vRoots(2); vWeights(5) = vWeights(2); } else if (iSize == 8) { - vRoots(0) = 0.18343f; vWeights(0) = 0.36268f; - vRoots(1) = 0.52553f; vWeights(1) = 0.31370f; - vRoots(2) = 0.79666f; vWeights(2) = 0.22238f; - vRoots(3) = 0.96028f; vWeights(3) = 0.10122f; + vRoots(0) = 0.18343; vWeights(0) = 0.36268; + vRoots(1) = 0.52553; vWeights(1) = 0.31370; + vRoots(2) = 0.79666; vWeights(2) = 0.22238; + vRoots(3) = 0.96028; vWeights(3) = 0.10122; vRoots(4) = -vRoots(0); vWeights(4) = vWeights(0); vRoots(5) = -vRoots(1); vWeights(5) = vWeights(1); vRoots(6) = -vRoots(2); vWeights(6) = vWeights(2); @@ -518,11 +518,11 @@ void BSplineBasis::GenerateRootsAndWeights(TColStd_Array1OfReal& vRoots, TColStd } else if (iSize == 10) { - vRoots(0) = 0.14887f; vWeights(0) = 0.29552f; - vRoots(1) = 0.43339f; vWeights(1) = 0.26926f; - vRoots(2) = 0.67940f; vWeights(2) = 0.21908f; - vRoots(3) = 0.86506f; vWeights(3) = 0.14945f; - vRoots(4) = 0.97390f; vWeights(4) = 0.06667f; + vRoots(0) = 0.14887; vWeights(0) = 0.29552; + vRoots(1) = 0.43339; vWeights(1) = 0.26926; + vRoots(2) = 0.67940; vWeights(2) = 0.21908; + vRoots(3) = 0.86506; vWeights(3) = 0.14945; + vRoots(4) = 0.97390; vWeights(4) = 0.06667; vRoots(5) = -vRoots(0); vWeights(5) = vWeights(0); vRoots(6) = -vRoots(1); vWeights(6) = vWeights(1); vRoots(7) = -vRoots(2); vWeights(7) = vWeights(2); @@ -531,12 +531,12 @@ void BSplineBasis::GenerateRootsAndWeights(TColStd_Array1OfReal& vRoots, TColStd } else { - vRoots(0) = 0.12523f; vWeights(0) = 0.24914f; - vRoots(1) = 0.36783f; vWeights(1) = 0.23349f; - vRoots(2) = 0.58731f; vWeights(2) = 0.20316f; - vRoots(3) = 0.76990f; vWeights(3) = 0.16007f; - vRoots(4) = 0.90411f; vWeights(4) = 0.10693f; - vRoots(5) = 0.98156f; vWeights(5) = 0.04717f; + vRoots(0) = 0.12523; vWeights(0) = 0.24914; + vRoots(1) = 0.36783; vWeights(1) = 0.23349; + vRoots(2) = 0.58731; vWeights(2) = 0.20316; + vRoots(3) = 0.76990; vWeights(3) = 0.16007; + vRoots(4) = 0.90411; vWeights(4) = 0.10693; + vRoots(5) = 0.98156; vWeights(5) = 0.04717; vRoots(6) = -vRoots(0); vWeights(6) = vWeights(0); vRoots(7) = -vRoots(1); vWeights(7) = vWeights(1); vRoots(8) = -vRoots(2); vWeights(8) = vWeights(2); @@ -615,12 +615,12 @@ void ParameterCorrection::CalcEigenvectors() planeFit.Fit(); - _clU = planeFit.GetDirU(); - _clV = planeFit.GetDirV(); - _clW = planeFit.GetNormal(); + _clU = Base::toVector(planeFit.GetDirU()); + _clV = Base::toVector(planeFit.GetDirV()); + _clW = Base::toVector(planeFit.GetNormal()); } -bool ParameterCorrection::DoInitialParameterCorrection(float fSizeFactor) +bool ParameterCorrection::DoInitialParameterCorrection(double fSizeFactor) { // falls Richtungen nicht vorgegeben, selber berechnen if (_bGetUVDir == false) @@ -641,27 +641,27 @@ bool ParameterCorrection::DoInitialParameterCorrection(float fSizeFactor) return true; } -bool ParameterCorrection::GetUVParameters(float fSizeFactor) +bool ParameterCorrection::GetUVParameters(double fSizeFactor) { // Eigenvektoren als neue Basis - Base::Vector3f e[3]; + Base::Vector3d e[3]; e[0] = _clU; e[1] = _clV; e[2] = _clW; //kanonische Basis des R^3 - Base::Vector3f b[3]; - b[0]=Base::Vector3f(1.0f,0.0f,0.0f); b[1]=Base::Vector3f(0.0f,1.0f,0.0f);b[2]=Base::Vector3f(0.0f,0.0f,1.0f); + Base::Vector3d b[3]; + b[0]=Base::Vector3d(1.0,0.0,0.0); b[1]=Base::Vector3d(0.0,1.0,0.0);b[2]=Base::Vector3d(0.0,0.0,1.0); // Erzeuge ein Rechtssystem aus den orthogonalen Eigenvektoren if ((e[0]%e[1])*e[2] < 0) { - Base::Vector3f tmp = e[0]; + Base::Vector3d tmp = e[0]; e[0] = e[1]; e[1] = tmp; } // Nun erzeuge die transpon. Rotationsmatrix - Wm4::Matrix3f clRotMatTrans; + Wm4::Matrix3d clRotMatTrans; for (int i=0; i<3; i++) { for (int j=0; j<3; j++) @@ -677,20 +677,20 @@ bool ParameterCorrection::GetUVParameters(float fSizeFactor) // Koordinatensystems for (int ii=_pvcPoints->Lower(); ii<=_pvcPoints->Upper(); ii++) { - Wm4::Vector3f clProjPnt = clRotMatTrans * ( Wm4::Vector3f( - (float)(*_pvcPoints)(ii).X(), - (float)(*_pvcPoints)(ii).Y(), - (float)(*_pvcPoints)(ii).Z())); + Wm4::Vector3d clProjPnt = clRotMatTrans * ( Wm4::Vector3d( + (*_pvcPoints)(ii).X(), + (*_pvcPoints)(ii).Y(), + (*_pvcPoints)(ii).Z())); vcProjPts.push_back(Base::Vector2D(clProjPnt.X(), clProjPnt.Y())); clBBox &= (Base::Vector2D(clProjPnt.X(), clProjPnt.Y())); } if ((clBBox.fMaxX == clBBox.fMinX) || (clBBox.fMaxY == clBBox.fMinY)) return false; - float tx = fSizeFactor*clBBox.fMinX-(fSizeFactor-1.0f)*clBBox.fMaxX; - float ty = fSizeFactor*clBBox.fMinY-(fSizeFactor-1.0f)*clBBox.fMaxY; - float fDeltaX = (2*fSizeFactor-1.0f)*(clBBox.fMaxX - clBBox.fMinX); - float fDeltaY = (2*fSizeFactor-1.0f)*(clBBox.fMaxY - clBBox.fMinY); + double tx = fSizeFactor*clBBox.fMinX-(fSizeFactor-1.0f)*clBBox.fMaxX; + double ty = fSizeFactor*clBBox.fMinY-(fSizeFactor-1.0f)*clBBox.fMaxY; + double fDeltaX = (2*fSizeFactor-1.0f)*(clBBox.fMaxX - clBBox.fMinX); + double fDeltaY = (2*fSizeFactor-1.0f)*(clBBox.fMaxY - clBBox.fMinY); // Berechne die u,v-Parameter mit u,v aus [0,1] _pvcUVParam->Init(gp_Pnt2d(0.0f, 0.0f)); @@ -711,7 +711,7 @@ bool ParameterCorrection::GetUVParameters(float fSizeFactor) return true; } -void ParameterCorrection::SetUVW(const Base::Vector3f& clU, const Base::Vector3f& clV, const Base::Vector3f& clW, bool bUseDir) +void ParameterCorrection::SetUVW(const Base::Vector3d& clU, const Base::Vector3d& clV, const Base::Vector3d& clW, bool bUseDir) { _clU = clU; _clV = clV; @@ -719,31 +719,31 @@ void ParameterCorrection::SetUVW(const Base::Vector3f& clU, const Base::Vector3f _bGetUVDir = bUseDir; } -void ParameterCorrection::GetUVW(Base::Vector3f& clU, Base::Vector3f& clV, Base::Vector3f& clW) const +void ParameterCorrection::GetUVW(Base::Vector3d& clU, Base::Vector3d& clV, Base::Vector3d& clW) const { clU = _clU; clV = _clV; clW = _clW; } -Base::Vector3f ParameterCorrection::GetGravityPoint() const +Base::Vector3d ParameterCorrection::GetGravityPoint() const { unsigned long ulSize = _pvcPoints->Length(); - float x=0.0f, y=0.0f, z=0.0f; + double x=0.0, y=0.0, z=0.0; for (int i=_pvcPoints->Lower(); i<=_pvcPoints->Upper(); i++) { - x += (float)(*_pvcPoints)(i).X(); - y += (float)(*_pvcPoints)(i).Y(); - z += (float)(*_pvcPoints)(i).Z(); + x += (*_pvcPoints)(i).X(); + y += (*_pvcPoints)(i).Y(); + z += (*_pvcPoints)(i).Z(); } - return Base::Vector3f(float(x/ulSize), float(y/ulSize), float(z/ulSize)); + return Base::Vector3d(x/ulSize, y/ulSize, z/ulSize); } Handle(Geom_BSplineSurface) ParameterCorrection::CreateSurface(const TColgp_Array1OfPnt& points, unsigned short usIter, bool bParaCor, - float fSizeFactor) + double fSizeFactor) { if (_pvcPoints != NULL) { @@ -774,7 +774,7 @@ Handle(Geom_BSplineSurface) ParameterCorrection::CreateSurface(const TColgp_Arra _usVOrder-1); } -void ParameterCorrection::EnableSmoothing(bool bSmooth, float fSmoothInfl) +void ParameterCorrection::EnableSmoothing(bool bSmooth, double fSmoothInfl) { _bSmoothing = bSmooth; _fSmoothInfluence = fSmoothInfl; @@ -810,10 +810,10 @@ void BSplineParameterCorrection::Init() // Initialisierungen _pvcUVParam = NULL; _pvcPoints = NULL; - _clFirstMatrix.Init(0.0f); - _clSecondMatrix.Init(0.0f); - _clThirdMatrix.Init(0.0f); - _clSmoothMatrix.Init(0.0f); + _clFirstMatrix.Init(0.0); + _clSecondMatrix.Init(0.0); + _clThirdMatrix.Init(0.0); + _clSmoothMatrix.Init(0.0); /* Berechne die Knotenvektoren */ unsigned short usUMax = _usUCtrlpoints-_usUOrder+1; @@ -823,7 +823,7 @@ void BSplineParameterCorrection::Init() // u-Richtung for (int i=0;i<=usUMax; i++) { - _vUKnots(i) = ((float)i) / ((float)usUMax); + _vUKnots(i) = i / usUMax; _vUMults(i) = 1; } _vUMults(0) = _usUOrder; @@ -831,7 +831,7 @@ void BSplineParameterCorrection::Init() // v-Richtung for (int i=0; i<=usVMax; i++) { - _vVKnots(i) = ((float)i) / ((float)usVMax); + _vVKnots(i) = i / usVMax; _vVMults(i) = 1; } _vVMults(0) = _usVOrder; @@ -842,7 +842,7 @@ void BSplineParameterCorrection::Init() _clVSpline.SetKnots(_vVKnots, _vVMults, _usVOrder); } -void BSplineParameterCorrection::SetUKnots(const std::vector& afKnots) +void BSplineParameterCorrection::SetUKnots(const std::vector& afKnots) { if (afKnots.size() != (unsigned long)(_usUCtrlpoints+_usUOrder)) return; @@ -861,7 +861,7 @@ void BSplineParameterCorrection::SetUKnots(const std::vector& afKnots) _clUSpline.SetKnots(_vUKnots, _vUMults, _usUOrder); } -void BSplineParameterCorrection::SetVKnots(const std::vector& afKnots) +void BSplineParameterCorrection::SetVKnots(const std::vector& afKnots) { if (afKnots.size() != (unsigned long)(_usVCtrlpoints+_usVOrder)) return; @@ -884,7 +884,7 @@ void BSplineParameterCorrection::DoParameterCorrection(unsigned short usIter) { int i=0; float fMaxDiff=0.0f, fMaxScalar=1.0f; - float fWeight = _fSmoothInfluence; + double fWeight = _fSmoothInfluence; Base::SequencerLauncher seq("Calc surface...", usIter*_pvcPoints->Length()); @@ -974,8 +974,8 @@ bool BSplineParameterCorrection::SolveWithoutSmoothing() //Bestimmung der Koeffizientenmatrix des überbestimmten LGS for (unsigned long i=0; iLength(); unsigned long ulDim = _usUCtrlpoints*_usVCtrlpoints; @@ -1039,8 +1039,8 @@ bool BSplineParameterCorrection::SolveWithSmoothing(float fWeight) //Bestimmung der Koeffizientenmatrix des überbestimmten LGS for (unsigned long i=0; i& afKnots); + void SetUKnots(const std::vector& afKnots); /** * Setzen des Knotenvektors */ - void SetVKnots(const std::vector& afKnots); + void SetVKnots(const std::vector& afKnots); /** * Gibt die erste Matrix der Glättungsterme zurück, falls berechnet @@ -424,20 +424,20 @@ public: /** * Verwende Glättungsterme */ - virtual void EnableSmoothing(bool bSmooth=true, float fSmoothInfl=1.0f); + virtual void EnableSmoothing(bool bSmooth=true, double fSmoothInfl=1.0f); /** * Verwende Glättungsterme */ - virtual void EnableSmoothing(bool bSmooth, float fSmoothInfl, - float fFirst, float fSec, float fThird); + virtual void EnableSmoothing(bool bSmooth, double fSmoothInfl, + double fFirst, double fSec, double fThird); protected: /** * Berechnet die Matrix zu den Glättungstermen * (siehe Dissertation U.Dietz) */ - virtual void CalcSmoothingTerms(bool bRecalc, float fFirst, float fSecond, float fThird); + virtual void CalcSmoothingTerms(bool bRecalc, double fFirst, double fSecond, double fThird); /** * Berechnet die Matrix zum ersten Glättungsterm From 4dcc5eb6cb7354735b06b539360c95017c52f84f Mon Sep 17 00:00:00 2001 From: jrheinlaender Date: Tue, 26 Mar 2013 19:13:43 +0430 Subject: [PATCH 13/17] Mod/Points moved from float -> double --- src/App/ComplexGeoData.h | 13 ++++++++++++- src/Mod/Points/App/Points.cpp | 15 +++++++++------ src/Mod/Points/App/Points.h | 22 +++++++++++----------- src/Mod/Points/App/PointsGrid.cpp | 2 +- src/Mod/Points/App/PointsGrid.h | 2 +- src/Mod/Points/App/Properties.cpp | 4 ++-- src/Mod/Points/App/Properties.h | 4 ++-- src/Mod/Points/Gui/ViewProvider.cpp | 6 +++--- 8 files changed, 41 insertions(+), 27 deletions(-) diff --git a/src/App/ComplexGeoData.h b/src/App/ComplexGeoData.h index 5e69badbf..8381417ea 100644 --- a/src/App/ComplexGeoData.h +++ b/src/App/ComplexGeoData.h @@ -153,6 +153,11 @@ protected: { return getTransform() * Base::Vector3d(vec.x,vec.y,vec.z); } + /// from local to outside + inline Base::Vector3d transformToOutside3d(const Base::Vector3d& vec) const + { + return getTransform() * vec; + } /// from local to inside inline Base::Vector3f transformToInside(const Base::Vector3d& vec) const @@ -162,6 +167,12 @@ protected: Base::Vector3d tmp = tmpM * vec; return Base::Vector3f((float)tmp.x,(float)tmp.y,(float)tmp.z); } + inline Base::Vector3d transformToInside3d(const Base::Vector3d& vec) const + { + Base::Matrix4D tmpM(getTransform()); + tmpM.inverse(); + return tmpM * vec; + } //Base::Matrix4D _Mtrx; }; @@ -169,4 +180,4 @@ protected: } //namespace App -#endif +#endif diff --git a/src/Mod/Points/App/Points.cpp b/src/Mod/Points/App/Points.cpp index 1156aea12..9ecdb826d 100644 --- a/src/Mod/Points/App/Points.cpp +++ b/src/Mod/Points/App/Points.cpp @@ -70,8 +70,8 @@ Data::Segment* PointKernel::getSubElement(const char* Type, unsigned long n) con void PointKernel::transformGeometry(const Base::Matrix4D &rclMat) { - std::vector& kernel = getBasicPoints(); - for (std::vector::iterator it = kernel.begin(); it != kernel.end(); ++it) + std::vector& kernel = getBasicPoints(); + for (std::vector::iterator it = kernel.begin(); it != kernel.end(); ++it) *it = rclMat * (*it); } @@ -94,7 +94,7 @@ void PointKernel::operator = (const PointKernel& Kernel) unsigned int PointKernel::getMemSize (void) const { - return _Points.size() * sizeof(Base::Vector3f); + return _Points.size() * sizeof(Base::Vector3d); } void PointKernel::Save (Base::Writer &writer) const @@ -111,8 +111,8 @@ void PointKernel::SaveDocFile (Base::Writer &writer) const Base::OutputStream str(writer.Stream()); uint32_t uCt = (uint32_t)size(); str << uCt; - // store the data without transforming it and save as float, not double - for (std::vector::const_iterator it = _Points.begin(); it != _Points.end(); ++it) { + // store the data without transforming it + for (std::vector::const_iterator it = _Points.begin(); it != _Points.end(); ++it) { str << it->x << it->y << it->z; } } @@ -141,6 +141,9 @@ void PointKernel::RestoreDocFile(Base::Reader &reader) str >> uCt; _Points.resize(uCt); for (unsigned long i=0; i < uCt; i++) { +// if doubleFileVersion +// double x, y, z +// else float x, y, z; str >> x >> y >> z; _Points[i].Set(x,y,z); @@ -176,7 +179,7 @@ void PointKernel::getFaces(std::vector &Points,std::vector::const_iterator index) +(const PointKernel* kernel, std::vector::const_iterator index) : _kernel(kernel), _p_it(index) { if(_p_it != kernel->_Points.end()) diff --git a/src/Mod/Points/App/Points.h b/src/Mod/Points/App/Points.h index 2da670a62..06efa3c4f 100644 --- a/src/Mod/Points/App/Points.h +++ b/src/Mod/Points/App/Points.h @@ -73,9 +73,9 @@ public: inline void setTransform(const Base::Matrix4D& rclTrf){_Mtrx = rclTrf;} inline Base::Matrix4D getTransform(void) const{return _Mtrx;} - std::vector& getBasicPoints() + std::vector& getBasicPoints() { return this->_Points; } - const std::vector& getBasicPoints() const + const std::vector& getBasicPoints() const { return this->_Points; } void getFaces(std::vector &Points,std::vector &Topo, float Accuracy, uint16_t flags=0) const; @@ -99,11 +99,11 @@ public: private: Base::Matrix4D _Mtrx; - std::vector _Points; + std::vector _Points; public: - typedef std::vector::difference_type difference_type; - typedef std::vector::size_type size_type; + typedef std::vector::difference_type difference_type; + typedef std::vector::size_type size_type; /// number of points stored size_type size(void) const {return this->_Points.size();} @@ -118,28 +118,28 @@ public: /// get the points inline const Base::Vector3d getPoint(const int idx) const { - return transformToOutside(_Points[idx]); + return transformToOutside3d(_Points[idx]); } /// set the points inline void setPoint(const int idx,const Base::Vector3d& point) { - _Points[idx] = transformToInside(point); + _Points[idx] = transformToInside3d(point); } /// insert the points inline void push_back(const Base::Vector3d& point) { - _Points.push_back(transformToInside(point)); + _Points.push_back(transformToInside3d(point)); } class PointsExport const_point_iterator { public: - typedef std::vector::const_iterator iter_type; + typedef std::vector::const_iterator iter_type; typedef iter_type::difference_type difference_type; typedef iter_type::iterator_category iterator_category; typedef const Base::Vector3d* pointer; typedef const Base::Vector3d& reference; typedef Base::Vector3d value_type; - const_point_iterator(const PointKernel*, std::vector::const_iterator index); + const_point_iterator(const PointKernel*, std::vector::const_iterator index); const_point_iterator(const const_point_iterator& pi); //~const_point_iterator(); @@ -161,7 +161,7 @@ public: void dereference(); const PointKernel* _kernel; Base::Vector3d _point; - std::vector::const_iterator _p_it; + std::vector::const_iterator _p_it; }; typedef const_point_iterator const_iterator; diff --git a/src/Mod/Points/App/PointsGrid.cpp b/src/Mod/Points/App/PointsGrid.cpp index 9bc45d623..6525df931 100644 --- a/src/Mod/Points/App/PointsGrid.cpp +++ b/src/Mod/Points/App/PointsGrid.cpp @@ -204,7 +204,7 @@ unsigned long PointsGrid::InSide (const Base::BoundBox3d &rclBB, std::vector &raulElements, const Base::Vector3d &rclOrg, float fMaxDist, bool bDelDoubles) const +unsigned long PointsGrid::InSide (const Base::BoundBox3d &rclBB, std::vector &raulElements, const Base::Vector3d &rclOrg, double fMaxDist, bool bDelDoubles) const { unsigned long i, j, k, ulMinX, ulMinY, ulMinZ, ulMaxX, ulMaxY, ulMaxZ; double fGridDiag = GetBoundBox(0, 0, 0).CalcDiagonalLength(); diff --git a/src/Mod/Points/App/PointsGrid.h b/src/Mod/Points/App/PointsGrid.h index f827be764..30ef0cc82 100644 --- a/src/Mod/Points/App/PointsGrid.h +++ b/src/Mod/Points/App/PointsGrid.h @@ -84,7 +84,7 @@ public: virtual unsigned long InSide (const Base::BoundBox3d &rclBB, std::set &raulElementss) const; /** Searches for elements lying in the intersection area of the grid and the bounding box. */ virtual unsigned long InSide (const Base::BoundBox3d &rclBB, std::vector &raulElements, - const Base::Vector3d &rclOrg, float fMaxDist, bool bDelDoubles = true) const; + const Base::Vector3d &rclOrg, double fMaxDist, bool bDelDoubles = true) const; /** Searches for the nearest grids that contain elements from a point, the result are grid indices. */ void SearchNearestFromPoint (const Base::Vector3d &rclPt, std::set &rclInd) const; //@} diff --git a/src/Mod/Points/App/Properties.cpp b/src/Mod/Points/App/Properties.cpp index aba32ce2c..ee8af76ca 100644 --- a/src/Mod/Points/App/Properties.cpp +++ b/src/Mod/Points/App/Properties.cpp @@ -159,10 +159,10 @@ void PropertyCurvatureList::setValues(const std::vector& lValues) hasSetValue(); } -std::vector PropertyCurvatureList::getCurvature( int mode ) const +std::vector PropertyCurvatureList::getCurvature( int mode ) const { const std::vector& fCurvInfo = getValues(); - std::vector fValues; + std::vector fValues; fValues.reserve(fCurvInfo.size()); // Mean curvature diff --git a/src/Mod/Points/App/Properties.h b/src/Mod/Points/App/Properties.h index fa4aa46d4..6832f5427 100644 --- a/src/Mod/Points/App/Properties.h +++ b/src/Mod/Points/App/Properties.h @@ -101,7 +101,7 @@ public: /** Curvature information. */ struct PointsExport CurvatureInfo { - float fMaxCurvature, fMinCurvature; + double fMaxCurvature, fMinCurvature; Base::Vector3f cMaxCurvDir, cMinCurvDir; }; @@ -128,7 +128,7 @@ public: int getSize(void) const {return _lValueList.size();} void setValue(const CurvatureInfo&); void setValues(const std::vector&); - std::vector getCurvature( int tMode) const; + std::vector getCurvature( int tMode) const; /// index operator const CurvatureInfo& operator[] (const int idx) const {return _lValueList.operator[] (idx);} diff --git a/src/Mod/Points/Gui/ViewProvider.cpp b/src/Mod/Points/Gui/ViewProvider.cpp index cbf165d1b..bc0cb3040 100644 --- a/src/Mod/Points/Gui/ViewProvider.cpp +++ b/src/Mod/Points/Gui/ViewProvider.cpp @@ -469,9 +469,9 @@ void ViewProviderPointsBuilder::createPoints(const App::Property* prop, SoCoordi // get all points int idx=0; - const std::vector& kernel = cPts.getBasicPoints(); - for (std::vector::const_iterator it = kernel.begin(); it != kernel.end(); ++it, idx++) { - coords->point.set1Value(idx, it->x, it->y, it->z); + const std::vector& kernel = cPts.getBasicPoints(); + for (std::vector::const_iterator it = kernel.begin(); it != kernel.end(); ++it, idx++) { + coords->point.set1Value(idx, (float)it->x, (float)it->y, (float)it->z); } points->numPoints = cPts.size(); From fdc3e50811ae3d39f6e93ede23349f854641a724 Mon Sep 17 00:00:00 2001 From: jrheinlaender Date: Wed, 27 Mar 2013 11:47:18 +0430 Subject: [PATCH 14/17] Added FileVersion attribute to XML format to distinguish legacy float binary files from new double binary files --- src/App/Document.cpp | 36 +++++++++++++++++++--- src/App/PropertyFile.cpp | 2 +- src/App/PropertyFile.h | 4 +-- src/App/PropertyGeo.cpp | 2 +- src/App/PropertyGeo.h | 2 +- src/App/PropertyPythonObject.cpp | 2 +- src/App/PropertyPythonObject.h | 2 +- src/App/PropertyStandard.cpp | 12 ++++++-- src/App/PropertyStandard.h | 4 +-- src/Base/Persistence.cpp | 2 +- src/Base/Persistence.h | 2 +- src/Base/Reader.cpp | 2 +- src/Base/Reader.h | 4 +++ src/Gui/Document.cpp | 4 +-- src/Gui/Document.h | 2 +- src/Gui/MergeDocuments.cpp | 2 +- src/Gui/MergeDocuments.h | 2 +- src/Gui/Thumbnail.cpp | 2 +- src/Gui/Thumbnail.h | 2 +- src/Mod/Fem/App/FemMesh.cpp | 2 +- src/Mod/Fem/App/FemMesh.h | 4 +-- src/Mod/Fem/App/FemMeshProperty.cpp | 4 +-- src/Mod/Fem/App/FemMeshProperty.h | 2 +- src/Mod/Mesh/App/Mesh.cpp | 20 ++++++------ src/Mod/Mesh/App/Mesh.h | 6 ++-- src/Mod/Mesh/App/MeshProperties.cpp | 10 +++--- src/Mod/Mesh/App/MeshProperties.h | 4 +-- src/Mod/Part/App/PropertyTopoShape.cpp | 10 +++--- src/Mod/Part/App/PropertyTopoShape.h | 6 ++-- src/Mod/Part/App/TopoShape.cpp | 2 +- src/Mod/Part/App/TopoShape.h | 2 +- src/Mod/Points/App/Points.cpp | 17 +++++----- src/Mod/Points/App/Points.h | 2 +- src/Mod/Points/App/PointsFeature.cpp | 4 +-- src/Mod/Points/App/PointsFeature.h | 2 +- src/Mod/Points/App/Properties.cpp | 2 +- src/Mod/Points/App/Properties.h | 2 +- src/Mod/Points/App/PropertyPointKernel.cpp | 4 +-- src/Mod/Points/App/PropertyPointKernel.h | 2 +- 39 files changed, 119 insertions(+), 78 deletions(-) diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 5ccde012e..8bf40b596 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -597,7 +597,11 @@ void Document::Save (Base::Writer &writer) const << " FreeCAD Document, see http://free-cad.sourceforge.net for more information..." << endl << "-->" << endl; - writer.Stream() << "" << endl; + //writer.Stream() << "" << endl; + writer.Stream() << "" << endl; PropertyContainer::Save(writer); @@ -612,6 +616,16 @@ void Document::Restore(Base::XMLReader &reader) reader.readElement("Document"); long scheme = reader.getAttributeAsInteger("SchemaVersion"); reader.DocumentSchema = scheme; + if (reader.hasAttribute("ProgramVersion")) { + reader.ProgramVersion = reader.getAttribute("ProgramVersion"); + } else { + reader.ProgramVersion = "pre-0.14"; + } + if (reader.hasAttribute("FileVersion")) { + reader.FileVersion = reader.getAttributeAsUnsigned("FileVersion"); + } else { + reader.FileVersion = 0; + } // When this document was created the FileName and Label properties // were set to the absolute path or file name, respectively. To save @@ -693,7 +707,11 @@ void Document::exportObjects(const std::vector& obj, Base::ZipWriter writer(out); writer.putNextEntry("Document.xml"); writer.Stream() << "" << endl; - writer.Stream() << "" << endl; + //writer.Stream() << "" << endl; + writer.Stream() << "" << endl; // Add this block to have the same layout as for normal documents writer.Stream() << "" << endl; writer.Stream() << "" << endl; @@ -800,6 +818,16 @@ Document::importObjects(Base::XMLReader& reader) reader.readElement("Document"); long scheme = reader.getAttributeAsInteger("SchemaVersion"); reader.DocumentSchema = scheme; + if (reader.hasAttribute("ProgramVersion")) { + reader.ProgramVersion = reader.getAttribute("ProgramVersion"); + } else { + reader.ProgramVersion = "pre-0.14"; + } + if (reader.hasAttribute("FileVersion")) { + reader.FileVersion = reader.getAttributeAsUnsigned("FileVersion"); + } else { + reader.FileVersion = 0; + } std::vector objs = readObjects(reader); @@ -1729,8 +1757,8 @@ std::vector Document::getObjectsOfType(const Base::Type& typeId std::vector Document::findObjects(const Base::Type& typeId, const char* objname) const { - boost::regex rx(objname); - boost::cmatch what; + boost::regex rx(objname); + boost::cmatch what; std::vector Objects; for (std::vector::const_iterator it = d->objectArray.begin(); it != d->objectArray.end(); ++it) { if ((*it)->getTypeId().isDerivedFrom(typeId)) { diff --git a/src/App/PropertyFile.cpp b/src/App/PropertyFile.cpp index 934023272..269d17902 100644 --- a/src/App/PropertyFile.cpp +++ b/src/App/PropertyFile.cpp @@ -327,7 +327,7 @@ void PropertyFileIncluded::SaveDocFile (Base::Writer &writer) const } } -void PropertyFileIncluded::RestoreDocFile(Base::Reader &reader) +void PropertyFileIncluded::RestoreDocFile(Base::Reader &reader, const int FileVersion) { Base::ofstream to(Base::FileInfo(_cValue.c_str())); if (!to) diff --git a/src/App/PropertyFile.h b/src/App/PropertyFile.h index 270fe35c9..b68ba80da 100644 --- a/src/App/PropertyFile.h +++ b/src/App/PropertyFile.h @@ -91,7 +91,7 @@ public: virtual void Restore(Base::XMLReader &reader); virtual void SaveDocFile (Base::Writer &writer) const; - virtual void RestoreDocFile(Base::Reader &reader); + virtual void RestoreDocFile(Base::Reader &reader, const int FileVersion); virtual Property *Copy(void) const; virtual void Paste(const Property &from); @@ -114,4 +114,4 @@ protected: } // namespace App -#endif // APP_PROPERTFILE_H +#endif // APP_PROPERTFILE_H diff --git a/src/App/PropertyGeo.cpp b/src/App/PropertyGeo.cpp index 9dfc4dd70..0da1d83d4 100644 --- a/src/App/PropertyGeo.cpp +++ b/src/App/PropertyGeo.cpp @@ -301,7 +301,7 @@ void PropertyVectorList::SaveDocFile (Base::Writer &writer) const } } -void PropertyVectorList::RestoreDocFile(Base::Reader &reader) +void PropertyVectorList::RestoreDocFile(Base::Reader &reader, const int FileVersion) { Base::InputStream str(reader); uint32_t uCt=0; diff --git a/src/App/PropertyGeo.h b/src/App/PropertyGeo.h index 9aa9ac178..53c972573 100644 --- a/src/App/PropertyGeo.h +++ b/src/App/PropertyGeo.h @@ -147,7 +147,7 @@ public: virtual void Restore(Base::XMLReader &reader); virtual void SaveDocFile (Base::Writer &writer) const; - virtual void RestoreDocFile(Base::Reader &reader); + virtual void RestoreDocFile(Base::Reader &reader, const int FileVersion); virtual Property *Copy(void) const; virtual void Paste(const Property &from); diff --git a/src/App/PropertyPythonObject.cpp b/src/App/PropertyPythonObject.cpp index 455ea65f6..0c916833d 100644 --- a/src/App/PropertyPythonObject.cpp +++ b/src/App/PropertyPythonObject.cpp @@ -372,7 +372,7 @@ void PropertyPythonObject::SaveDocFile (Base::Writer &writer) const writer.Stream().put(*it); } -void PropertyPythonObject::RestoreDocFile(Base::Reader &reader) +void PropertyPythonObject::RestoreDocFile(Base::Reader &reader, const int FileVersion) { aboutToSetValue(); std::string buffer; diff --git a/src/App/PropertyPythonObject.h b/src/App/PropertyPythonObject.h index bd4bec933..76608e800 100644 --- a/src/App/PropertyPythonObject.h +++ b/src/App/PropertyPythonObject.h @@ -63,7 +63,7 @@ public: /** Use Python's pickle module to restore the object */ virtual void Restore(Base::XMLReader &reader); virtual void SaveDocFile (Base::Writer &writer) const; - virtual void RestoreDocFile(Base::Reader &reader); + virtual void RestoreDocFile(Base::Reader &reader, const int FileVersion); virtual unsigned int getMemSize (void) const; virtual Property *Copy(void) const; diff --git a/src/App/PropertyStandard.cpp b/src/App/PropertyStandard.cpp index 724788c01..5d6eaba7e 100644 --- a/src/App/PropertyStandard.cpp +++ b/src/App/PropertyStandard.cpp @@ -1127,14 +1127,20 @@ void PropertyFloatList::SaveDocFile (Base::Writer &writer) const } } -void PropertyFloatList::RestoreDocFile(Base::Reader &reader) +void PropertyFloatList::RestoreDocFile(Base::Reader &reader, const int FileVersion) { Base::InputStream str(reader); uint32_t uCt=0; str >> uCt; std::vector values(uCt); for (std::vector::iterator it = values.begin(); it != values.end(); ++it) { - str >> *it; + if (FileVersion > 0) { + str >> *it; + } else { + float val; + str >> val; + (*it) = val; + } } setValues(values); } @@ -2084,7 +2090,7 @@ void PropertyColorList::SaveDocFile (Base::Writer &writer) const } } -void PropertyColorList::RestoreDocFile(Base::Reader &reader) +void PropertyColorList::RestoreDocFile(Base::Reader &reader, const int FileVersion) { Base::InputStream str(reader); uint32_t uCt=0; diff --git a/src/App/PropertyStandard.h b/src/App/PropertyStandard.h index c26688258..ef6936711 100644 --- a/src/App/PropertyStandard.h +++ b/src/App/PropertyStandard.h @@ -537,7 +537,7 @@ public: virtual void Restore(Base::XMLReader &reader); virtual void SaveDocFile (Base::Writer &writer) const; - virtual void RestoreDocFile(Base::Reader &reader); + virtual void RestoreDocFile(Base::Reader &reader, const int FileVersion); virtual Property *Copy(void) const; virtual void Paste(const Property &from); @@ -830,7 +830,7 @@ public: virtual void Restore(Base::XMLReader &reader); virtual void SaveDocFile (Base::Writer &writer) const; - virtual void RestoreDocFile(Base::Reader &reader); + virtual void RestoreDocFile(Base::Reader &reader, const int FileVersion); virtual Property *Copy(void) const; virtual void Paste(const Property &from); diff --git a/src/Base/Persistence.cpp b/src/Base/Persistence.cpp index 7054d6acb..141512c8d 100644 --- a/src/Base/Persistence.cpp +++ b/src/Base/Persistence.cpp @@ -65,6 +65,6 @@ void Persistence::SaveDocFile (Writer &/*writer*/) const { } -void Persistence::RestoreDocFile(Reader &/*reader*/) +void Persistence::RestoreDocFile(Reader &/*reader*/, const int FileVersion) { } diff --git a/src/Base/Persistence.h b/src/Base/Persistence.h index f05315653..1bc7a7977 100644 --- a/src/Base/Persistence.h +++ b/src/Base/Persistence.h @@ -145,7 +145,7 @@ public: * \endcode * @see Base::Reader,Base::XMLReader */ - virtual void RestoreDocFile(Reader &/*reader*/); + virtual void RestoreDocFile(Reader &/*reader*/, const int FileVersion); }; } //namespace Base diff --git a/src/Base/Reader.cpp b/src/Base/Reader.cpp index 496f583da..8aa12776a 100644 --- a/src/Base/Reader.cpp +++ b/src/Base/Reader.cpp @@ -304,7 +304,7 @@ void Base::XMLReader::readFiles(zipios::ZipInputStream &zipstream) const // no file name for the current entry in the zip was registered. if (jt != FileList.end()) { try { - jt->Object->RestoreDocFile(zipstream); + jt->Object->RestoreDocFile(zipstream, FileVersion); } catch(...) { // For any exception we just continue with the next file. diff --git a/src/Base/Reader.h b/src/Base/Reader.h index f35ff379d..9a5291fe9 100644 --- a/src/Base/Reader.h +++ b/src/Base/Reader.h @@ -165,6 +165,10 @@ public: /// Schema Version of the document int DocumentSchema; + /// Version of FreeCAD that wrote this document + std::string ProgramVersion; + /// Version of the file format + int FileVersion; protected: /// read the next element diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index f93aab1ee..a129ff893 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (c) 2004 Jürgen Riegel * + * Copyright (c) 2004 Jrgen Riegel * * * * This file is part of the FreeCAD CAx development system. * * * @@ -674,7 +674,7 @@ void Document::Restore(Base::XMLReader &reader) /** * Restores the properties of the view providers. */ -void Document::RestoreDocFile(Base::Reader &reader) +void Document::RestoreDocFile(Base::Reader &reader, const int FileVersion) { // We must create an XML parser to read from the input stream Base::XMLReader xmlReader("GuiDocument.xml", reader); diff --git a/src/Gui/Document.h b/src/Gui/Document.h index 85736c6b9..07fffccf8 100644 --- a/src/Gui/Document.h +++ b/src/Gui/Document.h @@ -119,7 +119,7 @@ public: /// This method is used to save large amounts of data to a binary file. virtual void SaveDocFile (Base::Writer &writer) const; /// This method is used to restore large amounts of data from a binary file. - virtual void RestoreDocFile(Base::Reader &reader); + virtual void RestoreDocFile(Base::Reader &reader, const int FileVersion); void exportObjects(const std::vector&, Base::Writer&); void importObjects(const std::vector&, Base::Reader&); //@} diff --git a/src/Gui/MergeDocuments.cpp b/src/Gui/MergeDocuments.cpp index 9b53d960c..be0d571be 100644 --- a/src/Gui/MergeDocuments.cpp +++ b/src/Gui/MergeDocuments.cpp @@ -160,7 +160,7 @@ void MergeDocuments::SaveDocFile (Base::Writer & w) const document->exportObjects(objects, w); } -void MergeDocuments::RestoreDocFile(Base::Reader & reader) +void MergeDocuments::RestoreDocFile(Base::Reader & reader, const int FileVersion) { std::vector obj = objects; // We must create an XML parser to read from the input stream diff --git a/src/Gui/MergeDocuments.h b/src/Gui/MergeDocuments.h index 42bc252e0..e4ee90d50 100644 --- a/src/Gui/MergeDocuments.h +++ b/src/Gui/MergeDocuments.h @@ -49,7 +49,7 @@ public: void Save (Base::Writer & w) const; void Restore(Base::XMLReader &r); void SaveDocFile (Base::Writer & w) const; - void RestoreDocFile(Base::Reader & r); + void RestoreDocFile(Base::Reader & r, const int FileVersion); private: zipios::ZipInputStream* stream; diff --git a/src/Gui/Thumbnail.cpp b/src/Gui/Thumbnail.cpp index df5cbdf3a..34e2b3de6 100644 --- a/src/Gui/Thumbnail.cpp +++ b/src/Gui/Thumbnail.cpp @@ -110,6 +110,6 @@ void Thumbnail::SaveDocFile (Base::Writer &writer) const writer.Stream().write(ba.constData(), ba.length()); } -void Thumbnail::RestoreDocFile(Base::Reader &reader) +void Thumbnail::RestoreDocFile(Base::Reader &reader, const int FileVersion) { } diff --git a/src/Gui/Thumbnail.h b/src/Gui/Thumbnail.h index daa66ad11..11b0c1b4d 100644 --- a/src/Gui/Thumbnail.h +++ b/src/Gui/Thumbnail.h @@ -50,7 +50,7 @@ public: /// This method is used to save large amounts of data to a binary file. void SaveDocFile (Base::Writer &writer) const; /// This method is used to restore large amounts of data from a binary file. - void RestoreDocFile(Base::Reader &reader); + void RestoreDocFile(Base::Reader &reader, const int FileVersion); //@} private: diff --git a/src/Mod/Fem/App/FemMesh.cpp b/src/Mod/Fem/App/FemMesh.cpp index 759b72bf7..e2d5dca10 100755 --- a/src/Mod/Fem/App/FemMesh.cpp +++ b/src/Mod/Fem/App/FemMesh.cpp @@ -744,7 +744,7 @@ void FemMesh::SaveDocFile (Base::Writer &writer) const fi.deleteFile(); } -void FemMesh::RestoreDocFile(Base::Reader &reader) +void FemMesh::RestoreDocFile(Base::Reader &reader, const int FileVersion) { // create a temporary file and copy the content from the zip stream Base::FileInfo fi(Base::FileInfo::getTempFileName().c_str()); diff --git a/src/Mod/Fem/App/FemMesh.h b/src/Mod/Fem/App/FemMesh.h index 274104b3f..15b1904a8 100755 --- a/src/Mod/Fem/App/FemMesh.h +++ b/src/Mod/Fem/App/FemMesh.h @@ -23,7 +23,7 @@ #ifndef FEM_FEMMESH_H #define FEM_FEMMESH_H - + #include #include @@ -65,7 +65,7 @@ public: virtual void Save (Base::Writer &/*writer*/) const; virtual void Restore(Base::XMLReader &/*reader*/); void SaveDocFile (Base::Writer &writer) const; - void RestoreDocFile(Base::Reader &reader); + void RestoreDocFile(Base::Reader &reader, const int FileVersion); /** @name Subelement management */ //@{ diff --git a/src/Mod/Fem/App/FemMeshProperty.cpp b/src/Mod/Fem/App/FemMeshProperty.cpp index 10e01fa9f..5221a3af2 100755 --- a/src/Mod/Fem/App/FemMeshProperty.cpp +++ b/src/Mod/Fem/App/FemMeshProperty.cpp @@ -162,9 +162,9 @@ void PropertyFemMesh::SaveDocFile (Base::Writer &writer) const _FemMesh->SaveDocFile(writer); } -void PropertyFemMesh::RestoreDocFile(Base::Reader &reader) +void PropertyFemMesh::RestoreDocFile(Base::Reader &reader, const int FileVersion) { aboutToSetValue(); - _FemMesh->RestoreDocFile(reader); + _FemMesh->RestoreDocFile(reader, FileVersion); hasSetValue(); } diff --git a/src/Mod/Fem/App/FemMeshProperty.h b/src/Mod/Fem/App/FemMeshProperty.h index 7b350ddc4..a4ac334ce 100755 --- a/src/Mod/Fem/App/FemMeshProperty.h +++ b/src/Mod/Fem/App/FemMeshProperty.h @@ -77,7 +77,7 @@ public: void Save (Base::Writer &writer) const; void Restore(Base::XMLReader &reader); void SaveDocFile (Base::Writer &writer) const; - void RestoreDocFile(Base::Reader &reader); + void RestoreDocFile(Base::Reader &reader, const int FileVersion); App::Property *Copy(void) const; void Paste(const App::Property &from); diff --git a/src/Mod/Mesh/App/Mesh.cpp b/src/Mod/Mesh/App/Mesh.cpp index 9a13a27a8..7a773779f 100644 --- a/src/Mod/Mesh/App/Mesh.cpp +++ b/src/Mod/Mesh/App/Mesh.cpp @@ -297,7 +297,7 @@ void MeshObject::Restore(Base::XMLReader &reader) // this is handled by the property class } -void MeshObject::RestoreDocFile(Base::Reader &reader) +void MeshObject::RestoreDocFile(Base::Reader &reader, const int FileVersion) { load(reader); } @@ -1154,8 +1154,8 @@ void MeshObject::removeSelfIntersections(const std::vector& indic for (it = indices.begin(); it != indices.end(); ) { unsigned long id1 = *it; ++it; unsigned long id2 = *it; ++it; - selfIntersections.push_back(std::make_pair - (id1,id2)); + selfIntersections.push_back(std::make_pair + (id1,id2)); } if (!selfIntersections.empty()) { @@ -1171,12 +1171,12 @@ void MeshObject::removeFoldsOnSurface() MeshCore::MeshEvalFoldsOnSurface s_eval(_kernel); MeshCore::MeshEvalFoldOversOnSurface f_eval(_kernel); - f_eval.Evaluate(); - std::vector inds = f_eval.GetIndices(); - - s_eval.Evaluate(); + f_eval.Evaluate(); + std::vector inds = f_eval.GetIndices(); + + s_eval.Evaluate(); std::vector inds1 = s_eval.GetIndices(); - + // remove duplicates inds.insert(inds.end(), inds1.begin(), inds1.end()); std::sort(inds.begin(), inds.end()); @@ -1188,8 +1188,8 @@ void MeshObject::removeFoldsOnSurface() // do this as additional check after removing folds on closed area for (int i=0; i<5; i++) { MeshCore::MeshEvalFoldsOnBoundary b_eval(_kernel); - if (b_eval.Evaluate()) - break; + if (b_eval.Evaluate()) + break; inds = b_eval.GetIndices(); if (!inds.empty()) deleteFacets(inds); diff --git a/src/Mod/Mesh/App/Mesh.h b/src/Mod/Mesh/App/Mesh.h index 441db4de3..2b40bc56e 100644 --- a/src/Mod/Mesh/App/Mesh.h +++ b/src/Mod/Mesh/App/Mesh.h @@ -141,7 +141,7 @@ public: void Save (Base::Writer &writer) const; void SaveDocFile (Base::Writer &writer) const; void Restore(Base::XMLReader &reader); - void RestoreDocFile(Base::Reader &reader); + void RestoreDocFile(Base::Reader &reader, const int FileVersion); void save(const char* file,MeshCore::MeshIO::Format f=MeshCore::MeshIO::Undefined, const MeshCore::Material* mat = 0) const; void save(std::ostream&) const; @@ -175,7 +175,7 @@ public: void addMesh(const MeshCore::MeshKernel&); void deleteFacets(const std::vector& removeIndices); void deletePoints(const std::vector& removeIndices); - std::vector > getComponents() const; + std::vector > getComponents() const; unsigned long countComponents() const; void removeComponents(unsigned long); /** @@ -364,4 +364,4 @@ private: } // namespace Mesh -#endif // MESH_MESH_H +#endif // MESH_MESH_H diff --git a/src/Mod/Mesh/App/MeshProperties.cpp b/src/Mod/Mesh/App/MeshProperties.cpp index 9e68cae10..e9f3a3e3e 100644 --- a/src/Mod/Mesh/App/MeshProperties.cpp +++ b/src/Mod/Mesh/App/MeshProperties.cpp @@ -45,7 +45,7 @@ using namespace Mesh; TYPESYSTEM_SOURCE(Mesh::PropertyNormalList, App::PropertyVectorList); TYPESYSTEM_SOURCE(Mesh::PropertyCurvatureList , App::PropertyLists); TYPESYSTEM_SOURCE(Mesh::PropertyMeshKernel , App::PropertyComplexGeoData); - + void PropertyNormalList::transform(const Base::Matrix4D &mat) { // A normal vector is only a direction with unit length, so we only need to rotate it @@ -221,7 +221,7 @@ void PropertyCurvatureList::SaveDocFile (Base::Writer &writer) const } } -void PropertyCurvatureList::RestoreDocFile(Base::Reader &reader) +void PropertyCurvatureList::RestoreDocFile(Base::Reader &reader, const int FileVersion) { Base::InputStream str(reader); uint32_t uCt=0; @@ -422,7 +422,7 @@ void PropertyMeshKernel::setPyObject(PyObject *value) } } else if (PyList_Check(value)) { - // new instance of MeshObject + // new instance of MeshObject Py::List triangles(value); MeshObject* mesh = MeshObject::createMeshFromList(triangles); setValuePtr(mesh); @@ -478,7 +478,7 @@ void PropertyMeshKernel::SaveDocFile (Base::Writer &writer) const _meshObject->save(writer.Stream()); } -void PropertyMeshKernel::RestoreDocFile(Base::Reader &reader) +void PropertyMeshKernel::RestoreDocFile(Base::Reader &reader, const int FileVersion) { aboutToSetValue(); _meshObject->load(reader); @@ -500,4 +500,4 @@ void PropertyMeshKernel::Paste(const App::Property &from) const PropertyMeshKernel& prop = dynamic_cast(from); *(this->_meshObject) = *(prop._meshObject); hasSetValue(); -} +} diff --git a/src/Mod/Mesh/App/MeshProperties.h b/src/Mod/Mesh/App/MeshProperties.h index 04bfb8dee..1552fbab7 100644 --- a/src/Mod/Mesh/App/MeshProperties.h +++ b/src/Mod/Mesh/App/MeshProperties.h @@ -107,7 +107,7 @@ public: void Restore(Base::XMLReader &reader); void SaveDocFile (Base::Writer &writer) const; - void RestoreDocFile(Base::Reader &reader); + void RestoreDocFile(Base::Reader &reader, const int FileVersion); /** @name Python interface */ //@{ @@ -205,7 +205,7 @@ public: void Restore(Base::XMLReader &reader); void SaveDocFile (Base::Writer &writer) const; - void RestoreDocFile(Base::Reader &reader); + void RestoreDocFile(Base::Reader &reader, const int FileVersion); App::Property *Copy(void) const; void Paste(const App::Property &from); diff --git a/src/Mod/Part/App/PropertyTopoShape.cpp b/src/Mod/Part/App/PropertyTopoShape.cpp index 718e7fee9..34add8d0c 100644 --- a/src/Mod/Part/App/PropertyTopoShape.cpp +++ b/src/Mod/Part/App/PropertyTopoShape.cpp @@ -261,8 +261,8 @@ void PropertyPartShape::SaveDocFile (Base::Writer &writer) const const TopoDS_Shape& myShape = copy.Shape(); BRepTools::Clean(myShape); // remove triangulation - // create a temporary file and copy the content to the zip stream - // once the tmp. filename is known use always the same because otherwise + // create a temporary file and copy the content to the zip stream + // once the tmp. filename is known use always the same because otherwise // we may run into some problems on the Linux platform static Base::FileInfo fi(Base::FileInfo::getTempFileName()); @@ -304,7 +304,7 @@ void PropertyPartShape::SaveDocFile (Base::Writer &writer) const fi.deleteFile(); } -void PropertyPartShape::RestoreDocFile(Base::Reader &reader) +void PropertyPartShape::RestoreDocFile(Base::Reader &reader, const int FileVersion) { BRep_Builder builder; @@ -397,7 +397,7 @@ void PropertyShapeHistory::SaveDocFile (Base::Writer &writer) const { } -void PropertyShapeHistory::RestoreDocFile(Base::Reader &reader) +void PropertyShapeHistory::RestoreDocFile(Base::Reader &reader, const int FileVersion) { } @@ -505,7 +505,7 @@ void PropertyFilletEdges::SaveDocFile (Base::Writer &writer) const } } -void PropertyFilletEdges::RestoreDocFile(Base::Reader &reader) +void PropertyFilletEdges::RestoreDocFile(Base::Reader &reader, const int FileVersion) { Base::InputStream str(reader); uint32_t uCt=0; diff --git a/src/Mod/Part/App/PropertyTopoShape.h b/src/Mod/Part/App/PropertyTopoShape.h index a75c85ccd..0adb189da 100644 --- a/src/Mod/Part/App/PropertyTopoShape.h +++ b/src/Mod/Part/App/PropertyTopoShape.h @@ -87,7 +87,7 @@ public: void Restore(Base::XMLReader &reader); void SaveDocFile (Base::Writer &writer) const; - void RestoreDocFile(Base::Reader &reader); + void RestoreDocFile(Base::Reader &reader, const int FileVersion); App::Property *Copy(void) const; void Paste(const App::Property &from); @@ -138,7 +138,7 @@ public: virtual void Restore(Base::XMLReader &reader); virtual void SaveDocFile (Base::Writer &writer) const; - virtual void RestoreDocFile(Base::Reader &reader); + virtual void RestoreDocFile(Base::Reader &reader, const int FileVersion); virtual Property *Copy(void) const; virtual void Paste(const Property &from); @@ -191,7 +191,7 @@ public: virtual void Restore(Base::XMLReader &reader); virtual void SaveDocFile (Base::Writer &writer) const; - virtual void RestoreDocFile(Base::Reader &reader); + virtual void RestoreDocFile(Base::Reader &reader, const int FileVersion); virtual Property *Copy(void) const; virtual void Paste(const Property &from); diff --git a/src/Mod/Part/App/TopoShape.cpp b/src/Mod/Part/App/TopoShape.cpp index bd3746a26..a6068cd0e 100644 --- a/src/Mod/Part/App/TopoShape.cpp +++ b/src/Mod/Part/App/TopoShape.cpp @@ -939,7 +939,7 @@ void TopoShape::SaveDocFile (Base::Writer &writer) const { } -void TopoShape::RestoreDocFile(Base::Reader &reader) +void TopoShape::RestoreDocFile(Base::Reader &reader, const int FileVersion) { } diff --git a/src/Mod/Part/App/TopoShape.h b/src/Mod/Part/App/TopoShape.h index 0369682ff..777084e4f 100644 --- a/src/Mod/Part/App/TopoShape.h +++ b/src/Mod/Part/App/TopoShape.h @@ -111,7 +111,7 @@ public: void Restore(Base::XMLReader &reader); void SaveDocFile (Base::Writer &writer) const; - void RestoreDocFile(Base::Reader &reader); + void RestoreDocFile(Base::Reader &reader, const int FileVersion); unsigned int getMemSize (void) const; //@} diff --git a/src/Mod/Points/App/Points.cpp b/src/Mod/Points/App/Points.cpp index 9ecdb826d..d2735f8f5 100644 --- a/src/Mod/Points/App/Points.cpp +++ b/src/Mod/Points/App/Points.cpp @@ -134,19 +134,22 @@ void PointKernel::Restore(Base::XMLReader &reader) } } -void PointKernel::RestoreDocFile(Base::Reader &reader) +void PointKernel::RestoreDocFile(Base::Reader &reader, const int FileVersion) { Base::InputStream str(reader); uint32_t uCt = 0; str >> uCt; _Points.resize(uCt); for (unsigned long i=0; i < uCt; i++) { -// if doubleFileVersion -// double x, y, z -// else - float x, y, z; - str >> x >> y >> z; - _Points[i].Set(x,y,z); + if (FileVersion > 0) { + double x, y, z; + str >> x >> y >> z; + _Points[i].Set(x,y,z); + } else { + float x, y, z; + str >> x >> y >> z; + _Points[i].Set(x,y,z); + } } } diff --git a/src/Mod/Points/App/Points.h b/src/Mod/Points/App/Points.h index 06efa3c4f..cec019cd5 100644 --- a/src/Mod/Points/App/Points.h +++ b/src/Mod/Points/App/Points.h @@ -90,7 +90,7 @@ public: void Save (Base::Writer &writer) const; void SaveDocFile (Base::Writer &writer) const; void Restore(Base::XMLReader &reader); - void RestoreDocFile(Base::Reader &reader); + void RestoreDocFile(Base::Reader &reader, const int FileVersion); void save(const char* file) const; void save(std::ostream&) const; void load(const char* file); diff --git a/src/Mod/Points/App/PointsFeature.cpp b/src/Mod/Points/App/PointsFeature.cpp index d7fb7eb94..bc84a8321 100644 --- a/src/Mod/Points/App/PointsFeature.cpp +++ b/src/Mod/Points/App/PointsFeature.cpp @@ -64,10 +64,10 @@ void Feature::Restore(Base::XMLReader &reader) GeoFeature::Restore(reader); } -void Feature::RestoreDocFile(Base::Reader &reader) +void Feature::RestoreDocFile(Base::Reader &reader, const int FileVersion) { // This gets only invoked if a points file has been added from Restore() - Points.RestoreDocFile(reader); + Points.RestoreDocFile(reader, FileVersion); } void Feature::onChanged(const App::Property* prop) diff --git a/src/Mod/Points/App/PointsFeature.h b/src/Mod/Points/App/PointsFeature.h index 67f0cc9cc..8e2bae02b 100644 --- a/src/Mod/Points/App/PointsFeature.h +++ b/src/Mod/Points/App/PointsFeature.h @@ -60,7 +60,7 @@ public: /** @name methods overide Feature */ //@{ void Restore(Base::XMLReader &reader); - void RestoreDocFile(Base::Reader &reader); + void RestoreDocFile(Base::Reader &reader, const int FileVersion); /// recalculate the Feature virtual App::DocumentObjectExecReturn *execute(void); /// returns the type name of the ViewProvider diff --git a/src/Mod/Points/App/Properties.cpp b/src/Mod/Points/App/Properties.cpp index ee8af76ca..99f71abef 100644 --- a/src/Mod/Points/App/Properties.cpp +++ b/src/Mod/Points/App/Properties.cpp @@ -291,7 +291,7 @@ void PropertyCurvatureList::SaveDocFile (Base::Writer &writer) const } } -void PropertyCurvatureList::RestoreDocFile(Base::Reader &reader) +void PropertyCurvatureList::RestoreDocFile(Base::Reader &reader, const int FileVersion) { Base::InputStream str(reader); uint32_t uCt=0; diff --git a/src/Mod/Points/App/Properties.h b/src/Mod/Points/App/Properties.h index 6832f5427..a48d6469d 100644 --- a/src/Mod/Points/App/Properties.h +++ b/src/Mod/Points/App/Properties.h @@ -141,7 +141,7 @@ public: void Restore(Base::XMLReader &reader); void SaveDocFile (Base::Writer &writer) const; - void RestoreDocFile(Base::Reader &reader); + void RestoreDocFile(Base::Reader &reader, const int FileVersion); //@} /** @name Undo/Redo */ diff --git a/src/Mod/Points/App/PropertyPointKernel.cpp b/src/Mod/Points/App/PropertyPointKernel.cpp index f0dcf9498..624e4c210 100644 --- a/src/Mod/Points/App/PropertyPointKernel.cpp +++ b/src/Mod/Points/App/PropertyPointKernel.cpp @@ -134,10 +134,10 @@ void PropertyPointKernel::SaveDocFile (Base::Writer &writer) const // does nothing } -void PropertyPointKernel::RestoreDocFile(Base::Reader &reader) +void PropertyPointKernel::RestoreDocFile(Base::Reader &reader, const int FileVersion) { aboutToSetValue(); - _cPoints->RestoreDocFile(reader); + _cPoints->RestoreDocFile(reader, FileVersion); hasSetValue(); } diff --git a/src/Mod/Points/App/PropertyPointKernel.h b/src/Mod/Points/App/PropertyPointKernel.h index 6f08944b5..ee8fe9977 100644 --- a/src/Mod/Points/App/PropertyPointKernel.h +++ b/src/Mod/Points/App/PropertyPointKernel.h @@ -78,7 +78,7 @@ public: void Save (Base::Writer &writer) const; void Restore(Base::XMLReader &reader); void SaveDocFile (Base::Writer &writer) const; - void RestoreDocFile(Base::Reader &reader); + void RestoreDocFile(Base::Reader &reader, const int FileVersion); //@} /** @name Modification */ From 15573eea04185e68b58fc6c5a49077b3b525356b Mon Sep 17 00:00:00 2001 From: jrheinlaender Date: Wed, 27 Mar 2013 18:59:41 +0430 Subject: [PATCH 15/17] Fixed python format flags "f" from float to double "d" --- src/Mod/Cam/App/AppCamPy.cpp | 2 +- src/Mod/Part/App/PrimitiveFeature.cpp | 12 ++++++------ src/Mod/Part/App/TopoShapeFacePyImp.cpp | 2 +- src/Mod/Part/App/TopoShapeWirePyImp.cpp | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Mod/Cam/App/AppCamPy.cpp b/src/Mod/Cam/App/AppCamPy.cpp index 7ed919260..a4c5fad77 100644 --- a/src/Mod/Cam/App/AppCamPy.cpp +++ b/src/Mod/Cam/App/AppCamPy.cpp @@ -356,7 +356,7 @@ static PyObject * offset(PyObject *self,PyObject *args) { double offset; PyObject *pcObj; - if (!PyArg_ParseTuple(args, "O!f",&(TopoShapePy::Type), &pcObj,&offset )) + if (!PyArg_ParseTuple(args, "O!d",&(TopoShapePy::Type), &pcObj,&offset )) return NULL; TopoShapePy *pcShape = static_cast(pcObj); //Original-Shape wird hier übergeben diff --git a/src/Mod/Part/App/PrimitiveFeature.cpp b/src/Mod/Part/App/PrimitiveFeature.cpp index 2bd0cd618..42c67cf52 100644 --- a/src/Mod/Part/App/PrimitiveFeature.cpp +++ b/src/Mod/Part/App/PrimitiveFeature.cpp @@ -168,12 +168,12 @@ 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"); + ADD_PROPERTY_TYPE(X1,(0.0),"Vertex 1 - Start",App::Prop_None,"X value of the start vertex"); + ADD_PROPERTY_TYPE(Y1,(0.0),"Vertex 1 - Start",App::Prop_None,"Y value of the Start vertex"); + ADD_PROPERTY_TYPE(Z1,(0.0),"Vertex 1 - Start",App::Prop_None,"Z value of the Start vertex"); + ADD_PROPERTY_TYPE(X2,(0.0),"Vertex 2 - Finish",App::Prop_None,"X value of the finish vertex"); + ADD_PROPERTY_TYPE(Y2,(0.0),"Vertex 2 - Finish",App::Prop_None,"Y value of the finish vertex"); + ADD_PROPERTY_TYPE(Z2,(1.0),"Vertex 2 - Finish",App::Prop_None,"Z value of the finish vertex"); } Line::~Line() diff --git a/src/Mod/Part/App/TopoShapeFacePyImp.cpp b/src/Mod/Part/App/TopoShapeFacePyImp.cpp index 7bb261dbe..a3c920f08 100644 --- a/src/Mod/Part/App/TopoShapeFacePyImp.cpp +++ b/src/Mod/Part/App/TopoShapeFacePyImp.cpp @@ -242,7 +242,7 @@ int TopoShapeFacePy::PyInit(PyObject* args, PyObject* /*kwd*/) PyObject* TopoShapeFacePy::makeOffset(PyObject *args) { double dist; - if (!PyArg_ParseTuple(args, "f",&dist)) + if (!PyArg_ParseTuple(args, "d",&dist)) return 0; const TopoDS_Face& f = TopoDS::Face(getTopoShapePtr()->_Shape); diff --git a/src/Mod/Part/App/TopoShapeWirePyImp.cpp b/src/Mod/Part/App/TopoShapeWirePyImp.cpp index 3ed758c14..0f24b5861 100644 --- a/src/Mod/Part/App/TopoShapeWirePyImp.cpp +++ b/src/Mod/Part/App/TopoShapeWirePyImp.cpp @@ -210,7 +210,7 @@ PyObject* TopoShapeWirePy::fixWire(PyObject *args) PyObject* TopoShapeWirePy::makeOffset(PyObject *args) { double dist; - if (!PyArg_ParseTuple(args, "f",&dist)) + if (!PyArg_ParseTuple(args, "d",&dist)) return 0; const TopoDS_Wire& w = TopoDS::Wire(getTopoShapePtr()->_Shape); From b24f0efbc1ca4e0fc4a2a3dbdf6005ac262511ef Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 29 Mar 2013 15:23:51 +0100 Subject: [PATCH 16/17] Remove FileVersion from RestoreDocFile, convert point data back to floats --- src/App/PropertyFile.cpp | 2 +- src/App/PropertyFile.h | 2 +- src/App/PropertyGeo.cpp | 15 +- src/App/PropertyGeo.h | 2 +- src/App/PropertyPythonObject.cpp | 2 +- src/App/PropertyPythonObject.h | 2 +- src/App/PropertyStandard.cpp | 13 +- src/App/PropertyStandard.h | 4 +- src/Base/Persistence.cpp | 2 +- src/Base/Persistence.h | 4 +- src/Base/Reader.cpp | 22 +- src/Base/Reader.h | 12 + src/Gui/Document.cpp | 5 +- src/Gui/Document.h | 2 +- src/Gui/MergeDocuments.cpp | 4 +- src/Gui/MergeDocuments.h | 2 +- src/Gui/Thumbnail.cpp | 2 +- src/Gui/Thumbnail.h | 2 +- src/Mod/Fem/App/FemMesh.cpp | 2 +- src/Mod/Fem/App/FemMesh.h | 2 +- src/Mod/Fem/App/FemMeshProperty.cpp | 4 +- src/Mod/Fem/App/FemMeshProperty.h | 2 +- src/Mod/Inspection/App/AppInspection.cpp | 5 +- src/Mod/Inspection/App/InspectionFeature.cpp | 149 ++++++++- src/Mod/Inspection/App/InspectionFeature.h | 52 ++- .../Inspection/Gui/ViewProviderInspection.cpp | 18 +- src/Mod/Mesh/App/Mesh.cpp | 2 +- src/Mod/Mesh/App/Mesh.h | 2 +- src/Mod/Mesh/App/MeshProperties.cpp | 152 ++++++++- src/Mod/Mesh/App/MeshProperties.h | 48 ++- src/Mod/Part/App/PropertyTopoShape.cpp | 6 +- src/Mod/Part/App/PropertyTopoShape.h | 6 +- src/Mod/Part/App/TopoShape.cpp | 2 +- src/Mod/Part/App/TopoShape.h | 2 +- src/Mod/Points/App/Points.cpp | 22 +- src/Mod/Points/App/Points.h | 39 ++- src/Mod/Points/App/PointsFeature.cpp | 4 +- src/Mod/Points/App/PointsFeature.h | 2 +- src/Mod/Points/App/Properties.cpp | 307 +++++++++++++++++- src/Mod/Points/App/Properties.h | 92 ++++-- src/Mod/Points/App/PropertyPointKernel.cpp | 4 +- src/Mod/Points/App/PropertyPointKernel.h | 2 +- src/Mod/Points/Gui/ViewProvider.cpp | 12 +- 43 files changed, 896 insertions(+), 141 deletions(-) diff --git a/src/App/PropertyFile.cpp b/src/App/PropertyFile.cpp index 269d17902..934023272 100644 --- a/src/App/PropertyFile.cpp +++ b/src/App/PropertyFile.cpp @@ -327,7 +327,7 @@ void PropertyFileIncluded::SaveDocFile (Base::Writer &writer) const } } -void PropertyFileIncluded::RestoreDocFile(Base::Reader &reader, const int FileVersion) +void PropertyFileIncluded::RestoreDocFile(Base::Reader &reader) { Base::ofstream to(Base::FileInfo(_cValue.c_str())); if (!to) diff --git a/src/App/PropertyFile.h b/src/App/PropertyFile.h index b68ba80da..b48bec3b2 100644 --- a/src/App/PropertyFile.h +++ b/src/App/PropertyFile.h @@ -91,7 +91,7 @@ public: virtual void Restore(Base::XMLReader &reader); virtual void SaveDocFile (Base::Writer &writer) const; - virtual void RestoreDocFile(Base::Reader &reader, const int FileVersion); + virtual void RestoreDocFile(Base::Reader &reader); virtual Property *Copy(void) const; virtual void Paste(const Property &from); diff --git a/src/App/PropertyGeo.cpp b/src/App/PropertyGeo.cpp index 0da1d83d4..3e025c10a 100644 --- a/src/App/PropertyGeo.cpp +++ b/src/App/PropertyGeo.cpp @@ -301,14 +301,23 @@ void PropertyVectorList::SaveDocFile (Base::Writer &writer) const } } -void PropertyVectorList::RestoreDocFile(Base::Reader &reader, const int FileVersion) +void PropertyVectorList::RestoreDocFile(Base::Reader &reader) { Base::InputStream str(reader); uint32_t uCt=0; str >> uCt; std::vector values(uCt); - for (std::vector::iterator it = values.begin(); it != values.end(); ++it) { - str >> it->x >> it->y >> it->z; + if (reader.getFileVersion() > 0) { + for (std::vector::iterator it = values.begin(); it != values.end(); ++it) { + str >> it->x >> it->y >> it->z; + } + } + else { + float x,y,z; + for (std::vector::iterator it = values.begin(); it != values.end(); ++it) { + str >> x >> y >> z; + it->Set(x, y, z); + } } setValues(values); } diff --git a/src/App/PropertyGeo.h b/src/App/PropertyGeo.h index 53c972573..9aa9ac178 100644 --- a/src/App/PropertyGeo.h +++ b/src/App/PropertyGeo.h @@ -147,7 +147,7 @@ public: virtual void Restore(Base::XMLReader &reader); virtual void SaveDocFile (Base::Writer &writer) const; - virtual void RestoreDocFile(Base::Reader &reader, const int FileVersion); + virtual void RestoreDocFile(Base::Reader &reader); virtual Property *Copy(void) const; virtual void Paste(const Property &from); diff --git a/src/App/PropertyPythonObject.cpp b/src/App/PropertyPythonObject.cpp index 0c916833d..455ea65f6 100644 --- a/src/App/PropertyPythonObject.cpp +++ b/src/App/PropertyPythonObject.cpp @@ -372,7 +372,7 @@ void PropertyPythonObject::SaveDocFile (Base::Writer &writer) const writer.Stream().put(*it); } -void PropertyPythonObject::RestoreDocFile(Base::Reader &reader, const int FileVersion) +void PropertyPythonObject::RestoreDocFile(Base::Reader &reader) { aboutToSetValue(); std::string buffer; diff --git a/src/App/PropertyPythonObject.h b/src/App/PropertyPythonObject.h index 76608e800..bd4bec933 100644 --- a/src/App/PropertyPythonObject.h +++ b/src/App/PropertyPythonObject.h @@ -63,7 +63,7 @@ public: /** Use Python's pickle module to restore the object */ virtual void Restore(Base::XMLReader &reader); virtual void SaveDocFile (Base::Writer &writer) const; - virtual void RestoreDocFile(Base::Reader &reader, const int FileVersion); + virtual void RestoreDocFile(Base::Reader &reader); virtual unsigned int getMemSize (void) const; virtual Property *Copy(void) const; diff --git a/src/App/PropertyStandard.cpp b/src/App/PropertyStandard.cpp index 5d6eaba7e..2b2f4846e 100644 --- a/src/App/PropertyStandard.cpp +++ b/src/App/PropertyStandard.cpp @@ -1127,16 +1127,19 @@ void PropertyFloatList::SaveDocFile (Base::Writer &writer) const } } -void PropertyFloatList::RestoreDocFile(Base::Reader &reader, const int FileVersion) +void PropertyFloatList::RestoreDocFile(Base::Reader &reader) { Base::InputStream str(reader); uint32_t uCt=0; str >> uCt; std::vector values(uCt); - for (std::vector::iterator it = values.begin(); it != values.end(); ++it) { - if (FileVersion > 0) { + if (reader.getFileVersion() > 0) { + for (std::vector::iterator it = values.begin(); it != values.end(); ++it) { str >> *it; - } else { + } + } + else { + for (std::vector::iterator it = values.begin(); it != values.end(); ++it) { float val; str >> val; (*it) = val; @@ -2090,7 +2093,7 @@ void PropertyColorList::SaveDocFile (Base::Writer &writer) const } } -void PropertyColorList::RestoreDocFile(Base::Reader &reader, const int FileVersion) +void PropertyColorList::RestoreDocFile(Base::Reader &reader) { Base::InputStream str(reader); uint32_t uCt=0; diff --git a/src/App/PropertyStandard.h b/src/App/PropertyStandard.h index ef6936711..c26688258 100644 --- a/src/App/PropertyStandard.h +++ b/src/App/PropertyStandard.h @@ -537,7 +537,7 @@ public: virtual void Restore(Base::XMLReader &reader); virtual void SaveDocFile (Base::Writer &writer) const; - virtual void RestoreDocFile(Base::Reader &reader, const int FileVersion); + virtual void RestoreDocFile(Base::Reader &reader); virtual Property *Copy(void) const; virtual void Paste(const Property &from); @@ -830,7 +830,7 @@ public: virtual void Restore(Base::XMLReader &reader); virtual void SaveDocFile (Base::Writer &writer) const; - virtual void RestoreDocFile(Base::Reader &reader, const int FileVersion); + virtual void RestoreDocFile(Base::Reader &reader); virtual Property *Copy(void) const; virtual void Paste(const Property &from); diff --git a/src/Base/Persistence.cpp b/src/Base/Persistence.cpp index 141512c8d..7054d6acb 100644 --- a/src/Base/Persistence.cpp +++ b/src/Base/Persistence.cpp @@ -65,6 +65,6 @@ void Persistence::SaveDocFile (Writer &/*writer*/) const { } -void Persistence::RestoreDocFile(Reader &/*reader*/, const int FileVersion) +void Persistence::RestoreDocFile(Reader &/*reader*/) { } diff --git a/src/Base/Persistence.h b/src/Base/Persistence.h index 1bc7a7977..dfa857b09 100644 --- a/src/Base/Persistence.h +++ b/src/Base/Persistence.h @@ -33,7 +33,7 @@ namespace Base { -typedef std::istream Reader; +class Reader; class Writer; class XMLReader; @@ -145,7 +145,7 @@ public: * \endcode * @see Base::Reader,Base::XMLReader */ - virtual void RestoreDocFile(Reader &/*reader*/, const int FileVersion); + virtual void RestoreDocFile(Reader &/*reader*/); }; } //namespace Base diff --git a/src/Base/Reader.cpp b/src/Base/Reader.cpp index 8aa12776a..79eb81c2b 100644 --- a/src/Base/Reader.cpp +++ b/src/Base/Reader.cpp @@ -60,7 +60,7 @@ using namespace std; // --------------------------------------------------------------------------- Base::XMLReader::XMLReader(const char* FileName, std::istream& str) - : DocumentSchema(0), Level(0), _File(FileName) + : DocumentSchema(0), ProgramVersion(""), FileVersion(0), Level(0), _File(FileName) { #ifdef _MSC_VER str.imbue(std::locale::empty()); @@ -304,7 +304,7 @@ void Base::XMLReader::readFiles(zipios::ZipInputStream &zipstream) const // no file name for the current entry in the zip was registered. if (jt != FileList.end()) { try { - jt->Object->RestoreDocFile(zipstream, FileVersion); + jt->Object->RestoreDocFile(Base::Reader(zipstream, FileVersion)); } catch(...) { // For any exception we just continue with the next file. @@ -472,3 +472,21 @@ void Base::XMLReader::warning(const XERCES_CPP_NAMESPACE_QUALIFIER SAXParseExcep void Base::XMLReader::resetErrors() { } + +// ---------------------------------------------------------- + +Base::Reader::Reader(std::istream& str, int version) + : std::istream(str.rdbuf()), _str(str), fileVersion(version) +{ +} + +int Base::Reader::getFileVersion() const +{ + return fileVersion; +} + +std::istream& Base::Reader::getStream() +{ + return this->_str; +} + diff --git a/src/Base/Reader.h b/src/Base/Reader.h index 9a5291fe9..df82a5653 100644 --- a/src/Base/Reader.h +++ b/src/Base/Reader.h @@ -232,6 +232,18 @@ protected: std::vector FileNames; }; +class BaseExport Reader : public std::istream +{ +public: + Reader(std::istream&, int version); + int getFileVersion() const; + std::istream& getStream(); + +private: + std::istream& _str; + int fileVersion; +}; + } diff --git a/src/Gui/Document.cpp b/src/Gui/Document.cpp index a129ff893..23c4d63cd 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -674,10 +674,11 @@ void Document::Restore(Base::XMLReader &reader) /** * Restores the properties of the view providers. */ -void Document::RestoreDocFile(Base::Reader &reader, const int FileVersion) +void Document::RestoreDocFile(Base::Reader &reader) { // We must create an XML parser to read from the input stream Base::XMLReader xmlReader("GuiDocument.xml", reader); + xmlReader.FileVersion = reader.getFileVersion(); int i,Cnt; @@ -722,7 +723,7 @@ void Document::RestoreDocFile(Base::Reader &reader, const int FileVersion) // In the file GuiDocument.xml new data files might be added if (!xmlReader.getFilenames().empty()) - xmlReader.readFiles(static_cast(reader)); + xmlReader.readFiles(static_cast(reader.getStream())); // reset modified flag setModified(false); diff --git a/src/Gui/Document.h b/src/Gui/Document.h index 07fffccf8..85736c6b9 100644 --- a/src/Gui/Document.h +++ b/src/Gui/Document.h @@ -119,7 +119,7 @@ public: /// This method is used to save large amounts of data to a binary file. virtual void SaveDocFile (Base::Writer &writer) const; /// This method is used to restore large amounts of data from a binary file. - virtual void RestoreDocFile(Base::Reader &reader, const int FileVersion); + virtual void RestoreDocFile(Base::Reader &reader); void exportObjects(const std::vector&, Base::Writer&); void importObjects(const std::vector&, Base::Reader&); //@} diff --git a/src/Gui/MergeDocuments.cpp b/src/Gui/MergeDocuments.cpp index be0d571be..9bcb9ecb5 100644 --- a/src/Gui/MergeDocuments.cpp +++ b/src/Gui/MergeDocuments.cpp @@ -160,7 +160,7 @@ void MergeDocuments::SaveDocFile (Base::Writer & w) const document->exportObjects(objects, w); } -void MergeDocuments::RestoreDocFile(Base::Reader & reader, const int FileVersion) +void MergeDocuments::RestoreDocFile(Base::Reader & reader) { std::vector obj = objects; // We must create an XML parser to read from the input stream @@ -199,5 +199,5 @@ void MergeDocuments::RestoreDocFile(Base::Reader & reader, const int FileVersion // In the file GuiDocument.xml new data files might be added if (!xmlReader.getFilenames().empty()) - xmlReader.readFiles(static_cast(reader)); + xmlReader.readFiles(static_cast(reader.getStream())); } diff --git a/src/Gui/MergeDocuments.h b/src/Gui/MergeDocuments.h index e4ee90d50..42bc252e0 100644 --- a/src/Gui/MergeDocuments.h +++ b/src/Gui/MergeDocuments.h @@ -49,7 +49,7 @@ public: void Save (Base::Writer & w) const; void Restore(Base::XMLReader &r); void SaveDocFile (Base::Writer & w) const; - void RestoreDocFile(Base::Reader & r, const int FileVersion); + void RestoreDocFile(Base::Reader & r); private: zipios::ZipInputStream* stream; diff --git a/src/Gui/Thumbnail.cpp b/src/Gui/Thumbnail.cpp index 34e2b3de6..df5cbdf3a 100644 --- a/src/Gui/Thumbnail.cpp +++ b/src/Gui/Thumbnail.cpp @@ -110,6 +110,6 @@ void Thumbnail::SaveDocFile (Base::Writer &writer) const writer.Stream().write(ba.constData(), ba.length()); } -void Thumbnail::RestoreDocFile(Base::Reader &reader, const int FileVersion) +void Thumbnail::RestoreDocFile(Base::Reader &reader) { } diff --git a/src/Gui/Thumbnail.h b/src/Gui/Thumbnail.h index 11b0c1b4d..daa66ad11 100644 --- a/src/Gui/Thumbnail.h +++ b/src/Gui/Thumbnail.h @@ -50,7 +50,7 @@ public: /// This method is used to save large amounts of data to a binary file. void SaveDocFile (Base::Writer &writer) const; /// This method is used to restore large amounts of data from a binary file. - void RestoreDocFile(Base::Reader &reader, const int FileVersion); + void RestoreDocFile(Base::Reader &reader); //@} private: diff --git a/src/Mod/Fem/App/FemMesh.cpp b/src/Mod/Fem/App/FemMesh.cpp index e2d5dca10..759b72bf7 100755 --- a/src/Mod/Fem/App/FemMesh.cpp +++ b/src/Mod/Fem/App/FemMesh.cpp @@ -744,7 +744,7 @@ void FemMesh::SaveDocFile (Base::Writer &writer) const fi.deleteFile(); } -void FemMesh::RestoreDocFile(Base::Reader &reader, const int FileVersion) +void FemMesh::RestoreDocFile(Base::Reader &reader) { // create a temporary file and copy the content from the zip stream Base::FileInfo fi(Base::FileInfo::getTempFileName().c_str()); diff --git a/src/Mod/Fem/App/FemMesh.h b/src/Mod/Fem/App/FemMesh.h index 15b1904a8..79733fc95 100755 --- a/src/Mod/Fem/App/FemMesh.h +++ b/src/Mod/Fem/App/FemMesh.h @@ -65,7 +65,7 @@ public: virtual void Save (Base::Writer &/*writer*/) const; virtual void Restore(Base::XMLReader &/*reader*/); void SaveDocFile (Base::Writer &writer) const; - void RestoreDocFile(Base::Reader &reader, const int FileVersion); + void RestoreDocFile(Base::Reader &reader); /** @name Subelement management */ //@{ diff --git a/src/Mod/Fem/App/FemMeshProperty.cpp b/src/Mod/Fem/App/FemMeshProperty.cpp index 5221a3af2..10e01fa9f 100755 --- a/src/Mod/Fem/App/FemMeshProperty.cpp +++ b/src/Mod/Fem/App/FemMeshProperty.cpp @@ -162,9 +162,9 @@ void PropertyFemMesh::SaveDocFile (Base::Writer &writer) const _FemMesh->SaveDocFile(writer); } -void PropertyFemMesh::RestoreDocFile(Base::Reader &reader, const int FileVersion) +void PropertyFemMesh::RestoreDocFile(Base::Reader &reader) { aboutToSetValue(); - _FemMesh->RestoreDocFile(reader, FileVersion); + _FemMesh->RestoreDocFile(reader); hasSetValue(); } diff --git a/src/Mod/Fem/App/FemMeshProperty.h b/src/Mod/Fem/App/FemMeshProperty.h index a4ac334ce..7b350ddc4 100755 --- a/src/Mod/Fem/App/FemMeshProperty.h +++ b/src/Mod/Fem/App/FemMeshProperty.h @@ -77,7 +77,7 @@ public: void Save (Base::Writer &writer) const; void Restore(Base::XMLReader &reader); void SaveDocFile (Base::Writer &writer) const; - void RestoreDocFile(Base::Reader &reader, const int FileVersion); + void RestoreDocFile(Base::Reader &reader); App::Property *Copy(void) const; void Paste(const App::Property &from); diff --git a/src/Mod/Inspection/App/AppInspection.cpp b/src/Mod/Inspection/App/AppInspection.cpp index 0c306f6d0..b8d5819cd 100644 --- a/src/Mod/Inspection/App/AppInspection.cpp +++ b/src/Mod/Inspection/App/AppInspection.cpp @@ -47,8 +47,9 @@ void InspectionExport initInspection() { (void) Py_InitModule3("Inspection", Inspection_methods, module_Inspection_doc); /* mod name, table ptr */ Base::Console().Log("Loading Inspection module... done\n"); - Inspection::Feature ::init(); - Inspection::Group ::init(); + Inspection::PropertyDistanceList ::init(); + Inspection::Feature ::init(); + Inspection::Group ::init(); } } // extern "C" diff --git a/src/Mod/Inspection/App/InspectionFeature.cpp b/src/Mod/Inspection/App/InspectionFeature.cpp index b0783ad43..f8cd42774 100644 --- a/src/Mod/Inspection/App/InspectionFeature.cpp +++ b/src/Mod/Inspection/App/InspectionFeature.cpp @@ -442,6 +442,151 @@ float InspectNominalShape::getDistance(const Base::Vector3f& point) // ---------------------------------------------------------------- +TYPESYSTEM_SOURCE(Inspection::PropertyDistanceList, App::PropertyLists); + +PropertyDistanceList::PropertyDistanceList() +{ + +} + +PropertyDistanceList::~PropertyDistanceList() +{ + +} + +void PropertyDistanceList::setSize(int newSize) +{ + _lValueList.resize(newSize); +} + +int PropertyDistanceList::getSize(void) const +{ + return static_cast(_lValueList.size()); +} + +void PropertyDistanceList::setValue(float lValue) +{ + aboutToSetValue(); + _lValueList.resize(1); + _lValueList[0]=lValue; + hasSetValue(); +} + +void PropertyDistanceList::setValues(const std::vector& values) +{ + aboutToSetValue(); + _lValueList = values; + hasSetValue(); +} + +PyObject *PropertyDistanceList::getPyObject(void) +{ + PyObject* list = PyList_New(getSize()); + for (int i = 0;i values; + values.resize(nSize); + + for (Py_ssize_t i=0; iob_type->tp_name; + throw Py::TypeError(error); + } + + values[i] = (float)PyFloat_AsDouble(item); + } + + setValues(values); + } + else if (PyFloat_Check(value)) { + setValue((float)PyFloat_AsDouble(value)); + } + else { + std::string error = std::string("type must be float or list of float, not "); + error += value->ob_type->tp_name; + throw Py::TypeError(error); + } +} + +void PropertyDistanceList::Save (Base::Writer &writer) const +{ + if (writer.isForceXML()) { + writer.Stream() << writer.ind() << "" << endl; + writer.incInd(); + for(int i = 0;i" << endl; ; + writer.decInd(); + writer.Stream() << writer.ind() <<"" << endl ; + } + else { + writer.Stream() << writer.ind() << "" << std::endl; + } +} + +void PropertyDistanceList::Restore(Base::XMLReader &reader) +{ + reader.readElement("FloatList"); + std::string file (reader.getAttribute("file") ); + + if (!file.empty()) { + // initate a file read + reader.addFile(file.c_str(),this); + } +} + +void PropertyDistanceList::SaveDocFile (Base::Writer &writer) const +{ + Base::OutputStream str(writer.Stream()); + uint32_t uCt = (uint32_t)getSize(); + str << uCt; + for (std::vector::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) { + str << *it; + } +} + +void PropertyDistanceList::RestoreDocFile(Base::Reader &reader) +{ + Base::InputStream str(reader); + uint32_t uCt=0; + str >> uCt; + std::vector values(uCt); + for (std::vector::iterator it = values.begin(); it != values.end(); ++it) { + str >> *it; + } + setValues(values); +} + +App::Property *PropertyDistanceList::Copy(void) const +{ + PropertyDistanceList *p= new PropertyDistanceList(); + p->_lValueList = _lValueList; + return p; +} + +void PropertyDistanceList::Paste(const App::Property &from) +{ + aboutToSetValue(); + _lValueList = dynamic_cast(from)._lValueList; + hasSetValue(); +} + +unsigned int PropertyDistanceList::getMemSize (void) const +{ + return static_cast(_lValueList.size() * sizeof(float)); +} + +// ---------------------------------------------------------------- + // helper class to use Qt's concurrent framework struct DistanceInspection { @@ -575,7 +720,7 @@ App::DocumentObjectExecReturn* Feature::execute(void) str << "Inspecting " << this->Label.getValue() << "..."; Base::SequencerLauncher seq(str.str().c_str(), count); - std::vector vals(count); + std::vector vals(count); for (unsigned long index = 0; index < count; index++) { Base::Vector3f pnt = actual->getPoint(index); @@ -599,7 +744,7 @@ App::DocumentObjectExecReturn* Feature::execute(void) float fRMS = 0; int countRMS = 0; - for (std::vector::iterator it = vals.begin(); it != vals.end(); ++it) { + for (std::vector::iterator it = vals.begin(); it != vals.end(); ++it) { if (fabs(*it) < FLT_MAX) { fRMS += (*it) * (*it); countRMS++; diff --git a/src/Mod/Inspection/App/InspectionFeature.h b/src/Mod/Inspection/App/InspectionFeature.h index 9efad3d89..d859b7b80 100644 --- a/src/Mod/Inspection/App/InspectionFeature.h +++ b/src/Mod/Inspection/App/InspectionFeature.h @@ -153,6 +153,56 @@ private: const TopoDS_Shape& _rShape; }; +class InspectionExport PropertyDistanceList: public App::PropertyLists +{ + TYPESYSTEM_HEADER(); + +public: + + /** + * A constructor. + * A more elaborate description of the constructor. + */ + PropertyDistanceList(); + + /** + * A destructor. + * A more elaborate description of the destructor. + */ + virtual ~PropertyDistanceList(); + + virtual void setSize(int newSize); + virtual int getSize(void) const; + + /** Sets the property + */ + void setValue(float); + + /// index operator + float 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& values); + + const std::vector &getValues(void) const{return _lValueList;} + + virtual PyObject *getPyObject(void); + virtual void setPyObject(PyObject *); + + virtual void Save (Base::Writer &writer) const; + virtual void Restore(Base::XMLReader &reader); + + virtual void SaveDocFile (Base::Writer &writer) const; + virtual void RestoreDocFile(Base::Reader &reader); + + virtual Property *Copy(void) const; + virtual void Paste(const Property &from); + virtual unsigned int getMemSize (void) const; + +private: + std::vector _lValueList; +}; + // ---------------------------------------------------------------- /** The inspection feature. @@ -173,7 +223,7 @@ public: App::PropertyFloat Thickness; App::PropertyLink Actual; App::PropertyLinkList Nominals; - App::PropertyFloatList Distances; + PropertyDistanceList Distances; //@} /** @name Actions */ diff --git a/src/Mod/Inspection/Gui/ViewProviderInspection.cpp b/src/Mod/Inspection/Gui/ViewProviderInspection.cpp index be8d258c7..f890b6daf 100644 --- a/src/Mod/Inspection/Gui/ViewProviderInspection.cpp +++ b/src/Mod/Inspection/Gui/ViewProviderInspection.cpp @@ -256,7 +256,7 @@ void ViewProviderInspection::updateData(const App::Property* prop) } } } - else if (prop->getTypeId() == App::PropertyFloatList::getClassTypeId()) { + else if (prop->getTypeId() == Inspection::PropertyDistanceList::getClassTypeId()) { // force an update of the Inventor data nodes if (this->pcObject) { App::Property* link = this->pcObject->getPropertyByName("Actual"); @@ -286,14 +286,14 @@ void ViewProviderInspection::setDistances() SoDebugError::post("ViewProviderInspection::setDistances", "Unknown property 'Distances'"); return; } - if (pDistances->getTypeId() != App::PropertyFloatList::getClassTypeId()) { + if (pDistances->getTypeId() != Inspection::PropertyDistanceList::getClassTypeId()) { SoDebugError::post("ViewProviderInspection::setDistances", - "Property 'Distances' has type %s (App::PropertyFloatList was expected)", pDistances->getTypeId().getName()); + "Property 'Distances' has type %s (Inspection::PropertyDistanceList was expected)", pDistances->getTypeId().getName()); return; } // distance values - const std::vector& fValues = ((App::PropertyFloatList*)pDistances)->getValues(); + const std::vector& fValues = static_cast(pDistances)->getValues(); if ((int)fValues.size() != this->pcCoords->point.getNum()) { pcMatBinding->value = SoMaterialBinding::OVERALL; return; @@ -308,7 +308,7 @@ void ViewProviderInspection::setDistances() float * tran = pcColorMat->transparency.startEditing(); unsigned long j=0; - for (std::vector::const_iterator jt = fValues.begin(); jt != fValues.end(); ++jt, j++) { + for (std::vector::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)) @@ -528,8 +528,8 @@ QString ViewProviderInspection::inspectDistance(const SoPickedPoint* pp) const // get the distances of the three points of the picked facet const SoFaceDetail * facedetail = static_cast(detail); App::Property* pDistance = this->pcObject->getPropertyByName("Distances"); - if (pDistance && pDistance->getTypeId() == App::PropertyFloatList::getClassTypeId()) { - App::PropertyFloatList* dist = (App::PropertyFloatList*)pDistance; + if (pDistance && pDistance->getTypeId() == Inspection::PropertyDistanceList::getClassTypeId()) { + Inspection::PropertyDistanceList* dist = static_cast(pDistance); int index1 = facedetail->getPoint(0)->getCoordinateIndex(); int index2 = facedetail->getPoint(1)->getCoordinateIndex(); int index3 = facedetail->getPoint(2)->getCoordinateIndex(); @@ -567,8 +567,8 @@ QString ViewProviderInspection::inspectDistance(const SoPickedPoint* pp) const // get the distance of the picked point int index = pointdetail->getCoordinateIndex(); App::Property* prop = this->pcObject->getPropertyByName("Distances"); - if ( prop && prop->getTypeId() == App::PropertyFloatList::getClassTypeId() ) { - App::PropertyFloatList* dist = (App::PropertyFloatList*)prop; + if (prop && prop->getTypeId() == Inspection::PropertyDistanceList::getClassTypeId()) { + Inspection::PropertyDistanceList* dist = static_cast(prop); float fVal = (*dist)[index]; info = QObject::tr("Distance: %1").arg(fVal); } diff --git a/src/Mod/Mesh/App/Mesh.cpp b/src/Mod/Mesh/App/Mesh.cpp index 7a773779f..aa14ccf10 100644 --- a/src/Mod/Mesh/App/Mesh.cpp +++ b/src/Mod/Mesh/App/Mesh.cpp @@ -297,7 +297,7 @@ void MeshObject::Restore(Base::XMLReader &reader) // this is handled by the property class } -void MeshObject::RestoreDocFile(Base::Reader &reader, const int FileVersion) +void MeshObject::RestoreDocFile(Base::Reader &reader) { load(reader); } diff --git a/src/Mod/Mesh/App/Mesh.h b/src/Mod/Mesh/App/Mesh.h index 2b40bc56e..3477556cd 100644 --- a/src/Mod/Mesh/App/Mesh.h +++ b/src/Mod/Mesh/App/Mesh.h @@ -141,7 +141,7 @@ public: void Save (Base::Writer &writer) const; void SaveDocFile (Base::Writer &writer) const; void Restore(Base::XMLReader &reader); - void RestoreDocFile(Base::Reader &reader, const int FileVersion); + void RestoreDocFile(Base::Reader &reader); void save(const char* file,MeshCore::MeshIO::Format f=MeshCore::MeshIO::Undefined, const MeshCore::Material* mat = 0) const; void save(std::ostream&) const; diff --git a/src/Mod/Mesh/App/MeshProperties.cpp b/src/Mod/Mesh/App/MeshProperties.cpp index e9f3a3e3e..a89087c54 100644 --- a/src/Mod/Mesh/App/MeshProperties.cpp +++ b/src/Mod/Mesh/App/MeshProperties.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include "Core/MeshKernel.h" #include "Core/MeshIO.h" @@ -42,10 +43,155 @@ using namespace Mesh; -TYPESYSTEM_SOURCE(Mesh::PropertyNormalList, App::PropertyVectorList); +TYPESYSTEM_SOURCE(Mesh::PropertyNormalList, App::PropertyLists); TYPESYSTEM_SOURCE(Mesh::PropertyCurvatureList , App::PropertyLists); TYPESYSTEM_SOURCE(Mesh::PropertyMeshKernel , App::PropertyComplexGeoData); +PropertyNormalList::PropertyNormalList() +{ + +} + +PropertyNormalList::~PropertyNormalList() +{ + +} + +void PropertyNormalList::setSize(int newSize) +{ + _lValueList.resize(newSize); +} + +int PropertyNormalList::getSize(void) const +{ + return static_cast(_lValueList.size()); +} + +void PropertyNormalList::setValue(const Base::Vector3f& lValue) +{ + aboutToSetValue(); + _lValueList.resize(1); + _lValueList[0]=lValue; + hasSetValue(); +} + +void PropertyNormalList::setValue(float x, float y, float z) +{ + aboutToSetValue(); + _lValueList.resize(1); + _lValueList[0].Set(x,y,z); + hasSetValue(); +} + +void PropertyNormalList::setValues(const std::vector& values) +{ + aboutToSetValue(); + _lValueList = values; + hasSetValue(); +} + +PyObject *PropertyNormalList::getPyObject(void) +{ + PyObject* list = PyList_New(getSize()); + + for (int i = 0;i values; + values.resize(nSize); + + for (Py_ssize_t i=0; i(val.getValue()); + } + + setValues(values); + } + else if (PyObject_TypeCheck(value, &(Base::VectorPy::Type))) { + Base::VectorPy *pcObject = static_cast(value); + Base::Vector3d* val = pcObject->getVectorPtr(); + setValue(Base::convertTo(*val)); + } + else if (PyTuple_Check(value) && PyTuple_Size(value) == 3) { + App::PropertyVector val; + val.setPyObject( value ); + setValue(Base::convertTo(val.getValue())); + } + else { + std::string error = std::string("type must be 'Vector' or list of 'Vector', not "); + error += value->ob_type->tp_name; + throw Py::TypeError(error); + } +} + +void PropertyNormalList::Save (Base::Writer &writer) const +{ + if (!writer.isForceXML()) { + writer.Stream() << writer.ind() << "" << std::endl; + } +} + +void PropertyNormalList::Restore(Base::XMLReader &reader) +{ + reader.readElement("VectorList"); + std::string file (reader.getAttribute("file") ); + + if (!file.empty()) { + // initate a file read + reader.addFile(file.c_str(),this); + } +} + +void PropertyNormalList::SaveDocFile (Base::Writer &writer) const +{ + Base::OutputStream str(writer.Stream()); + uint32_t uCt = (uint32_t)getSize(); + str << uCt; + for (std::vector::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) { + str << it->x << it->y << it->z; + } +} + +void PropertyNormalList::RestoreDocFile(Base::Reader &reader) +{ + Base::InputStream str(reader); + uint32_t uCt=0; + str >> uCt; + std::vector values(uCt); + for (std::vector::iterator it = values.begin(); it != values.end(); ++it) { + str >> it->x >> it->y >> it->z; + } + setValues(values); +} + +App::Property *PropertyNormalList::Copy(void) const +{ + PropertyNormalList *p= new PropertyNormalList(); + p->_lValueList = _lValueList; + return p; +} + +void PropertyNormalList::Paste(const App::Property &from) +{ + aboutToSetValue(); + _lValueList = dynamic_cast(from)._lValueList; + hasSetValue(); +} + +unsigned int PropertyNormalList::getMemSize (void) const +{ + return static_cast(_lValueList.size() * sizeof(Base::Vector3f)); +} + void PropertyNormalList::transform(const Base::Matrix4D &mat) { // A normal vector is only a direction with unit length, so we only need to rotate it @@ -221,7 +367,7 @@ void PropertyCurvatureList::SaveDocFile (Base::Writer &writer) const } } -void PropertyCurvatureList::RestoreDocFile(Base::Reader &reader, const int FileVersion) +void PropertyCurvatureList::RestoreDocFile(Base::Reader &reader) { Base::InputStream str(reader); uint32_t uCt=0; @@ -478,7 +624,7 @@ void PropertyMeshKernel::SaveDocFile (Base::Writer &writer) const _meshObject->save(writer.Stream()); } -void PropertyMeshKernel::RestoreDocFile(Base::Reader &reader, const int FileVersion) +void PropertyMeshKernel::RestoreDocFile(Base::Reader &reader) { aboutToSetValue(); _meshObject->load(reader); diff --git a/src/Mod/Mesh/App/MeshProperties.h b/src/Mod/Mesh/App/MeshProperties.h index 1552fbab7..94efa5786 100644 --- a/src/Mod/Mesh/App/MeshProperties.h +++ b/src/Mod/Mesh/App/MeshProperties.h @@ -50,18 +50,52 @@ class MeshPy; * Note: We need an own class for that to distinguish from the base vector list. * @author Werner Mayer */ -class MeshExport PropertyNormalList : public App::PropertyVectorList +class MeshExport PropertyNormalList: public App::PropertyLists { TYPESYSTEM_HEADER(); public: - PropertyNormalList() - { + PropertyNormalList(); + ~PropertyNormalList(); + + virtual void setSize(int newSize); + virtual int getSize(void) const; + + void setValue(const Base::Vector3f&); + void setValue(float x, float y, float z); + + const Base::Vector3f& operator[] (const int idx) const { + return _lValueList.operator[] (idx); } - virtual ~PropertyNormalList() - { + + void set1Value (const int idx, const Base::Vector3f& value) { + _lValueList.operator[] (idx) = value; } + + void setValues (const std::vector& values); + + const std::vector &getValues(void) const { + return _lValueList; + } + + virtual PyObject *getPyObject(void); + virtual void setPyObject(PyObject *); + + virtual void Save (Base::Writer &writer) const; + virtual void Restore(Base::XMLReader &reader); + + virtual void SaveDocFile (Base::Writer &writer) const; + virtual void RestoreDocFile(Base::Reader &reader); + + virtual App::Property *Copy(void) const; + virtual void Paste(const App::Property &from); + + virtual unsigned int getMemSize (void) const; + void transform(const Base::Matrix4D &rclMat); + +private: + std::vector _lValueList; }; /** Curvature information. */ @@ -107,7 +141,7 @@ public: void Restore(Base::XMLReader &reader); void SaveDocFile (Base::Writer &writer) const; - void RestoreDocFile(Base::Reader &reader, const int FileVersion); + void RestoreDocFile(Base::Reader &reader); /** @name Python interface */ //@{ @@ -205,7 +239,7 @@ public: void Restore(Base::XMLReader &reader); void SaveDocFile (Base::Writer &writer) const; - void RestoreDocFile(Base::Reader &reader, const int FileVersion); + void RestoreDocFile(Base::Reader &reader); App::Property *Copy(void) const; void Paste(const App::Property &from); diff --git a/src/Mod/Part/App/PropertyTopoShape.cpp b/src/Mod/Part/App/PropertyTopoShape.cpp index 34add8d0c..6b4b65392 100644 --- a/src/Mod/Part/App/PropertyTopoShape.cpp +++ b/src/Mod/Part/App/PropertyTopoShape.cpp @@ -304,7 +304,7 @@ void PropertyPartShape::SaveDocFile (Base::Writer &writer) const fi.deleteFile(); } -void PropertyPartShape::RestoreDocFile(Base::Reader &reader, const int FileVersion) +void PropertyPartShape::RestoreDocFile(Base::Reader &reader) { BRep_Builder builder; @@ -397,7 +397,7 @@ void PropertyShapeHistory::SaveDocFile (Base::Writer &writer) const { } -void PropertyShapeHistory::RestoreDocFile(Base::Reader &reader, const int FileVersion) +void PropertyShapeHistory::RestoreDocFile(Base::Reader &reader) { } @@ -505,7 +505,7 @@ void PropertyFilletEdges::SaveDocFile (Base::Writer &writer) const } } -void PropertyFilletEdges::RestoreDocFile(Base::Reader &reader, const int FileVersion) +void PropertyFilletEdges::RestoreDocFile(Base::Reader &reader) { Base::InputStream str(reader); uint32_t uCt=0; diff --git a/src/Mod/Part/App/PropertyTopoShape.h b/src/Mod/Part/App/PropertyTopoShape.h index 0adb189da..a75c85ccd 100644 --- a/src/Mod/Part/App/PropertyTopoShape.h +++ b/src/Mod/Part/App/PropertyTopoShape.h @@ -87,7 +87,7 @@ public: void Restore(Base::XMLReader &reader); void SaveDocFile (Base::Writer &writer) const; - void RestoreDocFile(Base::Reader &reader, const int FileVersion); + void RestoreDocFile(Base::Reader &reader); App::Property *Copy(void) const; void Paste(const App::Property &from); @@ -138,7 +138,7 @@ public: virtual void Restore(Base::XMLReader &reader); virtual void SaveDocFile (Base::Writer &writer) const; - virtual void RestoreDocFile(Base::Reader &reader, const int FileVersion); + virtual void RestoreDocFile(Base::Reader &reader); virtual Property *Copy(void) const; virtual void Paste(const Property &from); @@ -191,7 +191,7 @@ public: virtual void Restore(Base::XMLReader &reader); virtual void SaveDocFile (Base::Writer &writer) const; - virtual void RestoreDocFile(Base::Reader &reader, const int FileVersion); + virtual void RestoreDocFile(Base::Reader &reader); virtual Property *Copy(void) const; virtual void Paste(const Property &from); diff --git a/src/Mod/Part/App/TopoShape.cpp b/src/Mod/Part/App/TopoShape.cpp index a6068cd0e..bd3746a26 100644 --- a/src/Mod/Part/App/TopoShape.cpp +++ b/src/Mod/Part/App/TopoShape.cpp @@ -939,7 +939,7 @@ void TopoShape::SaveDocFile (Base::Writer &writer) const { } -void TopoShape::RestoreDocFile(Base::Reader &reader, const int FileVersion) +void TopoShape::RestoreDocFile(Base::Reader &reader) { } diff --git a/src/Mod/Part/App/TopoShape.h b/src/Mod/Part/App/TopoShape.h index 777084e4f..0369682ff 100644 --- a/src/Mod/Part/App/TopoShape.h +++ b/src/Mod/Part/App/TopoShape.h @@ -111,7 +111,7 @@ public: void Restore(Base::XMLReader &reader); void SaveDocFile (Base::Writer &writer) const; - void RestoreDocFile(Base::Reader &reader, const int FileVersion); + void RestoreDocFile(Base::Reader &reader); unsigned int getMemSize (void) const; //@} diff --git a/src/Mod/Points/App/Points.cpp b/src/Mod/Points/App/Points.cpp index d2735f8f5..28083b132 100644 --- a/src/Mod/Points/App/Points.cpp +++ b/src/Mod/Points/App/Points.cpp @@ -70,8 +70,8 @@ Data::Segment* PointKernel::getSubElement(const char* Type, unsigned long n) con void PointKernel::transformGeometry(const Base::Matrix4D &rclMat) { - std::vector& kernel = getBasicPoints(); - for (std::vector::iterator it = kernel.begin(); it != kernel.end(); ++it) + std::vector& kernel = getBasicPoints(); + for (std::vector::iterator it = kernel.begin(); it != kernel.end(); ++it) *it = rclMat * (*it); } @@ -112,7 +112,7 @@ void PointKernel::SaveDocFile (Base::Writer &writer) const uint32_t uCt = (uint32_t)size(); str << uCt; // store the data without transforming it - for (std::vector::const_iterator it = _Points.begin(); it != _Points.end(); ++it) { + for (std::vector::const_iterator it = _Points.begin(); it != _Points.end(); ++it) { str << it->x << it->y << it->z; } } @@ -134,22 +134,16 @@ void PointKernel::Restore(Base::XMLReader &reader) } } -void PointKernel::RestoreDocFile(Base::Reader &reader, const int FileVersion) +void PointKernel::RestoreDocFile(Base::Reader &reader) { Base::InputStream str(reader); uint32_t uCt = 0; str >> uCt; _Points.resize(uCt); for (unsigned long i=0; i < uCt; i++) { - if (FileVersion > 0) { - double x, y, z; - str >> x >> y >> z; - _Points[i].Set(x,y,z); - } else { - float x, y, z; - str >> x >> y >> z; - _Points[i].Set(x,y,z); - } + float x, y, z; + str >> x >> y >> z; + _Points[i].Set(x,y,z); } } @@ -182,7 +176,7 @@ void PointKernel::getFaces(std::vector &Points,std::vector::const_iterator index) +(const PointKernel* kernel, std::vector::const_iterator index) : _kernel(kernel), _p_it(index) { if(_p_it != kernel->_Points.end()) diff --git a/src/Mod/Points/App/Points.h b/src/Mod/Points/App/Points.h index cec019cd5..ae48d841d 100644 --- a/src/Mod/Points/App/Points.h +++ b/src/Mod/Points/App/Points.h @@ -46,6 +46,8 @@ class PointsExport PointKernel : public Data::ComplexGeoData TYPESYSTEM_HEADER(); public: + typedef Base::Vector3f value_type; + PointKernel(void) { } @@ -73,9 +75,9 @@ public: inline void setTransform(const Base::Matrix4D& rclTrf){_Mtrx = rclTrf;} inline Base::Matrix4D getTransform(void) const{return _Mtrx;} - std::vector& getBasicPoints() + std::vector& getBasicPoints() { return this->_Points; } - const std::vector& getBasicPoints() const + const std::vector& getBasicPoints() const { return this->_Points; } void getFaces(std::vector &Points,std::vector &Topo, float Accuracy, uint16_t flags=0) const; @@ -90,7 +92,7 @@ public: void Save (Base::Writer &writer) const; void SaveDocFile (Base::Writer &writer) const; void Restore(Base::XMLReader &reader); - void RestoreDocFile(Base::Reader &reader, const int FileVersion); + void RestoreDocFile(Base::Reader &reader); void save(const char* file) const; void save(std::ostream&) const; void load(const char* file); @@ -99,11 +101,11 @@ public: private: Base::Matrix4D _Mtrx; - std::vector _Points; + std::vector _Points; public: - typedef std::vector::difference_type difference_type; - typedef std::vector::size_type size_type; + typedef std::vector::difference_type difference_type; + typedef std::vector::size_type size_type; /// number of points stored size_type size(void) const {return this->_Points.size();} @@ -118,34 +120,35 @@ public: /// get the points inline const Base::Vector3d getPoint(const int idx) const { - return transformToOutside3d(_Points[idx]); + return transformToOutside(_Points[idx]); } /// set the points inline void setPoint(const int idx,const Base::Vector3d& point) { - _Points[idx] = transformToInside3d(point); + _Points[idx] = transformToInside(point); } /// insert the points inline void push_back(const Base::Vector3d& point) { - _Points.push_back(transformToInside3d(point)); + _Points.push_back(transformToInside(point)); } class PointsExport const_point_iterator { public: - typedef std::vector::const_iterator iter_type; + typedef Base::Vector3f value_single; + typedef Base::Vector3d value_type; + typedef std::vector::const_iterator iter_type; typedef iter_type::difference_type difference_type; typedef iter_type::iterator_category iterator_category; - typedef const Base::Vector3d* pointer; - typedef const Base::Vector3d& reference; - typedef Base::Vector3d value_type; + typedef const value_type* pointer; + typedef const value_type& reference; - const_point_iterator(const PointKernel*, std::vector::const_iterator index); + const_point_iterator(const PointKernel*, std::vector::const_iterator index); const_point_iterator(const const_point_iterator& pi); //~const_point_iterator(); const_point_iterator& operator=(const const_point_iterator& fi); - const Base::Vector3d& operator*(); - const Base::Vector3d* operator->(); + const value_type& operator*(); + const value_type* operator->(); bool operator==(const const_point_iterator& fi) const; bool operator!=(const const_point_iterator& fi) const; const_point_iterator& operator++(); @@ -160,8 +163,8 @@ public: private: void dereference(); const PointKernel* _kernel; - Base::Vector3d _point; - std::vector::const_iterator _p_it; + value_type _point; + std::vector::const_iterator _p_it; }; typedef const_point_iterator const_iterator; diff --git a/src/Mod/Points/App/PointsFeature.cpp b/src/Mod/Points/App/PointsFeature.cpp index bc84a8321..d7fb7eb94 100644 --- a/src/Mod/Points/App/PointsFeature.cpp +++ b/src/Mod/Points/App/PointsFeature.cpp @@ -64,10 +64,10 @@ void Feature::Restore(Base::XMLReader &reader) GeoFeature::Restore(reader); } -void Feature::RestoreDocFile(Base::Reader &reader, const int FileVersion) +void Feature::RestoreDocFile(Base::Reader &reader) { // This gets only invoked if a points file has been added from Restore() - Points.RestoreDocFile(reader, FileVersion); + Points.RestoreDocFile(reader); } void Feature::onChanged(const App::Property* prop) diff --git a/src/Mod/Points/App/PointsFeature.h b/src/Mod/Points/App/PointsFeature.h index 8e2bae02b..67f0cc9cc 100644 --- a/src/Mod/Points/App/PointsFeature.h +++ b/src/Mod/Points/App/PointsFeature.h @@ -60,7 +60,7 @@ public: /** @name methods overide Feature */ //@{ void Restore(Base::XMLReader &reader); - void RestoreDocFile(Base::Reader &reader, const int FileVersion); + void RestoreDocFile(Base::Reader &reader); /// recalculate the Feature virtual App::DocumentObjectExecReturn *execute(void); /// returns the type name of the ViewProvider diff --git a/src/Mod/Points/App/Properties.cpp b/src/Mod/Points/App/Properties.cpp index 99f71abef..b2e195272 100644 --- a/src/Mod/Points/App/Properties.cpp +++ b/src/Mod/Points/App/Properties.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include "Points.h" #include "Properties.h" @@ -42,28 +43,168 @@ using namespace Points; using namespace std; TYPESYSTEM_SOURCE(Points::PropertyGreyValue, App::PropertyFloat); -TYPESYSTEM_SOURCE(Points::PropertyGreyValueList, App::PropertyFloatList); -TYPESYSTEM_SOURCE(Points::PropertyNormalList, App::PropertyVectorList); +TYPESYSTEM_SOURCE(Points::PropertyGreyValueList, App::PropertyLists); +TYPESYSTEM_SOURCE(Points::PropertyNormalList, App::PropertyLists); TYPESYSTEM_SOURCE(Points::PropertyCurvatureList , App::PropertyLists); +PropertyGreyValueList::PropertyGreyValueList() +{ + +} + +PropertyGreyValueList::~PropertyGreyValueList() +{ + +} + +void PropertyGreyValueList::setSize(int newSize) +{ + _lValueList.resize(newSize); +} + +int PropertyGreyValueList::getSize(void) const +{ + return static_cast(_lValueList.size()); +} + +void PropertyGreyValueList::setValue(float lValue) +{ + aboutToSetValue(); + _lValueList.resize(1); + _lValueList[0]=lValue; + hasSetValue(); +} + +void PropertyGreyValueList::setValues(const std::vector& values) +{ + aboutToSetValue(); + _lValueList = values; + hasSetValue(); +} + +PyObject *PropertyGreyValueList::getPyObject(void) +{ + PyObject* list = PyList_New(getSize()); + for (int i = 0;i values; + values.resize(nSize); + + for (Py_ssize_t i=0; iob_type->tp_name; + throw Py::TypeError(error); + } + + values[i] = (float)PyFloat_AsDouble(item); + } + + setValues(values); + } + else if (PyFloat_Check(value)) { + setValue((float)PyFloat_AsDouble(value)); + } + else { + std::string error = std::string("type must be float or list of float, not "); + error += value->ob_type->tp_name; + throw Py::TypeError(error); + } +} + +void PropertyGreyValueList::Save (Base::Writer &writer) const +{ + if (writer.isForceXML()) { + writer.Stream() << writer.ind() << "" << endl; + writer.incInd(); + for(int i = 0;i" << endl; ; + writer.decInd(); + writer.Stream() << writer.ind() <<"" << endl ; + } + else { + writer.Stream() << writer.ind() << "" << std::endl; + } +} + +void PropertyGreyValueList::Restore(Base::XMLReader &reader) +{ + reader.readElement("FloatList"); + string file (reader.getAttribute("file") ); + + if (!file.empty()) { + // initate a file read + reader.addFile(file.c_str(),this); + } +} + +void PropertyGreyValueList::SaveDocFile (Base::Writer &writer) const +{ + Base::OutputStream str(writer.Stream()); + uint32_t uCt = (uint32_t)getSize(); + str << uCt; + for (std::vector::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) { + str << *it; + } +} + +void PropertyGreyValueList::RestoreDocFile(Base::Reader &reader) +{ + Base::InputStream str(reader); + uint32_t uCt=0; + str >> uCt; + std::vector values(uCt); + for (std::vector::iterator it = values.begin(); it != values.end(); ++it) { + str >> *it; + } + setValues(values); +} + +App::Property *PropertyGreyValueList::Copy(void) const +{ + PropertyGreyValueList *p= new PropertyGreyValueList(); + p->_lValueList = _lValueList; + return p; +} + +void PropertyGreyValueList::Paste(const App::Property &from) +{ + aboutToSetValue(); + _lValueList = dynamic_cast(from)._lValueList; + hasSetValue(); +} + +unsigned int PropertyGreyValueList::getMemSize (void) const +{ + return static_cast(_lValueList.size() * sizeof(float)); +} + void PropertyGreyValueList::removeIndices( const std::vector& uIndices ) { -#if 0 // We need a sorted array std::vector uSortedInds = uIndices; std::sort(uSortedInds.begin(), uSortedInds.end()); - const std::vector& rValueList = getValues(); + const std::vector& rValueList = getValues(); assert( uSortedInds.size() <= rValueList.size() ); if ( uSortedInds.size() > rValueList.size() ) return; - std::vector remainValue; + std::vector remainValue; remainValue.reserve(rValueList.size() - uSortedInds.size()); std::vector::iterator pos = uSortedInds.begin(); - for ( std::vector::const_iterator it = rValueList.begin(); it != rValueList.end(); ++it ) { + for ( std::vector::const_iterator it = rValueList.begin(); it != rValueList.end(); ++it ) { unsigned long index = it - rValueList.begin(); if (pos == uSortedInds.end()) remainValue.push_back( *it ); @@ -74,7 +215,151 @@ void PropertyGreyValueList::removeIndices( const std::vector& uIn } setValues(remainValue); -#endif +} + +PropertyNormalList::PropertyNormalList() +{ + +} + +PropertyNormalList::~PropertyNormalList() +{ + +} + +void PropertyNormalList::setSize(int newSize) +{ + _lValueList.resize(newSize); +} + +int PropertyNormalList::getSize(void) const +{ + return static_cast(_lValueList.size()); +} + +void PropertyNormalList::setValue(const Base::Vector3f& lValue) +{ + aboutToSetValue(); + _lValueList.resize(1); + _lValueList[0]=lValue; + hasSetValue(); +} + +void PropertyNormalList::setValue(float x, float y, float z) +{ + aboutToSetValue(); + _lValueList.resize(1); + _lValueList[0].Set(x,y,z); + hasSetValue(); +} + +void PropertyNormalList::setValues(const std::vector& values) +{ + aboutToSetValue(); + _lValueList = values; + hasSetValue(); +} + +PyObject *PropertyNormalList::getPyObject(void) +{ + PyObject* list = PyList_New(getSize()); + + for (int i = 0;i values; + values.resize(nSize); + + for (Py_ssize_t i=0; i(val.getValue()); + } + + setValues(values); + } + else if (PyObject_TypeCheck(value, &(Base::VectorPy::Type))) { + Base::VectorPy *pcObject = static_cast(value); + Base::Vector3d* val = pcObject->getVectorPtr(); + setValue(Base::convertTo(*val)); + } + else if (PyTuple_Check(value) && PyTuple_Size(value) == 3) { + App::PropertyVector val; + val.setPyObject( value ); + setValue(Base::convertTo(val.getValue())); + } + else { + std::string error = std::string("type must be 'Vector' or list of 'Vector', not "); + error += value->ob_type->tp_name; + throw Py::TypeError(error); + } +} + +void PropertyNormalList::Save (Base::Writer &writer) const +{ + if (!writer.isForceXML()) { + writer.Stream() << writer.ind() << "" << std::endl; + } +} + +void PropertyNormalList::Restore(Base::XMLReader &reader) +{ + reader.readElement("VectorList"); + std::string file (reader.getAttribute("file") ); + + if (!file.empty()) { + // initate a file read + reader.addFile(file.c_str(),this); + } +} + +void PropertyNormalList::SaveDocFile (Base::Writer &writer) const +{ + Base::OutputStream str(writer.Stream()); + uint32_t uCt = (uint32_t)getSize(); + str << uCt; + for (std::vector::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) { + str << it->x << it->y << it->z; + } +} + +void PropertyNormalList::RestoreDocFile(Base::Reader &reader) +{ + Base::InputStream str(reader); + uint32_t uCt=0; + str >> uCt; + std::vector values(uCt); + for (std::vector::iterator it = values.begin(); it != values.end(); ++it) { + str >> it->x >> it->y >> it->z; + } + setValues(values); +} + +App::Property *PropertyNormalList::Copy(void) const +{ + PropertyNormalList *p= new PropertyNormalList(); + p->_lValueList = _lValueList; + return p; +} + +void PropertyNormalList::Paste(const App::Property &from) +{ + aboutToSetValue(); + _lValueList = dynamic_cast(from)._lValueList; + hasSetValue(); +} + +unsigned int PropertyNormalList::getMemSize (void) const +{ + return static_cast(_lValueList.size() * sizeof(Base::Vector3f)); } void PropertyNormalList::transform(const Base::Matrix4D &mat) @@ -111,17 +396,17 @@ void PropertyNormalList::removeIndices( const std::vector& uIndic std::vector uSortedInds = uIndices; std::sort(uSortedInds.begin(), uSortedInds.end()); - const std::vector& rValueList = getValues(); + const std::vector& rValueList = getValues(); assert( uSortedInds.size() <= rValueList.size() ); if ( uSortedInds.size() > rValueList.size() ) return; - std::vector remainValue; + std::vector remainValue; remainValue.reserve(rValueList.size() - uSortedInds.size()); std::vector::iterator pos = uSortedInds.begin(); - for ( std::vector::const_iterator it = rValueList.begin(); it != rValueList.end(); ++it ) { + for ( std::vector::const_iterator it = rValueList.begin(); it != rValueList.end(); ++it ) { unsigned long index = it - rValueList.begin(); if (pos == uSortedInds.end()) remainValue.push_back( *it ); @@ -291,7 +576,7 @@ void PropertyCurvatureList::SaveDocFile (Base::Writer &writer) const } } -void PropertyCurvatureList::RestoreDocFile(Base::Reader &reader, const int FileVersion) +void PropertyCurvatureList::RestoreDocFile(Base::Reader &reader) { Base::InputStream str(reader); uint32_t uCt=0; diff --git a/src/Mod/Points/App/Properties.h b/src/Mod/Points/App/Properties.h index a48d6469d..004cfecf5 100644 --- a/src/Mod/Points/App/Properties.h +++ b/src/Mod/Points/App/Properties.h @@ -55,47 +55,101 @@ public: } }; -/** - * Own class to distinguish from real float list - */ -class PointsExport PropertyGreyValueList : public App::PropertyFloatList +class PointsExport PropertyGreyValueList: public App::PropertyLists { TYPESYSTEM_HEADER(); public: - PropertyGreyValueList() - { - } - virtual ~PropertyGreyValueList() - { - } + PropertyGreyValueList(); + virtual ~PropertyGreyValueList(); + + virtual void setSize(int newSize); + virtual int getSize(void) const; + + /** Sets the property + */ + void setValue(float); + + /// index operator + float 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& values); + + const std::vector &getValues(void) const{return _lValueList;} + + virtual PyObject *getPyObject(void); + virtual void setPyObject(PyObject *); + + virtual void Save (Base::Writer &writer) const; + virtual void Restore(Base::XMLReader &reader); + + virtual void SaveDocFile (Base::Writer &writer) const; + virtual void RestoreDocFile(Base::Reader &reader); + + virtual App::Property *Copy(void) const; + virtual void Paste(const App::Property &from); + virtual unsigned int getMemSize (void) const; /** @name Modify */ //@{ void removeIndices( const std::vector& ); //@} + +private: + std::vector _lValueList; }; -/** - * Own class to distinguish from real vector list - */ -class PointsExport PropertyNormalList : public App::PropertyVectorList +class PointsExport PropertyNormalList: public App::PropertyLists { TYPESYSTEM_HEADER(); public: - PropertyNormalList() - { + PropertyNormalList(); + ~PropertyNormalList(); + + virtual void setSize(int newSize); + virtual int getSize(void) const; + + void setValue(const Base::Vector3f&); + void setValue(float x, float y, float z); + + const Base::Vector3f& operator[] (const int idx) const { + return _lValueList.operator[] (idx); } - virtual ~PropertyNormalList() - { + + void set1Value (const int idx, const Base::Vector3f& value) { + _lValueList.operator[] (idx) = value; } + void setValues (const std::vector& values); + + const std::vector &getValues(void) const { + return _lValueList; + } + + virtual PyObject *getPyObject(void); + virtual void setPyObject(PyObject *); + + virtual void Save (Base::Writer &writer) const; + virtual void Restore(Base::XMLReader &reader); + + virtual void SaveDocFile (Base::Writer &writer) const; + virtual void RestoreDocFile(Base::Reader &reader); + + virtual App::Property *Copy(void) const; + virtual void Paste(const App::Property &from); + + virtual unsigned int getMemSize (void) const; + /** @name Modify */ //@{ void transform(const Base::Matrix4D &rclMat); void removeIndices( const std::vector& ); //@} + +private: + std::vector _lValueList; }; /** Curvature information. */ @@ -141,7 +195,7 @@ public: void Restore(Base::XMLReader &reader); void SaveDocFile (Base::Writer &writer) const; - void RestoreDocFile(Base::Reader &reader, const int FileVersion); + void RestoreDocFile(Base::Reader &reader); //@} /** @name Undo/Redo */ diff --git a/src/Mod/Points/App/PropertyPointKernel.cpp b/src/Mod/Points/App/PropertyPointKernel.cpp index 624e4c210..f0dcf9498 100644 --- a/src/Mod/Points/App/PropertyPointKernel.cpp +++ b/src/Mod/Points/App/PropertyPointKernel.cpp @@ -134,10 +134,10 @@ void PropertyPointKernel::SaveDocFile (Base::Writer &writer) const // does nothing } -void PropertyPointKernel::RestoreDocFile(Base::Reader &reader, const int FileVersion) +void PropertyPointKernel::RestoreDocFile(Base::Reader &reader) { aboutToSetValue(); - _cPoints->RestoreDocFile(reader, FileVersion); + _cPoints->RestoreDocFile(reader); hasSetValue(); } diff --git a/src/Mod/Points/App/PropertyPointKernel.h b/src/Mod/Points/App/PropertyPointKernel.h index ee8fe9977..6f08944b5 100644 --- a/src/Mod/Points/App/PropertyPointKernel.h +++ b/src/Mod/Points/App/PropertyPointKernel.h @@ -78,7 +78,7 @@ public: void Save (Base::Writer &writer) const; void Restore(Base::XMLReader &reader); void SaveDocFile (Base::Writer &writer) const; - void RestoreDocFile(Base::Reader &reader, const int FileVersion); + void RestoreDocFile(Base::Reader &reader); //@} /** @name Modification */ diff --git a/src/Mod/Points/Gui/ViewProvider.cpp b/src/Mod/Points/Gui/ViewProvider.cpp index bc0cb3040..1a28a7ae6 100644 --- a/src/Mod/Points/Gui/ViewProvider.cpp +++ b/src/Mod/Points/Gui/ViewProvider.cpp @@ -125,14 +125,14 @@ void ViewProviderPoints::setVertexColorMode(App::PropertyColorList* pcProperty) void ViewProviderPoints::setVertexGreyvalueMode(Points::PropertyGreyValueList* pcProperty) { - const std::vector& val = pcProperty->getValues(); + const std::vector& val = pcProperty->getValues(); unsigned long i=0; pcColorMat->enableNotify(false); pcColorMat->diffuseColor.deleteValues(0); pcColorMat->diffuseColor.setNum(val.size()); - for ( std::vector::const_iterator it = val.begin(); it != val.end(); ++it ) { + for ( std::vector::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& val = pcProperty->getValues(); + const std::vector& val = pcProperty->getValues(); unsigned long i=0; pcPointsNormal->enableNotify(false); pcPointsNormal->vector.deleteValues(0); pcPointsNormal->vector.setNum(val.size()); - for ( std::vector::const_iterator it = val.begin(); it != val.end(); ++it ) { + for ( std::vector::const_iterator it = val.begin(); it != val.end(); ++it ) { pcPointsNormal->vector.set1Value(i++, it->x, it->y, it->z); } @@ -469,8 +469,8 @@ void ViewProviderPointsBuilder::createPoints(const App::Property* prop, SoCoordi // get all points int idx=0; - const std::vector& kernel = cPts.getBasicPoints(); - for (std::vector::const_iterator it = kernel.begin(); it != kernel.end(); ++it, idx++) { + const std::vector& kernel = cPts.getBasicPoints(); + for (std::vector::const_iterator it = kernel.begin(); it != kernel.end(); ++it, idx++) { coords->point.set1Value(idx, (float)it->x, (float)it->y, (float)it->z); } From f69b57459baa263c4225ce4fe630a14cf8130cc6 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 30 Mar 2013 12:32:53 +0100 Subject: [PATCH 17/17] Support to write vector list and float lists in old format, fix issues in property editor, move back to float for curvature type --- src/App/Document.cpp | 3 +- src/App/PropertyGeo.cpp | 14 ++- src/App/PropertyStandard.cpp | 12 ++- src/Base/Writer.cpp | 12 ++- src/Base/Writer.h | 3 + src/Gui/SoFCDB.cpp | 1 - src/Gui/propertyeditor/PropertyItem.cpp | 111 +----------------------- src/Gui/propertyeditor/PropertyItem.h | 37 +------- src/Mod/PartDesign/App/FeatureDraft.cpp | 2 +- src/Mod/Points/App/Points.cpp | 20 +++-- src/Mod/Points/App/Points.h | 8 +- src/Mod/Points/App/Properties.cpp | 4 +- src/Mod/Points/App/Properties.h | 4 +- 13 files changed, 64 insertions(+), 167 deletions(-) diff --git a/src/App/Document.cpp b/src/App/Document.cpp index 8bf40b596..560c91724 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -601,7 +601,8 @@ void Document::Save (Base::Writer &writer) const writer.Stream() << "" << endl; + << App::Application::Config()["BuildRevision"] + << "\" FileVersion=\"" << writer.getFileVersion() << "\">" << endl; PropertyContainer::Save(writer); diff --git a/src/App/PropertyGeo.cpp b/src/App/PropertyGeo.cpp index 3e025c10a..3196d32b8 100644 --- a/src/App/PropertyGeo.cpp +++ b/src/App/PropertyGeo.cpp @@ -296,8 +296,18 @@ void PropertyVectorList::SaveDocFile (Base::Writer &writer) const Base::OutputStream str(writer.Stream()); uint32_t uCt = (uint32_t)getSize(); str << uCt; - for (std::vector::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) { - str << it->x << it->y << it->z; + if (writer.getFileVersion() > 0) { + for (std::vector::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) { + str << it->x << it->y << it->z; + } + } + else { + for (std::vector::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) { + float x = (float)it->x; + float y = (float)it->y; + float z = (float)it->z; + str << x << y << z; + } } } diff --git a/src/App/PropertyStandard.cpp b/src/App/PropertyStandard.cpp index 2b2f4846e..b860e6871 100644 --- a/src/App/PropertyStandard.cpp +++ b/src/App/PropertyStandard.cpp @@ -1122,8 +1122,16 @@ void PropertyFloatList::SaveDocFile (Base::Writer &writer) const Base::OutputStream str(writer.Stream()); uint32_t uCt = (uint32_t)getSize(); str << uCt; - for (std::vector::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) { - str << *it; + if (writer.getFileVersion() > 0) { + for (std::vector::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) { + str << *it; + } + } + else { + for (std::vector::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) { + float v = (float)*it; + str << v; + } } } diff --git a/src/Base/Writer.cpp b/src/Base/Writer.cpp index 621893a8a..875408e8c 100644 --- a/src/Base/Writer.cpp +++ b/src/Base/Writer.cpp @@ -49,7 +49,7 @@ using namespace zipios; // --------------------------------------------------------------------------- Writer::Writer(void) - : indent(0),forceXML(false) + : indent(0),forceXML(false),fileVersion(1) { indBuf[0] = '\0'; } @@ -98,6 +98,16 @@ bool Writer::isForceXML(void) return forceXML; } +void Writer::setFileVersion(int v) +{ + fileVersion = v; +} + +int Writer::getFileVersion() const +{ + return fileVersion; +} + std::string Writer::addFile(const char* Name,const Base::Persistence *Object) { // always check isForceXML() before requesting a file! diff --git a/src/Base/Writer.h b/src/Base/Writer.h index 083a5174d..f1eb7c3ed 100644 --- a/src/Base/Writer.h +++ b/src/Base/Writer.h @@ -62,6 +62,8 @@ public: void setForceXML(bool on); /// check on state bool isForceXML(void); + void setFileVersion(int); + int getFileVersion() const; /// insert a file as CDATA section in the XML file void insertAsciiFile(const char* FileName); @@ -106,6 +108,7 @@ protected: char indBuf[256]; bool forceXML; + int fileVersion; }; diff --git a/src/Gui/SoFCDB.cpp b/src/Gui/SoFCDB.cpp index 9a5680ab1..80436b732 100644 --- a/src/Gui/SoFCDB.cpp +++ b/src/Gui/SoFCDB.cpp @@ -112,7 +112,6 @@ void Gui::SoFCDB::init() PropertyAngleItem ::init(); PropertyBoolItem ::init(); PropertyVectorItem ::init(); - PropertyDoubleVectorItem ::init(); PropertyMatrixItem ::init(); PropertyPlacementItem ::init(); PropertyEnumItem ::init(); diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index c5d8cb9b9..2c97d3f0e 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -864,7 +864,7 @@ PropertyVectorItem::PropertyVectorItem() QVariant PropertyVectorItem::toString(const QVariant& prop) const { - const Base::Vector3f& value = prop.value(); + const Base::Vector3d& value = prop.value(); QString data = QString::fromAscii("[%1 %2 %3]") .arg(QLocale::system().toString(value.x, 'f', 2)) .arg(QLocale::system().toString(value.y, 'f', 2)) @@ -903,7 +903,7 @@ QWidget* PropertyVectorItem::createEditor(QWidget* parent, const QObject* /*rece void PropertyVectorItem::setEditorData(QWidget *editor, const QVariant& data) const { QLineEdit* le = qobject_cast(editor); - const Base::Vector3f& value = data.value(); + const Base::Vector3d& value = data.value(); QString text = QString::fromAscii("[%1 %2 %3]") .arg(QLocale::system().toString(value.x, 'f', 2)) .arg(QLocale::system().toString(value.y, 'f', 2)) @@ -949,109 +949,6 @@ void PropertyVectorItem::setZ(double z) // --------------------------------------------------------------- -TYPESYSTEM_SOURCE(Gui::PropertyEditor::PropertyDoubleVectorItem, Gui::PropertyEditor::PropertyItem); - -PropertyDoubleVectorItem::PropertyDoubleVectorItem() -{ - m_x = static_cast(PropertyFloatItem::create()); - m_x->setParent(this); - m_x->setPropertyName(QLatin1String("x")); - this->appendChild(m_x); - m_y = static_cast(PropertyFloatItem::create()); - m_y->setParent(this); - m_y->setPropertyName(QLatin1String("y")); - this->appendChild(m_y); - m_z = static_cast(PropertyFloatItem::create()); - m_z->setParent(this); - m_z->setPropertyName(QLatin1String("z")); - this->appendChild(m_z); -} - -QVariant PropertyDoubleVectorItem::toString(const QVariant& prop) const -{ - const Base::Vector3d& value = prop.value(); - QString data = QString::fromAscii("[%1 %2 %3]") - .arg(QLocale::system().toString(value.x, 'f', 2)) - .arg(QLocale::system().toString(value.y, 'f', 2)) - .arg(QLocale::system().toString(value.z, 'f', 2)); - return QVariant(data); -} - -QVariant PropertyDoubleVectorItem::value(const App::Property* prop) const -{ - // no real property class is using this - return QVariant::fromValue(Base::Vector3d()); -} - -void PropertyDoubleVectorItem::setValue(const QVariant& value) -{ - if (!value.canConvert()) - return; - const Base::Vector3d& val = value.value(); - QString data = QString::fromAscii("(%1, %2, %3)") - .arg(val.x,0,'f',decimals()) - .arg(val.y,0,'f',decimals()) - .arg(val.z,0,'f',decimals()); - setPropertyValue(data); -} - -QWidget* PropertyDoubleVectorItem::createEditor(QWidget* parent, const QObject* /*receiver*/, const char* /*method*/) const -{ - QLineEdit *le = new QLineEdit(parent); - le->setFrame(false); - le->setReadOnly(true); - return le; -} - -void PropertyDoubleVectorItem::setEditorData(QWidget *editor, const QVariant& data) const -{ - QLineEdit* le = qobject_cast(editor); - const Base::Vector3d& value = data.value(); - QString text = QString::fromAscii("[%1 %2 %3]") - .arg(QLocale::system().toString(value.x, 'f', 2)) - .arg(QLocale::system().toString(value.y, 'f', 2)) - .arg(QLocale::system().toString(value.z, 'f', 2)); - le->setText(text); -} - -QVariant PropertyDoubleVectorItem::editorData(QWidget *editor) const -{ - QLineEdit *le = qobject_cast(editor); - return QVariant(le->text()); -} - -double PropertyDoubleVectorItem::x() const -{ - return data(1,Qt::EditRole).value().x; -} - -void PropertyDoubleVectorItem::setX(double x) -{ - setData(QVariant::fromValue(Base::Vector3d(x, y(), z()))); -} - -double PropertyDoubleVectorItem::y() const -{ - return data(1,Qt::EditRole).value().y; -} - -void PropertyDoubleVectorItem::setY(double y) -{ - setData(QVariant::fromValue(Base::Vector3d(x(), y, z()))); -} - -double PropertyDoubleVectorItem::z() const -{ - return data(1,Qt::EditRole).value().z; -} - -void PropertyDoubleVectorItem::setZ(double z) -{ - setData(QVariant::fromValue(Base::Vector3d(x(), y(), z))); -} - -// --------------------------------------------------------------- - TYPESYSTEM_SOURCE(Gui::PropertyEditor::PropertyMatrixItem, Gui::PropertyEditor::PropertyItem); PropertyMatrixItem::PropertyMatrixItem() @@ -1481,12 +1378,12 @@ PropertyPlacementItem::PropertyPlacementItem() : init_axis(false), changed_value m_a->setParent(this); m_a->setPropertyName(QLatin1String("Angle")); this->appendChild(m_a); - m_d = static_cast(PropertyDoubleVectorItem::create()); + m_d = static_cast(PropertyVectorItem::create()); m_d->setParent(this); m_d->setPropertyName(QLatin1String("Axis")); m_d->setReadOnly(true); this->appendChild(m_d); - m_p = static_cast(PropertyDoubleVectorItem::create()); + m_p = static_cast(PropertyVectorItem::create()); m_p->setParent(this); m_p->setPropertyName(QLatin1String("Position")); m_p->setReadOnly(true); diff --git a/src/Gui/propertyeditor/PropertyItem.h b/src/Gui/propertyeditor/PropertyItem.h index e9990136d..a1a8f528d 100644 --- a/src/Gui/propertyeditor/PropertyItem.h +++ b/src/Gui/propertyeditor/PropertyItem.h @@ -335,39 +335,6 @@ private: PropertyFloatItem* m_z; }; -class GuiExport PropertyDoubleVectorItem: public PropertyItem -{ - Q_OBJECT - Q_PROPERTY(double x READ x WRITE setX DESIGNABLE true USER true) - Q_PROPERTY(double y READ y WRITE setY DESIGNABLE true USER true) - Q_PROPERTY(double z READ z WRITE setZ DESIGNABLE true USER true) - TYPESYSTEM_HEADER(); - - virtual QWidget* createEditor(QWidget* parent, const QObject* receiver, const char* method) const; - virtual void setEditorData(QWidget *editor, const QVariant& data) const; - virtual QVariant editorData(QWidget *editor) const; - - double x() const; - void setX(double x); - double y() const; - void setY(double y); - double z() const; - void setZ(double z); - -protected: - virtual QVariant toString(const QVariant&) const; - virtual QVariant value(const App::Property*) const; - virtual void setValue(const QVariant&); - -protected: - PropertyDoubleVectorItem(); - -private: - PropertyFloatItem* m_x; - PropertyFloatItem* m_y; - PropertyFloatItem* m_z; -}; - class GuiExport PropertyMatrixItem: public PropertyItem { Q_OBJECT @@ -510,8 +477,8 @@ private: bool changed_value; Base::Vector3d rot_axis; PropertyAngleItem * m_a; - PropertyDoubleVectorItem* m_d; - PropertyDoubleVectorItem* m_p; + PropertyVectorItem* m_d; + PropertyVectorItem* m_p; }; /** diff --git a/src/Mod/PartDesign/App/FeatureDraft.cpp b/src/Mod/PartDesign/App/FeatureDraft.cpp index b614afccc..bf787cd30 100644 --- a/src/Mod/PartDesign/App/FeatureDraft.cpp +++ b/src/Mod/PartDesign/App/FeatureDraft.cpp @@ -61,7 +61,7 @@ using namespace PartDesign; PROPERTY_SOURCE(PartDesign::Draft, PartDesign::DressUp) -const App::PropertyFloatConstraint::Constraints floatAngle = {0.0,89.9,0.1}; +const App::PropertyFloatConstraint::Constraints floatAngle = {0.0,89.99,0.1}; Draft::Draft() { diff --git a/src/Mod/Points/App/Points.cpp b/src/Mod/Points/App/Points.cpp index 28083b132..ebc38ecb4 100644 --- a/src/Mod/Points/App/Points.cpp +++ b/src/Mod/Points/App/Points.cpp @@ -70,8 +70,8 @@ Data::Segment* PointKernel::getSubElement(const char* Type, unsigned long n) con void PointKernel::transformGeometry(const Base::Matrix4D &rclMat) { - std::vector& kernel = getBasicPoints(); - for (std::vector::iterator it = kernel.begin(); it != kernel.end(); ++it) + std::vector& kernel = getBasicPoints(); + for (std::vector::iterator it = kernel.begin(); it != kernel.end(); ++it) *it = rclMat * (*it); } @@ -94,7 +94,7 @@ void PointKernel::operator = (const PointKernel& Kernel) unsigned int PointKernel::getMemSize (void) const { - return _Points.size() * sizeof(Base::Vector3d); + return _Points.size() * sizeof(value_type); } void PointKernel::Save (Base::Writer &writer) const @@ -112,7 +112,7 @@ void PointKernel::SaveDocFile (Base::Writer &writer) const uint32_t uCt = (uint32_t)size(); str << uCt; // store the data without transforming it - for (std::vector::const_iterator it = _Points.begin(); it != _Points.end(); ++it) { + for (std::vector::const_iterator it = _Points.begin(); it != _Points.end(); ++it) { str << it->x << it->y << it->z; } } @@ -176,12 +176,12 @@ void PointKernel::getFaces(std::vector &Points,std::vector::const_iterator index) +(const PointKernel* kernel, std::vector::const_iterator index) : _kernel(kernel), _p_it(index) { if(_p_it != kernel->_Points.end()) { - Base::Vector3d vertd(_p_it->x, _p_it->y, _p_it->z); + value_type vertd(_p_it->x, _p_it->y, _p_it->z); this->_point = _kernel->_Mtrx * vertd; } } @@ -207,17 +207,19 @@ PointKernel::const_point_iterator::operator=(const PointKernel::const_point_iter void PointKernel::const_point_iterator::dereference() { - Base::Vector3d vertd(_p_it->x, _p_it->y, _p_it->z); + value_type vertd(_p_it->x, _p_it->y, _p_it->z); this->_point = _kernel->_Mtrx * vertd; } -const Base::Vector3d& PointKernel::const_point_iterator::operator*() +const PointKernel::const_point_iterator::value_type& +PointKernel::const_point_iterator::operator*() { dereference(); return this->_point; } -const Base::Vector3d* PointKernel::const_point_iterator::operator->() +const PointKernel::const_point_iterator::value_type* +PointKernel::const_point_iterator::operator->() { dereference(); return &(this->_point); diff --git a/src/Mod/Points/App/Points.h b/src/Mod/Points/App/Points.h index ae48d841d..b04257207 100644 --- a/src/Mod/Points/App/Points.h +++ b/src/Mod/Points/App/Points.h @@ -134,15 +134,15 @@ public: class PointsExport const_point_iterator { public: - typedef Base::Vector3f value_single; + typedef PointKernel::value_type kernel_type; typedef Base::Vector3d value_type; - typedef std::vector::const_iterator iter_type; + typedef std::vector::const_iterator iter_type; typedef iter_type::difference_type difference_type; typedef iter_type::iterator_category iterator_category; typedef const value_type* pointer; typedef const value_type& reference; - const_point_iterator(const PointKernel*, std::vector::const_iterator index); + const_point_iterator(const PointKernel*, std::vector::const_iterator index); const_point_iterator(const const_point_iterator& pi); //~const_point_iterator(); @@ -164,7 +164,7 @@ public: void dereference(); const PointKernel* _kernel; value_type _point; - std::vector::const_iterator _p_it; + std::vector::const_iterator _p_it; }; typedef const_point_iterator const_iterator; diff --git a/src/Mod/Points/App/Properties.cpp b/src/Mod/Points/App/Properties.cpp index b2e195272..0c227f840 100644 --- a/src/Mod/Points/App/Properties.cpp +++ b/src/Mod/Points/App/Properties.cpp @@ -444,10 +444,10 @@ void PropertyCurvatureList::setValues(const std::vector& lValues) hasSetValue(); } -std::vector PropertyCurvatureList::getCurvature( int mode ) const +std::vector PropertyCurvatureList::getCurvature( int mode ) const { const std::vector& fCurvInfo = getValues(); - std::vector fValues; + std::vector fValues; fValues.reserve(fCurvInfo.size()); // Mean curvature diff --git a/src/Mod/Points/App/Properties.h b/src/Mod/Points/App/Properties.h index 004cfecf5..584515bb3 100644 --- a/src/Mod/Points/App/Properties.h +++ b/src/Mod/Points/App/Properties.h @@ -155,7 +155,7 @@ private: /** Curvature information. */ struct PointsExport CurvatureInfo { - double fMaxCurvature, fMinCurvature; + float fMaxCurvature, fMinCurvature; Base::Vector3f cMaxCurvDir, cMinCurvDir; }; @@ -182,7 +182,7 @@ public: int getSize(void) const {return _lValueList.size();} void setValue(const CurvatureInfo&); void setValues(const std::vector&); - std::vector getCurvature( int tMode) const; + std::vector getCurvature( int tMode) const; /// index operator const CurvatureInfo& operator[] (const int idx) const {return _lValueList.operator[] (idx);}