#include "fiko/pafta/pafta_dxf.hpp" #include "fiko_test.hpp" using namespace fiko; using namespace fiko::pafta; namespace { bool icerir(const std::string& s, const char* alt) { return s.find(alt) != std::string::npos; } size_t adet(const std::string& s, const char* alt) { size_t n = 0, k = 0; const std::string a(alt); while ((k = s.find(a, k)) != std::string::npos) { ++n; k += a.size(); } return n; } } // namespace FIKO_TEST(pafta_dxf_sayfa_ve_gorunumler) { Pafta p; p.antet.parca = "P-42"; const geometri::BrepGovde k = geometri::kutu(40, 30, 20); Gorunum g; g.ad = "Ön"; g.konum = {120, 150}; const u32 gid = p.gorunumEkle(g); std::unordered_map cizimler; cizimler[gid] = gorunumUret(k, geometri::Gorunum::On, p.olcek); FIKO_KONTROL(cizimler[gid].gecerli); const std::string dxf = paftaDxfMetni(p, cizimler); FIKO_KONTROL(icerir(dxf, "0\nSECTION\n2\nENTITIES\n")); FIKO_KONTROL(icerir(dxf, "0\nEOF\n")); FIKO_KONTROL(icerir(dxf, "GORUNUR")); // gövde kenarları FIKO_KONTROL(icerir(dxf, "CERCEVE")); // sayfa + antet çerçevesi FIKO_KONTROL(icerir(dxf, "P-42")); // antet metni FIKO_KONTROL(!icerir(dxf, "GIZLI")); // gizli çizgi kapalıyken katman yazılmaz // Görünüm sayfa konumuna taşınmış: en az bir çizgi x≈100..140 bandında. FIKO_KONTROL(icerir(dxf, "10\n100")); } FIKO_TEST(pafta_dxf_olcu_ve_deger) { Pafta p; p.antet.goster = false; Gorunum g; g.konum = {100, 100}; const u32 gid = p.gorunumEkle(g); Olcu o; o.gorunum = gid; o.tip = OlcuTip::Yatay; o.p1 = {-20, -10}; o.p2 = {20, -10}; o.ofset = -8; p.olcuEkle(o); const std::string dxf = paftaDxfMetni(p, {}); FIKO_KONTROL(icerir(dxf, "OLCU")); FIKO_KONTROL(icerir(dxf, "0\nTEXT\n")); FIKO_KONTROL(icerir(dxf, "40")); // gerçek değer 40 mm metinde FIKO_KONTROL(adet(dxf, "0\nLINE\n8\nOLCU\n") == 3); // iki uzantı + ölçü çizgisi } FIKO_TEST(pafta_dxf_bos_pafta_gecerli) { Pafta p; const std::string dxf = paftaDxfMetni(p, {}); FIKO_KONTROL(icerir(dxf, "ENTITIES")); FIKO_KONTROL(icerir(dxf, "0\nEOF\n")); // görünümsüz sayfa bile geçerli DXF }