BBox::BBox(const MEField<> &coords, const MeshObj &obj, double normexp) : isempty(false) { if (obj.get_type() != MeshObj::ELEMENT) Throw() << "Not able to create BBOx for non element"; const MeshObjTopo &topo = *GetMeshObjTopo(obj); const UInt npe = topo.num_nodes; dim = topo.spatial_dim; // Is a shell? TODO expand shell in normal directions if (topo.spatial_dim != topo.parametric_dim) { // Shell, expand by normexp in normal direction for (UInt i =0; i < dim; i++) { min[i] = std::numeric_limits<double>::max(); max[i] = -std::numeric_limits<double>::max(); } double nr[3]; MasterElement<> *me = GetME(coords, obj)(METraits<>()); std::vector<double> cd(3*me->num_functions()); GatherElemData<>(*me, coords, obj, &cd[0]); double pc[] = {0,0}; const Mapping<> *mp = GetMapping(obj)(MPTraits<>()); mp->normal(1,&cd[0], &pc[0], &nr[0]); double ns = std::sqrt(nr[0]*nr[0]+nr[1]*nr[1]+nr[2]*nr[2]); // Only normalize if bigger than 0.0 if (ns >1.0E-19) { nr[0] /= ns; nr[1] /= ns; nr[2] /= ns; } else { nr[0] =0.0; nr[1] =0.0; nr[2] =0.0; } /* if (obj.get_id() == 2426) { std::cout << "elem 2426 coords:"; std::copy(&cd[0], &cd[0] + 3*me->num_functions(), std::ostream_iterator<double>(std::cout, " ")); std::cout << std::endl; }*/ // Get cell diameter double diam = 0; for (UInt n = 1; n < me->num_functions(); n++) { double dist = std::sqrt( (cd[0]-cd[3*n])*(cd[0]-cd[3*n]) + (cd[1]-cd[3*n+1])*(cd[1]-cd[3*n+1]) + (cd[2]-cd[3*n+2])*(cd[2]-cd[3*n+2])); if (dist > diam) diam = dist; } normexp *= diam; for (UInt n = 0; n < npe; n++) { for (UInt j = 0; j < dim; j++) { double lm; if ((lm = (cd[n*dim + j] + normexp*nr[j])) < min[j]) min[j] = lm; if ((lm =(cd[n*dim + j] - normexp*nr[j])) < min[j]) min[j] = lm; if ((lm=(cd[n*dim + j] + normexp*nr[j])) > max[j]) max[j] = lm; if ((lm=(cd[n*dim + j] - normexp*nr[j])) > max[j]) max[j] = lm; } } // for n } else { // Good old fashioned element for (UInt i =0; i < dim; i++) { min[i] = std::numeric_limits<double>::max(); max[i] = -std::numeric_limits<double>::max(); } // Loop the nodes for (UInt n = 0; n < topo.num_nodes; n++) { const MeshObj &node = *(obj.Relations[n].obj); const double *coord = coords.data(node); for (UInt j = 0; j < dim; j++) { if (coord[j] < min[j]) min[j] = coord[j]; if (coord[j] > max[j]) max[j] = coord[j]; } } } // nonshell }