Commit 49e71cd1 authored by Martin Schultz's avatar Martin Schultz

* removed scaling functionalities from align plugin

parent 5192d400
Pipeline #594 passed with stage
......@@ -127,66 +127,6 @@ void moveCenterOfBBToOrigin(MeshT& _mesh) {
}
}
template< class MeshT >
void scaleToUnitCubeNonUniform(MeshT& _mesh) {
ACG::Vec3d min(DBL_MAX);
ACG::Vec3d max(-DBL_MAX);
for (typename MeshT::VertexIter v_it = _mesh.vertices_begin(); v_it != _mesh.vertices_end(); ++v_it) {
min.minimize(_mesh.point(*v_it));
max.maximize(_mesh.point(*v_it));
}
const ACG::Vec3d diagonal = max - min;
const double maxDiag = std::max(std::max(diagonal[0],diagonal[1]),diagonal[2]);
OpenMesh::MPropHandleT<ACG::Vec3d> origDiagonal;
if (!_mesh.get_property_handle(origDiagonal, "origDiagonal"))
_mesh.add_property(origDiagonal, "origDiagonal");
_mesh.mproperty(origDiagonal).set_persistent(true);
_mesh.property(origDiagonal) = diagonal;
for (typename MeshT::VertexIter v_it = _mesh.vertices_begin(); v_it != _mesh.vertices_end(); ++v_it) {
_mesh.point(*v_it)[0] /= diagonal[0];
_mesh.point(*v_it)[1] /= diagonal[1];
_mesh.point(*v_it)[2] /= diagonal[2];
}
}
template< class MeshT >
void scaleToUnitCubeUniform(MeshT& _mesh) {
ACG::Vec3d min(DBL_MAX);
ACG::Vec3d max(-DBL_MAX);
for (typename MeshT::VertexIter v_it = _mesh.vertices_begin(); v_it != _mesh.vertices_end(); ++v_it) {
min.minimize(_mesh.point(*v_it));
max.maximize(_mesh.point(*v_it));
}
const ACG::Vec3d diagonal = max - min;
const double maxDiag = std::max(std::max(diagonal[0],diagonal[1]),diagonal[2]);
OpenMesh::MPropHandleT<ACG::Vec3d> origDiagonal;
if (!_mesh.get_property_handle(origDiagonal, "origDiagonal"))
_mesh.add_property(origDiagonal, "origDiagonal");
_mesh.mproperty(origDiagonal).set_persistent(true);
_mesh.property(origDiagonal) = diagonal;
for (typename MeshT::VertexIter v_it = _mesh.vertices_begin(); v_it != _mesh.vertices_end(); ++v_it) {
_mesh.point(*v_it)[0] /= maxDiag;
_mesh.point(*v_it)[1] /= maxDiag;
_mesh.point(*v_it)[2] /= maxDiag;
}
}
} // namespace align
#define ALIGNT_CC
......@@ -22,20 +22,6 @@ void rotate(MeshT& _mesh);
template< class MeshT >
void moveCenterOfBBToOrigin(MeshT& _mesh);
/** \brief Scale mesh such that it has length 1 on each separate axis
*
* @param _mesh Mesh to modify
*/
template< class MeshT >
void scaleToUnitCubeNonUniform(MeshT& _mesh);
/** \brief Scale mesh such that it has length 1 on the largest axis (keeps ratios of axis)
*
* @param _mesh Mesh to modify
*/
template< class MeshT >
void scaleToUnitCubeUniform(MeshT& _mesh);
} // namespace align
......
......@@ -63,71 +63,6 @@ void PluginAlignMeshes::initializePlugin() {
emit addToolbox("Align Meshes", toolBox_);
connect(toolBox_->alignMeshesButton, SIGNAL(pressed()), SLOT(alignMeshes()));
connect(toolBox_->scaleToUnitCubeUniformButton, SIGNAL(pressed()), SLOT(scaleToUnitCubeUniform()));
connect(toolBox_->scaleToUnitCubeNonUniformButton, SIGNAL(pressed()), SLOT(scaleToUnitCubeNonUniform()));
}
void PluginAlignMeshes::scaleToUnitCubeNonUniform() {
for (PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS, DATA_TRIANGLE_MESH | DATA_POLY_MESH ); o_it
!= PluginFunctions::objectsEnd(); ++o_it) {
if(o_it->dataType() == DATA_TRIANGLE_MESH){
TriMesh& mesh = * PluginFunctions::triMesh(*o_it);
align::moveToCOG( mesh );
align::scaleToUnitCubeNonUniform( mesh );
align::moveToCOG( mesh );
emit log(LOGINFO,"Moved Triangle mesh scaleToUnitCubeNonUniform");
} else if(o_it->dataType() == DATA_POLY_MESH) {
PolyMesh& mesh = * PluginFunctions::polyMesh(*o_it);
align::moveToCOG( mesh );
align::scaleToUnitCubeNonUniform( mesh );
align::moveToCOG( mesh );
emit log(LOGINFO,"Moved poly mesh scaleToUnitCubeNonUniform");
}
emit updatedObject(o_it->id(), UPDATE_GEOMETRY);
}
}
void PluginAlignMeshes::scaleToUnitCubeUniform() {
for (PluginFunctions::ObjectIterator o_it(PluginFunctions::TARGET_OBJECTS, DATA_TRIANGLE_MESH); o_it
!= PluginFunctions::objectsEnd(); ++o_it) {
if(o_it->dataType() == DATA_TRIANGLE_MESH){
TriMesh& mesh = * PluginFunctions::triMesh(*o_it);
align::moveToCOG( mesh );
align::scaleToUnitCubeUniform( mesh );
align::moveToCOG( mesh );
emit log(LOGINFO,"Moved Triangle mesh scaleToUnitCubeUniform");
} else if(o_it->dataType() == DATA_POLY_MESH) {
PolyMesh& mesh = * PluginFunctions::polyMesh(*o_it);
align::moveToCOG( mesh );
align::scaleToUnitCubeUniform( mesh );
align::moveToCOG( mesh );
emit log(LOGINFO,"Moved poly mesh scaleToUnitCubeUniform");
}
emit updatedObject(o_it->id(), UPDATE_GEOMETRY);
}
}
void PluginAlignMeshes::alignMeshes() {
......
......@@ -88,8 +88,6 @@ public slots:
QString version() { return QString("1.0"); }
void alignMeshes();
void scaleToUnitCubeUniform();
void scaleToUnitCubeNonUniform();
private slots:
......
......@@ -16,22 +16,6 @@
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<widget class="QPushButton" name="scaleToUnitCubeUniformButton">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Scale meshes &lt;span style=&quot; color:#000000;&quot;&gt;such that their biggest boundingbox axis size is 1.0. The aspect ratio of the mesh is kept.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="statusTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Scale meshes &lt;span style=&quot; color:#000000;&quot;&gt;such that their biggest boundingbox axis size is 1.0. The aspect ratio of the mesh is kept.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Scale meshes &lt;span style=&quot; color:#000000;&quot;&gt;such that their biggest boundingbox axis size is 1.0. The aspect ratio of the mesh is kept.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Scale Meshes to Unit Cube Uniformly</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="alignMeshesButton">
<property name="toolTip">
......@@ -48,22 +32,6 @@
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QPushButton" name="scaleToUnitCubeNonUniformButton">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Scale meshes such that their boundingbox axis sizes are all 1.0. The aspect ratio of the mesh is &lt;span style=&quot; font-weight:600;&quot;&gt;not&lt;/span&gt; kept.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="statusTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Scale meshes such that their boundingbox axis sizes are all 1.0. The aspect ratio of the mesh is &lt;span style=&quot; font-weight:600;&quot;&gt;not&lt;/span&gt; kept.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Scale meshes such that their boundingbox axis sizes are all 1.0. The aspect ratio of the mesh is &lt;span style=&quot; font-weight:600;&quot;&gt;not&lt;/span&gt; kept.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>Scale Meshes to Unit Cube Non-Uniformly</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
......
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