MCPcopy Create free account
hub / github.com/KLayout/klayout / do_obj_snap2

Function do_obj_snap2

src/laybasic/laybasic/laySnap.cc:848–948  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

846}
847
848static TwoPointSnapToObjectResult
849do_obj_snap2 (lay::LayoutViewBase *view, const db::DPoint &pt1, const db::DPoint &pt2, const db::DVector &grid, double min_search_range, double max_search_range, const std::vector <db::DEdge> &cutlines)
850{
851 db::DPoint dp1 (pt1);
852 db::DPoint dp2 (pt2);
853
854 ContourFinder finder (dp1, grid, cutlines, cutlines.empty () ? 1 : 0 /*vertex snap on "any direction", edge vertexes*/);
855
856 double sr = min_search_range;
857 while (sr < max_search_range + 1e-6) {
858
859 finder.find (view, sr);
860
861 if ((cutlines.empty () && finder.any ()) || finder.any_exact ()) {
862
863 db::DPoint p1 = finder.get_found ();
864
865 std::vector <db::DEdge> cl;
866 db::DVector n;
867
868 if (! cutlines.empty ()) {
869
870 // select those cutlines that lead to the first intersection point
871 for (std::vector<db::DEdge>::const_iterator i = cutlines.begin (); i != cutlines.end (); ++i) {
872
873 db::DVector n = i->d ();
874 db::DVector d = dp2 - p1;
875 if (fabs (db::vprod (n, d)) < 1e-6 * n.length () * d.length ()) {
876 if (db::sprod_sign (n, d) < 0) {
877 n = -n;
878 }
879 cl.push_back (db::DEdge (p1, p1 + n));
880 }
881
882 }
883
884 } else if (finder.is_vertex ()) {
885
886 cl.push_back (db::DEdge (p1, dp2));
887
888 } else if (finder.has_found_edge ()) {
889
890 n = finder.get_found_edge ().d ().transformed (db::DTrans (db::DTrans::r90));
891 if (db::sprod_sign (n, dp2 - p1) < 0) {
892 n = -n;
893 }
894 cl.push_back (db::DEdge (p1, p1 + n));
895
896 }
897
898 ContourFinder finder2 (dp2, grid, cl, 0 /*no vertex snap*/, true /*directional cutlines*/);
899
900 double sr2 = min_search_range;
901 while (sr2 < max_search_range + 1e-6) {
902
903 finder2.find (view, sr2);
904 if (finder2.any_exact ()) {
905

Callers 1

obj_snap2Function · 0.85

Calls 15

anyMethod · 0.80
any_exactMethod · 0.80
get_foundMethod · 0.80
is_vertexMethod · 0.80
has_found_edgeMethod · 0.80
get_found_edgeMethod · 0.80
vprodFunction · 0.50
sprod_signFunction · 0.50
emptyMethod · 0.45
findMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected