From 3b5cdda8792b13eaf17d77149589cca0cbeda1df Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 7 May 2014 13:09:44 +0200 Subject: [PATCH] + fix flaws found with code analyzer tool --- src/App/FeatureTest.cpp | 4 +- src/Base/GeometryPyCXX.cpp | 2 +- src/Base/Stream.cpp | 24 +--- src/Gui/BitmapFactory.cpp | 5 +- src/Gui/SoFCUnifiedSelection.cpp | 4 +- src/Gui/Tree.cpp | 6 +- src/Mod/Mesh/App/Core/Degeneration.cpp | 8 +- src/Mod/Mesh/App/Core/Evaluation.cpp | 1 - src/Mod/Mesh/App/Core/MeshIO.cpp | 1 - src/Mod/Mesh/App/Core/SetOperations.cpp | 1 - src/Mod/Mesh/Gui/MeshEditor.cpp | 1 - src/Mod/Part/App/BSplineSurfacePyImp.cpp | 32 +++--- src/Mod/Part/App/FT2FC.cpp | 8 +- src/Mod/Part/App/TopoShapePyImp.cpp | 4 +- src/Mod/Part/Gui/DlgPrimitives.cpp | 2 +- .../PartDesign/Gui/TaskGrooveParameters.cpp | 4 +- src/Mod/PartDesign/Gui/TaskPadParameters.cpp | 4 +- .../PartDesign/Gui/TaskPocketParameters.cpp | 4 +- .../Gui/TaskRevolutionParameters.cpp | 4 +- src/Mod/Raytracing/Gui/Command.cpp | 105 +++++++++--------- src/Mod/Sketcher/App/Sketch.cpp | 4 +- src/Mod/Sketcher/App/freegcs/GCS.cpp | 2 +- 22 files changed, 111 insertions(+), 119 deletions(-) diff --git a/src/App/FeatureTest.cpp b/src/App/FeatureTest.cpp index 7cd82c3aa..6a34704af 100644 --- a/src/App/FeatureTest.cpp +++ b/src/App/FeatureTest.cpp @@ -123,6 +123,8 @@ DocumentObjectExecReturn *FeatureTest::execute(void) float f; void *s; + // Code analyzers may complain about some errors. This can be ignored + // because this is done on purpose to test the error handling mechanism switch(ExceptionType.getValue()) { case 0: break; @@ -131,7 +133,7 @@ DocumentObjectExecReturn *FeatureTest::execute(void) case 3: *i=0;printf("%i",*i);break; // seg-vault case 4: j=0; printf("%i",1/j); break; // int devision by zero case 5: f=0.0; printf("%f",1/f); break; // float devision by zero - case 6: s = malloc(3600000000ul);break; // out-of-memory + case 6: s = malloc(3600000000ul); free(s); break; // out-of-memory } ExecCount.setValue(ExecCount.getValue() + 1); diff --git a/src/Base/GeometryPyCXX.cpp b/src/Base/GeometryPyCXX.cpp index 027007471..843cb5bb6 100644 --- a/src/Base/GeometryPyCXX.cpp +++ b/src/Base/GeometryPyCXX.cpp @@ -39,7 +39,7 @@ bool Py::Vector::accepts (PyObject *obj) const if (obj && Vector_TypeCheck (obj)) { return true; } - else if (PyTuple_Check(obj)) { + else if (obj && PyTuple_Check(obj)) { return (PyTuple_Size(obj) == 3); } diff --git a/src/Base/Stream.cpp b/src/Base/Stream.cpp index 009cf7e23..2b9ce95e4 100644 --- a/src/Base/Stream.cpp +++ b/src/Base/Stream.cpp @@ -261,21 +261,17 @@ ByteArrayOStreambuf::seekoff(std::streambuf::off_type off, std::ios_base::seekdir way, std::ios_base::openmode /*mode*/) { - off_type begpos = 0; off_type endpos = 0; off_type curpos = _buffer->pos(); switch (way) { case std::ios_base::beg: - begpos = 0; endpos = off; break; case std::ios_base::cur: - begpos = curpos; - endpos = begpos + off; + endpos = curpos + off; break; case std::ios_base::end: - begpos = _buffer->size(); - endpos = begpos; + endpos = _buffer->size(); break; default: return pos_type(off_type(-1)); @@ -401,21 +397,17 @@ IODeviceOStreambuf::seekoff(std::streambuf::off_type off, std::ios_base::seekdir way, std::ios_base::openmode /*mode*/) { - off_type begpos = 0; off_type endpos = 0; off_type curpos = device->pos(); switch (way) { case std::ios_base::beg: - begpos = 0; endpos = off; break; case std::ios_base::cur: - begpos = curpos; - endpos = begpos + off; + endpos = curpos + off; break; case std::ios_base::end: - begpos = device->size(); - endpos = begpos; + endpos = device->size(); break; default: return pos_type(off_type(-1)); @@ -499,21 +491,17 @@ IODeviceIStreambuf::seekoff(std::streambuf::off_type off, std::ios_base::seekdir way, std::ios_base::openmode /*mode*/) { - off_type begpos = 0; off_type endpos = 0; off_type curpos = device->pos(); switch (way) { case std::ios_base::beg: - begpos = 0; endpos = off; break; case std::ios_base::cur: - begpos = curpos; - endpos = begpos + off; + endpos = curpos + off; break; case std::ios_base::end: - begpos = device->size(); - endpos = begpos; + endpos = device->size(); break; default: return pos_type(off_type(-1)); diff --git a/src/Gui/BitmapFactory.cpp b/src/Gui/BitmapFactory.cpp index 44f9656fb..8ffab66f6 100644 --- a/src/Gui/BitmapFactory.cpp +++ b/src/Gui/BitmapFactory.cpp @@ -240,14 +240,12 @@ QPixmap BitmapFactoryInst::pixmap(const char* name) const // try to find it in the given directories if (icon.isNull()) { - bool found = false; QList formats = QImageReader::supportedImageFormats(); formats.prepend("SVG"); // check first for SVG to use special import mechanism - for (QStringList::ConstIterator pt = d->paths.begin(); pt != d->paths.end() && !found; ++pt) { + for (QStringList::ConstIterator pt = d->paths.begin(); pt != d->paths.end(); ++pt) { QDir d(*pt); QString fileName = d.filePath(fn); if (loadPixmap(fileName, icon)) { - found = true; break; } else { @@ -256,7 +254,6 @@ QPixmap BitmapFactoryInst::pixmap(const char* name) const QString path = QString::fromAscii("%1.%2").arg(fileName). arg(QString::fromAscii((*fm).toLower().constData())); if (loadPixmap(path, icon)) { - found = true; break; } } diff --git a/src/Gui/SoFCUnifiedSelection.cpp b/src/Gui/SoFCUnifiedSelection.cpp index d03d87c5d..ef7346e41 100644 --- a/src/Gui/SoFCUnifiedSelection.cpp +++ b/src/Gui/SoFCUnifiedSelection.cpp @@ -355,7 +355,7 @@ SoFCUnifiedSelection::handleEvent(SoHandleEventAction * action) if (vp && vp->isDerivedFrom(ViewProviderDocumentObject::getClassTypeId())) vpd = static_cast(vp); - SbBool old_state = highlighted; + //SbBool old_state = highlighted; highlighted = FALSE; if (vpd && vpd->useNewSelectionModel() && vpd->isSelectable()) { std::string documentName = vpd->getObject()->getDocument()->getName(); @@ -391,7 +391,7 @@ SoFCUnifiedSelection::handleEvent(SoHandleEventAction * action) action.apply(currenthighlight); currenthighlight->unref(); currenthighlight = 0; - old_state = !highlighted; + //old_state = !highlighted; } currenthighlight = static_cast(sa.getPath()->copy()); diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index 8eaf075fe..9dcb8321b 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -204,10 +204,12 @@ void TreeWidget::contextMenuEvent (QContextMenuEvent * e) action->setData(QByteArray((*it)->getName())); if (*it == activeDoc) active = action; } - if (active) active->setChecked(true); - active = subMenuGroup.checkedAction(); + + if (active) + active->setChecked(true); subMenu.addActions(subMenuGroup.actions()); } + if (contextMenu.actions().count() > 0) contextMenu.exec(QCursor::pos()); } diff --git a/src/Mod/Mesh/App/Core/Degeneration.cpp b/src/Mod/Mesh/App/Core/Degeneration.cpp index e6ec99984..4608ca18c 100644 --- a/src/Mod/Mesh/App/Core/Degeneration.cpp +++ b/src/Mod/Mesh/App/Core/Degeneration.cpp @@ -645,10 +645,9 @@ bool MeshFixDeformedFacets::Fixup() if ( !it->IsDegenerated() ) { // store the angles to avoid to compute twice - float fCosAngles[3]; + float fCosAngles[3] = {0,0,0}; bool done=false; - // first check for angle > 120°: in this case we swap with the opposite edge for (int i=0; i<3; i++) { u = it->_aclPoints[(i+1)%3]-it->_aclPoints[i]; @@ -658,7 +657,12 @@ bool MeshFixDeformedFacets::Fixup() float fCosAngle = u * v; fCosAngles[i] = fCosAngle; + } + // first check for angle > 120°: in this case we swap with the opposite edge + for (int i=0; i<3; i++) + { + float fCosAngle = fCosAngles[i]; if (fCosAngle < -0.5f) { const MeshFacet& face = it.GetReference(); unsigned long uNeighbour = face._aulNeighbours[(i+1)%3]; diff --git a/src/Mod/Mesh/App/Core/Evaluation.cpp b/src/Mod/Mesh/App/Core/Evaluation.cpp index 45d6753a8..d6184e5c3 100644 --- a/src/Mod/Mesh/App/Core/Evaluation.cpp +++ b/src/Mod/Mesh/App/Core/Evaluation.cpp @@ -198,7 +198,6 @@ std::vector MeshEvalOrientation::GetIndices() const MeshFacetArray::_TConstIterator iBeg = rFAry.begin(); MeshFacetArray::_TConstIterator iEnd = rFAry.end(); - ulVisited = 0; ulStartFacet = 0; std::vector uIndices, uComplement; diff --git a/src/Mod/Mesh/App/Core/MeshIO.cpp b/src/Mod/Mesh/App/Core/MeshIO.cpp index 688f0d18f..c850c4d55 100644 --- a/src/Mod/Mesh/App/Core/MeshIO.cpp +++ b/src/Mod/Mesh/App/Core/MeshIO.cpp @@ -1235,7 +1235,6 @@ bool MeshInput::LoadInventor (std::istream &rstrIn) else if (points && line.find("INDEXEDFACESET {") != std::string::npos) { unsigned long ulPoints[3]; facets = true; - flag = true; unsigned long ulCt = 0; // Get the next line and check for the index field which might begin // with the first index already. diff --git a/src/Mod/Mesh/App/Core/SetOperations.cpp b/src/Mod/Mesh/App/Core/SetOperations.cpp index 4da554c40..46356f9ef 100644 --- a/src/Mod/Mesh/App/Core/SetOperations.cpp +++ b/src/Mod/Mesh/App/Core/SetOperations.cpp @@ -344,7 +344,6 @@ void SetOperations::TriangulateMesh (const MeshKernel &cutMesh, int side) Vector3f dirY = dirX % normal; // project points to 2D plane - i = 0; std::vector::iterator it; std::vector vertices; for (it = points.begin(); it != points.end(); it++) diff --git a/src/Mod/Mesh/Gui/MeshEditor.cpp b/src/Mod/Mesh/Gui/MeshEditor.cpp index 11c2a2c20..deeeef316 100644 --- a/src/Mod/Mesh/Gui/MeshEditor.cpp +++ b/src/Mod/Mesh/Gui/MeshEditor.cpp @@ -425,7 +425,6 @@ MeshFillHole::MeshFillHole(MeshHoleFiller& hf, Gui::View3DInventor* parent) SoBaseColor * markcol = new SoBaseColor; markcol->rgb.setValue(1.0f, 1.0f, 0.0f); - SoPointSet* marker = new SoPointSet(); myBridgeRoot->addChild(markcol); myVertex = new SoCoordinate3(); diff --git a/src/Mod/Part/App/BSplineSurfacePyImp.cpp b/src/Mod/Part/App/BSplineSurfacePyImp.cpp index 354010dc4..e27f90775 100644 --- a/src/Mod/Part/App/BSplineSurfacePyImp.cpp +++ b/src/Mod/Part/App/BSplineSurfacePyImp.cpp @@ -1292,27 +1292,32 @@ PyObject* BSplineSurfacePy::approximate(PyObject *args) } } - if(continuity<0 || continuity>3){ + if (continuity<0 || continuity>3) { Standard_Failure::Raise("continuity must be between 0 and 3"); } - GeomAbs_Shape c; - switch(continuity){ - case 0: - c = GeomAbs_C0; - case 1: - c = GeomAbs_C1; - case 2: - c = GeomAbs_C2; - case 3: - c = GeomAbs_C3; - } if (interpolationPoints.RowLength() < 2 || interpolationPoints.ColLength() < 2) { Standard_Failure::Raise("not enough points given"); } + GeomAbs_Shape c; + switch(continuity){ + case 0: + c = GeomAbs_C0; + break; + case 1: + c = GeomAbs_C1; + break; + case 2: + c = GeomAbs_C2; + break; + case 3: + c = GeomAbs_C3; + break; + } + GeomAPI_PointsToBSplineSurface surInterpolation; - if(len == 5){ + if (len == 5) { surInterpolation.Init(interpolationPoints, degMin, degMax, c, tol3d); } else { @@ -1334,7 +1339,6 @@ PyObject* BSplineSurfacePy::approximate(PyObject *args) PyObject* BSplineSurfacePy::interpolate(PyObject *args) { PyObject* obj; - Standard_Real tol3d = Precision::Approximation(); Standard_Real X0=0; Standard_Real dX=0; Standard_Real Y0=0; diff --git a/src/Mod/Part/App/FT2FC.cpp b/src/Mod/Part/App/FT2FC.cpp index 025437b26..23a36fd40 100644 --- a/src/Mod/Part/App/FT2FC.cpp +++ b/src/Mod/Part/App/FT2FC.cpp @@ -165,10 +165,10 @@ PyObject* FT2FC(const Py_UNICODE *PyUString, if (!PyList_Size(WireList)) // empty ==> whitespace Base::Console().Log("FT2FC char '0x%04x'/'%d' has no Wires!\n", currchar, currchar); else - PyErr = PyList_Append(CharList, WireList); + PyList_Append(CharList, WireList); PenPos += (cadv + tracking); prevchar = currchar; - } + } error = FT_Done_FreeType(FTLib); if(error) { @@ -285,7 +285,7 @@ PyObject* getGlyphContours(FT_Face FTFont, UNICHAR currchar, double PenPos, doub if (!ctx.Edges.empty()){ ctx.Wires.push_back(edgesToWire(ctx.Edges)); } - FT_Orientation fontClass = FT_Outline_Get_Orientation(&FTFont->glyph->outline); + /*FT_Orientation fontClass =*/ FT_Outline_Get_Orientation(&FTFont->glyph->outline); PyObject* ret = PyList_New(0); gp_Vec pointer = gp_Vec(PenPos * Scale,0.0,0.0); @@ -301,7 +301,7 @@ PyObject* getGlyphContours(FT_Face FTFont, UNICHAR currchar, double PenPos, doub ErrorMsg << "FT2FC OCC BRepScale failed \n"; throw std::runtime_error(ErrorMsg.str()); } - PyErr = PyList_Append(ret,new TopoShapeWirePy(new TopoShape(TopoDS::Wire(BRepScale.Shape())))); + PyList_Append(ret,new TopoShapeWirePy(new TopoShape(TopoDS::Wire(BRepScale.Shape())))); } return(ret); } diff --git a/src/Mod/Part/App/TopoShapePyImp.cpp b/src/Mod/Part/App/TopoShapePyImp.cpp index 8c70c5009..19bfcdab6 100644 --- a/src/Mod/Part/App/TopoShapePyImp.cpp +++ b/src/Mod/Part/App/TopoShapePyImp.cpp @@ -1602,7 +1602,7 @@ PyObject* TopoShapePy::distToShape(PyObject *args) pts = PyTuple_New(2); PyTuple_SetItem(pts,0,pPt1); PyTuple_SetItem(pts,1,pPt2); - int PyErr = PyList_Append(solnPts, pts); + PyList_Append(solnPts, pts); geom = PyTuple_New(6); PyTuple_SetItem(geom,0,pSuppType1); @@ -1611,7 +1611,7 @@ PyObject* TopoShapePy::distToShape(PyObject *args) PyTuple_SetItem(geom,3,pSuppType2); PyTuple_SetItem(geom,4,pSupportIndex2); PyTuple_SetItem(geom,5,pParm2); - PyErr = PyList_Append(solnGeom, geom); + PyList_Append(solnGeom, geom); } } else { diff --git a/src/Mod/Part/Gui/DlgPrimitives.cpp b/src/Mod/Part/Gui/DlgPrimitives.cpp index 1221dc9ad..d43d467db 100644 --- a/src/Mod/Part/Gui/DlgPrimitives.cpp +++ b/src/Mod/Part/Gui/DlgPrimitives.cpp @@ -313,7 +313,7 @@ void DlgPrimitives::executeCallback(Picker* p) viewer->setEditing(true); viewer->setRedirectToSceneGraph(true); SoNode* root = viewer->getSceneGraph(); - int mode; + int mode = 0; if (root && root->getTypeId().isDerivedFrom(Gui::SoFCUnifiedSelection::getClassTypeId())) { mode = static_cast(root)->selectionMode.getValue(); static_cast(root)->selectionMode.setValue(Gui::SoFCUnifiedSelection::OFF); diff --git a/src/Mod/PartDesign/Gui/TaskGrooveParameters.cpp b/src/Mod/PartDesign/Gui/TaskGrooveParameters.cpp index 3b5b63b6b..460d3f25a 100644 --- a/src/Mod/PartDesign/Gui/TaskGrooveParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskGrooveParameters.cpp @@ -304,8 +304,8 @@ bool TaskDlgGrooveParameters::reject() { // get the support and Sketch PartDesign::Groove* pcGroove = static_cast(GrooveView->getObject()); - Sketcher::SketchObject *pcSketch; - App::DocumentObject *pcSupport; + Sketcher::SketchObject *pcSketch = 0; + App::DocumentObject *pcSupport = 0; if (pcGroove->Sketch.getValue()) { pcSketch = static_cast(pcGroove->Sketch.getValue()); pcSupport = pcSketch->Support.getValue(); diff --git a/src/Mod/PartDesign/Gui/TaskPadParameters.cpp b/src/Mod/PartDesign/Gui/TaskPadParameters.cpp index 4a82efc85..27a22ea0e 100644 --- a/src/Mod/PartDesign/Gui/TaskPadParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPadParameters.cpp @@ -528,8 +528,8 @@ bool TaskDlgPadParameters::reject() { // get the support and Sketch PartDesign::Pad* pcPad = static_cast(PadView->getObject()); - Sketcher::SketchObject *pcSketch; - App::DocumentObject *pcSupport; + Sketcher::SketchObject *pcSketch = 0; + App::DocumentObject *pcSupport = 0; if (pcPad->Sketch.getValue()) { pcSketch = static_cast(pcPad->Sketch.getValue()); pcSupport = pcSketch->Support.getValue(); diff --git a/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp b/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp index b3271b5ff..872794fed 100644 --- a/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPocketParameters.cpp @@ -482,8 +482,8 @@ bool TaskDlgPocketParameters::reject() { // get the support and Sketch PartDesign::Pocket* pcPocket = static_cast(PocketView->getObject()); - Sketcher::SketchObject *pcSketch; - App::DocumentObject *pcSupport; + Sketcher::SketchObject *pcSketch = 0; + App::DocumentObject *pcSupport = 0; if (pcPocket->Sketch.getValue()) { pcSketch = static_cast(pcPocket->Sketch.getValue()); pcSupport = pcSketch->Support.getValue(); diff --git a/src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp b/src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp index 780b46560..5a97bad59 100644 --- a/src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskRevolutionParameters.cpp @@ -304,8 +304,8 @@ bool TaskDlgRevolutionParameters::reject() { // get the support and Sketch PartDesign::Revolution* pcRevolution = static_cast(RevolutionView->getObject()); - Sketcher::SketchObject *pcSketch; - App::DocumentObject *pcSupport; + Sketcher::SketchObject *pcSketch = 0; + App::DocumentObject *pcSupport = 0; if (pcRevolution->Sketch.getValue()) { pcSketch = static_cast(pcRevolution->Sketch.getValue()); pcSupport = pcSketch->Support.getValue(); diff --git a/src/Mod/Raytracing/Gui/Command.cpp b/src/Mod/Raytracing/Gui/Command.cpp index 275a36dd3..8144f7619 100644 --- a/src/Mod/Raytracing/Gui/Command.cpp +++ b/src/Mod/Raytracing/Gui/Command.cpp @@ -102,60 +102,59 @@ void CmdRaytracingWriteCamera::activated(int iMsg) if (ret != QMessageBox::Yes) return; } + + SoInput in; + in.setBuffer((void*)ppReturn,std::strlen(ppReturn)); + + SoNode* rootNode; + SoDB::read(&in,rootNode); + + if (!rootNode || !rootNode->getTypeId().isDerivedFrom(SoCamera::getClassTypeId())) + throw Base::Exception("CmdRaytracingWriteCamera::activated(): Could not read " + "camera information from ASCII stream....\n"); + + // root-node returned from SoDB::readAll() has initial zero + // ref-count, so reference it before we start using it to + // avoid premature destruction. + SoCamera * Cam = static_cast(rootNode); + Cam->ref(); + + SbRotation camrot = Cam->orientation.getValue(); + + SbVec3f upvec(0, 1, 0); // init to default up vector + camrot.multVec(upvec, upvec); + + SbVec3f lookat(0, 0, -1); // init to default view direction vector + camrot.multVec(lookat, lookat); + + SbVec3f pos = Cam->position.getValue(); + float Dist = Cam->focalDistance.getValue(); + + QStringList filter; + filter << QObject::tr("Povray(*.pov)"); + filter << QObject::tr("All Files (*.*)"); + QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(), QObject::tr("Export page"), QString(), filter.join(QLatin1String(";;"))); + if (fn.isEmpty()) + return; + std::string cFullName = (const char*)fn.toUtf8(); + + // building up the python string + std::stringstream out; + out << "Raytracing.writeCameraFile(\"" << strToPython(cFullName) << "\"," + << "(" << pos.getValue()[0] <<"," << pos.getValue()[1] <<"," << pos.getValue()[2] <<")," + << "(" << lookat.getValue()[0] <<"," << lookat.getValue()[1] <<"," << lookat.getValue()[2] <<")," ; + lookat *= Dist; + lookat += pos; + out << "(" << lookat.getValue()[0] <<"," << lookat.getValue()[1] <<"," << lookat.getValue()[2] <<")," + << "(" << upvec.getValue()[0] <<"," << upvec.getValue()[1] <<"," << upvec.getValue()[2] <<") )" ; + + doCommand(Doc,"import Raytracing"); + doCommand(Gui,out.str().c_str()); + + // Bring ref-count of root-node back to zero to cause the + // destruction of the camera. + Cam->unref(); } - - SoInput in; - in.setBuffer((void*)ppReturn,std::strlen(ppReturn)); - - SoNode* rootNode; - SoDB::read(&in,rootNode); - - if (!rootNode || !rootNode->getTypeId().isDerivedFrom(SoCamera::getClassTypeId())) - throw Base::Exception("CmdRaytracingWriteCamera::activated(): Could not read " - "camera information from ASCII stream....\n"); - - // root-node returned from SoDB::readAll() has initial zero - // ref-count, so reference it before we start using it to - // avoid premature destruction. - SoCamera * Cam = static_cast(rootNode); - Cam->ref(); - - SbRotation camrot = Cam->orientation.getValue(); - - SbVec3f upvec(0, 1, 0); // init to default up vector - camrot.multVec(upvec, upvec); - - SbVec3f lookat(0, 0, -1); // init to default view direction vector - camrot.multVec(lookat, lookat); - - SbVec3f pos = Cam->position.getValue(); - float Dist = Cam->focalDistance.getValue(); - - QStringList filter; - filter << QObject::tr("Povray(*.pov)"); - filter << QObject::tr("All Files (*.*)"); - QString fn = Gui::FileDialog::getSaveFileName(Gui::getMainWindow(), QObject::tr("Export page"), QString(), filter.join(QLatin1String(";;"))); - if (fn.isEmpty()) - return; - std::string cFullName = (const char*)fn.toUtf8(); - - // building up the python string - std::stringstream out; - out << "Raytracing.writeCameraFile(\"" << strToPython(cFullName) << "\"," - << "(" << pos.getValue()[0] <<"," << pos.getValue()[1] <<"," << pos.getValue()[2] <<")," - << "(" << lookat.getValue()[0] <<"," << lookat.getValue()[1] <<"," << lookat.getValue()[2] <<")," ; - lookat *= Dist; - lookat += pos; - out << "(" << lookat.getValue()[0] <<"," << lookat.getValue()[1] <<"," << lookat.getValue()[2] <<")," - << "(" << upvec.getValue()[0] <<"," << upvec.getValue()[1] <<"," << upvec.getValue()[2] <<") )" ; - - doCommand(Doc,"import Raytracing"); - doCommand(Gui,out.str().c_str()); - - - // Bring ref-count of root-node back to zero to cause the - // destruction of the camera. - Cam->unref(); } bool CmdRaytracingWriteCamera::isActive(void) diff --git a/src/Mod/Sketcher/App/Sketch.cpp b/src/Mod/Sketcher/App/Sketch.cpp index 36839636e..566ebb3f3 100644 --- a/src/Mod/Sketcher/App/Sketch.cpp +++ b/src/Mod/Sketcher/App/Sketch.cpp @@ -1245,8 +1245,8 @@ int Sketch::addDistanceConstraint(int geoId, double value) // line to line distance constraint int Sketch::addDistanceConstraint(int geoId1, int geoId2, double value) { - geoId1 = checkGeoId(geoId1); - geoId2 = checkGeoId(geoId2); + //geoId1 = checkGeoId(geoId1); + //geoId2 = checkGeoId(geoId2); //assert(Geoms[geoId1].type == Line); //assert(Geoms[geoId2].type == Line); diff --git a/src/Mod/Sketcher/App/freegcs/GCS.cpp b/src/Mod/Sketcher/App/freegcs/GCS.cpp index 5f8ea1850..2bd96f906 100644 --- a/src/Mod/Sketcher/App/freegcs/GCS.cpp +++ b/src/Mod/Sketcher/App/freegcs/GCS.cpp @@ -158,7 +158,7 @@ System::System(std::vector clist_) // create own (shallow) copy of constraints for (std::vector::iterator constr=clist_.begin(); constr != clist_.end(); ++constr) { - Constraint *newconstr; + Constraint *newconstr = 0; switch ((*constr)->getTypeId()) { case Equal: { ConstraintEqual *oldconstr = static_cast(*constr);