<commit_before>/*
 * Copyright 2015 Scientific Computation Research Center
 *
 * This work is open source software, licensed under the terms of the
 * BSD license as described in the LICENSE file in the top-level directory.
 */

#include <PCU.h>
#include "crv.h"
#include "crvAdapt.h"
#include <maCoarsen.h>
#include <maEdgeSwap.h>
#include <maOperator.h>
#include <cassert>

/* This is similar to maShape.cc, conceptually, but different enough
 * that some duplicate code makes sense */

namespace crv {

static ma::Entity* isEdgeQualityTag(ma::Mesh* m,
    ma::Entity* e, int tag)
{
  int index = tag-8;
  int ne = apf::Mesh::adjacentCount[m->getType(e)][1];
  if(index >= 0 && index < ne){
    ma::Downward edges;
    m->getDownward(e,1,edges);
    return edges[index];
  }
  return 0;
}

class EdgeSwapper : public ma::Operator
{
  public:
    EdgeSwapper(Adapt* a)
    {
      adapter = a;
      mesh = a->mesh;
      edges[0] = 0;
      edgeSwap = ma::makeEdgeSwap(a);
      md = mesh->getDimension();
      ns = 0;
    }
    virtual ~EdgeSwapper()<commit_msg>fixed coverity defect in crvShape<commit_after>/*
 * Copyright 2015 Scientific Computation Research Center
 *
 * This work is open source software, licensed under the terms of the
 * BSD license as described in the LICENSE file in the top-level directory.
 */

#include <PCU.h>
#include "crv.h"
#include "crvAdapt.h"
#include <maCoarsen.h>
#include <maEdgeSwap.h>
#include <maOperator.h>
#include <cassert>

/* This is similar to maShape.cc, conceptually, but different enough
 * that some duplicate code makes sense */

namespace crv {

static ma::Entity* isEdgeQualityTag(ma::Mesh* m,
    ma::Entity* e, int tag)
{
  int index = tag-8;
  int ne = apf::Mesh::adjacentCount[m->getType(e)][1];
  if(index >= 0 && index < ne){
    ma::Downward edges;
    m->getDownward(e,1,edges);
    return edges[index];
  }
  return 0;
}

class EdgeSwapper : public ma::Operator
{
  public:
    EdgeSwapper(Adapt* a)
    {
      adapter = a;
      mesh = a->mesh;
      simplex = 0;
      edges[0] = 0;
      edgeSwap = ma::makeEdgeSwap(a);
      md = mesh->getDimension();
      ns = 0;
    }
    virtual ~EdgeSwapper()
{'fraction_non_alphanumeric': 0.1317365269461078, 'fraction_numerical': 0.011515430677107323, 'mean_word_length': 3.344, 'pattern_counts': {'":': 0, '<': 15, '<?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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4462469', 'n_tokens_mistral': 770, 'n_tokens_neox': 746, 'n_words': 221}