<commit_before>// ======================================================================== //
// Copyright 2009-2015 Intel Corporation                                    //
//                                                                          //
// Licensed under the Apache License, Version 2.0 (the "License");          //
// you may not use this file except in compliance with the License.         //
// You may obtain a copy of the License at                                  //
//                                                                          //
//     http://www.apache.org/licenses/LICENSE-2.0                           //
//                                                                          //
// Unless required by applicable law or agreed to in writing, software      //
// distributed under the License is distributed on an "AS IS" BASIS,        //
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
// See the License for the specific language governing permissions and      //
// limitations under the License.                                           //
// ======================================================================== //

#pragma once

#include "geometry.h"
#include "buffer.h"

namespace embree
{
  /*! Triangle Mesh */
  struct TriangleMesh : public Geometry
  {
    /*! type of this geometry */
    static const Geometry::Type geom_type = Geometry::TRIANGLE_MESH;

    /*! triangle indices */
    struct Triangle 
    {
      uint32_t v[3];

      /*! outputs triangle indices */
      __forceinline friend std::ostream &operator<<(std::ostream& cout, const Triangle& t) {
        return cout << "{ tri " << t.v[0] << ", " << t.v[1] << ", " << t.v[2] << " }";
      }
    };
    
  public:

    /*! triangle mesh construction */
    TriangleMesh (Scene* parent, RTCGeometryFlags flags, size_t numTriangles, size_t numVertices, size_t numTimeSteps); 
  
    /*! writes the triangle mesh geometry to disk */
    void write(std::ofstream& file);

    /* geometry interface */
  public:
    void enabling();
    void disabling();
    void setMask (unsigned mask);
    void setBuffer(RTCBufferType type, void* ptr, size_t offset, size_t stride);
    void* map(RTCBufferType type);
    void unmap(RTCBufferType type);
    void immutable ();
    bool verify ();<commit_msg>started to add some simple infrastructure to identify shared triangles edges<commit_after>// ======================================================================== //
// Copyright 2009-2015 Intel Corporation                                    //
//                                                                          //
// Licensed under the Apache License, Version 2.0 (the "License");          //
// you may not use this file except in compliance with the License.         //
// You may obtain a copy of the License at                                  //
//                                                                          //
//     http://www.apache.org/licenses/LICENSE-2.0                           //
//                                                                          //
// Unless required by applicable law or agreed to in writing, software      //
// distributed under the License is distributed on an "AS IS" BASIS,        //
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. //
// See the License for the specific language governing permissions and      //
// limitations under the License.                                           //
// ======================================================================== //

#pragma once

#include "geometry.h"
#include "buffer.h"

namespace embree
{
  /*! Triangle Mesh */
  struct TriangleMesh : public Geometry
  {
    /*! type of this geometry */
    static const Geometry::Type geom_type = Geometry::TRIANGLE_MESH;

    /*! triangle indices */
    struct Triangle 
    {
      uint32_t v[3];

      /*! outputs triangle indices */
      __forceinline friend std::ostream &operator<<(std::ostream& cout, const Triangle& t) {
        return cout << "{ tri " << t.v[0] << ", " << t.v[1] << ", " << t.v[2] << " }";
      }
    };

    /*! triangle edge based on two indices */
    struct Edge 
    {
      uint64_t e;

      __forceinline Edge() {}

      __forceinline Edge(const uint32_t &v0,
                         const uint32_t &v1)
      {
        e = v0 < v1 ? (((uint64_t)v1 << 32) | (uint64_t)v0) : (((uint64_t)v0 << 32) | (uint64_t)v1);
      }

      __forceinline friend bool operator==( const Edge& a, const Edge& b ) 
      { return a.e == b.e; };

    };


    /*! tests if a shared exists between another triangle */
    __forceinline bool hasSharedEdge(const Triangle &tri0,
                                     const Triangle &tri1)
    {
      const Edge tri0_edge0(tri0.v[0],tri0.v[1]);
      const Edge tri0_edge1(tri0.v[1],tri0.v[2]);
      const Edge tri0_edge2(tri0.v[2],tri0.v[0]);
      const Edge tri1_edge0(tri1.v[0],tri1.v[1]);
      const Edge tri1_edge1(tri1.v[1],tri1.v[2]);
      const Edge tri1_edge2(tri1.v[2],tri1.v[0]);
      if (tri0_edge0 == tri1_edge0 || tri0_edge0 == tri1_edge1 || tri0_edge0 == tri1_edge2) return true; 
      if (tri0_edge1 == tri1_edge0 || tri0_edge1 == tri1_edge1 || tri0_edge1 == tri1_edge2) return true; 
      if (tri0_edge2 == tri1_edge0 || tri0_edge2 == tri1_edge1 || tri0_edge2 == tri1_edge2) return true; 
      return false;
    }

    
  public:

    /*! triangle mesh construction */
    TriangleMesh (Scene* parent, RTCGeometryFlags flags, size_t numTriangles, size_t numVertices, size_t numTimeSteps); 
  
    /*! writes the triangle mesh geometry to disk */
    void write(std::ofstream& file);

    /* geometry interface */
  public:
    void enabling();
    void disabling();
    void setMask (unsigned mask);
    void setBuffer(RTCBufferType type, void* ptr, size_t offset, size_t stride);
    void* map(RTCBufferType type);
    void unmap(RTCBufferType type);
    void immutable ();
    bool verify ();
{'fraction_non_alphanumeric': 0.15647273330018233, 'fraction_numerical': 0.022542681916127964, 'mean_word_length': 1.8275538894095595, 'pattern_counts': {'":': 0, '<': 40, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 27, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1867636', 'n_tokens_mistral': 1633, 'n_tokens_neox': 1532, 'n_words': 482}