33 #ifndef __H__UG__resolve_intersections_impl__
34 #define __H__UG__resolve_intersections_impl__
50 namespace grid_intersection_impl {
79 template <
class TAPos>
82 #ifdef UG_INTERSECTION_DEBUG_PATH
83 static int fileCounter = 0;
85 std::string pathName = UG_INTERSECTION_DEBUG_PATH;
86 std::string filename =
87 mkstr(pathName <<
"/" << filePrefix
88 <<
"-" << fileCounter <<
".ugx");
89 UG_LOG(
"Saving intersection debug geometry to " << filename << std::endl);
94 template <
class TAPos>
97 #ifdef UG_INTERSECTION_DEBUG_PATH
98 static int fileCounter = 0;
100 std::string pathName = UG_INTERSECTION_DEBUG_PATH;
101 std::string filename =
102 mkstr(pathName <<
"/" << filePrefix
103 <<
"-" << fileCounter <<
".ugx");
104 UG_LOG(
"Saving 2d intersection debug geometry to " << filename << std::endl);
107 std::vector<vector3> vrts;
111 vrts.push_back(aaPos[*iter]);
113 std::vector<vector2> vrts2d(vrts.size());
121 aaPos[*iter] =
vector3(vrts2d[counter].x(), vrts2d[counter].y(), 0);
129 aaPos[*iter] = vrts[counter];
136 template <
class TAAPosVRT>
138 Edge* e, TAAPosVRT& aaPos,
141 typedef typename TAAPosVRT::ValueType vector_t;
143 number snapThresholdSq = snapThreshold * snapThreshold;
164 if((t >= 0) && (t <= 1.)){
167 RegularVertex* nVrt = SplitEdge<RegularVertex>(grid, grid, e);
187 template <
class TAAPosVRT>
189 Face* f, TAAPosVRT& aaPos,
191 std::vector<Face*>* pNewFacesOut)
194 typedef typename TAAPosVRT::ValueType vector_t;
197 pNewFacesOut->clear();
199 number snapThresholdSq = snapThreshold * snapThreshold;
217 bool refined =
false;
259 for(
size_t i = 0; i < f->
num_edges(); ++i){
265 Vertex* newEdgeVrts[4] = {NULL, NULL, NULL, NULL};
267 Vertex* newFaceVrt = NULL;
268 vector<Face*> newFaces;
269 if(f->
refine(newFaces, &newFaceVrt, newEdgeVrts, NULL)){
283 for(
size_t j = 0; j < newFaces.size(); ++j){
287 pNewFacesOut->push_back(newFaces[j]);
310 for(
size_t i = 0; i < f->
num_edges(); ++i){
320 pNewFacesOut->push_back(nf);
416 template <
class TAAPosVRT>
418 TAAPosVRT& aaPos,
number snapThreshold)
420 typedef typename TAAPosVRT::ValueType vector_t;
426 number snapThresholdSq = snapThreshold * snapThreshold;
444 RegularVertex* nVrt1 = SplitEdge<RegularVertex>(grid, grid, e1);
445 RegularVertex* nVrt2 = SplitEdge<RegularVertex>(grid, grid, e2);
476 template <
class TAAPosVRT>
478 TAAPosVRT& aaPos,
number snapThreshold)
481 typedef typename TAAPosVRT::ValueType vector_t;
492 bool refined =
false;
493 vector<Face*> newFaces;
494 Vertex* newFaceVrt = NULL;
500 if((
s >= 0) && (
s <= 1.)){
503 Vertex* newEdgeVrts[3] = {NULL, NULL, NULL};
504 refined = f->
refine(newFaces, &newFaceVrt, newEdgeVrts, vrt);
509 bool intersecting =
false;
521 if(intersecting && (
s >= 0) && (
s <= 1.))
525 Vertex* newEdgeVrts[4] = {NULL, NULL, NULL, NULL};
526 refined = f->
refine(newFaces, &newFaceVrt, newEdgeVrts, vrt);
535 for(
size_t i = 0; i < newFaces.size(); ++i)
541 RegularVertex* nVrt = SplitEdge<RegularVertex>(grid, grid, e);
562 template <
class TVrtIter,
class TAAPos>
564 const TVrtIter vrtsBegin,
const TVrtIter vrtsEnd,
565 const typename TAAPos::ValueType& rayFrom,
566 const typename TAAPos::ValueType& rayDir,
568 bool clearContainer =
true)
570 typedef typename TAAPos::ValueType vector_t;
575 for(TVrtIter i_vrt = vrtsBegin; i_vrt != vrtsEnd; ++i_vrt){
578 vrtsOut.insert(std::pair<number, Vertex*>(t, *i_vrt));
587 template <
class TVrtIter,
class TAAPos>
589 TVrtIter vrtsBegin, TVrtIter vrtsEnd,
592 if(vrtsBegin == vrtsEnd)
595 typedef typename TAAPos::ValueType vector_t;
599 std::multimap<number, Vertex*> vrtMap;
604 std::vector<Face*> faces;
606 for(
size_t i = 0; i < faces.size(); ++i){
617 std::vector<Vertex*> conVrts(faces.size());
618 std::vector<bool> orientations(faces.size());
619 for(
size_t i = 0; i < faces.size(); ++i){
630 std::multimap<number, Vertex*>::iterator iter = vrtMap.begin();
632 Vertex* nextVrt = iter->second;
635 if(curVrt != nextVrt){
641 for(
size_t i = 0; i < faces.size(); ++i){
642 if(conVrts[i] == curVrt || conVrts[i] == nextVrt)
663 if(nextVrt == edge->
vertex(1))
668 if(iter != vrtMap.end())
669 nextVrt = iter->second;
671 nextVrt = edge->
vertex(1);
695 template <
class TAPos>
703 typedef octree_t::box_t box_t;
704 typedef typename TAPos::ValueType vector_t;
707 number snapThresholdSq =
sq(snapThreshold);
710 size_t numEdges = elems.
num<
Edge>();
713 bool useOctree = (numVrts > 10 && numEdges > 10);
714 octree_t octree(grid, aPos);
720 VecSet(offset, snapThreshold);
721 std::vector<Vertex*> closeVrts;
722 std::vector<Vertex*> insertVrts;
729 closeVrts.push_back(*iter);
734 std::map<Vertex*, Record> snapVrtMap;
735 std::vector<Edge*> edges;
736 edges.reserve(elems.
num<
Edge>());
738 edges.push_back(*eIter);
741 for(
size_t iEdge = 0; iEdge < edges.size(); ++iEdge){
742 Edge* e = edges[iEdge];
745 corner[0] = aaPos[e->
vertex(0)];
746 corner[1] = aaPos[e->
vertex(1)];
750 box_t bbox(corner, 2);
757 for(
size_t i = 0; i < closeVrts.size(); ++i){
758 Vertex* vrt = closeVrts[i];
768 if(distSq <= snapThresholdSq){
769 Record& rec = snapVrtMap[vrt];
770 if(distSq < rec.distanceSq){
771 rec.closestEdge = (int)iEdge;
772 rec.distanceSq = distSq;
780 for(
size_t iEdge = 0; iEdge < edges.size(); ++iEdge){
781 Edge* e = edges[iEdge];
784 corner[0] = aaPos[e->
vertex(0)];
785 corner[1] = aaPos[e->
vertex(1)];
789 box_t bbox(corner, 2);
797 for(
size_t i = 0; i < closeVrts.size(); ++i){
798 Vertex* vrt = closeVrts[i];
802 std::map<Vertex*, Record>::iterator imap = snapVrtMap.find(vrt);
803 if(imap != snapVrtMap.end()){
804 Record& rec = imap->second;
805 if(rec.closestEdge == (
int)iEdge)
806 insertVrts.push_back(vrt);
810 if(!insertVrts.empty()){
811 MultiEdgeSplit(grid, e, insertVrts.begin(), insertVrts.end(), aaPos);
825 template <
class TObjectCollection,
class TAPos>
827 TObjectCollection& elems,
833 typedef octree_t::box_t box_t;
834 typedef typename TAPos::ValueType vector_t;
837 number snapThresholdSq =
sq(snapThreshold);
839 size_t numVrts = elems.template num<Vertex>();
840 size_t numFaces = elems.template num<Face>();
843 bool useOctree = (numVrts > 10 && numFaces > 10);
844 octree_t octree(grid, aPos);
846 octree.create_tree(elems.template begin<Vertex>(), elems.template end<Vertex>());
849 VecSet(offset, snapThreshold);
851 std::vector<Vertex*> closeVrts;
852 std::vector<Vertex*> insertVrts;
855 closeVrts.reserve(elems.template num<Vertex>());
857 iter != elems.template end<Vertex>(); ++iter)
859 closeVrts.push_back(*iter);
863 std::queue<Face*> qFaces;
866 iter != elems.template end<Face>(); ++iter)
871 std::vector<Face*> newFaces;
873 while(!qFaces.empty()){
877 Face* f = qFaces.front();
882 bbox = box_t(bbox, aaPos[f->
vertex(i)]);
889 for(
size_t i = 0; i < closeVrts.size(); ++i){
890 Vertex* vrt = closeVrts[i];
896 if(
VecDistanceSq(aaPos[vrt], aaPos[corner]) <= snapThresholdSq){
910 for(
size_t j = 0; j < newFaces.size(); ++j){
911 qFaces.push(newFaces[j]);
931 template <
class TObjectCollection,
class TAAPosVRT>
933 TObjectCollection& elems,
941 iter != elems.template end<Edge>(); ++iter)
949 const size_t maxIntersections =
sq(elems.template num<Edge>());
950 size_t numIntersections = 0;
952 for(
EdgeIterator mainIter = elems.template begin<Edge>();
953 mainIter != elems.template end<Edge>();)
955 if(numIntersections > maxIntersections){
956 UG_LOG(
"Intersection threshold reached in IntersectCloseEdges. "
957 " Not all intersections may have been resolved.\n");
958 UG_LOG(
" num-initial-edges: " << sqrt(maxIntersections) <<
"\n");
971 for(
EdgeIterator iter = elems.template begin<Edge>(); *iter != e;)
985 for(
size_t i = 0; i < edges.
size(); ++i){
999 template <
class TAAPosVRT>
1001 const typename TAAPosVRT::ValueType& p,
1002 TAAPosVRT& aaPos,
number snapThreshold)
1004 number snapThrSq = snapThreshold * snapThreshold;
1006 for(
size_t i = 0; i < array.size(); ++i){
1017 template <
class TAAPosVRT>
1019 TAAPosVRT& aaPos,
number snapThreshold)
1021 number snapThrSq = snapThreshold * snapThreshold;
1026 for (
size_t i = 1; i < array.size(); ++i) {
1028 if (dist < bestDistance) {
1029 bestDistance = dist;
1033 return (bestDistance < snapThrSq) ? bestElem : -1;
1038 template <
class TAAPosVRT,
class vector_t>
1040 TAAPosVRT& aaPos,
number snapThreshold,
1044 for (
size_t i = 0; i < numPoints; ++i) {
1067 vector2 t0_ARR[] = {p00, p01, p02};
1068 vector2 t1_ARR[] = {p10, p11, p12};
1074 for(
size_t i = 0; i < 3; ++i){
1075 maxLenSq = std::max(maxLenSq,
VecLengthSq(t0[i]));
1076 maxLenSq = std::max(maxLenSq,
VecLengthSq(t1[i]));
1092 for(
int i_tri = 0; i_tri < 2; ++i_tri){
1093 for(
int i0 = 0; i0 < 3; ++i0){
1108 bool separable =
true;
1109 for(
int j = 0; j < 3; ++j){
1116 if(
VecDot(v, n) * refDot > sml){
1131 int matchingCorner[] = {-1, -1, -1};
1133 for(
int i = 0; i < 3; ++i){
1136 for(
int j = 0; j < 3; ++j){
1138 matchingCorner[i] = j;
1147 for(
int i0 = 0; i0 < 3; ++i0){
1151 if((matchingCorner[i0] == -1) || (matchingCorner[i1] == -1)){
1153 edgesOut.push_back(t1[i0]);
1154 edgesOut.push_back(t1[i1]);
1159 bool gotOne =
false;
1160 for(
int j0 = 0; j0 < 3; ++j0){
1165 t0[j0], t0[j1], sml))
1169 edgesOut.push_back(t1[i0]);
1170 edgesOut.push_back(vi);
1177 "An intersection has to exist if one point is "
1178 "inside and one point is outside!\n"
1179 <<
" checked line: " << t1[i0] <<
" - " << t1[i1]
1180 <<
"\nchecked tri: " << t0[0] <<
", " << t0[1] <<
", " << t0[2]);
1183 else if(isInside[i1]){
1185 bool gotOne =
false;
1186 for(
int j0 = 0; j0 < 3; ++j0){
1191 t0[j0], t0[j1], sml))
1195 edgesOut.push_back(vi);
1196 edgesOut.push_back(t1[i1]);
1203 "An intersection has to exist if one point is "
1204 "inside and one point is outside!\n"
1205 <<
" checked line: " << t1[i0] <<
" - " << t1[i1]
1206 <<
"\nchecked tri: " << t0[0] <<
", " << t0[1] <<
", " << t0[2]);
1213 for(
int j0 = 0; j0 < 3; ++j0){
1217 t0[j0], t0[j1], sml))
1224 UG_COND_THROW(numInts == 1,
"Either 0 or 2 intersections have to exist!\n"
1225 <<
" checked line: " << t1[i0] <<
" - " << t1[i1]
1226 <<
"\nchecked tri: " << t0[0] <<
", " << t0[1] <<
", " << t0[2]);
1228 edgesOut.push_back(ints[0]);
1229 edgesOut.push_back(ints[1]);
1233 return !edgesOut.empty();
1260 UG_LOG(
"Construction of local orthonormal system failed...\n");
1275 vector3 v, vp0, vp1, vp2, vp3, vp4, vp5;
1289 std::vector<vector2> edges2d;
1294 edgesOut.resize(edges2d.size());
1295 for(
size_t i = 0; i < edges2d.size(); ++i){
1310 template <
class TAAPos>
1335 template <
class TAAPos>
1336 Sphere<typename TAAPos::ValueType>
1343 maxDistSq = std::max<number>(maxDistSq,
1346 s.radius = sqrt(maxDistSq);
1352 template <
class TAPos>
1357 using namespace std;
1365 sel.
select(trisBegin, trisEnd);
1370 aPos, snapThreshold);
1378 typedef octree_t::box_t box_t;
1380 octree_t octree(grid, aPos);
1381 octree.create_tree(trisBegin, trisEnd);
1397 AEdgeDescVec aEdgeDescVec;
1403 std::vector<vector3> planarIntersections;
1406 vector<Face*> closeTris;
1410 size_t triCounter = 0;
1412 triIter1 != sel.
end<
Triangle>(); ++triIter1, ++triCounter)
1414 Face* t1 = *triIter1;
1417 bbox.min = bbox.max = aaPos[t1->
vertex(0)];
1419 bbox = box_t(bbox, aaPos[t1->
vertex(i)]);
1420 bbox.min -=
vector3(snapThreshold, snapThreshold, snapThreshold);
1421 bbox.max +=
vector3(snapThreshold, snapThreshold, snapThreshold);
1427 for(
size_t i_close = 0; i_close < closeTris.size(); ++i_close){
1428 Face* t2 = closeTris[i_close];
1429 Face* t[2]; t[0] = t1; t[1] = t2;
1453 if(fabs(d) > 1. - snapThreshold){
1459 for(
int i_tri = 0; i_tri < 2; ++i_tri){
1467 for(
int j_tri = 0; j_tri < 2; ++j_tri){
1468 vector<Vertex*>& vrts = aaVrtVec[t[j_tri]];
1470 for(
size_t i = 0; i < t[j_tri]->num_vertices(); ++i)
1471 vrts.push_back(t[j_tri]->vertex(i));
1475 vector<Vertex*>& vrts = aaVrtVec[t1];
1477 for(
size_t i = 0; i < planarIntersections.size(); i+=2){
1479 for(
int j = 0; j < 2; ++j){
1481 planarIntersections[i+j],
1482 aaPos, snapThreshold);
1485 vector<Vertex*>& vrts2 = aaVrtVec[t2];
1487 planarIntersections[i+j],
1488 aaPos, snapThreshold);
1491 inds[j] = (int)vrts.size();
1492 vrts.push_back(vrts2[ind]);
1498 aaPos[vrt] = planarIntersections[i+j];
1499 inds[j] = (int)vrts.size();
1500 vrts.push_back(vrt);
1503 if(inds[0] != inds[1])
1504 aaEdgeDescVec[t1].push_back(make_pair(inds[0], inds[1]));
1523 &ip[0], &ip[1],
SMALL) == 1)
1538 for(
size_t i_tri = 0; i_tri < 2; ++i_tri){
1541 Face* tri = t[i_tri];
1542 vector<Vertex*>& vrts = aaVrtVec[tri];
1545 vrts.push_back(tri->
vertex(i));
1582 for(
size_t i = 0; i < 2; ++i){
1584 aaPos, snapThreshold);
1586 aaPos, snapThreshold);
1595 tind1 = (int)aaVrtVec[t[0]].size();
1596 tind2 = (int)aaVrtVec[t[1]].size();
1597 aaVrtVec[t[0]].push_back(vrt);
1598 aaVrtVec[t[1]].push_back(vrt);
1602 tind1 = (int)aaVrtVec[t[0]].size();
1603 aaVrtVec[t[0]].push_back((aaVrtVec[t[1]])[tind2]);
1606 else if(tind2 == -1){
1608 tind2 = (int)aaVrtVec[t[1]].size();
1609 aaVrtVec[t[1]].push_back((aaVrtVec[t[0]])[tind1]);
1619 if(inds1[0] != inds1[1])
1620 aaEdgeDescVec[t[0]].push_back(make_pair(inds1[0], inds1[1]));
1621 if(inds2[0] != inds2[1])
1622 aaEdgeDescVec[t[1]].push_back(make_pair(inds2[0], inds2[1]));
1630 vector<Triangle*> vDelTris;
1633 vector<Vertex*> cutVertices;
1644 vector<Vertex*> tgridVrts;
1648 std::vector<Vertex*> dblVrts;
1651 triIter != sel.
end<
Triangle>(); ++triIter, ++triCounter)
1655 if(aaVrtVec[t].size() > 3){
1660 vector<Vertex*>& vrts = aaVrtVec[t];
1661 for(
size_t i = 0; i < vrts.size(); ++i){
1663 aaVrt[vrt] = vrts[i];
1664 taaPos[vrt] = aaPos[vrts[i]];
1665 tgridVrts.push_back(vrt);
1669 vector<pair<int, int> >& edgeDescs = aaEdgeDescVec[t];
1677 for(
size_t i = 0; i < edgeDescs.size(); ++i){
1679 tgridVrts[edgeDescs[i].second]));
1692 aPos, snapThreshold);
1757 aaPos[aaVrt[*viter]] = taaPos[*viter];
1758 cutVertices.push_back(aaVrt[*viter]);
1768 vDelTris.push_back(*triIter);
1789 UG_LOG(
"TriangleFill_SweepLine failed for tri " << triCounter <<
"\n");
1793 iter != tgrid.
end<
Vertex>(); ++iter, ++cnt)
1797 UG_LOG(
" " << taaPos[*iter]);
1818 sel.
select(vDelTris.begin(), vDelTris.end());
1819 sel.
select(cutVertices.begin(), cutVertices.end());
A generic specialization of IAttachment.
Definition: attachment_pipe.h:263
virtual Vertex * vertex(size_t index) const
Definition: grid_objects_2d.h:120
Can be used to store information about an edge and to construct an edge.
Definition: grid_base_objects.h:464
Base-class for edges.
Definition: grid_base_objects.h:397
virtual Vertex * vertex(size_t index) const
Definition: grid_base_objects.h:366
Can be queried for the edges and vertices of a face.
Definition: grid_base_objects.h:684
virtual Vertex * vertex(size_t index) const
Definition: grid_base_objects.h:701
void set_vertex(uint index, Vertex *vrt)
Definition: grid_base_objects.h:706
Faces are 2-dimensional objects.
Definition: grid_base_objects.h:510
virtual bool refine(std::vector< Face * > &vNewFacesOut, Vertex **newFaceVertexOut, Vertex **newEdgeVertices, Vertex *newFaceVertex=NULL, Vertex **pSubstituteVertices=NULL, int snapPointIndex=-1)
Definition: grid_base_objects.h:594
virtual EdgeDescriptor edge_desc(int index) const
returns the i-th edge of the face.
Definition: grid_base_objects.h:537
uint num_edges() const
Definition: grid_base_objects.h:545
Definition: grid_base_objects.h:483
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
void end_marking()
ends a marking sequence. Call this method when you're done with marking.
Definition: grid.cpp:1285
uint get_attachment_data_index(TGeomObj *pObj) const
Definition: grid_impl.hpp:419
EdgeIterator edges_begin()
Definition: grid.h:515
void register_element(Vertex *v, GridObject *pParent=NULL)
Definition: grid.h:870
void attach_to_vertices_dv(TAttachment &attachment, const typename TAttachment::ValueType &defaultValue)
Definition: grid.h:754
bool is_marked(GridObject *obj) const
returns true if the object is marked, false if not.
Definition: grid_impl.hpp:843
VertexIterator vertices_begin()
Definition: grid.h:513
VertexIterator vertices_end()
Definition: grid.h:514
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 mark(GridObject *obj)
marks the object. Calls are only valid between calls to Grid::begin_marking and Grid::end_marking.
Definition: grid_impl.hpp:773
virtual GridObjectCollection get_grid_objects()
returns the the GridObjectCollection of the grid:
Definition: grid.cpp:527
void erase(GridObject *geomObj)
Definition: grid.cpp:459
void begin_marking()
begin marking.
Definition: grid.cpp:1262
void clear_geometry()
clears the grids geometry. Registered attachments remain.
Definition: grid.cpp:226
size_t num_vertices() const
Definition: grid.h:551
geometry_traits< TGeomObj >::iterator begin()
Definition: grid_impl.hpp:164
Edge * get_element(const EdgeVertices &ev)
returns the element for the given vertices.
Definition: grid.h:614
void attach_to_faces(IAttachment &attachment, bool passOnValues)
Definition: grid.h:730
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
void attach_to_vertices(IAttachment &attachment, bool passOnValues)
Definition: grid.h:728
geometry_traits< TGeomObj >::iterator create(GridObject *pParent=NULL)
create a custom element.
Definition: grid_impl.hpp:69
geometry_traits< TGeomObj >::iterator end()
Definition: grid_impl.hpp:175
EdgeIterator edges_end()
Definition: grid.h:516
void detach_from_faces(IAttachment &attachment)
Definition: grid.h:789
a helper class that holds a collection of possibly unconnected geometric-objects.
Definition: grid_object_collection.h:96
geometry_traits< TGeomObj >::iterator begin(size_t level=0)
Definition: grid_object_collection_impl.hpp:95
geometry_traits< TGeomObj >::iterator end(size_t level=0)
Definition: grid_object_collection_impl.hpp:106
size_t num() const
Definition: grid_object_collection_impl.hpp:130
void select(GridObject *elem, byte status)
selects an element
Definition: selector_interface_impl.hpp:56
void enable_selection_inheritance(bool bEnable)
Definition: selector_interface.cpp:195
void enable_autoselection(bool bEnable)
Definition: selector_interface.cpp:190
A class for fixed size, dense matrices.
Definition: math_matrix.h:52
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
a face with four points.
Definition: grid_objects_2d.h:323
Edges connect two vertices.
Definition: grid_objects_1d.h:66
A basic vertex-type.
Definition: grid_objects_0d.h:62
specialization of ISelector for a grid of class Grid.
Definition: selector_grid.h:96
geometry_traits< TElem >::iterator end()
Definition: selector_grid_impl.hpp:134
bool empty() const
Definition: selector_grid_impl.hpp:91
VertexIterator vertices_end()
Definition: selector_grid.h:173
virtual void clear()
Definition: selector_grid.cpp:155
VertexIterator vertices_begin()
Definition: selector_grid.h:172
geometry_traits< TElem >::iterator begin()
Definition: selector_grid_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
Instances of this class or of derived classes are thrown if errors arise.
Definition: error.h:104
const std::string & get_msg() const
returns the initial message
Definition: error.h:137
Base-class for all vertex-types.
Definition: grid_base_objects.h:231
Definition: lg_ntree.h:338
bool EdgeContains(EdgeVertices *e, Vertex *vrt)
Definition: grid_util_impl.hpp:45
int NumAssociatedFaces(Grid &grid, Edge *e)
returns the number of associated faces of the given edge
Definition: edge_util.cpp:247
int CalculateNormal(vector3 &vNormOut, Grid &grid, Edge *e, Grid::AttachmentAccessor< Vertex, APosition > &aaPos, Grid::AttachmentAccessor< Face, ANormal > *paaNormFACE)
Calculates the normal of the given edge.
Definition: edge_util.cpp:314
bool FaceContains(Face *f, EdgeVertices *ev)
returns true if the given face contains the two given vertices
Definition: grid_util.cpp:561
void Triangulate(Grid &grid, Quadrilateral *q, Grid::VertexAttachmentAccessor< APosition > *paaPos)
removes the quadrilateral and replaces it by two triangles.
Definition: face_util.cpp:273
UG_API size_t NumSharedVertices(Grid &grid, TElemPtr1 elem1, TElemPtr2 elem2)
returns the number of vertices that are shared by two objects
Definition: misc_util_impl.hpp:200
std::string ElementDebugInfo(const Grid &grid, GridObject *e)
Returns a string containing information on the given element.
Definition: debug_util.cpp:991
void CollectFaces(std::vector< Face * > &vFacesOut, Grid &grid, Vertex *vrt, bool clearContainer)
Collects all faces that exist in the given grid which contain the given vertex.
Definition: grid_util.cpp:458
void SelectInnerSelectionVertices(TSelector &sel)
selects all vertices that are only connected to selected elements.
Definition: selection_util.cpp:641
void SelectAssociatedVertices(TSelector &sel, TElemIterator elemsBegin, TElemIterator elemsEnd, ISelector::status_t status=ISelector::SELECTED)
selects all associated vertices of the elements between elemsBegin and elemsEnd
Definition: selection_util_impl.hpp:229
void SelectInnerSelectionEdges(TSelector &sel)
selects all edges that are only connected to selected elements.
Definition: selection_util.cpp:748
void MergeVertices(Grid &grid, Vertex *v1, Vertex *v2)
merges two vertices and restructures the adjacent elements.
Definition: vertex_util.cpp:395
Vertex * GetConnectedVertex(Edge *e, Vertex *v)
returns the vertex that is connected to v via e.
Definition: vertex_util.cpp:78
@ GRIDOPT_STANDARD_INTERCONNECTION
All elements store references to associated lower dimensional geometric objects.
Definition: grid_constants.h:107
#define UG_THROW(msg)
Definition: error.h:57
#define UG_LOG(msg)
Definition: log.h:367
#define UG_COND_THROW(cond, msg)
UG_COND_THROW(cond, msg) : performs a UG_THROW(msg) if cond == true.
Definition: error.h:61
double number
Definition: types.h:124
void TransposedMatVecMult(vector_t_out &vOut, const matrix_t &m, const vector_t_in &v)
Transposed Matrix - Vector Muliplication.
Definition: math_matrix_vector_functions_common_impl.hpp:111
void MatVecMult(vector_t_out &vOut, const matrix_t &m, const vector_t_in &v)
Matrix - Vector Multiplication.
Definition: math_matrix_vector_functions_common_impl.hpp:49
number ProjectPointToLine(vector_t &vOut, const vector_t &v, const vector_t &from, const vector_t &to)
finds the projection of v onto the line defined by from and to
Definition: math_util_impl.hpp:186
bool TransformPointSetTo2D(vector2 *pointSetOut, const vector3 *pointSet, size_t numPoints)
transforms points from 3d space to 2d space.
Definition: math_util.cpp:294
bool LineLineIntersection2d(vector_t &vOut, number &t0Out, number &t1Out, const vector_t &from0, const vector_t &to0, const vector_t &from1, const vector_t &to1, const number threshold=0)
calculates the intersection of a two lines in 2d
Definition: math_util_impl.hpp:443
bool LineLineProjection(number &t1Out, number &t2Out, const vector_t &a1, const vector_t &a2, const vector_t &b1, const vector_t &b2)
calculates the closest point between the rays through the given lines.
Definition: math_util_impl.hpp:488
bool ConstructOrthonormalSystem(matrix33 &matOut, const vector3 &v, size_t vColInd)
constructs a orthonormal matrix given a vector in 3d.
Definition: math_util.cpp:211
number DropAPerpendicular(vector_t &vOut, const vector_t &v, const vector_t &v0, const vector_t &v1)
finds the projection of v onto the line defined by v0 and v1
Definition: math_util_impl.hpp:123
bool PointIsInsideTriangle(const vector_t &v, const vector_t &v0, const vector_t &v1, const vector_t &v2)
Returns true if the point lies inside or on the boundary of a triangle.
Definition: math_util_impl.hpp:971
TNumber sq(TNumber val)
returns the square of a value (val*val)
Definition: math_util_impl.hpp:91
void CalculateCenter(vector_t ¢erOut, const vector_t *pointSet, size_t numPoints)
calculates the center of a point-set
Definition: math_util_impl.hpp:98
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
void ProjectPointToPlane(vector_t &vOut, const vector_t &v, const vector_t &p, const vector_t &n)
projects v onto the plane defined by the point p and the planes normal n.
Definition: math_util_impl.hpp:342
UG_API bool TriangleTriangleIntersection(const MathVector< 3 > &p0, const MathVector< 3 > &p1, const MathVector< 3 > &p2, const MathVector< 3 > &q0, const MathVector< 3 > &q1, const MathVector< 3 > &q2, MathVector< 3 > *ip1Out=NULL, MathVector< 3 > *ip2Out=NULL, number snapThreshold=SMALL)
checks whether two triangles intersect and returns the intervals, if they do.
Definition: tritri.cpp:390
number DistancePointToPlane(const vector_t &v, const vector_t &p, const vector_t &n)
Calculates the distance between the specified point and the plane.
Definition: math_util_impl.hpp:332
number ProjectPointToRay(vector_t &vOut, const vector_t &v, const vector_t &from, const vector_t &dir)
finds the projection of v onto the ray defined by from and dir
Definition: math_util_impl.hpp:160
vector_t::value_type VecLength(const vector_t &v)
returns the length of v. Slower than VecLengthSq.
Definition: math_vector_functions_common_impl.hpp:341
void VecCopy(vector_target_t &target, const vector_source_t &source, typename vector_target_t::value_type fill)
Copy contents between vectors of possibly different types.
Definition: math_vector_functions_common_impl.hpp:56
MathVector< 2, number > vector2
a 2d vector
Definition: ugmath_types.h:69
void VecSet(vector_t &vInOut, typename vector_t::value_type s)
Set each vector component to scalar (componentwise)
Definition: math_vector_functions_common_impl.hpp:539
void VecScaleAdd(vector_t &vOut, typename vector_t::value_type s1, const vector_t &v1, typename vector_t::value_type s2, const vector_t &v2)
Scales two Vectors, adds them and returns the sum in a third vector.
Definition: math_vector_functions_common_impl.hpp:265
void VecSubtract(vector_t &vOut, const vector_t &v1, const vector_t &v2)
subtracts v2 from v1 and stores the result in a vOut
Definition: math_vector_functions_common_impl.hpp:226
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 CalculateTriangleNormal(vector_t &vOut, const vector_t &v1, const vector_t &v2, const vector_t &v3)
Calculates a triangle-normal in 3d (output has length 1).
Definition: math_vector_functions_common_impl.hpp:528
MathVector< 3, number > vector3
a 3d vector
Definition: ugmath_types.h:72
vector_t::value_type VecLengthSq(const vector_t &v)
returns the squared length of v. Faster than VecLength.
Definition: math_vector_functions_common_impl.hpp:324
void VecScale(vector_t &vOut, const vector_t &v, typename vector_t::value_type s)
scales a MathVector<N>
Definition: math_vector_functions_common_impl.hpp:252
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
std::pair< counting_iterator< size_t >, counting_iterator< size_t > > vertices(ug::BidirectionalMatrix< T > const &M)
Definition: bidirectional_boost.h:60
int num_vertices(ug::BidirectionalMatrix< T > const &M)
Definition: bidirectional_boost.h:70
Definition: smart_pointer.h:814
void DebugSave2d(Grid &grid, const char *filePrefix, TAPos aPos)
Definition: resolve_intersections_impl.hpp:95
void DebugSave(Grid &grid, const char *filePrefix, TAPos aPos)
Definition: resolve_intersections_impl.hpp:80
ElementStorage< Vertex >::SectionContainer::iterator VertexIterator
This Iterator will be used as base-class for iterators of specialized geometric objects.
Definition: grid_base_object_traits.h:73
ElementStorage< Face >::SectionContainer::iterator FaceIterator
Definition: grid_base_object_traits.h:79
bool SaveGridToFile(Grid &grid, ISubsetHandler &sh, const char *filename, TAPos &aPos)
Saves a grid to a file. Position data is read from the specified attachment.
Definition: file_io.cpp:468
const number SMALL
Definition: math_constants.h:41
bool FindElementsInIntersectingNodes(std::vector< typename tree_t::elem_t > &elemsOut, const tree_t &tree, const typename tree_t::box_t &bbox)
Definition: ntree_traverser.h:274
ElementStorage< Edge >::SectionContainer::iterator EdgeIterator
Definition: grid_base_object_traits.h:76
void SpacialVertexSort(std::multimap< number, Vertex * > &vrtsOut, const TVrtIter vrtsBegin, const TVrtIter vrtsEnd, const typename TAAPos::ValueType &rayFrom, const typename TAAPos::ValueType &rayDir, TAAPos aaPos, bool clearContainer=true)
sorts vertices along the specified ray
Definition: resolve_intersections_impl.hpp:563
int FindClosestVertexInPointSet(const vector_t *pointSet, const Vertex *p, TAAPosVRT &aaPos, number snapThreshold, size_t numPoints)
returns the index of the closest vertex to p if closer than snapThreshold
Definition: resolve_intersections_impl.hpp:1039
bool ProjectVerticesToCloseEdges(Grid &grid, GridObjectCollection elems, TAAPosVRT &aaPos, number snapThreshold)
bool ResolveVertexFaceIntersection(Grid &grid, Vertex *v, Face *f, TAAPosVRT &aaPos, number snapThreshold, std::vector< Face * > *pNewFacesOut)
Definition: resolve_intersections_impl.hpp:188
bool IntersectCoplanarTriangles(std::vector< vector2 > &edgesOut, const vector2 &p00, const vector2 &p01, const vector2 &p02, const vector2 &p10, const vector2 &p11, const vector2 &p12)
Intersects Coplanar Triangles.
Definition: resolve_intersections_impl.hpp:1059
Vertex * ResolveEdgeEdgeIntersection(Grid &grid, Edge *e1, Edge *e2, TAAPosVRT &aaPos, number snapThreshold)
Definition: resolve_intersections_impl.hpp:417
geometry_traits< Triangle >::iterator TriangleIterator
Definition: grid_objects_2d.h:211
int FindCloseVertexInArray(const std::vector< Vertex * > &array, const typename TAAPosVRT::ValueType &p, TAAPosVRT &aaPos, number snapThreshold)
returns the index of the first vertex closer to p than snapThreshold.
int FindClosestVertexInArray(const std::vector< Vertex * > &array, const Vertex *p, TAAPosVRT &aaPos, number snapThreshold)
returns the index of the closest vertex to p if closer than snapThreshold.
Sphere< typename TAAPos::ValueType > CalculateBoundingSphere(FaceVertices *face, TAAPos aaPos)
Definition: resolve_intersections_impl.hpp:1337
APosition aPosition("position", true)
The standard 3d position type.
Definition: common_attachments.h:84
bool IntersectCloseEdges(Grid &grid, TObjectCollection &elems, TAAPosVRT &aaPos, number snapThreshold)
Definition: resolve_intersections_impl.hpp:932
bool ResolveEdgeFaceIntersection(Grid &grid, Edge *e, Face *f, TAAPosVRT &aaPos, number snapThreshold)
Definition: resolve_intersections_impl.hpp:477
Vertex * ResolveVertexEdgeIntersection(Grid &grid, Vertex *v, Edge *e, TAAPosVRT &aaPos, number snapThreshold)
Definition: resolve_intersections_impl.hpp:137
bool ResolveTriangleIntersections(Grid &grid, TriangleIterator trisBegin, TriangleIterator trisEnd, number snapThreshold, TAPos &aPos)
Definition: resolve_intersections_impl.hpp:1353
void RemoveDuplicates(Grid &grid, TElemIter elemsBegin, TElemIter elemsEnd)
Removes elements which share the same set of vertices with other elements in the given range.
Definition: remove_duplicates_util.h:44
bool ProjectVerticesToCloseFaces(Grid &grid, TObjectCollection &elems, TAPos &aPos, number snapThreshold)
Definition: resolve_intersections_impl.hpp:826
bool EdgeOrientationMatches(EdgeVertices *ev, Face *f)
checks if the edge-orientation of the edge and the face matches.
Definition: orientation_util.cpp:37
bool TriangleFill_SweepLine(vector< int > &facesOut, const vector< vector2 > &srcVrtsOrig, vector< int > &srcEdges)
Performs triangulation of a polygon and resoves additional inner edges.
Definition: triangle_fill_sweep_line.cpp:942
void MultiEdgeSplit(Grid &grid, Edge *edge, TVrtIter vrtsBegin, TVrtIter vrtsEnd, TAAPos aaPos)
Inserts the specified vertices on the given edge.
Definition: resolve_intersections_impl.hpp:588
#define mkstr(s)
Comfortable (but not necessarily efficient) string building.
Definition: stringify.h:100
Definition: resolve_intersections_impl.hpp:688
Record()
Definition: resolve_intersections_impl.hpp:689
number distanceSq
Definition: resolve_intersections_impl.hpp:691
int closestEdge
Definition: resolve_intersections_impl.hpp:690