Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
NormalFixing.cc
1
2 /*===========================================================================*\
3 * *
4 * OpenFlipper *
5 * Copyright (c) 2001-2015, RWTH-Aachen University *
6 * Department of Computer Graphics and Multimedia *
7 * All rights reserved. *
8 * www.openflipper.org *
9 * *
10 *---------------------------------------------------------------------------*
11 * This file is part of OpenFlipper. *
12 *---------------------------------------------------------------------------*
13 * *
14 * Redistribution and use in source and binary forms, with or without *
15 * modification, are permitted provided that the following conditions *
16 * are met: *
17 * *
18 * 1. Redistributions of source code must retain the above copyright notice, *
19 * this list of conditions and the following disclaimer. *
20 * *
21 * 2. Redistributions in binary form must reproduce the above copyright *
22 * notice, this list of conditions and the following disclaimer in the *
23 * documentation and/or other materials provided with the distribution. *
24 * *
25 * 3. Neither the name of the copyright holder nor the names of its *
26 * contributors may be used to endorse or promote products derived from *
27 * this software without specific prior written permission. *
28 * *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
30 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
31 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
32 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
33 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
34 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
35 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
36 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
37 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
38 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
39 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
40 * *
41 \*===========================================================================*/
42
43 /*===========================================================================*\
44 * *
45 * $Revision$ *
46 * $LastChangedBy$ *
47 * $Date$ *
48 * *
49 \*===========================================================================*/
50
51
52
53
54 #include "MeshRepairPlugin.hh"
55
56
57 //-----------------------------------------------------------------------------
58
59
60 void MeshRepairPlugin::updateFaceNormals(int _objectId) {
61 BaseObjectData* object = 0;
62 PluginFunctions::getObject(_objectId,object);
63
64 if ( object == 0) {
65 emit log(LOGERR,tr("updateFaceNormals: Unable to get object %1. ").arg(_objectId) );
66 return;
67 }
68
69 if ( object->dataType(DATA_TRIANGLE_MESH) ) {
70 TriMesh* mesh = PluginFunctions::triMesh(object);
71 mesh->update_face_normals();
72 emit updatedObject(_objectId, UPDATE_ALL);
73 emit createBackup( _objectId, "Updated Face Normals", UPDATE_ALL);
74 emit scriptInfo( "updateFaceNormals(" + QString::number(_objectId) + ")" );
75 } else if ( object->dataType(DATA_POLY_MESH) ) {
76 PolyMesh* mesh = PluginFunctions::polyMesh(object);
77 mesh->update_face_normals();
78 emit updatedObject(_objectId, UPDATE_ALL);
79 emit createBackup( _objectId, "Updated Face Normals", UPDATE_ALL);
80 emit scriptInfo( "updateFaceNormals(" + QString::number(_objectId) + ")" );
81 } else
82 emit log(LOGERR,tr("updateFaceNormals: MeshRepair only works on triangle and poly meshes!") );
83
84 }
85
86
87 //-----------------------------------------------------------------------------
88
89 void MeshRepairPlugin::updateHalfedgeNormals(int _objectId) {
90 BaseObjectData* object = 0;
91 PluginFunctions::getObject(_objectId,object);
92
93 if ( object == 0) {
94 emit log(LOGERR,tr("updateFaceNormals: Unable to get object %1. ").arg(_objectId) );
95 return;
96 }
97
98 if ( object->dataType(DATA_TRIANGLE_MESH) ) {
99 TriMesh* mesh = PluginFunctions::triMesh(object);
100 mesh->request_halfedge_normals();
101 mesh->update_halfedge_normals();
102 emit updatedObject(_objectId, UPDATE_ALL);
103 emit createBackup( _objectId, "Updated Face Normals", UPDATE_ALL);
104 emit scriptInfo( "updateFaceNormals(" + QString::number(_objectId) + ")" );
105 } else if ( object->dataType(DATA_POLY_MESH) ) {
106 PolyMesh* mesh = PluginFunctions::polyMesh(object);
107 mesh->request_halfedge_normals();
108 mesh->update_halfedge_normals();
109 emit updatedObject(_objectId, UPDATE_ALL);
110 emit createBackup( _objectId, "Updated Face Normals", UPDATE_ALL);
111 emit scriptInfo( "updateFaceNormals(" + QString::number(_objectId) + ")" );
112 } else
113 emit log(LOGERR,tr("updateFaceNormals: MeshRepair only works on triangle and poly meshes!") );
114
115 }
116
117
118 //-----------------------------------------------------------------------------
119
120
121 void MeshRepairPlugin::updateVertexNormals(int _objectId){
122 BaseObjectData* object = 0;
123 PluginFunctions::getObject(_objectId,object);
124
125 if ( object == 0) {
126 emit log(LOGERR,tr("updateVertexNormals: Unable to get object %1. ").arg(_objectId) );
127 return;
128 }
129
130 if ( object->dataType(DATA_TRIANGLE_MESH) ) {
131 TriMesh* mesh = PluginFunctions::triMesh(object);
132 mesh->update_vertex_normals();
133 emit updatedObject(_objectId, UPDATE_ALL);
134 emit createBackup( _objectId, "Updated Vertex Normals", UPDATE_ALL);
135 emit scriptInfo( "updateVertexNormals(" + QString::number(_objectId) + ")" );
136 } else if ( object->dataType(DATA_POLY_MESH) ) {
137 PolyMesh* mesh = PluginFunctions::polyMesh(object);
138 mesh->update_vertex_normals();
139 emit updatedObject(_objectId, UPDATE_ALL);
140 emit createBackup( _objectId, "Updated Vertex Normals", UPDATE_ALL);
141 emit scriptInfo( "updateVertexNormals(" + QString::number(_objectId) + ")" );
142 } else
143 emit log(LOGERR,tr("updateVertexNormals: MeshRepair only works on triangle and poly meshes!") );
144 }
145
146 //-----------------------------------------------------------------------------
147
148 void MeshRepairPlugin::updateNormals(int _objectId) {
149 BaseObjectData* object = 0;
150 PluginFunctions::getObject(_objectId,object);
151
152 if ( object == 0) {
153 emit log(LOGERR,tr("updateNormals: Unable to get object %1. ").arg(_objectId) );
154 return;
155 }
156
157 if ( object->dataType(DATA_TRIANGLE_MESH) ) {
158 TriMesh* mesh = PluginFunctions::triMesh(object);
159 mesh->update_normals();
160 emit scriptInfo( "updateNormals(" + QString::number(_objectId) + ")" );
161 } else if ( object->dataType(DATA_POLY_MESH) ) {
162 PolyMesh* mesh = PluginFunctions::polyMesh(object);
163 mesh->update_normals();
164 emit updatedObject(_objectId, UPDATE_ALL);
165 emit createBackup( _objectId, "Updated All Normals", UPDATE_ALL);
166 emit scriptInfo( "updateNormals(" + QString::number(_objectId) + ")" );
167 } else
168 emit log(LOGERR,tr("updateNormals: MeshRepair only works on triangle and poly meshes!") );
169 }
170
171
MeshRepairPlugin::updateNormals
void updateNormals(int _objectId)
Recomputes the face and vertex normals of an object.
Definition: NormalFixing.cc:148
OpenMesh::PolyMesh_ArrayKernelT
Definition: PolyMesh_ArrayKernelT.hh:98
MeshRepairPlugin::updateVertexNormals
void updateVertexNormals(int _objectId)
Recomputes the vertex normals of an object.
Definition: NormalFixing.cc:121
LOGERR
Definition: LoggingInterface.hh:107
BaseObjectData
Definition: BaseObjectData.hh:105
UPDATE_ALL
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
PluginFunctions::getObject
bool getObject(int _identifier, BSplineCurveObject *&_object)
Definition: PluginFunctionsBSplineCurve.cc:75
PluginFunctions::polyMesh
PolyMesh * polyMesh(BaseObjectData *_object)
Get a poly mesh from an object.
Definition: PluginFunctionsPolyMesh.cc:134
OpenMesh::PolyMeshT::update_halfedge_normals
void update_halfedge_normals(const double _feature_angle=0.8)
Update normal vectors for all halfedges.
Definition: PolyMeshT.cc:274
MeshRepairPlugin::updateHalfedgeNormals
void updateHalfedgeNormals(int _objectId)
Recomputes the halfedge normals of an object.
Definition: NormalFixing.cc:89
BaseObject::dataType
bool dataType(DataType _type) const
Definition: BaseObject.cc:232
PluginFunctions::triMesh
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.
Definition: PluginFunctionsTriangleMesh.cc:140
DATA_POLY_MESH
#define DATA_POLY_MESH
Definition: PolyMesh.hh:65
OpenMesh::PolyMeshT::update_vertex_normals
void update_vertex_normals()
Update normal vectors for all vertices.
Definition: PolyMeshT.cc:448
OpenMesh::PolyMeshT::update_face_normals
void update_face_normals()
Update normal vectors for all faces.
Definition: PolyMeshT.cc:259
MeshRepairPlugin::updateFaceNormals
void updateFaceNormals(int _objectId)
Recomputes the face normals of an object.
Definition: NormalFixing.cc:60
OpenMesh::PolyMeshT::update_normals
void update_normals()
Compute normals for all primitives.
Definition: PolyMeshT.cc:241
DATA_TRIANGLE_MESH
#define DATA_TRIANGLE_MESH
Definition: TriangleMesh.hh:66