diff --git a/src/App/ComplexGeoData.h b/src/App/ComplexGeoData.h index 878839596..45e4c46ef 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,10 +167,16 @@ 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; + } }; } //namespace App -#endif +#endif diff --git a/src/App/Document.cpp b/src/App/Document.cpp index f5f96cd0c..6045106f3 100644 --- a/src/App/Document.cpp +++ b/src/App/Document.cpp @@ -653,7 +653,12 @@ void Document::Save (Base::Writer &writer) const << " FreeCAD Document, see http://www.freecadweb.org for more information..." << endl << "-->" << endl; - writer.Stream() << "" << endl; + //writer.Stream() << "" << endl; + writer.Stream() << "" << endl; PropertyContainer::Save(writer); @@ -668,6 +673,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 @@ -736,7 +751,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; @@ -843,6 +862,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); @@ -1821,8 +1850,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 70d8622e9..5858d8e1e 100644 --- a/src/App/PropertyFile.cpp +++ b/src/App/PropertyFile.cpp @@ -401,7 +401,7 @@ void PropertyFileIncluded::SaveDocFile (Base::Writer &writer) const } } -void PropertyFileIncluded::RestoreDocFile(Base::Reader &reader, const int DocumentSchema) +void PropertyFileIncluded::RestoreDocFile(Base::Reader &reader) { Base::FileInfo fi(_cValue.c_str()); Base::ofstream to(fi); diff --git a/src/App/PropertyFile.h b/src/App/PropertyFile.h index abbcf60ca..7136c7905 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 DocumentSchema); + 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 12db5b7b3..0dd33b8a3 100644 --- a/src/App/PropertyGeo.cpp +++ b/src/App/PropertyGeo.cpp @@ -296,19 +296,38 @@ 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; + } } } -void PropertyVectorList::RestoreDocFile(Base::Reader &reader, const int DocumentSchema) +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 9522b590f..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 DocumentSchema); + virtual void RestoreDocFile(Base::Reader &reader); virtual Property *Copy(void) const; virtual void Paste(const Property &from); diff --git a/src/App/PropertyLinks.cpp b/src/App/PropertyLinks.cpp index 2d3926a5c..d03a4f951 100644 --- a/src/App/PropertyLinks.cpp +++ b/src/App/PropertyLinks.cpp @@ -552,7 +552,7 @@ void PropertyLinkSubList::setValues(const std::vector& lValue,c PyObject *PropertyLinkSubList::getPyObject(void) { - int count = getSize(); + unsigned int count = getSize(); #if 0//FIXME: Should switch to tuple Py::Tuple sequence(count); #else diff --git a/src/App/PropertyPythonObject.cpp b/src/App/PropertyPythonObject.cpp index 8b741b48d..df42a5a73 100644 --- a/src/App/PropertyPythonObject.cpp +++ b/src/App/PropertyPythonObject.cpp @@ -374,7 +374,7 @@ void PropertyPythonObject::SaveDocFile (Base::Writer &writer) const writer.Stream().put(*it); } -void PropertyPythonObject::RestoreDocFile(Base::Reader &reader, const int DocumentSchema) +void PropertyPythonObject::RestoreDocFile(Base::Reader &reader) { aboutToSetValue(); std::string buffer; diff --git a/src/App/PropertyPythonObject.h b/src/App/PropertyPythonObject.h index 869787b22..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 DocumentSchema); + 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 eb34fe5d7..39d25deb7 100644 --- a/src/App/PropertyStandard.cpp +++ b/src/App/PropertyStandard.cpp @@ -1145,21 +1145,32 @@ 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; + } } } -void PropertyFloatList::RestoreDocFile(Base::Reader &reader, const int DocumentSchema) +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 (DocumentSchema > 4) { + 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; @@ -2120,7 +2131,7 @@ void PropertyColorList::SaveDocFile (Base::Writer &writer) const } } -void PropertyColorList::RestoreDocFile(Base::Reader &reader, const int DocumentSchema) +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 5922531a9..d7cafc6d4 100644 --- a/src/App/PropertyStandard.h +++ b/src/App/PropertyStandard.h @@ -540,7 +540,7 @@ public: virtual void Restore(Base::XMLReader &reader); virtual void SaveDocFile (Base::Writer &writer) const; - virtual void RestoreDocFile(Base::Reader &reader, const int DocumentSchema); + virtual void RestoreDocFile(Base::Reader &reader); virtual Property *Copy(void) const; virtual void Paste(const Property &from); @@ -833,7 +833,7 @@ public: virtual void Restore(Base::XMLReader &reader); virtual void SaveDocFile (Base::Writer &writer) const; - virtual void RestoreDocFile(Base::Reader &reader, const int DocumentSchema); + 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 f6d91f08b..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 DocumentSchema) +void Persistence::RestoreDocFile(Reader &/*reader*/) { } diff --git a/src/Base/Persistence.h b/src/Base/Persistence.h index 10a017057..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 DocumentSchema); + virtual void RestoreDocFile(Reader &/*reader*/); }; } //namespace Base diff --git a/src/Base/Reader.cpp b/src/Base/Reader.cpp index 5131da11b..f3d7b595e 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, DocumentSchema); + jt->Object->RestoreDocFile(Base::Reader(zipstream,DocumentSchema)); } 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 a4b3fc34c..df82a5653 100644 --- a/src/Base/Reader.h +++ b/src/Base/Reader.h @@ -167,6 +167,8 @@ public: int DocumentSchema; /// Version of FreeCAD that wrote this document std::string ProgramVersion; + /// Version of the file format + int FileVersion; protected: /// read the next element @@ -230,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/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/Document.cpp b/src/Gui/Document.cpp index b1aedc313..e89cc6ffb 100644 --- a/src/Gui/Document.cpp +++ b/src/Gui/Document.cpp @@ -649,10 +649,11 @@ void Document::Restore(Base::XMLReader &reader) /** * Restores the properties of the view providers. */ -void Document::RestoreDocFile(Base::Reader &reader, const int DocumentSchema) +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; @@ -708,7 +709,7 @@ void Document::RestoreDocFile(Base::Reader &reader, const int DocumentSchema) // 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 82cc07141..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 DocumentSchema); + 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 796961941..9af26e8bc 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 DocumentSchema) +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 DocumentSch // 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 af8171619..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 DocumentSchema); + void RestoreDocFile(Base::Reader & r); private: zipios::ZipInputStream* stream; diff --git a/src/Gui/SoFCDB.cpp b/src/Gui/SoFCDB.cpp index 692b13d23..963f59c19 100644 --- a/src/Gui/SoFCDB.cpp +++ b/src/Gui/SoFCDB.cpp @@ -113,7 +113,6 @@ void Gui::SoFCDB::init() PropertyAngleItem ::init(); PropertyBoolItem ::init(); PropertyVectorItem ::init(); - PropertyDoubleVectorItem ::init(); PropertyMatrixItem ::init(); PropertyPlacementItem ::init(); PropertyEnumItem ::init(); diff --git a/src/Gui/Thumbnail.cpp b/src/Gui/Thumbnail.cpp index 7d9a2968b..ac0d4490e 100644 --- a/src/Gui/Thumbnail.cpp +++ b/src/Gui/Thumbnail.cpp @@ -117,7 +117,7 @@ void Thumbnail::SaveDocFile (Base::Writer &writer) const writer.Stream().write(ba.constData(), ba.length()); } -void Thumbnail::RestoreDocFile(Base::Reader &reader, const int DocumentSchema) +void Thumbnail::RestoreDocFile(Base::Reader &reader) { } diff --git a/src/Gui/Thumbnail.h b/src/Gui/Thumbnail.h index c1c4dd024..2f387a600 100644 --- a/src/Gui/Thumbnail.h +++ b/src/Gui/Thumbnail.h @@ -52,7 +52,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 DocumentSchema); + void RestoreDocFile(Base::Reader &reader); //@} private: diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index 1655818e9..67516ff65 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -905,7 +905,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)) @@ -944,7 +944,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)) @@ -990,109 +990,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() @@ -1522,12 +1419,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 9f666cdb3..f271debcd 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/Fem/App/FemMesh.cpp b/src/Mod/Fem/App/FemMesh.cpp index d5e912eb4..0d3323549 100755 --- a/src/Mod/Fem/App/FemMesh.cpp +++ b/src/Mod/Fem/App/FemMesh.cpp @@ -783,7 +783,7 @@ void FemMesh::SaveDocFile (Base::Writer &writer) const fi.deleteFile(); } -void FemMesh::RestoreDocFile(Base::Reader &reader, const int DocumentSchema) +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 fd10f7de5..70c330636 100755 --- a/src/Mod/Fem/App/FemMesh.h +++ b/src/Mod/Fem/App/FemMesh.h @@ -66,7 +66,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 DocumentSchema); + 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 134e81bd0..d700bf024 100755 --- a/src/Mod/Fem/App/FemMeshProperty.cpp +++ b/src/Mod/Fem/App/FemMeshProperty.cpp @@ -151,9 +151,9 @@ void PropertyFemMesh::SaveDocFile (Base::Writer &writer) const _FemMesh->SaveDocFile(writer); } -void PropertyFemMesh::RestoreDocFile(Base::Reader &reader, const int DocumentSchema) +void PropertyFemMesh::RestoreDocFile(Base::Reader &reader ) { aboutToSetValue(); - _FemMesh->RestoreDocFile(reader, DocumentSchema); + _FemMesh->RestoreDocFile(reader); hasSetValue(); } diff --git a/src/Mod/Fem/App/FemMeshProperty.h b/src/Mod/Fem/App/FemMeshProperty.h index 0a853a9dd..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 DocumentSchema); + void RestoreDocFile(Base::Reader &reader); App::Property *Copy(void) const; void Paste(const App::Property &from); diff --git a/src/Mod/Fem/Gui/ViewProviderFemMesh.cpp b/src/Mod/Fem/Gui/ViewProviderFemMesh.cpp index 2dc526ab3..c1ddf0a13 100755 --- a/src/Mod/Fem/Gui/ViewProviderFemMesh.cpp +++ b/src/Mod/Fem/Gui/ViewProviderFemMesh.cpp @@ -513,15 +513,15 @@ void ViewProviderFemMesh::setColorByNodeId(const std::map &Node pcShapeMaterial->diffuseColor.finishEditing(); } - -void ViewProviderFemMesh::resetColorByNodeId(void) -{ - pcMatBinding->value = SoMaterialBinding::OVERALL; - pcShapeMaterial->diffuseColor.setNum(0); + +void ViewProviderFemMesh::resetColorByNodeId(void) +{ + pcMatBinding->value = SoMaterialBinding::OVERALL; + pcShapeMaterial->diffuseColor.setNum(0); const App::Color& c = ShapeColor.getValue(); pcShapeMaterial->diffuseColor.setValue(c.r,c.g,c.b); - -} + +} // ---------------------------------------------------------------------------- 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 489acea84..ff82c2772 100644 --- a/src/Mod/Inspection/Gui/ViewProviderInspection.cpp +++ b/src/Mod/Inspection/Gui/ViewProviderInspection.cpp @@ -257,7 +257,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"); @@ -287,14 +287,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; @@ -309,7 +309,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)) @@ -539,8 +539,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(); @@ -578,8 +578,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 d40352601..b65665805 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 DocumentSchema) +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 67b24579d..28e3e9728 100644 --- a/src/Mod/Mesh/App/Mesh.h +++ b/src/Mod/Mesh/App/Mesh.h @@ -147,7 +147,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 DocumentSchema); + 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 a8c1e1d04..7c3425834 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 DocumentSchema) +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 DocumentSchema) +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 41457931e..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 DocumentSchema); + 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 DocumentSchema); + 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 ca8918f4e..830f50445 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 DocumentSchema) +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 DocumentSchema) +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 DocumentSchema) +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 e17a8c45e..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 DocumentSchema); + 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 DocumentSchema); + 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 DocumentSchema); + 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 082d59611..8f51543e1 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 DocumentSchema) +void TopoShape::RestoreDocFile(Base::Reader &reader) { } diff --git a/src/Mod/Part/App/TopoShape.h b/src/Mod/Part/App/TopoShape.h index e79d2d06a..9e7ecd9a1 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 DocumentSchema); + void RestoreDocFile(Base::Reader &reader); unsigned int getMemSize (void) const; //@} 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..bf787cd30 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.99,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 2f28e6112..c72700162 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"); } @@ -173,7 +173,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); } } diff --git a/src/Mod/Points/App/Points.cpp b/src/Mod/Points/App/Points.cpp index 56090b8a1..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::Vector3f); + return _Points.size() * sizeof(value_type); } 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; } } @@ -134,7 +134,7 @@ void PointKernel::Restore(Base::XMLReader &reader) } } -void PointKernel::RestoreDocFile(Base::Reader &reader, const int DocumentSchema) +void PointKernel::RestoreDocFile(Base::Reader &reader) { Base::InputStream str(reader); uint32_t uCt = 0; @@ -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 7cee43733..b04257207 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 DocumentSchema); + 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();} @@ -132,20 +134,21 @@ public: class PointsExport const_point_iterator { public: - typedef std::vector::const_iterator iter_type; + typedef PointKernel::value_type kernel_type; + 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 39f8bc11f..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 DocumentSchema) +void Feature::RestoreDocFile(Base::Reader &reader) { // This gets only invoked if a points file has been added from Restore() - Points.RestoreDocFile(reader, DocumentSchema); + 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 b819666fe..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 DocumentSchema); + 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/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 d4b9d9def..8a52e1148 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,10 +43,151 @@ 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 @@ -77,6 +219,151 @@ void PropertyGreyValueList::removeIndices( const std::vector& uIn #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) { // A normal vector is only a direction with unit length, so we only need to rotate it @@ -111,17 +398,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 +578,7 @@ void PropertyCurvatureList::SaveDocFile (Base::Writer &writer) const } } -void PropertyCurvatureList::RestoreDocFile(Base::Reader &reader, const int DocumentSchema) +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 3976bf7f1..584515bb3 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 DocumentSchema); + 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 c26675362..9134efd8d 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 DocumentSchema) +void PropertyPointKernel::RestoreDocFile(Base::Reader &reader) { aboutToSetValue(); - _cPoints->RestoreDocFile(reader, DocumentSchema); + _cPoints->RestoreDocFile(reader); hasSetValue(); } diff --git a/src/Mod/Points/App/PropertyPointKernel.h b/src/Mod/Points/App/PropertyPointKernel.h index 1ac3f5308..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 DocumentSchema); + void RestoreDocFile(Base::Reader &reader); //@} /** @name Modification */ diff --git a/src/Mod/Points/Gui/ViewProvider.cpp b/src/Mod/Points/Gui/ViewProvider.cpp index cbf165d1b..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,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(); 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