Commit 98bb0f15 authored by Jan Möbius's avatar Jan Möbius

Cleanup the MeshSelection file a bit (Make all referneces const ref)

Cleanup MeshInfo to be more consistent (Use pointers for all mesh parameters)
	- Change cog to get a pointer to the esh
	- Change getBoundingBox to get a pointer to the mesh
Thanks to Vladimir Chalupecky for reporting the inconsistencies.

refs #1372

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@16055 383ad7c9-94d9-4d36-a494-682f7c89f535
parent fb7cd784
...@@ -1303,12 +1303,12 @@ void MovePlugin::slotMoveManipToCOG() { ...@@ -1303,12 +1303,12 @@ void MovePlugin::slotMoveManipToCOG() {
if ( object->manipulatorNode()->visible() ){ if ( object->manipulatorNode()->visible() ){
if ( object->dataType( DATA_TRIANGLE_MESH ) ) if ( object->dataType( DATA_TRIANGLE_MESH ) )
object->manipulatorNode()->set_center( MeshInfo::cog(*PluginFunctions::triMesh(object)) ); object->manipulatorNode()->set_center( MeshInfo::cog(PluginFunctions::triMesh(object)) );
else if ( object->dataType( DATA_POLY_MESH ) ) else if ( object->dataType( DATA_POLY_MESH ) )
object->manipulatorNode()->set_center( MeshInfo::cog(*PluginFunctions::polyMesh(object)) ); object->manipulatorNode()->set_center( MeshInfo::cog(PluginFunctions::polyMesh(object)) );
#ifdef ENABLE_TSPLINEMESH_SUPPORT #ifdef ENABLE_TSPLINEMESH_SUPPORT
else if ( object->dataType( DATA_TSPLINE_MESH ) ) else if ( object->dataType( DATA_TSPLINE_MESH ) )
object->manipulatorNode()->set_center( MeshInfo::cog(*PluginFunctions::tsplineMesh(object)) ); object->manipulatorNode()->set_center( MeshInfo::cog(PluginFunctions::tsplineMesh(object)) );
#endif #endif
updateManipulatorDialog(); updateManipulatorDialog();
...@@ -1528,15 +1528,15 @@ void MovePlugin::slotMoveToOrigin() { ...@@ -1528,15 +1528,15 @@ void MovePlugin::slotMoveToOrigin() {
// Compute cog for all objects // Compute cog for all objects
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) { for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) {
if ( o_it->dataType( DATA_TRIANGLE_MESH )) { if ( o_it->dataType( DATA_TRIANGLE_MESH )) {
TriMesh& mesh = *PluginFunctions::triMesh(*o_it); TriMesh* mesh = PluginFunctions::triMesh(*o_it);
cog += MeshInfo::cog(mesh) * double(mesh.n_vertices()); cog += MeshInfo::cog(mesh) * double(mesh->n_vertices());
vertexCount += double(mesh.n_vertices()); vertexCount += double(mesh->n_vertices());
} }
if ( o_it->dataType( DATA_POLY_MESH )) { if ( o_it->dataType( DATA_POLY_MESH )) {
PolyMesh& mesh = *PluginFunctions::polyMesh(*o_it); PolyMesh* mesh = PluginFunctions::polyMesh(*o_it);
cog += MeshInfo::cog(mesh) * double(mesh.n_vertices()); cog += MeshInfo::cog(mesh) * double(mesh->n_vertices());
vertexCount += double(mesh.n_vertices()); vertexCount += double(mesh->n_vertices());
} }
#ifdef ENABLE_TSPLINEMESH_SUPPORT #ifdef ENABLE_TSPLINEMESH_SUPPORT
...@@ -1555,25 +1555,25 @@ void MovePlugin::slotMoveToOrigin() { ...@@ -1555,25 +1555,25 @@ void MovePlugin::slotMoveToOrigin() {
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) { for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) {
if ( o_it->dataType( DATA_TRIANGLE_MESH )) { if ( o_it->dataType( DATA_TRIANGLE_MESH )) {
TriMesh& mesh = *PluginFunctions::triMesh(*o_it); TriMesh* mesh = PluginFunctions::triMesh(*o_it);
if ( !useCommonCOG ) if ( !useCommonCOG )
cog = MeshInfo::cog(mesh); cog = MeshInfo::cog(mesh);
for ( TriMesh::VertexIter v_it = mesh.vertices_begin(); v_it != mesh.vertices_end() ; ++v_it) for ( TriMesh::VertexIter v_it = mesh->vertices_begin(); v_it != mesh->vertices_end() ; ++v_it)
mesh.set_point(v_it , ( mesh.point(v_it) ) - cog ); mesh->set_point(v_it , ( mesh->point(v_it) ) - cog );
o_it->manipulatorNode()->set_center( o_it->manipulatorNode()->center() - cog ); o_it->manipulatorNode()->set_center( o_it->manipulatorNode()->center() - cog );
} }
if ( o_it->dataType( DATA_POLY_MESH )) { if ( o_it->dataType( DATA_POLY_MESH )) {
PolyMesh& mesh = *PluginFunctions::polyMesh(*o_it); PolyMesh* mesh = PluginFunctions::polyMesh(*o_it);
if ( !useCommonCOG ) if ( !useCommonCOG )
cog = MeshInfo::cog(mesh); cog = MeshInfo::cog(mesh);
for ( PolyMesh::VertexIter v_it = mesh.vertices_begin(); v_it != mesh.vertices_end() ; ++v_it) for ( PolyMesh::VertexIter v_it = mesh->vertices_begin(); v_it != mesh->vertices_end() ; ++v_it)
mesh.set_point(v_it , ( mesh.point(v_it) ) - cog ); mesh->set_point(v_it , ( mesh->point(v_it) ) - cog );
o_it->manipulatorNode()->set_center( o_it->manipulatorNode()->center() - cog ); o_it->manipulatorNode()->set_center( o_it->manipulatorNode()->center() - cog );
...@@ -1581,13 +1581,13 @@ void MovePlugin::slotMoveToOrigin() { ...@@ -1581,13 +1581,13 @@ void MovePlugin::slotMoveToOrigin() {
#ifdef ENABLE_TSPLINEMESH_SUPPORT #ifdef ENABLE_TSPLINEMESH_SUPPORT
if ( o_it->dataType( DATA_TSPLINE_MESH )) { if ( o_it->dataType( DATA_TSPLINE_MESH )) {
TSplineMesh& mesh = *PluginFunctions::tsplineMesh(*o_it); TSplineMesh* mesh = PluginFunctions::tsplineMesh(*o_it);
if ( !useCommonCOG ) if ( !useCommonCOG )
cog = MeshInfo::cog(mesh); cog = MeshInfo::cog(mesh);
for ( TSplineMesh::VertexIter v_it = mesh.vertices_begin(); v_it != mesh.vertices_end() ; ++v_it) for ( TSplineMesh::VertexIter v_it = mesh->vertices_begin(); v_it != mesh->vertices_end() ; ++v_it)
mesh.set_point(v_it , ( mesh.point(v_it) ) - cog ); mesh->set_point(v_it , ( mesh->point(v_it) ) - cog );
o_it->manipulatorNode()->set_center( o_it->manipulatorNode()->center() - cog ); o_it->manipulatorNode()->set_center( o_it->manipulatorNode()->center() - cog );
......
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