Commit 50cc4173 authored by Jan Möbius's avatar Jan Möbius

Various cppcheck fixed

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@17381 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 881a88f5
...@@ -903,7 +903,7 @@ me_insertCircle(QMouseEvent* _event) ...@@ -903,7 +903,7 @@ me_insertCircle(QMouseEvent* _event)
return; return;
const ACG::Vec3d n = createCircle_Normal_, x0 = createCircle_Point_; const ACG::Vec3d n = createCircle_Normal_, x0 = createCircle_Point_;
const double t = ((n | x0) - (n | hit_point)) / (n | n); const double t = ((n | x0) - (n | hit_point)) / n.sqrnorm();
const ACG::Vec3d onPlane = hit_point + t * n, d = onPlane - x0; const ACG::Vec3d onPlane = hit_point + t * n, d = onPlane - x0;
const double r = d.norm(); const double r = d.norm();
const ACG::Vec3d mainAxis = (onPlane - x0).normalize(), sideAxis = (mainAxis % n).normalize(); const ACG::Vec3d mainAxis = (onPlane - x0).normalize(), sideAxis = (mainAxis % n).normalize();
...@@ -1055,9 +1055,8 @@ me_move( QMouseEvent* _event ) ...@@ -1055,9 +1055,8 @@ me_move( QMouseEvent* _event )
if(!PluginFunctions::getObject(createCircle_CurrSelIndex_, L)) if(!PluginFunctions::getObject(createCircle_CurrSelIndex_, L))
return; return;
PolyLineCircleData* LD = (PolyLineCircleData*)L->objectData(CIRCLE_DATA); PolyLineCircleData* LD = dynamic_cast<PolyLineCircleData*>(L->objectData(CIRCLE_DATA));
double cr; double cr;
const double rm = LD->circleMainRadius_, rs = LD->circleSideRadius_;
ACG::Vec3d onPlane; ACG::Vec3d onPlane;
const ACG::Vec3d x0 = LD->circleCenter_, n = LD->circleNormal_; const ACG::Vec3d x0 = LD->circleCenter_, n = LD->circleNormal_;
...@@ -1551,47 +1550,44 @@ pick_triangle_mesh( QPoint mPos, ...@@ -1551,47 +1550,44 @@ pick_triangle_mesh( QPoint mPos,
unsigned int target_idx = 0, node_idx = 0; unsigned int target_idx = 0, node_idx = 0;
ACG::Vec3d hit_point; ACG::Vec3d hit_point;
BaseObjectData* object(0);
if( PluginFunctions::scenegraphPick( ACG::SceneGraph::PICK_FACE, mPos, node_idx, target_idx, &hit_point ) ) if( PluginFunctions::scenegraphPick( ACG::SceneGraph::PICK_FACE, mPos, node_idx, target_idx, &hit_point ) )
{ {
// first check if a sphere was clicked // first check if a sphere was clicked
ACG::SceneGraph::BaseNode* root_node(PluginFunctions::getRootNode()); BaseObjectData* object(0);
ACG::SceneGraph::BaseNode* found_node;
found_node = ACG::SceneGraph::find_node(root_node, node_idx);
if( PluginFunctions::getPickedObject( node_idx, object ) ) if( PluginFunctions::getPickedObject( node_idx, object ) )
{ {
if( object->picked( node_idx ) && object->dataType(DATA_TRIANGLE_MESH) ) if( object->picked( node_idx ) && object->dataType(DATA_TRIANGLE_MESH) )
{ {
// get mesh object // get mesh object
_mesh_object_ = dynamic_cast<TriMeshObject*>(object); _mesh_object_ = dynamic_cast<TriMeshObject*>(object);
// get mesh and face handle // get mesh and face handle
TriMesh & m = *PluginFunctions::triMesh(object); TriMesh & m = *PluginFunctions::triMesh(object);
_fh = m.face_handle(target_idx); _fh = m.face_handle(target_idx);
TriMesh::FaceVertexIter fv_it(m,_fh); TriMesh::FaceVertexIter fv_it(m,_fh);
TriMesh::VertexHandle closest = *fv_it; TriMesh::VertexHandle closest = *fv_it;
float shortest_distance = (m.point(closest) - hit_point).sqrnorm(); float shortest_distance = (m.point(closest) - hit_point).sqrnorm();
++fv_it; ++fv_it;
if ( (m.point(*fv_it ) - hit_point).sqrnorm() < shortest_distance ) { if ( (m.point(*fv_it ) - hit_point).sqrnorm() < shortest_distance ) {
shortest_distance = (m.point(*fv_it ) - hit_point).sqrnorm(); shortest_distance = (m.point(*fv_it ) - hit_point).sqrnorm();
closest = *fv_it; closest = *fv_it;
} }
++fv_it; ++fv_it;
if ( (m.point(*fv_it ) - hit_point).sqrnorm() < shortest_distance ) { if ( (m.point(*fv_it ) - hit_point).sqrnorm() < shortest_distance ) {
shortest_distance = (m.point(*fv_it ) - hit_point).sqrnorm(); // Unnecessary : shortest_distance = (m.point(*fv_it ) - hit_point).sqrnorm();
closest = *fv_it; closest = *fv_it;
} }
// stroe closest vh // stroe closest vh
_vh = closest; _vh = closest;
_hitPoint = hit_point; _hitPoint = hit_point;
return true; return true;
} }
} }
} }
......
...@@ -89,7 +89,7 @@ createCircle_getPointOnMesh(TriMeshObject* _triMeshObject, ACG::Vec3d _center, A ...@@ -89,7 +89,7 @@ createCircle_getPointOnMesh(TriMeshObject* _triMeshObject, ACG::Vec3d _center, A
for(unsigned int j = 0; j < c.size(); j++) { for(unsigned int j = 0; j < c.size(); j++) {
//ACG::Vec3d norAtInt = M->mesh()->normal(c[j].first); //ACG::Vec3d norAtInt = M->mesh()->normal(c[j].first);
ACG::Vec3d p = _pOnPlane + _n * c[j].second, dir = _center - p; ACG::Vec3d p = _pOnPlane + _n * c[j].second, dir = _center - p;
double dist = sqrt(dir | dir); const double dist = dir.norm();
if(dist < smDist) { if(dist < smDist) {
smDist = dist; smDist = dist;
if(_pOut) if(_pOut)
...@@ -108,7 +108,7 @@ PolyLinePlugin:: ...@@ -108,7 +108,7 @@ PolyLinePlugin::
createCircle_getHitInfo(PolyLineCircleData* _circleData, ACG::Vec3d _hit_Point, ACG::Vec3d* _pOut, double* r, ACG::Vec3d* _onPlaneO) createCircle_getHitInfo(PolyLineCircleData* _circleData, ACG::Vec3d _hit_Point, ACG::Vec3d* _pOut, double* r, ACG::Vec3d* _onPlaneO)
{ {
ACG::Vec3d n = _circleData->circleNormal_, x0 = _circleData->circleCenter_; ACG::Vec3d n = _circleData->circleNormal_, x0 = _circleData->circleCenter_;
double t = ((n | x0) - (n | _hit_Point)) / (n | n); double t = ((n | x0) - (n | _hit_Point)) / n.sqrnorm();
ACG::Vec3d onPlane = _hit_Point + t * n, d = onPlane - x0; ACG::Vec3d onPlane = _hit_Point + t * n, d = onPlane - x0;
if(r) if(r)
*r = d.norm(); *r = d.norm();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment