int main(){ SwapCase a; SwapCase b; a.num = 2; b.num = 6; swap<int>(a.num, b.num); a.fnum = -90; b.fnum = 200; swap<float>(a.fnum, b.fnum); a.lett = 'P'; b.lett = 'Q'; swap<char>(a.lett, b.lett); a.yep = false; b.yep = true; swap<bool>(a.yep, b.yep); //----------------------------------------------- Point<int> c; Point<int> d; c.SetZero(); d.SetZero(); c.SetPoint(56, 29); d.SetPoint(852, 213); c.DistanceTo(d); //------------------- Point<float> e; Point<float> f; e.SetZero(); f.SetZero(); e.SetPoint(56, 29); f.SetPoint(852, 213); e.DistanceTo(f); return 0; }
/** This is based on a nearest node criterion to all boundaries. @todo Improve efficiency. In most cases, we should be able to specify boundaries as planes @todo Somewhat dependent on the resolution of the model boundary */ bool OmegaBDistanceConfigurator::configure(Model& m) const { Point<3> ebc; m.UpdateIndices(); vector<size_t> omega_ids; omega_ids.reserve(m.Region("Model").Elements()); for (const auto& eit : m.Region("Model").ElementVector()) { ebc = eit->BaryCenter(); double dmin = numeric_limits<double>::max(); for (Model::boundaryIterator bit = m.BoundariesBegin(); bit != m.BoundariesEnd(); ++bit) { if (!is_main_boundary_id(bit->first.second)) continue; for (const auto& bnit : bit->second.NodeVector()) { double const dist = ebc.DistanceTo(bnit->Coordinate()); if (dist < dmin) dmin = dist; } } if (dmin >= dist_) omega_ids.push_back(eit->Idx()); } if (omega_ids.size()) { m.FormRegionFrom("omega", omega_ids); return true; } return false; }
//we don't define setters for this class, so it would technically be more efficient to calculate //length in our constructor and then store it as a property... double Length() { return p1.DistanceTo(p2); }