Commit 36221228 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 024833db
......@@ -171,19 +171,19 @@ int componentCount(MeshT* _mesh ) {
template < typename MeshT >
inline
void getBoundingBox( MeshT& _mesh,
void getBoundingBox( MeshT* _mesh,
typename MeshT::Point& _min ,
typename MeshT::Point& _max) {
if ( _mesh.n_vertices() == 0 ) {
if ( _mesh->n_vertices() == 0 ) {
std::cerr << "Unable to compute Bounding Box: No points in Mesh!" << std::endl;
}
// Use any point as initial value
_min = _mesh.point(_mesh.vertex_handle(0));
_max = _mesh.point(_mesh.vertex_handle(0));
_min = _mesh->point(_mesh->vertex_handle(0));
_max = _mesh->point(_mesh->vertex_handle(0));
for (typename MeshT::VertexIter v_it = _mesh.vertices_begin() ; v_it != _mesh.vertices_end() ; ++v_it ) {
_min.minimize( _mesh.point(v_it.handle()) );
_max.maximize( _mesh.point(v_it.handle()) );
for (typename MeshT::VertexIter v_it = _mesh->vertices_begin() ; v_it != _mesh->vertices_end() ; ++v_it ) {
_min.minimize( _mesh->point(v_it.handle()) );
_max.maximize( _mesh->point(v_it.handle()) );
}
}
......@@ -193,13 +193,13 @@ void getBoundingBox( MeshT& _mesh,
template < typename MeshT >
inline
typename MeshT::Point
cog ( const MeshT& _mesh ) {
typename MeshT::ConstVertexIter v_it, v_end=_mesh.vertices_end();
cog ( const MeshT* _mesh ) {
typename MeshT::ConstVertexIter v_it, v_end=_mesh->vertices_end();
typename MeshT::Point cog(0.0,0.0,0.0);
for (v_it = _mesh.vertices_begin(); v_it != v_end ; ++v_it)
cog += _mesh.point(v_it);
cog = 1.0 / (typename MeshT::Scalar)_mesh.n_vertices() * cog;
for (v_it = _mesh->vertices_begin(); v_it != v_end ; ++v_it)
cog += _mesh->point(v_it);
cog = 1.0 / (typename MeshT::Scalar)_mesh->n_vertices() * cog;
return cog;
}
......
......@@ -96,7 +96,7 @@ int componentCount(MeshT* _mesh );
*/
template < typename MeshT >
inline
void getBoundingBox( MeshT& _mesh,
void getBoundingBox( MeshT* _mesh,
typename MeshT::Point& _min ,
typename MeshT::Point& _max);
......@@ -107,7 +107,7 @@ void getBoundingBox( MeshT& _mesh,
template < typename MeshT >
inline
typename MeshT::Point
cog ( const MeshT& _mesh );
cog ( const MeshT* _mesh );
//=============================================================================
} // MeshInfo Namespace
......
......@@ -69,7 +69,7 @@ namespace MeshSelection {
template< typename MeshT >
inline
void selectVertices(MeshT* _mesh, std::vector< int >& _vertices) {
void selectVertices(MeshT* _mesh, const std::vector< int >& _vertices) {
const int n_vertices = (int)_mesh->n_vertices();
for ( uint i = 0 ; i < _vertices.size() ; ++i )
......@@ -83,7 +83,7 @@ void selectVertices(MeshT* _mesh, std::vector< int >& _vertices) {
template< typename MeshT >
inline
void unselectVertices(MeshT* _mesh, std::vector< int >& _vertices) {
void unselectVertices(MeshT* _mesh, const std::vector< int >& _vertices) {
const int n_vertices = (int)_mesh->n_vertices();
for ( uint i = 0 ; i < _vertices.size() ; ++i )
......@@ -237,7 +237,7 @@ std::vector< int > getVertexSelection(MeshT* _mesh, bool& _invert) {
template< typename MeshT >
inline
void selectBoundaryVertices(MeshT* _mesh, typename MeshT::VertexHandle& _vh){
void selectBoundaryVertices(MeshT* _mesh, const typename MeshT::VertexHandle& _vh){
OpenMesh::VPropHandleT< bool > visited;
_mesh->add_property(visited, "Visited Vertices");
......@@ -271,9 +271,9 @@ void selectBoundaryVertices(MeshT* _mesh, typename MeshT::VertexHandle& _vh){
template< typename MeshT >
inline
void convertVertexToEdgeSelection(MeshT* _mesh, std::vector< int >& _vertices) {
void convertVertexToEdgeSelection(MeshT* _mesh, const std::vector< int >& _vertices) {
for (std::vector<int>::iterator v = _vertices.begin(); v != _vertices.end(); ++v) {
for ( std::vector<int>::const_iterator v = _vertices.begin(); v != _vertices.end(); ++v) {
typename MeshT::VertexHandle vh(*v);
typename MeshT::VertexOHalfedgeIter ohe_iter = _mesh->voh_iter(vh);
......@@ -282,7 +282,7 @@ void convertVertexToEdgeSelection(MeshT* _mesh, std::vector< int >& _vertices) {
// test if both incident vertices are in _vertices
typename MeshT::VertexHandle ovh = _mesh->to_vertex_handle(ohe_iter.handle());
// search for ovh in _vertices
for(std::vector<int>::iterator it = _vertices.begin(); it != _vertices.end(); ++it) {
for(std::vector<int>::const_iterator it = _vertices.begin(); it != _vertices.end(); ++it) {
if((*it) == ovh.idx()) {
_mesh->status(_mesh->edge_handle(ohe_iter.handle())).set_selected(true);
break;
......@@ -314,9 +314,9 @@ void convertVertexToEdgeSelection(MeshT* _mesh) {
template< typename MeshT >
inline
void convertVertexToHalfedgeSelection(MeshT* _mesh, std::vector< int >& _vertices) {
void convertVertexToHalfedgeSelection(MeshT* _mesh, const std::vector< int >& _vertices) {
for (std::vector<int>::iterator v = _vertices.begin(); v != _vertices.end(); ++v) {
for (std::vector<int>::const_iterator v = _vertices.begin(); v != _vertices.end(); ++v) {
typename MeshT::VertexHandle vh(*v);
typename MeshT::VertexOHalfedgeIter ohe_iter = _mesh->voh_iter(vh);
......@@ -325,7 +325,7 @@ void convertVertexToHalfedgeSelection(MeshT* _mesh, std::vector< int >& _vertice
// test if both incident vertices are in _vertices
typename MeshT::VertexHandle ovh = _mesh->to_vertex_handle(ohe_iter.handle());
// search for ovh in _vertices
for(std::vector<int>::iterator it = _vertices.begin(); it != _vertices.end(); ++it) {
for(std::vector<int>::const_iterator it = _vertices.begin(); it != _vertices.end(); ++it) {
if((*it) == ovh.idx()) {
_mesh->status(ohe_iter.handle()).set_selected(true);
_mesh->status(_mesh->opposite_halfedge_handle(ohe_iter.handle())).set_selected(true);
......@@ -362,7 +362,7 @@ void convertVertexToHalfedgeSelection(MeshT* _mesh) {
template< typename MeshT >
inline
void convertVertexToFaceSelection(MeshT* _mesh, std::vector< int >& _vertices) {
void convertVertexToFaceSelection(MeshT* _mesh, const std::vector< int >& _vertices) {
for(typename MeshT::FaceIter f_it = _mesh->faces_begin(); f_it != _mesh->faces_end(); ++f_it) {
typename MeshT::FaceVertexIter fv_it = _mesh->fv_iter(f_it);
......@@ -371,7 +371,7 @@ void convertVertexToFaceSelection(MeshT* _mesh, std::vector< int >& _vertices) {
for(; fv_it; ++fv_it) {
// search fv_it in _vertices
bool onefound = false;
for(std::vector<int>::iterator it = _vertices.begin(); it != _vertices.end(); ++it) {
for(std::vector<int>::const_iterator it = _vertices.begin(); it != _vertices.end(); ++it) {
if((*it) == fv_it.handle().idx()) { onefound = true; break; }
}
if(!onefound) {
......@@ -454,7 +454,7 @@ void clearFeatureVertices(MeshT* _mesh) {
template< typename MeshT >
inline
void setArea(MeshT* _mesh, std::vector< int >& _vertices , unsigned int _type, bool _state) {
void setArea(MeshT* _mesh, const std::vector< int >& _vertices , unsigned int _type, bool _state) {
for ( uint i = 0 ; i < _vertices.size() ; ++i ) {
if ( _vertices[i] > (int)_mesh->n_vertices() )
continue;
......@@ -513,7 +513,7 @@ std::vector< int > getArea(MeshT* _mesh, unsigned int _type , bool& _invert) {
template< typename MeshT >
inline
void selectEdges(MeshT* _mesh, std::vector< int >& _edges) {
void selectEdges(MeshT* _mesh, const std::vector< int >& _edges) {
const int n_edges = (int)_mesh->n_edges();
for ( uint i = 0 ; i < _edges.size() ; ++i )
......@@ -527,7 +527,7 @@ void selectEdges(MeshT* _mesh, std::vector< int >& _edges) {
template< typename MeshT >
inline
void unselectEdges(MeshT* _mesh, std::vector< int >& _edges) {
void unselectEdges(MeshT* _mesh, const std::vector< int >& _edges) {
const int n_edges = (int)_mesh->n_edges();
for ( uint i = 0 ; i < _edges.size() ; ++i )
......@@ -625,9 +625,9 @@ std::vector< int > getEdgeSelection(MeshT* _mesh, bool& _invert) {
template< typename MeshT >
inline
void convertEdgeToVertexSelection(MeshT* _mesh, std::vector< int >& _edges) {
void convertEdgeToVertexSelection(MeshT* _mesh, const std::vector< int >& _edges) {
for (std::vector<int>::iterator e = _edges.begin(); e != _edges.end(); ++e) {
for (std::vector<int>::const_iterator e = _edges.begin(); e != _edges.end(); ++e) {
typename MeshT::EdgeHandle eh(*e);
typename MeshT::HalfedgeHandle heh0 = _mesh->halfedge_handle(eh, 0);
......@@ -660,7 +660,7 @@ void convertEdgeToVertexSelection(MeshT* _mesh) {
template< typename MeshT >
inline
void convertEdgeToFaceSelection(MeshT* _mesh, std::vector< int >& _edges) {
void convertEdgeToFaceSelection(MeshT* _mesh, const std::vector< int >& _edges) {
for(typename MeshT::FaceIter f_it = _mesh->faces_begin(); f_it != _mesh->faces_end(); ++f_it) {
typename MeshT::FaceEdgeIter fe_it = _mesh->fe_iter(f_it);
......@@ -669,7 +669,7 @@ void convertEdgeToFaceSelection(MeshT* _mesh, std::vector< int >& _edges) {
for(; fe_it; ++fe_it) {
// search fe_it in _edges
bool onefound = false;
for(std::vector<int>::iterator it = _edges.begin(); it != _edges.end(); ++it) {
for(std::vector<int>::const_iterator it = _edges.begin(); it != _edges.end(); ++it) {
if((*it) == fe_it.handle().idx()) { onefound = true; break; }
}
if(!onefound) {
......@@ -765,7 +765,7 @@ void clearFeatureEdges(MeshT* _mesh) {
template< typename MeshT >
inline
void selectHalfedges(MeshT* _mesh, std::vector< int >& _halfedges) {
void selectHalfedges(MeshT* _mesh, const std::vector< int >& _halfedges) {
const int n_halfedges = (int)_mesh->n_halfedges();
for ( uint i = 0 ; i < _halfedges.size() ; ++i )
......@@ -779,7 +779,7 @@ void selectHalfedges(MeshT* _mesh, std::vector< int >& _halfedges) {
template< typename MeshT >
inline
void unselectHalfedges(MeshT* _mesh, std::vector< int >& _halfedges) {
void unselectHalfedges(MeshT* _mesh, const std::vector< int >& _halfedges) {
const int n_halfedges = (int)_mesh->n_halfedges();
for ( uint i = 0 ; i < _halfedges.size() ; ++i )
......@@ -895,7 +895,7 @@ void convertHalfedgeToFaceSelection(MeshT* _mesh) {
template< typename MeshT >
inline
void selectFaces(MeshT* _mesh, IdList& _faces) {
void selectFaces(MeshT* _mesh, const IdList& _faces) {
const int n_faces = (int)_mesh->n_faces();
for ( uint i = 0 ; i < _faces.size() ; ++i )
......@@ -909,7 +909,7 @@ void selectFaces(MeshT* _mesh, IdList& _faces) {
template< typename MeshT >
inline
void unselectFaces(MeshT* _mesh, IdList& _faces) {
void unselectFaces(MeshT* _mesh, const IdList& _faces) {
const int n_faces = (int)_mesh->n_faces();
for ( uint i = 0 ; i < _faces.size() ; ++i )
......@@ -1072,9 +1072,9 @@ std::vector< int > getFaceSelection(MeshT* _mesh, bool& _invert) {
template< typename MeshT >
inline
void convertFaceToVertexSelection(MeshT* _mesh, std::vector< int >& _faces) {
void convertFaceToVertexSelection(MeshT* _mesh, const std::vector< int >& _faces) {
for (std::vector<int>::iterator f = _faces.begin(); f != _faces.end(); ++f) {
for (std::vector<int>::const_iterator f = _faces.begin(); f != _faces.end(); ++f) {
typename MeshT::FaceHandle fh(*f);
......@@ -1103,9 +1103,9 @@ void convertFaceToVertexSelection(MeshT* _mesh) {
template< typename MeshT >
inline
void convertFaceToEdgeSelection(MeshT* _mesh, std::vector< int >& _faces) {
void convertFaceToEdgeSelection(MeshT* _mesh, const std::vector< int >& _faces) {
for (std::vector<int>::iterator f = _faces.begin(); f != _faces.end(); ++f) {
for (std::vector<int>::const_iterator f = _faces.begin(); f != _faces.end(); ++f) {
typename MeshT::FaceHandle fh(*f);
......
......@@ -78,12 +78,12 @@ namespace MeshSelection {
/// Select given vertices of a mesh
template< typename MeshT >
inline
void selectVertices(MeshT* _mesh, std::vector< int >& _vertices);
void selectVertices(MeshT* _mesh, const std::vector< int >& _vertices);
/// Unselect given vertices of a mesh
template< typename MeshT >
inline
void unselectVertices(MeshT* _mesh, std::vector< int >& _vertices);
void unselectVertices(MeshT* _mesh, const std::vector< int >& _vertices);
/// Select all vertices of a mesh
template< typename MeshT >
......@@ -136,7 +136,7 @@ std::vector< int > getVertexSelection(MeshT* _mesh, bool& _invert);
*/
template< typename MeshT >
inline
void selectBoundaryVertices(MeshT* _mesh, typename MeshT::VertexHandle& _vh);
void selectBoundaryVertices(MeshT* _mesh, const typename MeshT::VertexHandle& _vh);
/**
* Select for each vertex in _vertices all incident edges
......@@ -144,7 +144,7 @@ void selectBoundaryVertices(MeshT* _mesh, typename MeshT::VertexHandle& _vh);
*/
template< typename MeshT >
inline
void convertVertexToEdgeSelection(MeshT* _mesh, std::vector< int >& _vertices);
void convertVertexToEdgeSelection(MeshT* _mesh, const std::vector< int >& _vertices);
/**
* For each selected vertex select all incident edges
......@@ -159,7 +159,7 @@ void convertVertexToEdgeSelection(MeshT* _mesh);
*/
template< typename MeshT >
inline
void convertVertexToHalfedgeSelection(MeshT* _mesh, std::vector< int >& _vertices);
void convertVertexToHalfedgeSelection(MeshT* _mesh, const std::vector< int >& _vertices);
/**
* For each selected vertex select all incident halfedges
......@@ -174,7 +174,7 @@ void convertVertexToHalfedgeSelection(MeshT* _mesh);
*/
template< typename MeshT >
inline
void convertVertexToFaceSelection(MeshT* _mesh, std::vector< int >& _vertices);
void convertVertexToFaceSelection(MeshT* _mesh, const std::vector< int >& _vertices);
/**
* For each selected vertex select all adjacent faces
......@@ -217,7 +217,7 @@ void clearFeatureVertices(MeshT* _mesh);
* */
template< typename MeshT >
inline
void setArea(MeshT* _mesh, std::vector< int >& _vertices , unsigned int _type, bool _state);
void setArea(MeshT* _mesh, const std::vector< int >& _vertices , unsigned int _type, bool _state);
/** Reset Modeling Status for vertices
*
......@@ -249,12 +249,12 @@ std::vector< int > getArea(MeshT* _mesh, unsigned int _type , bool& _invert);
/// Select given edges of a mesh
template< typename MeshT >
inline
void selectEdges(MeshT* _mesh, std::vector< int >& _edges);
void selectEdges(MeshT* _mesh, const std::vector< int >& _edges);
/// Unselect given edges of a mesh
template< typename MeshT >
inline
void unselectEdges(MeshT* _mesh, std::vector< int >& _edges);
void unselectEdges(MeshT* _mesh, const std::vector< int >& _edges);
/// Select all edges of a mesh
template< typename MeshT >
......@@ -294,7 +294,7 @@ std::vector< int > getEdgeSelection(MeshT* _mesh, bool& _invert);
*/
template< typename MeshT >
inline
void convertEdgeToVertexSelection(MeshT* _mesh, std::vector< int >& _edges);
void convertEdgeToVertexSelection(MeshT* _mesh, const std::vector< int >& _edges);
/**
* For each selected edge select all incident vertices
......@@ -309,7 +309,7 @@ void convertEdgeToVertexSelection(MeshT* _mesh);
*/
template< typename MeshT >
inline
void convertEdgeToFaceSelection(MeshT* _mesh, std::vector< int >& _edges);
void convertEdgeToFaceSelection(MeshT* _mesh, const std::vector< int >& _edges);
/**
* For each selected edge select all adjacent faces
......@@ -357,12 +357,12 @@ void clearFeatureEdges(MeshT* _mesh);
/// Select given edges of a mesh
template< typename MeshT >
inline
void selectHalfedges(MeshT* _mesh, std::vector< int >& _halfedges);
void selectHalfedges(MeshT* _mesh, const std::vector< int >& _halfedges);
/// Unselect given edges of a mesh
template< typename MeshT >
inline
void unselectHalfedges(MeshT* _mesh, std::vector< int >& _halfedges);
void unselectHalfedges(MeshT* _mesh, const std::vector< int >& _halfedges);
/// Select all edges of a mesh
template< typename MeshT >
......@@ -418,12 +418,12 @@ void convertHalfedgeToFaceSelection(MeshT* _mesh);
/// Select given faces of a mesh
template< typename MeshT >
inline
void selectFaces(MeshT* _mesh, std::vector< int >& _faces );
void selectFaces(MeshT* _mesh, const std::vector< int >& _faces );
/// Unselect given faces of a mesh
template< typename MeshT >
inline
void unselectFaces(MeshT* _mesh, std::vector< int >& _faces );
void unselectFaces(MeshT* _mesh, const std::vector< int >& _faces );
/// Select all faces of a mesh
template< typename MeshT >
......@@ -479,7 +479,7 @@ std::vector< int > getFaceSelection(MeshT* _mesh, bool& _invert);
*/
template< typename MeshT >
inline
void convertFaceToVertexSelection(MeshT* _mesh, std::vector< int >& _faces);
void convertFaceToVertexSelection(MeshT* _mesh, const std::vector< int >& _faces);
/**
* For each selected face select all adjacent vertices
......
......@@ -521,7 +521,7 @@ void InfoMeshObjectPlugin::printMeshInfo( MeshT* _mesh , int _id, unsigned int _
//Calculate Bounding Box(min,max,cog)
ACG::Vec3d min;
ACG::Vec3d max;
MeshInfo::getBoundingBox(*_mesh, min, max);
MeshInfo::getBoundingBox(_mesh, min, max);
//Bounding Box Size
ACG::Vec3d diff = max-min;
......@@ -539,7 +539,7 @@ void InfoMeshObjectPlugin::printMeshInfo( MeshT* _mesh , int _id, unsigned int _
info_->bbSizeZ->setText( QString::number(diff[2],'f') );
//COG
ACG::Vec3d cog = MeshInfo::cog(*_mesh);
ACG::Vec3d cog = MeshInfo::cog(_mesh);
info_->cogX->setText( QString::number(cog[0],'f') );
info_->cogY->setText( QString::number(cog[1],'f') );
......
......@@ -392,7 +392,7 @@ Vector InfoMeshObjectPlugin::cog(int _id)
return Vector();
}
return MeshInfo::cog(*mesh);
return MeshInfo::cog(mesh);
} else {
PolyMesh* mesh = PluginFunctions::polyMesh(object);
......@@ -402,7 +402,7 @@ Vector InfoMeshObjectPlugin::cog(int _id)
return Vector();
}
return MeshInfo::cog(*mesh);
return MeshInfo::cog(mesh);
}
}
......@@ -436,7 +436,7 @@ Vector InfoMeshObjectPlugin::boundingBoxMin(int _id)
ACG::Vec3d min;
ACG::Vec3d max;
MeshInfo::getBoundingBox(*mesh, min, max);
MeshInfo::getBoundingBox(mesh, min, max);
return min;
......@@ -450,7 +450,7 @@ Vector InfoMeshObjectPlugin::boundingBoxMin(int _id)
ACG::Vec3d min;
ACG::Vec3d max;
MeshInfo::getBoundingBox(*mesh, min, max);
MeshInfo::getBoundingBox(mesh, min, max);
return min;
}
......@@ -486,7 +486,7 @@ Vector InfoMeshObjectPlugin::boundingBoxMax(int _id)
ACG::Vec3d min;
ACG::Vec3d max;
MeshInfo::getBoundingBox(*mesh, min, max);
MeshInfo::getBoundingBox(mesh, min, max);
return max;
......@@ -500,7 +500,7 @@ Vector InfoMeshObjectPlugin::boundingBoxMax(int _id)
ACG::Vec3d min;
ACG::Vec3d max;
MeshInfo::getBoundingBox(*mesh, min, max);
MeshInfo::getBoundingBox(mesh, min, max);
return max;
}
......@@ -536,7 +536,7 @@ Vector InfoMeshObjectPlugin::boundingBoxSize(int _id)
ACG::Vec3d min;
ACG::Vec3d max;
MeshInfo::getBoundingBox(*mesh, min, max);
MeshInfo::getBoundingBox(mesh, min, max);
return (max - min);
......@@ -550,7 +550,7 @@ Vector InfoMeshObjectPlugin::boundingBoxSize(int _id)
ACG::Vec3d min;
ACG::Vec3d max;
MeshInfo::getBoundingBox(*mesh, min, max);
MeshInfo::getBoundingBox(mesh, min, max);
return (max - min);
}
......
......@@ -1303,12 +1303,12 @@ void MovePlugin::slotMoveManipToCOG() {
if ( object->manipulatorNode()->visible() ){
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 ) )
object->manipulatorNode()->set_center( MeshInfo::cog(*PluginFunctions::polyMesh(object)) );
object->manipulatorNode()->set_center( MeshInfo::cog(PluginFunctions::polyMesh(object)) );
#ifdef ENABLE_TSPLINEMESH_SUPPORT
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
updateManipulatorDialog();
......@@ -1528,15 +1528,15 @@ void MovePlugin::slotMoveToOrigin() {
// Compute cog for all objects
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) {
if ( o_it->dataType( DATA_TRIANGLE_MESH )) {
TriMesh& mesh = *PluginFunctions::triMesh(*o_it);
cog += MeshInfo::cog(mesh) * double(mesh.n_vertices());
vertexCount += double(mesh.n_vertices());
TriMesh* mesh = PluginFunctions::triMesh(*o_it);
cog += MeshInfo::cog(mesh) * double(mesh->n_vertices());
vertexCount += double(mesh->n_vertices());
}
if ( o_it->dataType( DATA_POLY_MESH )) {
PolyMesh& mesh = *PluginFunctions::polyMesh(*o_it);
cog += MeshInfo::cog(mesh) * double(mesh.n_vertices());
vertexCount += double(mesh.n_vertices());
PolyMesh* mesh = PluginFunctions::polyMesh(*o_it);
cog += MeshInfo::cog(mesh) * double(mesh->n_vertices());
vertexCount += double(mesh->n_vertices());
}
#ifdef ENABLE_TSPLINEMESH_SUPPORT
......@@ -1555,25 +1555,25 @@ void MovePlugin::slotMoveToOrigin() {
for ( PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS) ; o_it != PluginFunctions::objectsEnd(); ++o_it) {
if ( o_it->dataType( DATA_TRIANGLE_MESH )) {
TriMesh& mesh = *PluginFunctions::triMesh(*o_it);
TriMesh* mesh = PluginFunctions::triMesh(*o_it);
if ( !useCommonCOG )
cog = MeshInfo::cog(mesh);
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 );
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 );
o_it->manipulatorNode()->set_center( o_it->manipulatorNode()->center() - cog );
}
if ( o_it->dataType( DATA_POLY_MESH )) {
PolyMesh& mesh = *PluginFunctions::polyMesh(*o_it);
PolyMesh* mesh = PluginFunctions::polyMesh(*o_it);
if ( !useCommonCOG )
cog = MeshInfo::cog(mesh);
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 );
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 );
o_it->manipulatorNode()->set_center( o_it->manipulatorNode()->center() - cog );
......@@ -1581,13 +1581,13 @@ void MovePlugin::slotMoveToOrigin() {
#ifdef ENABLE_TSPLINEMESH_SUPPORT
if ( o_it->dataType( DATA_TSPLINE_MESH )) {
TSplineMesh& mesh = *PluginFunctions::tsplineMesh(*o_it);
TSplineMesh* mesh = PluginFunctions::tsplineMesh(*o_it);
if ( !useCommonCOG )
cog = MeshInfo::cog(mesh);
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 );
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 );
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