void interval_set_element_iter_4_discrete_types()
{
    typedef IntervalSet<T> IntervalSetT;
    typedef typename IntervalSetT::interval_type IntervalT;
    typedef std::vector<T> VectorT;

    IntervalSetT set_a;
    set_a.add(I_I(1,3)).add(I_I(6,7));

    VectorT vec(5), cev(5);
    vec[0]=MK_v(1);vec[1]=MK_v(2);vec[2]=MK_v(3);vec[3]=MK_v(6);vec[4]=MK_v(7);
    cev[0]=MK_v(7);cev[1]=MK_v(6);cev[2]=MK_v(3);cev[3]=MK_v(2);cev[4]=MK_v(1);

    VectorT dest;
    std::copy(elements_begin(set_a), elements_end(set_a), std::back_inserter(dest));
    BOOST_CHECK_EQUAL( vec == dest, true );

    dest.clear();
    std::copy(elements_rbegin(set_a), elements_rend(set_a), std::back_inserter(dest));
    BOOST_CHECK_EQUAL( cev == dest, true );

    dest.clear();
    std::reverse_copy(elements_begin(set_a), elements_end(set_a), std::back_inserter(dest));
    BOOST_CHECK_EQUAL( cev == dest, true );

    dest.clear();
    std::reverse_copy(elements_rbegin(set_a), elements_rend(set_a), std::back_inserter(dest));
    BOOST_CHECK_EQUAL( vec == dest, true );
}
void LRSplineEvalGrid::testCoefComputation()
{

    std::vector<double> tmpCoefs(dim_*order_v_*order_v_);
    std::vector<double> coefs;
    std::vector<double> tmpPoints(dim_*order_v_*order_v_);
    double *p =&tmpPoints[0];
    int i=0;
//    for(auto it=orig.elements_begin(); it!=orig.elements_end(); it++, i++) {
    for(auto it=elements_begin(); it!=elements_end(); it++, i++) {
	param_float_type ll_x, ll_y, ur_x, ur_y;
	low(*it, ll_x, ll_y);
	high(*it, ur_x, ur_y);
	double ll[2];
	ll[0] = ll_x;
	ll[1] = ll_y;
	double ur[2];
	ur[0] = ur_x;
	ur[1] = ur_y;
	int index = i;
//	knotIntervals.push_back(KnotInterval(ll, ur, index));
	evaluateGrid(*it, &tmpPoints[0]);
	computeBezCoefs(dim_, &tmpPoints[0], order_u_, order_v_, &tmpCoefs[0]);
//	coefficients.insert(coefficients.end(), tmpCoefs.begin(), tmpCoefs.end());
	coefs.insert(coefs.end(), tmpCoefs.begin(), tmpCoefs.end());
	// element_boundaries.push_back(ll_x);
	// element_boundaries.push_back(ll_y);
	// element_boundaries.push_back(ur_x);
	// element_boundaries.push_back(ur_y);
    }
//    m_knotSearcher.reset(new KnotIntervalSearcher(knotIntervals, glm::ivec2(128, 128)));
    // m_patchesU = 10;
    // m_patchesV = 10;
    // init(&element_boundaries[0], &coefficients[0]);
    std::cout << "Done with testCoefComputation()." << std::endl;
}
Example #3
0
bool UnstructuredMesh::contract ()
{
  LOG_SCOPE ("contract()", "Mesh");

  // Flag indicating if this call actually changes the mesh
  bool mesh_changed = false;

  element_iterator in        = elements_begin();
  const element_iterator end = elements_end();

#ifdef DEBUG
  for ( ; in != end; ++in)
    if (*in != libmesh_nullptr)
      {
        Elem * el = *in;
        libmesh_assert(el->active() || el->subactive() || el->ancestor());
      }
  in = elements_begin();
#endif

  // Loop over the elements.
  for ( ; in != end; ++in)
    if (*in != libmesh_nullptr)
      {
        Elem * el = *in;

        // Delete all the subactive ones
        if (el->subactive())
          {
            // No level-0 element should be subactive.
            // Note that we CAN'T test elem->level(), as that
            // touches elem->parent()->dim(), and elem->parent()
            // might have already been deleted!
            libmesh_assert(el->parent());

            // Delete the element
            // This just sets a pointer to NULL, and doesn't
            // invalidate any iterators
            this->delete_elem(el);

            // the mesh has certainly changed
            mesh_changed = true;
          }
        else
          {
            // Compress all the active ones
            if (el->active())
              el->contract();
            else
              libmesh_assert (el->ancestor());
          }
      }

  // Strip any newly-created NULL voids out of the element array
  this->renumber_nodes_and_elements();

  // FIXME: Need to understand why deleting subactive children
  // invalidates the point locator.  For now we will clear it explicitly
  this->clear_point_locator();

  return mesh_changed;
}