void biarc::update() { INITPART pointlist(splineset) pointdata(p1,getdval(x1),getdval(y1),getdval(z1)) pointdata(p2,getdval(x2),getdval(y2),getdval(z2)) pointdata(p3,getdval(x3),getdval(y3),getdval(z3)) pointdata(p4,getdval(x4),getdval(y4),getdval(z4)) pointdata(p5,getdval(x5),getdval(y5),getdval(z5)) visgeo(point1,SphereSurface(p1,1)) visgeo(point2,SphereSurface(p2,1)) visgeo(point3,SphereSurface(p3,1)) visgeo(point4,SphereSurface(p4,1)) visgeo(point5,SphereSurface(p5,1)) splineset << p1 << p2 << p3 << p4 << p5; TopoDS_Shape spline = hsf::AddNewSplineSShape(splineset); vis(spline) FOR(i,1,100) gp_Pnt pcrv = hsf::AddNewPointonCurve(spline,(double)i/100); gp_Pnt pcrv2 = pcrv; pcrv2.SetZ(0); if(pcrv.Distance(pcrv2)) { TopoDS_Shape l1 = hsf::AddNewLineptpt(pcrv2,pcrv); vis(l1) }
void logicop::logic::getShape(pcollection& plycol, polycross::VPoint* centinel) { pointlist *shgen = DEBUG_NEW pointlist(); polycross::VPoint* vpnt = centinel; do { shgen->push_back(TP(vpnt->cp()->x(), vpnt->cp()->y())); vpnt = vpnt->next(); }while (centinel != vpnt); plycol.push_back(shgen); }
pointlist* logicop::stretcher::execute() { unsigned plysize = _poly.size(); pointlist* streched = DEBUG_NEW pointlist(); for (unsigned i = 0; i < plysize; i++) { TP npnt; VERIFY(0 == _segl[i]->moved()->crossP(*(_segl[(i+1)%plysize]->moved()), npnt)); streched->push_back(npnt); } return streched; }
pointlist* logicop::logic::hole2simple(const pointlist& outside, const pointlist& inside) { polycross::segmentlist _seg1(outside,1); polycross::segmentlist _seg2(inside ,2); polycross::XQ _eq(_seg1, _seg2); // create the event queue polycross::BindCollection BC; _eq.sweep2bind(BC); polycross::BindSegment* sbc = BC.get_highest(); //insert 2 bind points and link them polycross::BPoint* cpsegA = _seg1.insertBindPoint(sbc->poly0seg(), sbc->poly0pnt()); polycross::BPoint* cpsegB = _seg2.insertBindPoint(sbc->poly1seg(), sbc->poly1pnt()); cpsegA->linkto(cpsegB); cpsegB->linkto(cpsegA); // normalize the segment lists _seg1.normalize(outside); _seg2.normalize(inside); // // dump the new polygons in VList terms polycross::VPoint* outshape = _seg1.dump_points(); polycross::VPoint* inshape = _seg2.dump_points(); // traverse and form the resulting shape polycross::VPoint* centinel = outshape; pointlist *shgen = DEBUG_NEW pointlist(); bool direction = true; /*next*/ polycross::VPoint* pickup = centinel; polycross::VPoint* prev = centinel->prev(); bool modify = false; do { shgen->push_back(TP(pickup->cp()->x(), pickup->cp()->y())); modify = (-1 == prev->visited()); prev = pickup; pickup = pickup->follower(direction, modify); } while (pickup != centinel); // clean-up dumped points cleanupDumped(outshape); cleanupDumped(inshape); // Validate the resulting polygon laydata::valid_poly check(*shgen); // delete shgen; if (!check.valid()) { std::ostringstream ost; ost << ": Resulting shape is invalid - " << check.failtype(); tell_log(console::MT_ERROR, ost.str()); } else { if (laydata::shp_OK != check.status()) *shgen = check.get_validated(); } return shgen; }
/*!The method uses #_shape1 and #_shape2 structure as an input data and produces one or more polygons representing the result of the logical ANDNOT between the input polygons. Method returns false if no output shapes are generated, and true otherwise*/ bool logicop::logic::ANDNOT(pcollection& plycol) { bool result = false; polycross::VPoint* centinel = NULL; bool direction; if (0 != _crossp) { // get first external and non crossing point if (NULL == (centinel = getFirstOutside(_poly1, _shape2))) if (NULL == (centinel = getFirstOutside(_poly2, _shape1))) assert(false); else direction = false; /*prev*/ else direction = true; /*next*/ } else { // No crossing points found, but polygons still might be overlapping... // if poly1 is inside poly2, or both are non overlapping -> // resulting shape is null // if poly2 is inside poly1, then we have to generate a polygon // combining both shapes if (_shape2->inside(_poly1)) { plycol.push_back(hole2simple(_poly1, _poly2)); return true; } else return false; } // assert(centinel); polycross::VPoint* collector = centinel; do { if (0 == collector->visited()) { pointlist *shgen = DEBUG_NEW pointlist(); polycross::VPoint* pickup = collector; do { pickup = pickup->follower(direction, true); shgen->push_back(TP(pickup->cp()->x(), pickup->cp()->y())); } while (pickup != collector); plycol.push_back(shgen); result = true; } collector = collector->prev(); } while (collector != centinel); return result; }
/*!The method uses #_shape1 and #_shape2 structure as an input data and produces one or more polygons representing the result of the logical AND between the input polygons. Method returns false if no output shapes are generated, and true otherwise*/ bool logicop::logic::AND(pcollection& plycol) { bool result = false; polycross::VPoint* centinel = NULL; bool direction = true; /*next*/ if (0 != _crossp) { // get first external and non crossing point if ((NULL == (centinel = getFirstOutside(_poly2, _shape1))) && (NULL == (centinel = getFirstOutside(_poly1, _shape2))) ) { assert(false); } } else { // If there are no crossing points found, this still does not mean // that the operation will fail. Polygons might be fully overlapping... // Check that an arbitraty point from poly1 is inside poly2 ... if (_shape1->inside(_poly2)) centinel = _shape1; // ... if not, check that an arbitrary point from poly2 is inside poly1 ... else if (_shape2->inside(_poly1)) centinel = _shape2; // ... if not - still insysting - check that the polygons coincides else if (NULL == (centinel = checkCoinciding(_poly1, _shape2))) return false; // If we've got here means that one of the polygons is completely // overlapped by the other one. So we need to return the outer one getShape(plycol, centinel); return true; } // assert(centinel); polycross::VPoint* collector = centinel; do { if (0 == collector->visited()) { pointlist *shgen = DEBUG_NEW pointlist(); polycross::VPoint* pickup = collector; do { pickup = pickup->follower(direction); shgen->push_back(TP(pickup->cp()->x(), pickup->cp()->y())); } while (pickup != collector); plycol.push_back(shgen); result = true; } collector = collector->prev(); } while (collector != centinel); return result; }
void logicop::CrossFix::traverseOne(polycross::VPoint* const centinel, pcollection& plycol) { bool direction = true; /*next*/ pointlist *shgen = DEBUG_NEW pointlist(); // always push the entry point shgen->push_back(TP(centinel->cp()->x(), centinel->cp()->y())); polycross::VPoint* collector = centinel->next(); while ( *(collector->cp()) != *(centinel->cp()) ) { shgen->push_back(TP(collector->cp()->x(), collector->cp()->y())); if (0 == collector->visited()) { traverseOne(collector, plycol); } collector = collector->follower(direction, false); } plycol.push_back(shgen); }
void Calbr::drcEdge::showError(laydata::tdtdesign* atdb, word la) { real DBscale = DATC->DBscale(); //Convert drcEdge to pointlist pointlist *plDB = DEBUG_NEW pointlist(); plDB->reserve(2); telldata::ttpnt* pt1, *pt2; /* real xx, yy; // DATC->unlockDB(); wxString xstr = convert(_coords.x1, _precision); wxString ystr = convert(_coords.y1, _precision); xstr.ToDouble(&xx); ystr.ToDouble(&yy);*/ pt1 = DEBUG_NEW telldata::ttpnt(_coords.x1, _coords.y1); /*xstr = convert(_coords.x2, _precision); ystr = convert(_coords.y2, _precision); xstr.ToDouble(&xx); ystr.ToDouble(&yy);*/ pt2 = DEBUG_NEW telldata::ttpnt(_coords.x2, _coords.y2); //pt2 = DEBUG_NEW telldata::ttpnt(xx, yy); plDB->push_back(TP(pt1->x(), pt1->y(), DBscale)); plDB->push_back(TP(pt2->x(), pt2->y(), DBscale)); //ATDB->addpoly(1,plDB); real w = 0.01; // telldata::ttlayout* wr = DEBUG_NEW telldata::ttlayout(ATDB->addwire(1,plDB, // static_cast<word>(rint(w * DBscale))), 1); // laydata::tdtdesign* ATDB = DATC->lockDB(); atdb->addwire(la, plDB, static_cast<word>(rint(w * DBscale))); //DATC->unlockDB(); delete pt1; delete pt2; delete plDB; }
/*!The method uses #_shape1 and #_shape2 structure as an input data and produces one or more polygons representing the result of the logical OR between the input polygons. Method returns false if no output shapes are generated, and true otherwise*/ bool logicop::logic::OR(pcollection& plycol) { bool result = false; bool direction = true; /*next*/ pcollection lclcol; // local collection of the resulting shapes polycross::VPoint* centinel = NULL; if (0 != _crossp) { // get first external and non crossing point if ((NULL == (centinel = getFirstOutside(_poly2, _shape1))) && (NULL == (centinel = getFirstOutside(_poly1, _shape2))) ) { assert(false); } } else { // If there are no crossing points found, this still does not mean // that the operation will fail. Polygons might be fully overlapping... // Check that an arbitraty point from poly1 is inside poly2 ... if (_shape1->inside(_poly2)) centinel = _shape2; // ... if not, check that an arbitrary point from poly2 is inside poly1 ... else if (_shape2->inside(_poly1)) centinel = _shape1; // ... if not - still insysting - check that the polygons coincides else if (NULL == (centinel = checkCoinciding(_poly1, _shape2))) return false; // If we've got here means that one of the polygons is completely // overlapped by the other one. So we need to return the outer one getShape(plycol, centinel); return true; } // assert(centinel); polycross::VPoint* collector = centinel; do { if (0 == collector->visited()) { pointlist *shgen = DEBUG_NEW pointlist(); polycross::VPoint* pickup = collector; direction = (0 == lclcol.size()); do { pickup = pickup->follower(direction); shgen->push_back(TP(pickup->cp()->x(), pickup->cp()->y())); } while (pickup != collector); direction = true; lclcol.push_back(shgen); result = true; } collector = collector->next(); } while (collector != centinel); if (!result) return result; // Validate all resulting polygons pcollection lclvalidated; while (!lclcol.empty()) { pointlist* csh = lclcol.front(); laydata::valid_poly check(*csh); delete csh; lclcol.pop_front(); if (check.valid()) lclvalidated.push_back(DEBUG_NEW pointlist(check.get_validated())); } if (lclvalidated.empty()) return false; // Convert all collected shapes to a single normalized polygon pointlist* respoly = lclvalidated.front();lclvalidated.pop_front(); while (0 < lclvalidated.size()) { pointlist* curpolyA = respoly; pointlist* curpolyB = lclvalidated.front(); respoly = hole2simple(*curpolyA, *curpolyB); lclvalidated.pop_front(); delete curpolyA; delete curpolyB; } plycol.push_back(respoly); return result; }