From 31afafcba65c56bd6a64f749779e7664e779d2d2 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 10 Oct 2013 17:15:03 +0200 Subject: [PATCH] + Fix double to float cast --- src/Base/Vector3D.h | 8 +++++--- src/Mod/Drawing/App/ProjectionAlgos.cpp | 16 ++++++++-------- src/Mod/Drawing/App/ProjectionAlgos.h | 4 ++-- src/Mod/Import/App/ImportOCAF.cpp | 18 +++++++++--------- src/Mod/Mesh/App/Core/Trim.cpp | 20 ++++++++++---------- src/Mod/Mesh/App/FeatureMeshDefects.cpp | 4 ++-- src/Mod/Mesh/App/FeatureMeshSolid.cpp | 16 ++++++++-------- 7 files changed, 44 insertions(+), 42 deletions(-) diff --git a/src/Base/Vector3D.h b/src/Base/Vector3D.h index 395d5afe6..9feb55736 100644 --- a/src/Base/Vector3D.h +++ b/src/Base/Vector3D.h @@ -253,9 +253,11 @@ private: template inline _Vec1 convertTo(const _Vec2& v) { - typedef _Vec2 vec_type; - typedef vec_traits traits_type; - typedef typename traits_type::float_type float_type; + typedef _Vec1 out_type; + typedef _Vec2 inp_type; + typedef vec_traits traits_type; + typedef vec_traits traits_out; + typedef typename traits_out::float_type float_type; traits_type t(v); return _Vec1((float_type)t.x(),(float_type)t.y(),(float_type)t.z()); }; diff --git a/src/Mod/Drawing/App/ProjectionAlgos.cpp b/src/Mod/Drawing/App/ProjectionAlgos.cpp index 3fe04ae2a..92ba3283a 100644 --- a/src/Mod/Drawing/App/ProjectionAlgos.cpp +++ b/src/Mod/Drawing/App/ProjectionAlgos.cpp @@ -146,14 +146,14 @@ void ProjectionAlgos::execute(void) } -std::string ProjectionAlgos::getSVG(ExtractionType type, float scale, float tolerance) +std::string ProjectionAlgos::getSVG(ExtractionType type, double scale, double tolerance) { std::stringstream result; SVGOutput output; float hfactor = 0.5f; // hidden line size factor, was 0.15f / 0.35f; if (!H.IsNull() && (type & WithHidden)) { - float width = hfactor * scale; + double width = hfactor * scale; BRepMesh::Mesh(H,tolerance); result << "" << endl; } if (!HO.IsNull() && (type & WithHidden)) { - float width = hfactor * scale; + double width = hfactor * scale; BRepMesh::Mesh(HO,tolerance); result << "" << endl; } if (!VO.IsNull()) { - float width = scale; + double width = scale; BRepMesh::Mesh(VO,tolerance); result << "" << endl; } if (!V.IsNull()) { - float width = scale; + double width = scale; BRepMesh::Mesh(V,tolerance); result << "" << endl; } if (!V1.IsNull() && (type & WithSmooth)) { - float width = scale; + double width = scale; BRepMesh::Mesh(V1,tolerance); result << "" << endl; } if (!H1.IsNull() && (type & WithSmooth) && (type & WithHidden)) { - float width = hfactor * scale; + double width = hfactor * scale; BRepMesh::Mesh(H1,tolerance); result << "GetColor(aShape, XCAFDoc_ColorGen, aColor) || aColorTool->GetColor(aShape, XCAFDoc_ColorSurf, aColor) || aColorTool->GetColor(aShape, XCAFDoc_ColorCurv, aColor)) { - color.r = aColor.Red(); - color.g = aColor.Green(); - color.b = aColor.Blue(); + color.r = (float)aColor.Red(); + color.g = (float)aColor.Green(); + color.b = (float)aColor.Blue(); std::vector colors; colors.push_back(color); applyColors(part, colors); @@ -246,9 +246,9 @@ void ImportOCAF::createShape(const TopoDS_Shape& aShape, const TopLoc_Location& aColorTool->GetColor(xp.Current(), XCAFDoc_ColorSurf, aColor) || aColorTool->GetColor(xp.Current(), XCAFDoc_ColorCurv, aColor)) { int index = faces.FindIndex(xp.Current()); - color.r = aColor.Red(); - color.g = aColor.Green(); - color.b = aColor.Blue(); + color.r = (float)aColor.Red(); + color.g = (float)aColor.Green(); + color.b = (float)aColor.Blue(); faceColors[index-1] = color; found_face_color = true; } @@ -438,9 +438,9 @@ void ImportXCAF::createShape(const TopoDS_Shape& shape, bool perface, bool setna if (jt != myColorMap.end()) { int index = faces.FindIndex(xp.Current()); App::Color color; - color.r = jt->second.Red(); - color.g = jt->second.Green(); - color.b = jt->second.Blue(); + color.r = (float)jt->second.Red(); + color.g = (float)jt->second.Green(); + color.b = (float)jt->second.Blue(); faceColors[index-1] = color; found_face_color = true; } diff --git a/src/Mod/Mesh/App/Core/Trim.cpp b/src/Mod/Mesh/App/Core/Trim.cpp index 27a64c156..9c8c65a59 100644 --- a/src/Mod/Mesh/App/Core/Trim.cpp +++ b/src/Mod/Mesh/App/Core/Trim.cpp @@ -169,15 +169,15 @@ bool MeshTrimming::IsPolygonPointInFacet(unsigned long ulIndex, Base::Vector3f& A = clFacPoly[0]; B = clFacPoly[1]; C = clFacPoly[2]; - fDetABC = A.fX*B.fY+A.fY*C.fX+B.fX*C.fY-(B.fY*C.fX+A.fY*B.fX+A.fX*C.fY); + fDetABC = (float)(A.fX*B.fY+A.fY*C.fX+B.fX*C.fY-(B.fY*C.fX+A.fY*B.fX+A.fX*C.fY)); for (unsigned long j=0; j calculate the corresponding 3d-point if (clFacPoly.Contains(myPoly[j])) { P = myPoly[j]; - fDetPAC = A.fX*P.fY+A.fY*C.fX+P.fX*C.fY-(P.fY*C.fX+A.fY*P.fX+A.fX*C.fY); - fDetPBC = P.fX*B.fY+P.fY*C.fX+B.fX*C.fY-(B.fY*C.fX+P.fY*B.fX+P.fX*C.fY); - fDetPAB = A.fX*B.fY+A.fY*P.fX+B.fX*P.fY-(B.fY*P.fX+A.fY*B.fX+A.fX*P.fY); + fDetPAC = (float)(A.fX*P.fY+A.fY*C.fX+P.fX*C.fY-(P.fY*C.fX+A.fY*P.fX+A.fX*C.fY)); + fDetPBC = (float)(P.fX*B.fY+P.fY*C.fX+B.fX*C.fY-(B.fY*C.fX+P.fY*B.fX+P.fX*C.fY)); + fDetPAB = (float)(A.fX*B.fY+A.fY*P.fX+B.fX*P.fY-(B.fY*P.fX+A.fY*B.fX+A.fX*P.fY)); u = fDetPBC / fDetABC; v = fDetPAC / fDetABC; w = fDetPAB / fDetABC; @@ -224,13 +224,13 @@ bool MeshTrimming::GetIntersectionPointsOfPolygonAndFacet(unsigned long ulIndex, if (clPolyLine.Intersect(clFacLine, S)) { bool bPushBack=true; - float fP1P2 = (P2-P1).Length(); - float fSP1 = (P1-S).Length(); - float fSP2 = (P2-S).Length(); + float fP1P2 = (float)(P2-P1).Length(); + float fSP1 = (float)(P1-S).Length(); + float fSP2 = (float)(P2-S).Length(); - float fP3P4 = (P4-P3).Length(); - float fSP3 = (P3-S).Length(); - float fSP4 = (P4-S).Length(); + float fP3P4 = (float)(P4-P3).Length(); + float fSP3 = (float)(P3-S).Length(); + float fSP4 = (float)(P4-S).Length(); // compute propotion of length float l = fSP1 / fP1P2; float m = fSP2 / fP1P2; diff --git a/src/Mod/Mesh/App/FeatureMeshDefects.cpp b/src/Mod/Mesh/App/FeatureMeshDefects.cpp index 163c9a0ee..a618b5397 100644 --- a/src/Mod/Mesh/App/FeatureMeshDefects.cpp +++ b/src/Mod/Mesh/App/FeatureMeshDefects.cpp @@ -252,7 +252,7 @@ App::DocumentObjectExecReturn *FixDeformations::execute(void) Mesh::PropertyMeshKernel* kernel = static_cast(prop); std::auto_ptr mesh(new MeshObject); *mesh = kernel->getValue(); - mesh->validateDeformations(MaxAngle.getValue()); + mesh->validateDeformations((float)MaxAngle.getValue()); this->Mesh.setValuePtr(mesh.release()); } @@ -310,7 +310,7 @@ App::DocumentObjectExecReturn *FillHoles::execute(void) Mesh::PropertyMeshKernel* kernel = static_cast(prop); std::auto_ptr mesh(new MeshObject); *mesh = kernel->getValue(); - MeshCore::ConstraintDelaunayTriangulator cTria(MaxArea.getValue()); + MeshCore::ConstraintDelaunayTriangulator cTria((float)MaxArea.getValue()); //MeshCore::Triangulator cTria(mesh->getKernel()); mesh->fillupHoles(FillupHolesOfLength.getValue(), 1, cTria); this->Mesh.setValuePtr(mesh.release()); diff --git a/src/Mod/Mesh/App/FeatureMeshSolid.cpp b/src/Mod/Mesh/App/FeatureMeshSolid.cpp index 9c414216b..0b409e01f 100644 --- a/src/Mod/Mesh/App/FeatureMeshSolid.cpp +++ b/src/Mod/Mesh/App/FeatureMeshSolid.cpp @@ -61,7 +61,7 @@ short Sphere::mustExecute() const App::DocumentObjectExecReturn *Sphere::execute(void) { - std::auto_ptr mesh(MeshObject::createSphere(Radius.getValue(),Sampling.getValue())); + std::auto_ptr mesh(MeshObject::createSphere((float)Radius.getValue(),Sampling.getValue())); if (mesh.get()) { mesh->setPlacement(this->Placement.getValue()); Mesh.setValue(mesh->getKernel()); @@ -97,7 +97,7 @@ short Ellipsoid::mustExecute() const App::DocumentObjectExecReturn *Ellipsoid::execute(void) { - std::auto_ptr mesh(MeshObject::createEllipsoid(Radius1.getValue(),Radius2.getValue(),Sampling.getValue())); + std::auto_ptr mesh(MeshObject::createEllipsoid((float)Radius1.getValue(),(float)Radius2.getValue(),Sampling.getValue())); if (mesh.get()) { mesh->setPlacement(this->Placement.getValue()); Mesh.setValue(mesh->getKernel()); @@ -138,8 +138,8 @@ short Cylinder::mustExecute() const App::DocumentObjectExecReturn *Cylinder::execute(void) { - std::auto_ptr mesh(MeshObject::createCylinder(Radius.getValue(),Length.getValue(), - Closed.getValue(),EdgeLength.getValue(),Sampling.getValue())); + std::auto_ptr mesh(MeshObject::createCylinder((float)Radius.getValue(),(float)Length.getValue(), + Closed.getValue(),(float)EdgeLength.getValue(),Sampling.getValue())); if (mesh.get()) { mesh->setPlacement(this->Placement.getValue()); Mesh.setValue(mesh->getKernel()); @@ -183,8 +183,8 @@ short Cone::mustExecute() const App::DocumentObjectExecReturn *Cone::execute(void) { - std::auto_ptr mesh(MeshObject::createCone(Radius1.getValue(),Radius2.getValue(),Length.getValue(), - Closed.getValue(),EdgeLength.getValue(),Sampling.getValue())); + std::auto_ptr mesh(MeshObject::createCone((float)Radius1.getValue(),(float)Radius2.getValue(),(float)Length.getValue(), + Closed.getValue(),(float)EdgeLength.getValue(),Sampling.getValue())); if (mesh.get()) { mesh->setPlacement(this->Placement.getValue()); Mesh.setValue(mesh->getKernel()); @@ -220,7 +220,7 @@ short Torus::mustExecute() const App::DocumentObjectExecReturn *Torus::execute(void) { - std::auto_ptr mesh(MeshObject::createTorus(Radius1.getValue(),Radius2.getValue(),Sampling.getValue())); + std::auto_ptr mesh(MeshObject::createTorus((float)Radius1.getValue(),(float)Radius2.getValue(),Sampling.getValue())); if (mesh.get()) { mesh->setPlacement(this->Placement.getValue()); Mesh.setValue(mesh->getKernel()); @@ -256,7 +256,7 @@ short Cube::mustExecute() const App::DocumentObjectExecReturn *Cube::execute(void) { - std::auto_ptr mesh(MeshObject::createCube(Length.getValue(),Width.getValue(),Height.getValue())); + std::auto_ptr mesh(MeshObject::createCube((float)Length.getValue(),(float)Width.getValue(),(float)Height.getValue())); if (mesh.get()) { mesh->setPlacement(this->Placement.getValue()); Mesh.setValue(mesh->getKernel());