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:
jriegel
2013-09-26 00:05:05 +02:00
69 changed files with 1116 additions and 415 deletions

View File

@@ -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"

View File

@@ -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++;

View File

@@ -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 */

View File

@@ -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);
}