Merge branch 'refs/heads/double-precision-werner'
Conflicts: src/App/Document.cpp src/App/PropertyGeo.cpp src/App/PropertyStandard.cpp src/Base/Reader.cpp src/Base/Reader.h src/Gui/propertyeditor/PropertyItem.cpp src/Mod/Fem/Gui/ViewProviderFemMesh.cpp src/Mod/Inspection/Gui/ViewProviderInspection.cpp src/Mod/Mesh/App/MeshProperties.cpp src/Mod/Part/App/TopoShapeFacePyImp.cpp src/Mod/PartDesign/App/FeatureRevolution.cpp
This commit is contained in:
commit
30b189c1da
|
@ -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
|
||||
|
|
|
@ -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() << "<Document SchemaVersion=\"5\">" << endl;
|
||||
//writer.Stream() << "<Document SchemaVersion=\"4\">" << endl;
|
||||
writer.Stream() << "<Document SchemaVersion=\"4\" ProgramVersion=\""
|
||||
<< App::Application::Config()["BuildVersionMajor"] << "."
|
||||
<< App::Application::Config()["BuildVersionMinor"] << "R"
|
||||
<< App::Application::Config()["BuildRevision"]
|
||||
<< "\" FileVersion=\"" << writer.getFileVersion() << "\">" << 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<App::DocumentObject*>& obj,
|
|||
Base::ZipWriter writer(out);
|
||||
writer.putNextEntry("Document.xml");
|
||||
writer.Stream() << "<?xml version='1.0' encoding='utf-8'?>" << endl;
|
||||
writer.Stream() << "<Document SchemaVersion=\"4\">" << endl;
|
||||
//writer.Stream() << "<Document SchemaVersion=\"4\">" << endl;
|
||||
writer.Stream() << "<Document SchemaVersion=\"4\" ProgramVersion=\""
|
||||
<< App::Application::Config()["BuildVersionMajor"] << "."
|
||||
<< App::Application::Config()["BuildVersionMinor"] << "R"
|
||||
<< App::Application::Config()["BuildRevision"] << "\" FileVersion=\"1\">" << endl;
|
||||
// Add this block to have the same layout as for normal documents
|
||||
writer.Stream() << "<Properties Count=\"0\">" << endl;
|
||||
writer.Stream() << "</Properties>" << 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<App::DocumentObject*> objs = readObjects(reader);
|
||||
|
||||
|
@ -1821,8 +1850,8 @@ std::vector<DocumentObject*> Document::getObjectsOfType(const Base::Type& typeId
|
|||
|
||||
std::vector<DocumentObject*> 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<DocumentObject*> Objects;
|
||||
for (std::vector<DocumentObject*>::const_iterator it = d->objectArray.begin(); it != d->objectArray.end(); ++it) {
|
||||
if ((*it)->getTypeId().isDerivedFrom(typeId)) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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<Base::Vector3d>::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) {
|
||||
str << it->x << it->y << it->z;
|
||||
if (writer.getFileVersion() > 0) {
|
||||
for (std::vector<Base::Vector3d>::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) {
|
||||
str << it->x << it->y << it->z;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (std::vector<Base::Vector3d>::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<Base::Vector3d> values(uCt);
|
||||
for (std::vector<Base::Vector3d>::iterator it = values.begin(); it != values.end(); ++it) {
|
||||
str >> it->x >> it->y >> it->z;
|
||||
if (reader.getFileVersion() > 0) {
|
||||
for (std::vector<Base::Vector3d>::iterator it = values.begin(); it != values.end(); ++it) {
|
||||
str >> it->x >> it->y >> it->z;
|
||||
}
|
||||
}
|
||||
else {
|
||||
float x,y,z;
|
||||
for (std::vector<Base::Vector3d>::iterator it = values.begin(); it != values.end(); ++it) {
|
||||
str >> x >> y >> z;
|
||||
it->Set(x, y, z);
|
||||
}
|
||||
}
|
||||
setValues(values);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -552,7 +552,7 @@ void PropertyLinkSubList::setValues(const std::vector<DocumentObject*>& 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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<double>::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) {
|
||||
str << *it;
|
||||
if (writer.getFileVersion() > 0) {
|
||||
for (std::vector<double>::const_iterator it = _lValueList.begin(); it != _lValueList.end(); ++it) {
|
||||
str << *it;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (std::vector<double>::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<double> values(uCt);
|
||||
for (std::vector<double>::iterator it = values.begin(); it != values.end(); ++it) {
|
||||
if (DocumentSchema > 4) {
|
||||
if (reader.getFileVersion() > 0) {
|
||||
for (std::vector<double>::iterator it = values.begin(); it != values.end(); ++it) {
|
||||
str >> *it;
|
||||
} else {
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (std::vector<double>::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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -65,6 +65,6 @@ void Persistence::SaveDocFile (Writer &/*writer*/) const
|
|||
{
|
||||
}
|
||||
|
||||
void Persistence::RestoreDocFile(Reader &/*reader*/, const int DocumentSchema)
|
||||
void Persistence::RestoreDocFile(Reader &/*reader*/)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<std::string> 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;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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!
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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<zipios::ZipInputStream&>(reader));
|
||||
xmlReader.readFiles(static_cast<zipios::ZipInputStream&>(reader.getStream()));
|
||||
|
||||
// reset modified flag
|
||||
setModified(false);
|
||||
|
|
|
@ -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<App::DocumentObject*>&, Base::Writer&);
|
||||
void importObjects(const std::vector<App::DocumentObject*>&, Base::Reader&);
|
||||
//@}
|
||||
|
|
|
@ -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<App::DocumentObject*> 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<zipios::ZipInputStream&>(reader));
|
||||
xmlReader.readFiles(static_cast<zipios::ZipInputStream&>(reader.getStream()));
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -113,7 +113,6 @@ void Gui::SoFCDB::init()
|
|||
PropertyAngleItem ::init();
|
||||
PropertyBoolItem ::init();
|
||||
PropertyVectorItem ::init();
|
||||
PropertyDoubleVectorItem ::init();
|
||||
PropertyMatrixItem ::init();
|
||||
PropertyPlacementItem ::init();
|
||||
PropertyEnumItem ::init();
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -905,7 +905,7 @@ PropertyVectorItem::PropertyVectorItem()
|
|||
|
||||
QVariant PropertyVectorItem::toString(const QVariant& prop) const
|
||||
{
|
||||
const Base::Vector3f& value = prop.value<Base::Vector3f>();
|
||||
const Base::Vector3d& value = prop.value<Base::Vector3d>();
|
||||
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<QLineEdit*>(editor);
|
||||
const Base::Vector3f& value = data.value<Base::Vector3f>();
|
||||
const Base::Vector3d& value = data.value<Base::Vector3d>();
|
||||
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*>(PropertyFloatItem::create());
|
||||
m_x->setParent(this);
|
||||
m_x->setPropertyName(QLatin1String("x"));
|
||||
this->appendChild(m_x);
|
||||
m_y = static_cast<PropertyFloatItem*>(PropertyFloatItem::create());
|
||||
m_y->setParent(this);
|
||||
m_y->setPropertyName(QLatin1String("y"));
|
||||
this->appendChild(m_y);
|
||||
m_z = static_cast<PropertyFloatItem*>(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<Base::Vector3d>();
|
||||
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>(Base::Vector3d());
|
||||
}
|
||||
|
||||
void PropertyDoubleVectorItem::setValue(const QVariant& value)
|
||||
{
|
||||
if (!value.canConvert<Base::Vector3d>())
|
||||
return;
|
||||
const Base::Vector3d& val = value.value<Base::Vector3d>();
|
||||
QString data = QString::fromAscii("(%1, %2, %3)")
|
||||
.arg(val.x,0,'f',decimals())
|
||||
.arg(val.y,0,'f',decimals())
|
||||
.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<QLineEdit*>(editor);
|
||||
const Base::Vector3d& value = data.value<Base::Vector3d>();
|
||||
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<QLineEdit*>(editor);
|
||||
return QVariant(le->text());
|
||||
}
|
||||
|
||||
double PropertyDoubleVectorItem::x() const
|
||||
{
|
||||
return data(1,Qt::EditRole).value<Base::Vector3d>().x;
|
||||
}
|
||||
|
||||
void PropertyDoubleVectorItem::setX(double x)
|
||||
{
|
||||
setData(QVariant::fromValue(Base::Vector3d(x, y(), z())));
|
||||
}
|
||||
|
||||
double PropertyDoubleVectorItem::y() const
|
||||
{
|
||||
return data(1,Qt::EditRole).value<Base::Vector3d>().y;
|
||||
}
|
||||
|
||||
void PropertyDoubleVectorItem::setY(double y)
|
||||
{
|
||||
setData(QVariant::fromValue(Base::Vector3d(x(), y, z())));
|
||||
}
|
||||
|
||||
double PropertyDoubleVectorItem::z() const
|
||||
{
|
||||
return data(1,Qt::EditRole).value<Base::Vector3d>().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*>(PropertyDoubleVectorItem::create());
|
||||
m_d = static_cast<PropertyVectorItem*>(PropertyVectorItem::create());
|
||||
m_d->setParent(this);
|
||||
m_d->setPropertyName(QLatin1String("Axis"));
|
||||
m_d->setReadOnly(true);
|
||||
this->appendChild(m_d);
|
||||
m_p = static_cast<PropertyDoubleVectorItem*>(PropertyDoubleVectorItem::create());
|
||||
m_p = static_cast<PropertyVectorItem*>(PropertyVectorItem::create());
|
||||
m_p->setParent(this);
|
||||
m_p->setPropertyName(QLatin1String("Position"));
|
||||
m_p->setReadOnly(true);
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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 */
|
||||
//@{
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -513,15 +513,15 @@ void ViewProviderFemMesh::setColorByNodeId(const std::map<long,App::Color> &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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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<int>(_lValueList.size());
|
||||
}
|
||||
|
||||
void PropertyDistanceList::setValue(float lValue)
|
||||
{
|
||||
aboutToSetValue();
|
||||
_lValueList.resize(1);
|
||||
_lValueList[0]=lValue;
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
void PropertyDistanceList::setValues(const std::vector<float>& values)
|
||||
{
|
||||
aboutToSetValue();
|
||||
_lValueList = values;
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
PyObject *PropertyDistanceList::getPyObject(void)
|
||||
{
|
||||
PyObject* list = PyList_New(getSize());
|
||||
for (int i = 0;i<getSize(); i++)
|
||||
PyList_SetItem( list, i, PyFloat_FromDouble(_lValueList[i]));
|
||||
return list;
|
||||
}
|
||||
|
||||
void PropertyDistanceList::setPyObject(PyObject *value)
|
||||
{
|
||||
if (PyList_Check(value)) {
|
||||
Py_ssize_t nSize = PyList_Size(value);
|
||||
std::vector<float> values;
|
||||
values.resize(nSize);
|
||||
|
||||
for (Py_ssize_t i=0; i<nSize;++i) {
|
||||
PyObject* item = PyList_GetItem(value, i);
|
||||
if (!PyFloat_Check(item)) {
|
||||
std::string error = std::string("type in list must be float, not ");
|
||||
error += item->ob_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() << "<FloatList count=\"" << getSize() <<"\">" << endl;
|
||||
writer.incInd();
|
||||
for(int i = 0;i<getSize(); i++)
|
||||
writer.Stream() << writer.ind() << "<F v=\"" << _lValueList[i] <<"\"/>" << endl; ;
|
||||
writer.decInd();
|
||||
writer.Stream() << writer.ind() <<"</FloatList>" << endl ;
|
||||
}
|
||||
else {
|
||||
writer.Stream() << writer.ind() << "<FloatList file=\"" <<
|
||||
writer.addFile(getName(), this) << "\"/>" << 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<float>::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<float> values(uCt);
|
||||
for (std::vector<float>::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<const PropertyDistanceList&>(from)._lValueList;
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
unsigned int PropertyDistanceList::getMemSize (void) const
|
||||
{
|
||||
return static_cast<unsigned int>(_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<double> vals(count);
|
||||
std::vector<float> 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<double>::iterator it = vals.begin(); it != vals.end(); ++it) {
|
||||
for (std::vector<float>::iterator it = vals.begin(); it != vals.end(); ++it) {
|
||||
if (fabs(*it) < FLT_MAX) {
|
||||
fRMS += (*it) * (*it);
|
||||
countRMS++;
|
||||
|
|
|
@ -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<float>& values);
|
||||
|
||||
const std::vector<float> &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<float> _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 */
|
||||
|
|
|
@ -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<double>& fValues = ((App::PropertyFloatList*)pDistances)->getValues();
|
||||
const std::vector<float>& fValues = static_cast<Inspection::PropertyDistanceList*>(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<double>::const_iterator jt = fValues.begin(); jt != fValues.end(); ++jt, j++) {
|
||||
for (std::vector<float>::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<const SoFaceDetail*>(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<Inspection::PropertyDistanceList*>(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<Inspection::PropertyDistanceList*>(prop);
|
||||
float fVal = (*dist)[index];
|
||||
info = QObject::tr("Distance: %1").arg(fVal);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include <Base/Writer.h>
|
||||
#include <Base/Reader.h>
|
||||
#include <Base/Stream.h>
|
||||
#include <Base/VectorPy.h>
|
||||
|
||||
#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<int>(_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<Base::Vector3f>& values)
|
||||
{
|
||||
aboutToSetValue();
|
||||
_lValueList = values;
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
PyObject *PropertyNormalList::getPyObject(void)
|
||||
{
|
||||
PyObject* list = PyList_New(getSize());
|
||||
|
||||
for (int i = 0;i<getSize(); i++)
|
||||
PyList_SetItem(list, i, new Base::VectorPy(_lValueList[i]));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
void PropertyNormalList::setPyObject(PyObject *value)
|
||||
{
|
||||
if (PyList_Check(value)) {
|
||||
Py_ssize_t nSize = PyList_Size(value);
|
||||
std::vector<Base::Vector3f> values;
|
||||
values.resize(nSize);
|
||||
|
||||
for (Py_ssize_t i=0; i<nSize;++i) {
|
||||
PyObject* item = PyList_GetItem(value, i);
|
||||
App::PropertyVector val;
|
||||
val.setPyObject( item );
|
||||
values[i] = Base::convertTo<Base::Vector3f>(val.getValue());
|
||||
}
|
||||
|
||||
setValues(values);
|
||||
}
|
||||
else if (PyObject_TypeCheck(value, &(Base::VectorPy::Type))) {
|
||||
Base::VectorPy *pcObject = static_cast<Base::VectorPy*>(value);
|
||||
Base::Vector3d* val = pcObject->getVectorPtr();
|
||||
setValue(Base::convertTo<Base::Vector3f>(*val));
|
||||
}
|
||||
else if (PyTuple_Check(value) && PyTuple_Size(value) == 3) {
|
||||
App::PropertyVector val;
|
||||
val.setPyObject( value );
|
||||
setValue(Base::convertTo<Base::Vector3f>(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() << "<VectorList file=\"" << writer.addFile(getName(), this) << "\"/>" << 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<Base::Vector3f>::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<Base::Vector3f> values(uCt);
|
||||
for (std::vector<Base::Vector3f>::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<const PropertyNormalList&>(from)._lValueList;
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
unsigned int PropertyNormalList::getMemSize (void) const
|
||||
{
|
||||
return static_cast<unsigned int>(_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);
|
||||
|
|
|
@ -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<Base::Vector3f>& values);
|
||||
|
||||
const std::vector<Base::Vector3f> &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<Base::Vector3f> _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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
//@}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -66,7 +66,7 @@ short LinearPattern::mustExecute() const
|
|||
|
||||
const std::list<gp_Trsf> LinearPattern::getTransformations(const std::vector<App::DocumentObject*>)
|
||||
{
|
||||
float distance = Length.getValue();
|
||||
double distance = Length.getValue();
|
||||
if (distance < Precision::Confusion())
|
||||
throw Base::Exception("Pattern length too small");
|
||||
int occurrences = Occurrences.getValue();
|
||||
|
|
|
@ -65,7 +65,7 @@ short PolarPattern::mustExecute() const
|
|||
|
||||
const std::list<gp_Trsf> PolarPattern::getTransformations(const std::vector<App::DocumentObject*>)
|
||||
{
|
||||
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<gp_Trsf> PolarPattern::getTransformations(const std::vector<App:
|
|||
axis = refSketch->getAxis(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<Part::Feature*>(refObject);
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -73,7 +73,7 @@ TaskChamferParameters::TaskChamferParameters(ViewProviderChamfer *ChamferView,QW
|
|||
void TaskChamferParameters::onLengthChanged(double len)
|
||||
{
|
||||
PartDesign::Chamfer* pcChamfer = static_cast<PartDesign::Chamfer*>(ChamferView->getObject());
|
||||
pcChamfer->Size.setValue((float)len);
|
||||
pcChamfer->Size.setValue(len);
|
||||
pcChamfer->getDocument()->recomputeFeature(pcChamfer);
|
||||
}
|
||||
|
||||
|
|
|
@ -287,7 +287,7 @@ void TaskDraftParameters::showObject()
|
|||
void TaskDraftParameters::onAngleChanged(double angle)
|
||||
{
|
||||
PartDesign::Draft* pcDraft = static_cast<PartDesign::Draft*>(DraftView->getObject());
|
||||
pcDraft->Angle.setValue((float)angle);
|
||||
pcDraft->Angle.setValue(angle);
|
||||
pcDraft->getDocument()->recomputeFeature(pcDraft);
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@ TaskFilletParameters::TaskFilletParameters(ViewProviderFillet *FilletView,QWidge
|
|||
void TaskFilletParameters::onLengthChanged(double len)
|
||||
{
|
||||
PartDesign::Fillet* pcFillet = static_cast<PartDesign::Fillet*>(FilletView->getObject());
|
||||
pcFillet->Radius.setValue((float)len);
|
||||
pcFillet->Radius.setValue(len);
|
||||
pcFillet->getDocument()->recomputeFeature(pcFillet);
|
||||
}
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ TaskGrooveParameters::TaskGrooveParameters(ViewProviderGroove *GrooveView,QWidge
|
|||
void TaskGrooveParameters::onAngleChanged(double len)
|
||||
{
|
||||
PartDesign::Groove* pcGroove = static_cast<PartDesign::Groove*>(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<PartDesign::Groove*>(GrooveView->getObject());
|
||||
pcGroove->getDocument()->recomputeFeature(pcGroove);
|
||||
pcGroove->getDocument()->recomputeFeature(pcGroove);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -235,7 +235,7 @@ void TaskPadParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
|||
void TaskPadParameters::onLengthChanged(double len)
|
||||
{
|
||||
PartDesign::Pad* pcPad = static_cast<PartDesign::Pad*>(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<PartDesign::Pad*>(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);
|
||||
|
|
|
@ -215,7 +215,7 @@ void TaskPocketParameters::onSelectionChanged(const Gui::SelectionChanges& msg)
|
|||
void TaskPocketParameters::onLengthChanged(double len)
|
||||
{
|
||||
PartDesign::Pocket* pcPocket = static_cast<PartDesign::Pocket*>(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);
|
||||
|
|
|
@ -124,7 +124,7 @@ TaskRevolutionParameters::TaskRevolutionParameters(ViewProviderRevolution *Revol
|
|||
void TaskRevolutionParameters::onAngleChanged(double len)
|
||||
{
|
||||
PartDesign::Revolution* pcRevolution = static_cast<PartDesign::Revolution*>(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<PartDesign::Revolution*>(RevolutionView->getObject());
|
||||
pcRevolution->getDocument()->recomputeFeature(pcRevolution);
|
||||
pcRevolution->getDocument()->recomputeFeature(pcRevolution);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -70,8 +70,8 @@ Data::Segment* PointKernel::getSubElement(const char* Type, unsigned long n) con
|
|||
|
||||
void PointKernel::transformGeometry(const Base::Matrix4D &rclMat)
|
||||
{
|
||||
std::vector<Base::Vector3f>& kernel = getBasicPoints();
|
||||
for (std::vector<Base::Vector3f>::iterator it = kernel.begin(); it != kernel.end(); ++it)
|
||||
std::vector<value_type>& kernel = getBasicPoints();
|
||||
for (std::vector<value_type>::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<Base::Vector3f>::const_iterator it = _Points.begin(); it != _Points.end(); ++it) {
|
||||
// store the data without transforming it
|
||||
for (std::vector<value_type>::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<Base::Vector3d> &Points,std::vector<Facet
|
|||
// ----------------------------------------------------------------------------
|
||||
|
||||
PointKernel::const_point_iterator::const_point_iterator
|
||||
(const PointKernel* kernel, std::vector<Base::Vector3f>::const_iterator index)
|
||||
(const PointKernel* kernel, std::vector<kernel_type>::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);
|
||||
|
|
|
@ -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<Base::Vector3f>& getBasicPoints()
|
||||
std::vector<value_type>& getBasicPoints()
|
||||
{ return this->_Points; }
|
||||
const std::vector<Base::Vector3f>& getBasicPoints() const
|
||||
const std::vector<value_type>& getBasicPoints() const
|
||||
{ return this->_Points; }
|
||||
void getFaces(std::vector<Base::Vector3d> &Points,std::vector<Facet> &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<Base::Vector3f> _Points;
|
||||
std::vector<value_type> _Points;
|
||||
|
||||
public:
|
||||
typedef std::vector<Base::Vector3f>::difference_type difference_type;
|
||||
typedef std::vector<Base::Vector3f>::size_type size_type;
|
||||
typedef std::vector<value_type>::difference_type difference_type;
|
||||
typedef std::vector<value_type>::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<Base::Vector3f>::const_iterator iter_type;
|
||||
typedef PointKernel::value_type kernel_type;
|
||||
typedef Base::Vector3d value_type;
|
||||
typedef std::vector<kernel_type>::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<Base::Vector3f>::const_iterator index);
|
||||
const_point_iterator(const PointKernel*, std::vector<kernel_type>::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<Base::Vector3f>::const_iterator _p_it;
|
||||
value_type _point;
|
||||
std::vector<kernel_type>::const_iterator _p_it;
|
||||
};
|
||||
|
||||
typedef const_point_iterator const_iterator;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -204,7 +204,7 @@ unsigned long PointsGrid::InSide (const Base::BoundBox3d &rclBB, std::vector<uns
|
|||
return raulElements.size();
|
||||
}
|
||||
|
||||
unsigned long PointsGrid::InSide (const Base::BoundBox3d &rclBB, std::vector<unsigned long> &raulElements, const Base::Vector3d &rclOrg, float fMaxDist, bool bDelDoubles) const
|
||||
unsigned long PointsGrid::InSide (const Base::BoundBox3d &rclBB, std::vector<unsigned long> &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();
|
||||
|
|
|
@ -84,7 +84,7 @@ public:
|
|||
virtual unsigned long InSide (const Base::BoundBox3d &rclBB, std::set<unsigned long> &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<unsigned long> &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<unsigned long> &rclInd) const;
|
||||
//@}
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <Base/Persistence.h>
|
||||
#include <Base/Stream.h>
|
||||
#include <Base/Writer.h>
|
||||
#include <Base/VectorPy.h>
|
||||
|
||||
#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<int>(_lValueList.size());
|
||||
}
|
||||
|
||||
void PropertyGreyValueList::setValue(float lValue)
|
||||
{
|
||||
aboutToSetValue();
|
||||
_lValueList.resize(1);
|
||||
_lValueList[0]=lValue;
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
void PropertyGreyValueList::setValues(const std::vector<float>& values)
|
||||
{
|
||||
aboutToSetValue();
|
||||
_lValueList = values;
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
PyObject *PropertyGreyValueList::getPyObject(void)
|
||||
{
|
||||
PyObject* list = PyList_New(getSize());
|
||||
for (int i = 0;i<getSize(); i++)
|
||||
PyList_SetItem( list, i, PyFloat_FromDouble(_lValueList[i]));
|
||||
return list;
|
||||
}
|
||||
|
||||
void PropertyGreyValueList::setPyObject(PyObject *value)
|
||||
{
|
||||
if (PyList_Check(value)) {
|
||||
Py_ssize_t nSize = PyList_Size(value);
|
||||
std::vector<float> values;
|
||||
values.resize(nSize);
|
||||
|
||||
for (Py_ssize_t i=0; i<nSize;++i) {
|
||||
PyObject* item = PyList_GetItem(value, i);
|
||||
if (!PyFloat_Check(item)) {
|
||||
std::string error = std::string("type in list must be float, not ");
|
||||
error += item->ob_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() << "<FloatList count=\"" << getSize() <<"\">" << endl;
|
||||
writer.incInd();
|
||||
for(int i = 0;i<getSize(); i++)
|
||||
writer.Stream() << writer.ind() << "<F v=\"" << _lValueList[i] <<"\"/>" << endl; ;
|
||||
writer.decInd();
|
||||
writer.Stream() << writer.ind() <<"</FloatList>" << endl ;
|
||||
}
|
||||
else {
|
||||
writer.Stream() << writer.ind() << "<FloatList file=\"" <<
|
||||
writer.addFile(getName(), this) << "\"/>" << 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<float>::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<float> values(uCt);
|
||||
for (std::vector<float>::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<const PropertyGreyValueList&>(from)._lValueList;
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
unsigned int PropertyGreyValueList::getMemSize (void) const
|
||||
{
|
||||
return static_cast<unsigned int>(_lValueList.size() * sizeof(float));
|
||||
}
|
||||
|
||||
void PropertyGreyValueList::removeIndices( const std::vector<unsigned long>& uIndices )
|
||||
{
|
||||
#if 0
|
||||
|
@ -77,6 +219,151 @@ void PropertyGreyValueList::removeIndices( const std::vector<unsigned long>& uIn
|
|||
#endif
|
||||
}
|
||||
|
||||
PropertyNormalList::PropertyNormalList()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
PropertyNormalList::~PropertyNormalList()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void PropertyNormalList::setSize(int newSize)
|
||||
{
|
||||
_lValueList.resize(newSize);
|
||||
}
|
||||
|
||||
int PropertyNormalList::getSize(void) const
|
||||
{
|
||||
return static_cast<int>(_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<Base::Vector3f>& values)
|
||||
{
|
||||
aboutToSetValue();
|
||||
_lValueList = values;
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
PyObject *PropertyNormalList::getPyObject(void)
|
||||
{
|
||||
PyObject* list = PyList_New(getSize());
|
||||
|
||||
for (int i = 0;i<getSize(); i++)
|
||||
PyList_SetItem(list, i, new Base::VectorPy(_lValueList[i]));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
void PropertyNormalList::setPyObject(PyObject *value)
|
||||
{
|
||||
if (PyList_Check(value)) {
|
||||
Py_ssize_t nSize = PyList_Size(value);
|
||||
std::vector<Base::Vector3f> values;
|
||||
values.resize(nSize);
|
||||
|
||||
for (Py_ssize_t i=0; i<nSize;++i) {
|
||||
PyObject* item = PyList_GetItem(value, i);
|
||||
App::PropertyVector val;
|
||||
val.setPyObject( item );
|
||||
values[i] = Base::convertTo<Base::Vector3f>(val.getValue());
|
||||
}
|
||||
|
||||
setValues(values);
|
||||
}
|
||||
else if (PyObject_TypeCheck(value, &(Base::VectorPy::Type))) {
|
||||
Base::VectorPy *pcObject = static_cast<Base::VectorPy*>(value);
|
||||
Base::Vector3d* val = pcObject->getVectorPtr();
|
||||
setValue(Base::convertTo<Base::Vector3f>(*val));
|
||||
}
|
||||
else if (PyTuple_Check(value) && PyTuple_Size(value) == 3) {
|
||||
App::PropertyVector val;
|
||||
val.setPyObject( value );
|
||||
setValue(Base::convertTo<Base::Vector3f>(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() << "<VectorList file=\"" << writer.addFile(getName(), this) << "\"/>" << 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<Base::Vector3f>::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<Base::Vector3f> values(uCt);
|
||||
for (std::vector<Base::Vector3f>::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<const PropertyNormalList&>(from)._lValueList;
|
||||
hasSetValue();
|
||||
}
|
||||
|
||||
unsigned int PropertyNormalList::getMemSize (void) const
|
||||
{
|
||||
return static_cast<unsigned int>(_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<unsigned long>& uIndic
|
|||
std::vector<unsigned long> uSortedInds = uIndices;
|
||||
std::sort(uSortedInds.begin(), uSortedInds.end());
|
||||
|
||||
const std::vector<Base::Vector3d>& rValueList = getValues();
|
||||
const std::vector<Base::Vector3f>& rValueList = getValues();
|
||||
|
||||
assert( uSortedInds.size() <= rValueList.size() );
|
||||
if ( uSortedInds.size() > rValueList.size() )
|
||||
return;
|
||||
|
||||
std::vector<Base::Vector3d> remainValue;
|
||||
std::vector<Base::Vector3f> remainValue;
|
||||
remainValue.reserve(rValueList.size() - uSortedInds.size());
|
||||
|
||||
std::vector<unsigned long>::iterator pos = uSortedInds.begin();
|
||||
for ( std::vector<Base::Vector3d>::const_iterator it = rValueList.begin(); it != rValueList.end(); ++it ) {
|
||||
for ( std::vector<Base::Vector3f>::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;
|
||||
|
|
|
@ -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<float>& values);
|
||||
|
||||
const std::vector<float> &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<unsigned long>& );
|
||||
//@}
|
||||
|
||||
private:
|
||||
std::vector<float> _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<Base::Vector3f>& values);
|
||||
|
||||
const std::vector<Base::Vector3f> &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<unsigned long>& );
|
||||
//@}
|
||||
|
||||
private:
|
||||
std::vector<Base::Vector3f> _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 */
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -125,14 +125,14 @@ void ViewProviderPoints::setVertexColorMode(App::PropertyColorList* pcProperty)
|
|||
|
||||
void ViewProviderPoints::setVertexGreyvalueMode(Points::PropertyGreyValueList* pcProperty)
|
||||
{
|
||||
const std::vector<double>& val = pcProperty->getValues();
|
||||
const std::vector<float>& val = pcProperty->getValues();
|
||||
unsigned long i=0;
|
||||
|
||||
pcColorMat->enableNotify(false);
|
||||
pcColorMat->diffuseColor.deleteValues(0);
|
||||
pcColorMat->diffuseColor.setNum(val.size());
|
||||
|
||||
for ( std::vector<double>::const_iterator it = val.begin(); it != val.end(); ++it ) {
|
||||
for ( std::vector<float>::const_iterator it = val.begin(); it != val.end(); ++it ) {
|
||||
pcColorMat->diffuseColor.set1Value(i++, SbColor(*it, *it, *it));
|
||||
}
|
||||
|
||||
|
@ -142,14 +142,14 @@ void ViewProviderPoints::setVertexGreyvalueMode(Points::PropertyGreyValueList* p
|
|||
|
||||
void ViewProviderPoints::setVertexNormalMode(Points::PropertyNormalList* pcProperty)
|
||||
{
|
||||
const std::vector<Base::Vector3d>& val = pcProperty->getValues();
|
||||
const std::vector<Base::Vector3f>& val = pcProperty->getValues();
|
||||
unsigned long i=0;
|
||||
|
||||
pcPointsNormal->enableNotify(false);
|
||||
pcPointsNormal->vector.deleteValues(0);
|
||||
pcPointsNormal->vector.setNum(val.size());
|
||||
|
||||
for ( std::vector<Base::Vector3d>::const_iterator it = val.begin(); it != val.end(); ++it ) {
|
||||
for ( std::vector<Base::Vector3f>::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<Base::Vector3f>& kernel = cPts.getBasicPoints();
|
||||
for (std::vector<Base::Vector3f>::const_iterator it = kernel.begin(); it != kernel.end(); ++it, idx++) {
|
||||
coords->point.set1Value(idx, it->x, it->y, it->z);
|
||||
const std::vector<Points::PointKernel::value_type>& kernel = cPts.getBasicPoints();
|
||||
for (std::vector<Points::PointKernel::value_type>::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();
|
||||
|
|
|
@ -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<double>(planeFit.GetDirU());
|
||||
_clV = Base::toVector<double>(planeFit.GetDirV());
|
||||
_clW = Base::toVector<double>(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<float>& afKnots)
|
||||
void BSplineParameterCorrection::SetUKnots(const std::vector<double>& afKnots)
|
||||
{
|
||||
if (afKnots.size() != (unsigned long)(_usUCtrlpoints+_usUOrder))
|
||||
return;
|
||||
|
@ -861,7 +861,7 @@ void BSplineParameterCorrection::SetUKnots(const std::vector<float>& afKnots)
|
|||
_clUSpline.SetKnots(_vUKnots, _vUMults, _usUOrder);
|
||||
}
|
||||
|
||||
void BSplineParameterCorrection::SetVKnots(const std::vector<float>& afKnots)
|
||||
void BSplineParameterCorrection::SetVKnots(const std::vector<double>& 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; i<ulSize; i++)
|
||||
{
|
||||
float fU = (float)(*_pvcUVParam)(i).X();
|
||||
float fV = (float)(*_pvcUVParam)(i).Y();
|
||||
double fU = (*_pvcUVParam)(i).X();
|
||||
double fV = (*_pvcUVParam)(i).Y();
|
||||
unsigned long ulIdx=0;
|
||||
|
||||
for (unsigned short j=0; j<_usUCtrlpoints; j++)
|
||||
|
@ -1019,7 +1019,7 @@ bool BSplineParameterCorrection::SolveWithoutSmoothing()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool BSplineParameterCorrection::SolveWithSmoothing(float fWeight)
|
||||
bool BSplineParameterCorrection::SolveWithSmoothing(double fWeight)
|
||||
{
|
||||
unsigned long ulSize = _pvcPoints->Length();
|
||||
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<ulSize; i++)
|
||||
{
|
||||
float fU = (float)(*_pvcUVParam)(i).X();
|
||||
float fV = (float)(*_pvcUVParam)(i).Y();
|
||||
double fU = (*_pvcUVParam)(i).X();
|
||||
double fV = (*_pvcUVParam)(i).Y();
|
||||
unsigned long ulIdx=0;
|
||||
|
||||
for (unsigned short j=0; j<_usUCtrlpoints; j++)
|
||||
|
@ -1103,7 +1103,7 @@ bool BSplineParameterCorrection::SolveWithSmoothing(float fWeight)
|
|||
return true;
|
||||
}
|
||||
|
||||
void BSplineParameterCorrection::CalcSmoothingTerms(bool bRecalc, float fFirst, float fSecond, float fThird)
|
||||
void BSplineParameterCorrection::CalcSmoothingTerms(bool bRecalc, double fFirst, double fSecond, double fThird)
|
||||
{
|
||||
if (bRecalc)
|
||||
{
|
||||
|
@ -1210,13 +1210,13 @@ void BSplineParameterCorrection::CalcThirdSmoothMatrix(Base::SequencerLauncher&
|
|||
}
|
||||
}
|
||||
|
||||
void BSplineParameterCorrection::EnableSmoothing(bool bSmooth, float fSmoothInfl)
|
||||
void BSplineParameterCorrection::EnableSmoothing(bool bSmooth, double fSmoothInfl)
|
||||
{
|
||||
EnableSmoothing(bSmooth, fSmoothInfl, 1.0f, 0.0f, 0.0f);
|
||||
}
|
||||
|
||||
void BSplineParameterCorrection::EnableSmoothing(bool bSmooth, float fSmoothInfl,
|
||||
float fFirst, float fSec, float fThird)
|
||||
void BSplineParameterCorrection::EnableSmoothing(bool bSmooth, double fSmoothInfl,
|
||||
double fFirst, double fSec, double fThird)
|
||||
{
|
||||
if (_bSmoothing && bSmooth)
|
||||
CalcSmoothingTerms(false, fFirst, fSec, fThird);
|
||||
|
|
|
@ -263,12 +263,12 @@ protected:
|
|||
* auf die Ausgleichsebene projiziert. Von diesen Punkten wird die Boundingbox berechnet, dann werden
|
||||
* die u/v-Parameter für die Punkte berechnet.
|
||||
*/
|
||||
virtual bool DoInitialParameterCorrection(float fSizeFactor=0.0f);
|
||||
virtual bool DoInitialParameterCorrection(double fSizeFactor=0.0f);
|
||||
|
||||
/**
|
||||
* Berechnet die u.v-Werte der Punkte
|
||||
*/
|
||||
virtual bool GetUVParameters(float fSizeFactor);
|
||||
virtual bool GetUVParameters(double fSizeFactor);
|
||||
|
||||
/**
|
||||
* Führt eine Parameterkorrektur durch.
|
||||
|
@ -283,7 +283,7 @@ protected:
|
|||
/**
|
||||
* Löst ein reguläres Gleichungssystem
|
||||
*/
|
||||
virtual bool SolveWithSmoothing(float fWeight)=0;
|
||||
virtual bool SolveWithSmoothing(double fWeight)=0;
|
||||
|
||||
public:
|
||||
/**
|
||||
|
@ -293,39 +293,39 @@ public:
|
|||
const TColgp_Array1OfPnt& points,
|
||||
unsigned short usIter,
|
||||
bool bParaCor,
|
||||
float fSizeFactor=0.0f);
|
||||
double fSizeFactor=0.0f);
|
||||
/**
|
||||
* Setzen der u/v-Richtungen
|
||||
* Dritter Parameter gibt an, ob die Richtungen tatsächlich verwendet werden sollen.
|
||||
*/
|
||||
virtual void SetUVW(const Base::Vector3f& clU, const Base::Vector3f& clV, const Base::Vector3f& clW, bool bUseDir=true);
|
||||
virtual void SetUVW(const Base::Vector3d& clU, const Base::Vector3d& clV, const Base::Vector3d& clW, bool bUseDir=true);
|
||||
|
||||
/**
|
||||
* Gibt die u/v/w-Richtungen zurück
|
||||
*/
|
||||
virtual void GetUVW(Base::Vector3f& clU, Base::Vector3f& clV, Base::Vector3f& clW) const;
|
||||
virtual void GetUVW(Base::Vector3d& clU, Base::Vector3d& clV, Base::Vector3d& clW) const;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
virtual Base::Vector3f GetGravityPoint() const;
|
||||
virtual Base::Vector3d GetGravityPoint() const;
|
||||
|
||||
/**
|
||||
* Verwende Glättungsterme
|
||||
*/
|
||||
virtual void EnableSmoothing(bool bSmooth=true, float fSmoothInfl=1.0f);
|
||||
virtual void EnableSmoothing(bool bSmooth=true, double fSmoothInfl=1.0f);
|
||||
|
||||
protected:
|
||||
bool _bGetUVDir; //! Stellt fest, ob u/v-Richtung vorgegeben wird
|
||||
bool _bSmoothing; //! Glättung verwenden
|
||||
float _fSmoothInfluence; //! Einfluß der Glättung
|
||||
double _fSmoothInfluence; //! Einfluß der Glättung
|
||||
unsigned short _usUOrder; //! Ordnung in u-Richtung
|
||||
unsigned short _usVOrder; //! Ordnung in v-Richtung
|
||||
unsigned short _usUCtrlpoints; //! Anzahl der Kontrollpunkte in u-Richtung
|
||||
unsigned short _usVCtrlpoints; //! Anzahl der Kontrollpunkte in v-Richtung
|
||||
Base::Vector3f _clU; //! u-Richtung
|
||||
Base::Vector3f _clV; //! v-Richtung
|
||||
Base::Vector3f _clW; //! w-Richtung (senkrecht zu u-und w-Richtung)
|
||||
Base::Vector3d _clU; //! u-Richtung
|
||||
Base::Vector3d _clV; //! v-Richtung
|
||||
Base::Vector3d _clW; //! w-Richtung (senkrecht zu u-und w-Richtung)
|
||||
TColgp_Array1OfPnt* _pvcPoints; //! Punktliste der Rohdaten
|
||||
TColgp_Array1OfPnt2d* _pvcUVParam; //! Parameterwerte zu den Punkten aus der Liste
|
||||
TColgp_Array2OfPnt _vCtrlPntsOfSurf; //! Array von Kontrollpunkten
|
||||
|
@ -378,18 +378,18 @@ protected:
|
|||
* Löst ein reguläres Gleichungssystem durch LU-Zerlegung. Es fließen je nach Gewichtung
|
||||
* Glättungsterme mit ein
|
||||
*/
|
||||
virtual bool SolveWithSmoothing(float fWeight);
|
||||
virtual bool SolveWithSmoothing(double fWeight);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Setzen des Knotenvektors
|
||||
*/
|
||||
void SetUKnots(const std::vector<float>& afKnots);
|
||||
void SetUKnots(const std::vector<double>& afKnots);
|
||||
|
||||
/**
|
||||
* Setzen des Knotenvektors
|
||||
*/
|
||||
void SetVKnots(const std::vector<float>& afKnots);
|
||||
void SetVKnots(const std::vector<double>& 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
|
||||
|
|
Loading…
Reference in New Issue
Block a user