<commit_before>//===========================================================================
//                                                                           
// File: LRSplineEvalGrid.h                                                 
//                                                                           
// Created: Tue Jan 22 10:00:29 2013                                         
//                                                                           
// Author: <NAME> <<EMAIL>>
//                                                                           
// Revision: $Id$
//                                                                           
// Description:
//                                                                           
//===========================================================================

#ifndef _LRSPLINEEVALGRID_H
#define _LRSPLINEEVAVGRID_H


#include "GoTools/lrsplines2D/LRSplineSurface.h"
#include "GoTools/lrsplines2D/Element2D.h"

#include <vector>


namespace Go
{


// struct simpleElement {
// glm::vec2 &low() {return m_low;}
// const glm::vec2 &low() const {return m_low;}
// glm::vec2 &high() {return m_high;}
// const glm::vec2 &high() const {return m_high;}
// glm::vec2 m_low;
// glm::vec2 m_high;
// simpleElement(glm::vec2 newLow,	glm::vec2 newHigh) :
// m_low(newLow), m_high(newHigh) {;}
// };

typedef Element2D simpleElement;


// =============================================================================
class LRSplineEvalGrid
// =============================================================================
{
public:

  LRSplineEvalGrid();

//    LRSplineEvalGrid(int numElements);

  LRSplineEvalGrid(LRSplineSurface& lr_spline);

  std::vector<Element2D>::iterator elements_begin()// const
    {
      return elements_.begin();
    }

  std::vector<Element2D>::iterator elements_end()// const
    {
      return elements_.end();
    }

  void evaluate(Element2D &elem, float u, float v, float *res) const
    {
      assert(dim_ ==1 || dim_ == 3);

      Point result(dim_);
      result.setValue(0.0);

      const std::vector<LRBSpline2D*> covering_B_functions = elem.getSupport();

      for (auto b = covering_B_functions.begin();
	   b != covering_B_functions.end(); ++b)
	{
	  const bool u_on_end = (u == (*b)->umax());
	  const bool v_on_end = (v == (*b)->vmax());

	  result += (*b)->eval(u, 
			       v, 
			       mesh_.knotsBegin(XFIXED), 
			       mesh_.knotsBegin(YFIXED), 
			       0, // No derivs.
			       0, // No derivs.
			       u_on_end, 
			       v_on_end);
	}

      if (dim_ == 3)
	{
	  res[0] = result[0];
	  res[1] = result[1];
	  res[2] = result[2];
	}
      else
	{
	  res[0] = u;
	  res[1] = v;
	  res[2] = result[0];
	}
    }

  int numElements() const
    {
      return elements_.size();
    }

  int dim() const
    {
      return 3; // If dim is 1 we use the parameter domain as the first two dimensions.
    }

  int orderU() const
    {
      return order_u_;
    }<commit_msg>Evaluating using (u, v, s(u,v)) for 3D case.<commit_after>//===========================================================================
//                                                                           
// File: LRSplineEvalGrid.h                                                 
//                                                                           
// Created: Tue Jan 22 10:00:29 2013                                         
//                                                                           
// Author: <NAME> <<EMAIL>>
//                                                                           
// Revision: $Id$
//                                                                           
// Description:
//                                                                           
//===========================================================================

#ifndef _LRSPLINEEVALGRID_H
#define _LRSPLINEEVAVGRID_H


#include "GoTools/lrsplines2D/LRSplineSurface.h"
#include "GoTools/lrsplines2D/Element2D.h"

#include <vector>


namespace Go
{


// struct simpleElement {
// glm::vec2 &low() {return m_low;}
// const glm::vec2 &low() const {return m_low;}
// glm::vec2 &high() {return m_high;}
// const glm::vec2 &high() const {return m_high;}
// glm::vec2 m_low;
// glm::vec2 m_high;
// simpleElement(glm::vec2 newLow,	glm::vec2 newHigh) :
// m_low(newLow), m_high(newHigh) {;}
// };

typedef Element2D simpleElement;


// =============================================================================
class LRSplineEvalGrid
// =============================================================================
{
public:

  LRSplineEvalGrid();

//    LRSplineEvalGrid(int numElements);

  LRSplineEvalGrid(LRSplineSurface& lr_spline);

  std::vector<Element2D>::iterator elements_begin()// const
    {
      return elements_.begin();
    }

  std::vector<Element2D>::iterator elements_end()// const
    {
      return elements_.end();
    }

  void evaluate(Element2D &elem, float u, float v, float *res) const
    {
      assert(dim_ ==1 || dim_ == 3);

      Point result(dim_);
      result.setValue(0.0);

      const std::vector<LRBSpline2D*> covering_B_functions = elem.getSupport();

      for (auto b = covering_B_functions.begin();
	   b != covering_B_functions.end(); ++b)
	{
	  const bool u_on_end = (u == (*b)->umax());
	  const bool v_on_end = (v == (*b)->vmax());

	  result += (*b)->eval(u, 
			       v, 
			       mesh_.knotsBegin(XFIXED), 
			       mesh_.knotsBegin(YFIXED), 
			       0, // No derivs.
			       0, // No derivs.
			       u_on_end, 
			       v_on_end);
	}

      if (dim_ == 3)
	{
#if 0
	  res[0] = result[0];
	  res[1] = result[1];
#else // @@sbr201301 Setting first two params to parameter domain.
	  res[0] = u;
	  res[1] = v;
#endif
	  res[2] = result[2];
	}
      else
	{
	  res[0] = u;
	  res[1] = v;
	  res[2] = result[0];
	}
    }

  int numElements() const
    {
      return elements_.size();
    }

  int dim() const
    {
      return 3; // If dim is 1 we use the parameter domain as the first two dimensions.
    }

  int orderU() const
    {
      return order_u_;
    }
{'fraction_non_alphanumeric': 0.21887647725433057, 'fraction_numerical': 0.01683665209648697, 'mean_word_length': 1.6503646503646503, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 44, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '978211', 'n_tokens_mistral': 1918, 'n_tokens_neox': 1746, 'n_words': 375}