corner of polygon, connected to one point
#include <corner.h>
Public Member Functions | |
mesh3d::point * | point () |
mesh3d::polygon * | polygon () |
void | compute_normal (std::tr1::shared_ptr< attribute_map< mesh3d::corner *, vec3 > > corner_normals, std::tr1::shared_ptr< attribute_map< mesh3d::polygon *, vec3 > > polygon_normals, std::tr1::shared_ptr< attribute_map< mesh3d::point *, vec3 > > point_locations, float cos_max_smoothing_angle) |
Friends | |
class | polygon |
Definition at line 41 of file corner.h.
mesh3d::point* mesh3d::corner::point | ( | ) | [inline] |
mesh3d::polygon* mesh3d::corner::polygon | ( | ) | [inline] |
void mesh3d::corner::compute_normal | ( | std::tr1::shared_ptr< attribute_map< mesh3d::corner *, vec3 > > | corner_normals, | |
std::tr1::shared_ptr< attribute_map< mesh3d::polygon *, vec3 > > | polygon_normals, | |||
std::tr1::shared_ptr< attribute_map< mesh3d::point *, vec3 > > | point_locations, | |||
float | cos_max_smoothing_angle | |||
) |
Definition at line 40 of file corner.cpp.
00046 { 00047 mesh3d::polygon *pol = polygon(); 00048 mesh3d::point *pnt = point (); 00049 00050 vec3 corner_normal; 00051 00052 if(polygon_normals->has(pol) == false) 00053 { 00054 corner_normal = vec3(0, 0, 0); 00055 } 00056 else 00057 { 00058 vec3 polygon_normal = polygon_normals->value(pol); 00059 corner_normal = polygon_normal; 00060 00061 size_t point_corners = 0; 00062 size_t participants = 0; 00063 for( 00064 point::corner_collection::iterator i = pnt->corners().begin(); 00065 i != pnt->corners().end(); 00066 ++i 00067 ) 00068 { 00069 ++point_corners; 00070 mesh3d::corner *point_corner = *i; 00071 mesh3d::polygon *neighbor_pol = point_corner->polygon(); 00072 if( 00073 (pol != neighbor_pol ) && 00074 (polygon_normals->has(neighbor_pol) ) && 00075 (neighbor_pol->corners().size() > 2) 00076 ) 00077 { 00078 vec3 neighbor_normal = polygon_normals->value(neighbor_pol); 00079 float cos_angle = dot( 00080 polygon_normal, 00081 neighbor_normal 00082 ); 00083 if(cos_angle < cos_max_smoothing_angle) 00084 { 00085 corner_normal += neighbor_normal; 00086 ++participants; 00087 } 00088 } 00089 } 00090 00091 corner_normal = normalize(corner_normal); 00092 } 00093 corner_normals->set_value(this, corner_normal); 00094 }