33 #ifndef __H__UG_simplification
34 #define __H__UG_simplification
45 number maxSquaredHeightToBaseAreaRatio)
54 return (hsq / area) < maxSquaredHeightToBaseAreaRatio;
63 number maxSquaredHeightToBaseAreaRatio)
76 return (hsq / area) < maxSquaredHeightToBaseAreaRatio;
84 return (hsq / area) < maxSquaredHeightToBaseAreaRatio;
102 template <
class TVrtIter,
class TAAPos>
104 number maxSquaredHeightToBaseAreaRatio, TAAPos aaPos)
111 std::vector<Vertex*> candidates;
113 for(TVrtIter iter = vrtsBegin; iter != vrtsEnd;)
119 if(faces.
size() != 3)
124 size_t numConVrts = 0;
125 for(
size_t i = 0; i < faces.
size(); ++i){
134 for(
size_t j = 1; j < 3; ++j){
138 for(
size_t k = 0; k < numConVrts; ++k){
139 if(conVrts[k] == cv){
146 conVrts[numConVrts] = cv;
155 aaPos[conVrts[1]], aaPos[conVrts[2]],
156 maxSquaredHeightToBaseAreaRatio))
166 template <
class TVrtIter,
class TAAPos>
168 number maxSquaredHeightToBaseAreaRatio, TAAPos aaPos)
176 vector<Vertex*> poly;
177 vector<Edge*> conEdges;
185 std::vector<Vertex*> candidates;
186 std::vector<Vertex*> newCandidates;
188 for(TVrtIter iter = vrtsBegin; iter != vrtsEnd; ++iter)
189 newCandidates.push_back(*iter);
191 while(newCandidates.size() != candidates.size())
193 candidates.swap(newCandidates);
194 newCandidates.clear();
196 for(
size_t icand = 0; icand < candidates.size(); ++icand)
198 Vertex* vrt = candidates[icand];
201 newCandidates.push_back(vrt);
205 if(faces.
size() < 3 || faces.
size() > 4)
210 size_t numConVrts = 0;
211 for(
size_t i = 0; i < faces.
size(); ++i){
220 for(
size_t j = 1; j < 3; ++j){
224 for(
size_t k = 0; k < numConVrts; ++k){
225 if(conVrts[k] == cv){
232 conVrts[numConVrts] = cv;
239 if(numConVrts != faces.
size())
244 aaPos[conVrts[1]], aaPos[conVrts[2]],
245 maxSquaredHeightToBaseAreaRatio))
248 newCandidates.pop_back();
253 else if(numConVrts == 4){
256 for(
size_t i = 0; i < faces.
size(); ++i){
257 std::pair<GridBaseObjectId, int> opObj = faces[i]->get_opposing_object(vrt);
258 if(opObj.first ==
EDGE){
261 conEdges.push_back(e);
265 if(conEdges.size() != 4)
275 for(
int diag = 0; diag < 2; ++diag){
279 int i3 = (diag + 3) % 4;
290 for(
int idiag = 0; idiag < 2; ++idiag){
291 int diag = (firstDiag + idiag) % 2;
295 int i3 = (diag + 3) % 4;
298 aaPos[poly[i2]], aaPos[poly[i3]]))
308 maxSquaredHeightToBaseAreaRatio))
311 newCandidates.pop_back();
Base-class for edges.
Definition: grid_base_objects.h:397
Can be queried for the edges and vertices of a face.
Definition: grid_base_objects.h:684
Faces are 2-dimensional objects.
Definition: grid_base_objects.h:510
virtual Vertex * vertex(size_t index) const
Definition: grid_base_objects.h:486
virtual size_t num_vertices() const
Definition: grid_base_objects.h:488
Manages the elements of a grid and their interconnection.
Definition: grid.h:132
Edge * get_edge(Vertex *v1, Vertex *v2)
returns the edge between v1 and v2, if it exists. Returns NULL if not.
Definition: grid.cpp:1069
Face * get_face(const FaceVertices &fv)
returns the face that is described by fv.
Definition: grid.cpp:1135
void erase(GridObject *geomObj)
Definition: grid.cpp:459
geometry_traits< TGeomObj >::iterator begin()
Definition: grid_impl.hpp:164
void associated_elements(traits< Vertex >::secure_container &elemsOut, TElem *e)
Puts all elements of type TAss which are contained in 'e' or which contain 'e' into elemsOut.
Definition: grid_impl.hpp:466
geometry_traits< TGeomObj >::iterator create(GridObject *pParent=NULL)
create a custom element.
Definition: grid_impl.hpp:69
Container which holds an array of pointers.
Definition: pointer_const_array.h:84
size_t size() const
returns the size of the associated array.
Definition: pointer_const_array_impl.hpp:106
only used to initialize a triangle. for all other tasks you should use FaceDescriptor.
Definition: grid_objects_2d.h:78
the most simple form of a face
Definition: grid_objects_2d.h:174
Base-class for all vertex-types.
Definition: grid_base_objects.h:231
bool CreatePolyChain(std::vector< Vertex * > &polyChainOut, Grid &grid, TEdgeIter edgesBegin, TEdgeIter edgesEnd)
given a list of edges, this method collects associated vertices in a polychain
Definition: polychain_util_impl.hpp:127
int GetVertexIndex(EdgeVertices *e, Vertex *v)
returns the index at which vertex v is found in the given edge
Definition: vertex_util.cpp:44
double number
Definition: types.h:124
number TriangleArea(const vector_t &p1, const vector_t &p2, const vector_t &p3)
calculates the are of the triangle defined by p1, p2 and p3
Definition: math_util_impl.hpp:914
bool RayTriangleIntersection(vector_t &vOut, number &bc1Out, number &bc2Out, number &tOut, const vector_t &p0, const vector_t &p1, const vector_t &p2, const vector_t &vFrom, const vector_t &vDir, const number small=SMALL)
calculates the intersection of a ray with a triangle
Definition: math_util_impl.hpp:506
number TriangleQuality_Area(const vector_t &p1, const vector_t &p2, const vector_t &p3)
returns a value between 0 and 1. The higher the better.
Definition: math_util_impl.hpp:940
void CalculateTriangleNormalNoNormalize(vector_t &vOut, const vector_t &v1, const vector_t &v2, const vector_t &v3)
Calculates a triangle-normal in 3d (no normalization is performed).
Definition: math_vector_functions_common_impl.hpp:514
vector_t::value_type VecDistanceSq(const vector_t &v1, const vector_t &v2)
returns the squared distance of two vector_ts.
Definition: math_vector_functions_common_impl.hpp:351
void VecAdd(vector_t &vOut, const vector_t &v1, const vector_t &v2)
adds two MathVector<N>s and stores the result in a third one
Definition: math_vector_functions_common_impl.hpp:185
vector_t::value_type VecDot(const vector_t &v1, const vector_t &v2)
returns the dot-product of two vector_ts
Definition: math_vector_functions_common_impl.hpp:385
Definition: smart_pointer.h:814
bool Valence3VertexIsObsolete(const vector3 &p, const vector3 &c0, const vector3 &c1, const vector3 &c2, number maxSquaredHeightToBaseAreaRatio)
Definition: simplification.h:43
void ReplaceValence3Vertices(Grid &g, TVrtIter vrtsBegin, TVrtIter vrtsEnd, number maxSquaredHeightToBaseAreaRatio, TAAPos aaPos)
Definition: simplification.h:103
const number SMALL
Definition: math_constants.h:41
void ReplaceLowValenceVertices(Grid &g, TVrtIter vrtsBegin, TVrtIter vrtsEnd, number maxSquaredHeightToBaseAreaRatio, TAAPos aaPos)
Definition: simplification.h:167
bool QuadDiagonalIsValid(const vector3 &c0, const vector3 &c1, const vector3 &c2, const vector3 &c3)
returns true if the normals of the resulting triangles point into the same direction
Definition: simplification.h:92
@ EDGE
Definition: grid_base_objects.h:61
bool Valence4VertexIsObsolete(const vector3 &p, const vector3 &c0, const vector3 &c1, const vector3 &c2, const vector3 &c3, number maxSquaredHeightToBaseAreaRatio)
Definition: simplification.h:60