Commit 62595e4a authored by Henrik Zimmer's avatar Henrik Zimmer

Added TSplineMesh type

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@8429 383ad7c9-94d9-4d36-a494-682f7c89f535
parent f9c47287
include (plugin)
openflipper_plugin ( TRANSLATION_LANGUAGES de_DE INSTALLDATA Icons )
if (EXISTS ${CMAKE_SOURCE_DIR}/ObjectTypes/TSplineMesh)
add_definitions (-DENABLE_TSPLINEMESH_SUPPORT)
endif ()
openflipper_plugin ( TSplineMesh TRANSLATION_LANGUAGES de_DE INSTALLDATA Icons )
......@@ -63,6 +63,9 @@
#include <ObjectTypes/PolyLine/PolyLine.hh>
#endif
#ifdef ENABLE_TSPLINEMESH_SUPPORT
#include <ObjectTypes/TSplineMesh/TSplineMesh.hh>
#endif
/** \brief Default Constructor
......@@ -433,6 +436,10 @@ void MovePlugin::moveObject(ACG::Matrix4x4d mat, int _id) {
transformMesh(mat , *PluginFunctions::triMesh(object) );
} else if ( object->dataType() == DATA_POLY_MESH ) {
transformMesh(mat , *PluginFunctions::polyMesh(object) );
#ifdef ENABLE_TSPLINEMESH_SUPPORT
} else if ( object->dataType() == DATA_TSPLINE_MESH ) {
transformMesh(mat , *PluginFunctions::tsplineMesh(object) );
#endif
#ifdef ENABLE_POLYLINE_SUPPORT
} else if ( object->dataType() == DATA_POLY_LINE ) {
transformPolyLine(mat , *PluginFunctions::polyLine(object) );
......@@ -680,18 +687,30 @@ void MovePlugin::placeManip(QMouseEvent * _event, bool _snap) {
hitPoint = getNearestVertex(PluginFunctions::triMesh(object), target_idx, hitPoint);
} else if ( object->dataType(DATA_POLY_MESH) ) {
hitPoint = getNearestVertex(PluginFunctions::polyMesh(object), target_idx, hitPoint);
#ifdef ENABLE_TSPLINEMESH_SUPPORT
} else if ( object->dataType(DATA_TSPLINE_MESH) ) {
hitPoint = getNearestVertex(PluginFunctions::tsplineMesh(object), target_idx, hitPoint);
#endif
}
} else if (selectionType_ == EDGE) {
if ( object->dataType(DATA_TRIANGLE_MESH) ) {
hitPoint = getNearestEdge(PluginFunctions::triMesh(object), target_idx, hitPoint);
} else if ( object->dataType(DATA_POLY_MESH) ) {
hitPoint = getNearestEdge(PluginFunctions::polyMesh(object), target_idx, hitPoint);
#ifdef ENABLE_TSPLINEMESH_SUPPORT
} else if ( object->dataType(DATA_TSPLINE_MESH) ) {
hitPoint = getNearestEdge(PluginFunctions::tsplineMesh(object), target_idx, hitPoint);
#endif
}
} else if (selectionType_ == FACE) {
if ( object->dataType(DATA_TRIANGLE_MESH) ) {
hitPoint = getNearestFace(PluginFunctions::triMesh(object), target_idx, hitPoint);
} else if ( object->dataType(DATA_POLY_MESH) ) {
hitPoint = getNearestFace(PluginFunctions::polyMesh(object), target_idx, hitPoint);
#ifdef ENABLE_TSPLINEMESH_SUPPORT
} else if ( object->dataType(DATA_TSPLINE_MESH) ) {
hitPoint = getNearestFace(PluginFunctions::tsplineMesh(object), target_idx, hitPoint);
#endif
}
}
......@@ -1077,6 +1096,10 @@ void MovePlugin::slotMoveManipToCOG() {
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)) );
#ifdef ENABLE_TSPLINEMESH_SUPPORT
else if ( object->dataType( DATA_TSPLINE_MESH ) )
object->manipulatorNode()->set_center( MeshInfo::cog(*PluginFunctions::tsplineMesh(object)) );
#endif
updateManipulatorDialog();
object->manipulatorNode()->loadIdentity();
......@@ -1148,6 +1171,11 @@ void MovePlugin::slotRotate() {
if (object->dataType(DATA_POLY_MESH))
transformMesh(getLastManipulatorMatrix(true),
(*PluginFunctions::polyMesh(object)));
#ifdef ENABLE_TSPLINEMESH_SUPPORT
if (object->dataType(DATA_TSPLINE_MESH))
transformMesh(getLastManipulatorMatrix(true),
(*PluginFunctions::tsplineMesh(object)));
#endif
updateManipulatorDialog();
......@@ -1219,6 +1247,11 @@ void MovePlugin::slotScale() {
if (object->dataType(DATA_POLY_MESH))
transformMesh(getLastManipulatorMatrix(true),
(*PluginFunctions::polyMesh(object)));
#ifdef ENABLE_TSPLINEMESH_SUPPORT
if (object->dataType(DATA_TSPLINE_MESH))
transformMesh(getLastManipulatorMatrix(true),
(*PluginFunctions::tsplineMesh(object)));
#endif
updateManipulatorDialog();
......@@ -1265,6 +1298,14 @@ void MovePlugin::slotMoveToOrigin() {
cog += MeshInfo::cog(mesh) * double(mesh.n_vertices());
vertexCount += double(mesh.n_vertices());
}
#ifdef ENABLE_TSPLINEMESH_SUPPORT
if ( o_it->dataType( DATA_TSPLINE_MESH )) {
TSplineMesh& mesh = *PluginFunctions::tsplineMesh(*o_it);
cog += MeshInfo::cog(mesh) * double(mesh.n_vertices());
vertexCount += double(mesh.n_vertices());
}
#endif
}
cog = cog / vertexCount;
......@@ -1298,6 +1339,20 @@ void MovePlugin::slotMoveToOrigin() {
}
#ifdef ENABLE_TSPLINEMESH_SUPPORT
if ( o_it->dataType( DATA_TSPLINE_MESH )) {
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 );
o_it->manipulatorNode()->set_center( o_it->manipulatorNode()->center() - cog );
}
#endif
emit updatedObject( o_it->id() );
updateManipulatorDialog();
......@@ -1348,6 +1403,14 @@ void MovePlugin::slotUnifyBoundingBoxDiagonal()
bb_min.minimize(bb_min_tmp);
bb_max.maximize(bb_max_tmp);
}
#ifdef ENABLE_TSPLINEMESH_SUPPORT
if ( o_it->dataType( DATA_TSPLINE_MESH )) {
TSplineMesh& mesh = *PluginFunctions::tsplineMesh(*o_it);
getBB(mesh,bb_min_tmp,bb_max_tmp);
bb_min.minimize(bb_min_tmp);
bb_max.maximize(bb_max_tmp);
}
#endif
}
}
......@@ -1359,11 +1422,19 @@ void MovePlugin::slotUnifyBoundingBoxDiagonal()
unifyBBDiag(*PluginFunctions::triMesh(*o_it),bb_min,bb_max);
else if ( o_it->dataType( DATA_POLY_MESH ) )
unifyBBDiag(*PluginFunctions::polyMesh(*o_it),bb_min,bb_max);
#ifdef ENABLE_TSPLINEMESH_SUPPORT
else if ( o_it->dataType( DATA_TSPLINE_MESH ) )
unifyBBDiag(*PluginFunctions::tsplineMesh(*o_it),bb_min,bb_max);
#endif
} else {
if ( o_it->dataType( DATA_TRIANGLE_MESH ) )
unifyBBDiag(*PluginFunctions::triMesh(*o_it));
else if ( o_it->dataType( DATA_POLY_MESH ) )
unifyBBDiag(*PluginFunctions::polyMesh(*o_it));
#ifdef ENABLE_TSPLINEMESH_SUPPORT
else if ( o_it->dataType( DATA_TSPLINE_MESH ) )
unifyBBDiag(*PluginFunctions::tsplineMesh(*o_it));
#endif
}
emit updatedObject( o_it->id() );
......
......@@ -46,6 +46,9 @@
#ifdef ENABLE_POLYLINE_SUPPORT
#include <ObjectTypes/PolyLine/PolyLine.hh>
#endif
#ifdef ENABLE_TSPLINEMESH_SUPPORT
#include <ObjectTypes/TSplineMesh/TSplineMesh.hh>
#endif
#include <MeshTools/MeshFunctions.hh>
......@@ -132,7 +135,17 @@ void MovePlugin::translate( int _objectId , Vector _vector) {
for (; v_it!=v_end; ++v_it)
mesh.set_point(v_it,mesh.point(v_it) + _vector );
#ifdef ENABLE_TSPLINEMESH_SUPPORT
} else if ( object->dataType( DATA_TSPLINE_MESH ) ) {
TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(object));
TSplineMesh::VertexIter v_it = mesh.vertices_begin();
TSplineMesh::VertexIter v_end = mesh.vertices_end();
for (; v_it!=v_end; ++v_it)
mesh.set_point(v_it,mesh.point(v_it) + _vector );
}
#endif
#ifdef ENABLE_POLYLINE_SUPPORT
else if ( object->dataType(DATA_POLY_LINE) ) {
std::cerr << "Todo : translate PolyLine" << std::endl;
......@@ -185,6 +198,16 @@ void MovePlugin::translate( int _objectId , IdList _vHandles, Vector _vector ){
PolyMesh::VertexHandle vh( _vHandles[i] );
mesh.set_point(vh ,mesh.point( vh ) + _vector );
}
#ifdef ENABLE_TSPLINEMESH_SUPPORT
} else if ( object->dataType( DATA_TSPLINE_MESH ) ) {
TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(object));
for (uint i=0; i < _vHandles.size(); i++){
TSplineMesh::VertexHandle vh( _vHandles[i] );
mesh.set_point(vh ,mesh.point( vh ) + _vector );
}
#endif
}
#ifdef ENABLE_POLYLINE_SUPPORT
......@@ -240,6 +263,16 @@ void MovePlugin::translateSelection( int _objectId , Vector _vector) {
for (; v_it!=v_end; ++v_it)
if ( mesh.status(v_it).selected() )
mesh.set_point(v_it,mesh.point(v_it) + _vector );
#ifdef ENABLE_TSPLINEMESH_SUPPORT
} else if ( object->dataType( DATA_TSPLINE_MESH ) ) {
TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(object));
TSplineMesh::VertexIter v_it = mesh.vertices_begin();
TSplineMesh::VertexIter v_end = mesh.vertices_end();
for (; v_it!=v_end; ++v_it)
if ( mesh.status(v_it).selected() )
mesh.set_point(v_it,mesh.point(v_it) + _vector );
#endif
}
#ifdef ENABLE_POLYLINE_SUPPORT
......@@ -296,6 +329,17 @@ void MovePlugin::transform( int _objectId , Matrix4x4 _matrix ){
mesh.set_point (v_it, _matrix.transform_point ( mesh.point(v_it) ) );
mesh.set_normal(v_it, _matrix.transform_vector( mesh.normal(v_it) ) );
}
#ifdef ENABLE_TSPLINEMESH_SUPPORT
} else if ( object->dataType( DATA_TSPLINE_MESH ) ) {
TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(object));
TSplineMesh::VertexIter v_it = mesh.vertices_begin();
TSplineMesh::VertexIter v_end = mesh.vertices_end();
for (; v_it!=v_end; ++v_it){
mesh.set_point (v_it, _matrix.transform_point ( mesh.point(v_it) ) );
mesh.set_normal(v_it, _matrix.transform_vector( mesh.normal(v_it) ) );
}
#endif
}
#ifdef ENABLE_POLYLINE_SUPPORT
......@@ -361,6 +405,19 @@ void MovePlugin::transform( int _objectId , IdList _vHandles, Matrix4x4 _matrix
mesh.set_point (vh, _matrix.transform_point ( mesh.point(vh) ) );
mesh.set_normal(vh, _matrix.transform_vector( mesh.normal(vh) ) );
}
#ifdef ENABLE_TSPLINEMESH_SUPPORT
} else if ( object->dataType( DATA_TSPLINE_MESH ) ) {
TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(object));
TSplineMesh::VertexIter v_it = mesh.vertices_begin();
TSplineMesh::VertexIter v_end = mesh.vertices_end();
for (uint i=0; i < _vHandles.size(); i++){
TSplineMesh::VertexHandle vh( _vHandles[i] );
mesh.set_point (vh, _matrix.transform_point ( mesh.point(vh) ) );
mesh.set_normal(vh, _matrix.transform_vector( mesh.normal(vh) ) );
}
#endif
}
#ifdef ENABLE_POLYLINE_SUPPORT
......@@ -425,6 +482,19 @@ void MovePlugin::transformVertexSelection( int _objectId , Matrix4x4 _matrix ){
mesh.set_point (v_it, _matrix.transform_point ( mesh.point(v_it) ) );
mesh.set_normal(v_it, _matrix.transform_vector( mesh.normal(v_it) ) );
}
#ifdef ENABLE_TSPLINEMESH_SUPPORT
} else if ( object->dataType( DATA_TSPLINE_MESH ) ) {
TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(object));
TSplineMesh::VertexIter v_it = mesh.vertices_begin();
TSplineMesh::VertexIter v_end = mesh.vertices_end();
for (; v_it!=v_end; ++v_it)
if ( mesh.status(v_it).selected() )
{
mesh.set_point (v_it, _matrix.transform_point ( mesh.point(v_it) ) );
mesh.set_normal(v_it, _matrix.transform_vector( mesh.normal(v_it) ) );
}
#endif
}
#ifdef ENABLE_POLYLINE_SUPPORT
......@@ -513,6 +583,31 @@ void MovePlugin::transformFaceSelection( int _objectId , Matrix4x4 _matrix ){
mesh.set_point (v_it, _matrix.transform_point ( mesh.point(v_it) ) );
mesh.set_normal(v_it, _matrix.transform_vector( mesh.normal(v_it) ) );
}
#ifdef ENABLE_TSPLINEMESH_SUPPORT
} else if ( object->dataType( DATA_TSPLINE_MESH ) ) {
TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(object));
//init tags
TSplineMesh::VertexIter v_it, v_end( mesh.vertices_end() );
for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
mesh.status(v_it).set_tagged(false);
TSplineMesh::FaceIter f_it = mesh.faces_begin();
TSplineMesh::FaceIter f_end = mesh.faces_end();
for (; f_it!=f_end; ++f_it)
if ( mesh.status(f_it).selected() )
{
for(TSplineMesh::FVIter fv_it = mesh.fv_iter(f_it); fv_it; ++fv_it)
mesh.status(fv_it).set_tagged(true);
}
for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
if ( mesh.status(v_it).tagged() ){
mesh.set_point (v_it, _matrix.transform_point ( mesh.point(v_it) ) );
mesh.set_normal(v_it, _matrix.transform_vector( mesh.normal(v_it) ) );
}
#endif
}
......@@ -597,6 +692,33 @@ void MovePlugin::transformEdgeSelection( int _objectId , Matrix4x4 _matrix ){
mesh.set_point (v_it, _matrix.transform_point ( mesh.point(v_it) ) );
mesh.set_normal(v_it, _matrix.transform_vector( mesh.normal(v_it) ) );
}
#ifdef ENABLE_TSPLINEMESH_SUPPORT
} else if ( object->dataType( DATA_TSPLINE_MESH ) ) {
TSplineMesh& mesh = (*PluginFunctions::tsplineMesh(object));
//init tags
TSplineMesh::VertexIter v_it, v_end( mesh.vertices_end() );
for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
mesh.status(v_it).set_tagged(false);
TSplineMesh::EdgeIter e_it = mesh.edges_begin();
TSplineMesh::EdgeIter e_end = mesh.edges_end();
for (; e_it!=e_end; ++e_it)
if ( mesh.status(e_it).selected() )
{
TSplineMesh::HalfedgeHandle hh = mesh.halfedge_handle( e_it, 0 );
mesh.status( mesh.from_vertex_handle( hh ) ).set_tagged(true);
mesh.status( mesh.to_vertex_handle( hh ) ).set_tagged(true);
}
for (v_it=mesh.vertices_begin(); v_it!=v_end; ++v_it)
if ( mesh.status(v_it).tagged() ){
mesh.set_point (v_it, _matrix.transform_point ( mesh.point(v_it) ) );
mesh.set_normal(v_it, _matrix.transform_vector( mesh.normal(v_it) ) );
}
#endif
}
#ifdef ENABLE_POLYLINE_SUPPORT
......
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