text:
#ifdef _MSC_VER
  #pragma warning( disable : 4503 )     //truncated name decoration
#endif

#include <cmath>
#include <iostream>
#include <iomanip>

#include "viennagrid/forwards.hpp"
#include "viennagrid/config/default_configs.hpp"
#include "viennagrid/mesh/element_creation.hpp"
#include "viennagrid/point.hpp"
#include "viennagrid/algorithm/distance.hpp"
#include "viennagrid/algorithm/volume.hpp"
#include "viennagrid/algorithm/cross_prod.hpp"
#include "viennagrid/algorithm/norm.hpp"

inline void fuzzy_check(double a, double b)
{
  if (a > b || a < b)
  {
    if (   (std::abs(a - b) / std::max( std::abs(a), std::abs(b) ) > 1e-10)
        && (std::abs(a - b) > 1e-10)
    )
    {
      std::cerr << "FAILED!" << std::endl;
      std::cerr << "Result mismatch: " << a << " vs. " << b << std::endl;
      //exit(EXIT_FAILURE);
    }
  }
  std::cout << "PASSED! (" << a << ", " << b << ")" << std::endl;
}

inline double heron_triangle_area(double a, double b, double c)
{
  double s = (a + b + c) / 2.0;

  return std::sqrt(s * (s - a) * (s - b) * (s - c));
}

/* Computes the height on c of a triangle with edge lenghts a, b, c */
inline double height_from_edge_lengths(double a, double b, double c)
{
  return heron_triangle_area(a, b, c) / c * 2.0;
}

/* Computes the height in d of a tetrahedron with edge lenghts a, b, c, d */
template <typename PointType>
double height_for_tetrahedron(PointType const & A,
                              PointType const & B,
                              PointType const & C,
                              PointType const & D)
{
  double V = std::abs( viennagrid::inner_prod(A - D, viennagrid::cross_prod(B - D, C - D)) / 6.0 );
  double base_area = 0.5 * viennagrid::norm_2(viennagrid::cross_prod(B - A, C - A));

  return 3.0 * V / base_area;
}

template <typename MeshType, typename LineType>
double line_distance_via_cross_prod(MeshType const & mesh, LineType const & line0, LineType const & line1)
{
  //typedef typename LineType::config_type     ConfigType;
  //typedef typename viennagrid::result_of::point<ConfigType>::type    PointType;
  typedef typename viennagrid::result_of::point<MeshType>::type PointType;

  PointType const & A = viennagrid::point(mesh, viennagrid::elements<viennagrid::vertex_tag>(line0)[0]);
  PointType const & B = viennagrid::point(mesh, viennagrid::elements<viennagrid::vertex_tag>(line0)[1]);

  PointType const & C = viennagrid::point(mesh, viennagrid::elements<viennagrid::vertex_tag>(line1)[0]);
  PointType const & D = viennagrid::point(mesh, viennagrid::elements<viennagrid::vertex_tag>(line1)[1]);

  PointType dir_0 = B - A;
  PointType dir_1 = D - C;

  //compute unit normal vector:
  PointType n = viennagrid::cross_prod(dir_0, dir_1);
  n /= viennagrid::norm_2(n);

  return std::abs( viennagrid::inner_prod(C - A, n) );
}

//
// Line 3d
//

inline void setup_mesh(viennagrid::line_3d_mesh & mesh)
{
  typedef viennagrid::line_3d_mesh                      MeshType;
//   typedef viennagrid::config::line_2d                             ConfigType;
  typedef viennagrid::line_tag                                    CellTag;

  typedef viennagrid::result_of::point<MeshType>::type          PointType;
  typedef viennagrid::result_of::handle<MeshType, viennagrid::vertex_tag>::type       VertexHandleType;
  typedef viennagrid::result_of::element<MeshType, CellTag>::type        CellType;

  const size_t s = 9;
  PointType p[s];
  VertexHandleType v[s];

  p[0] = PointType(3.0, 0.0, 1.0);
  p[1] = PointType(1.0, 1.0, 3.0);
  p[2] = PointType(5.0, 1.0, 3.0);
  p[3] = PointType(3.0, 2.0, 2.0);
  p[4] = PointType(0.0, 3.0, 4.0);
  p[5] = PointType(3.0, 3.0, 1.0);
  p[6] = PointType(1.0, 4.0, 3.0);
  p[7] = PointType(2.0, 1.0, 2.0);
  p[8] = PointType(3.0, 2.0, 3.0);

  //upgrade to vertex:
  std::cout << "Adding vertices to mesh..." << std::endl;
  for (size_t i = 0; i < s; ++i)
  {
    v[i] = viennagrid::make_vertex( mesh, p[i] );
//     viennagrid::point( mesh, v[i] ) = p[i];
  }

  std::cout << "Adding cells to mesh..." << std::endl;
  VertexHandleType vertices[2];

  vertices[0] = v[0];
  vertices[1] = v[6];
  viennagrid::make_element<CellType>( mesh, vertices, vertices+2 );

  vertices[0] = v[1];
  vertices[1] = v[4];
  viennagrid::make_element<CellType>( mesh, vertices, vertices+2 );

  vertices[0] = v[1];
  vertices[1] = v[5];
  viennagrid::make_element<CellType>( mesh, vertices, vertices+2 );

  vertices[0] = v[2];
  vertices[1] = v[3];
  viennagrid::make_element<CellType>( mesh, vertices, vertices+2 );

  vertices[0] = v[7];
  vertices[1] = v[8];
  viennagrid::make_element<CellType>( mesh, vertices, vertices+2 );
}

inline void test(viennagrid::line_3d_mesh)
{
  typedef viennagrid::line_3d_mesh                            Mesh;
  typedef viennagrid::line_tag                                          CellTag;

  typedef viennagrid::result_of::point<Mesh>::type                PointType;
  typedef viennagrid::result_of::element<Mesh, CellTag>::type  CellType;

  Mesh mesh;

  setup_mesh(mesh);

  CellType line0 = viennagrid::elements<CellTag>(mesh)[0];
  CellType line1 = viennagrid::elements<CellTag>(mesh)[1];
  CellType line2 = viennagrid::elements<CellTag>(mesh)[2];
  CellType line3 = viennagrid::elements<CellTag>(mesh)[3];
  CellType line  = viennagrid::elements<CellTag>(mesh)[4];
  CellType & line4 = line;

  double line_length = viennagrid::volume(line);

  //
  // Distance checks for points to line
  //

  std::cout << "Distance of point A to line... ";
  PointType A(0, 0, 0);
  fuzzy_check( viennagrid::distance(A, line), 3.0 );

  std::cout << "Distance of point B to line... ";
  PointType B(1, 0, 1);
  fuzzy_check( viennagrid::distance(B, line), std::sqrt(3.0) );

  std::cout << "Distance of point C to line... ";
  PointType C(2, 0, 3);
  fuzzy_check( viennagrid::distance(C, line), std::sqrt(2.0) );

  std::cout << "Distance of point D to line... ";
  PointType D(3, 0, 2);
  fuzzy_check( viennagrid::distance(D, line),
               height_from_edge_lengths(std::sqrt(2.0), std::sqrt(5.0), line_length) );

  std::cout << "Distance of point E to line... ";
  PointType E(4, 0, 1);
  fuzzy_check( viennagrid::distance(E, line),
               height_from_edge_lengths(std::sqrt(6.0), std::sqrt(9.0), line_length) );

  std::cout << "Distance of point F to line... ";
  PointType F(0, 1, 1);
  fuzzy_check( viennagrid::distance(F, line), std::sqrt(5.0) );

  std::cout << "Distance of point G to line... ";
  PointType G(1, 1, 1);
  fuzzy_check( viennagrid::distance(G, line), std::sqrt(2.0) );

  std::cout << "Distance of point H to line... ";
  PointType H(3, 1, 2);
  fuzzy_check( viennagrid::distance(H, line),
               height_from_edge_lengths(std::sqrt(1.0), std::sqrt(2.0), line_length) );

  std::cout << "Distance of point I to line... ";
  PointType I(4, 1, 3);
  fuzzy_check( viennagrid::distance(I, line),
               height_from_edge_lengths(std::sqrt(5.0), std::sqrt(2.0), line_length) );

  std::cout << "Distance of point J to line... ";
  PointType J(0, 2, 3);
  fuzzy_check( viennagrid::distance(J, line), std::sqrt(6.0) );

  std::cout << "Distance of point K to line... ";
  PointType K(2, 2, 2);
  fuzzy_check( viennagrid::distance(K, line),
               height_from_edge_lengths(std::sqrt(1.0), std::sqrt(2.0), line_length) );

  std::cout << "Distance of point L to line... ";
  PointType L(5, 2, 1);
  fuzzy_check( viennagrid::distance(L, line), std::sqrt(8.0) );

  std::cout << "Distance of point M to line... ";
  PointType M(5, 3, 1);
  fuzzy_check( viennagrid::distance(M, line), std::sqrt(9.0) );

  std::cout << "Distance of point N to line... ";
  PointType N(0, 4, 2);
  fuzzy_check( viennagrid::distance(N, line),
               height_from_edge_lengths(std::sqrt(13.0), std::sqrt(14.0), line_length) );

  std::cout << "Distance of point O to line... ";
  PointType O(1, 4, 2);
  fuzzy_check( viennagrid::distance(O, line),
               height_from_edge_lengths(std::sqrt(10.0), std::sqrt(9.0), line_length) );

  std::cout << "Distance of point P to line... ";
  PointType P(4, 4, 3);
  fuzzy_check( viennagrid::distance(P, line), std::sqrt(5.0) );

  std::cout << "Distance of point Q to line... ";
  PointType Q(2, 5, 3);
  fuzzy_check( viennagrid::distance(Q, line), std::sqrt(10.0) );

  std::cout << "Distance of point R to line... ";
  PointType R(3, 5, 4);
  fuzzy_check( viennagrid::distance(R, line), std::sqrt(10.0) );

  //
  // Distance checks line to line
  //

  std::cout << "Distance of line0 to line0... ";
  fuzzy_check( viennagrid::distance(line0, line0), 0.0 );

  std::cout << "Distance of line0 to line1... ";
  fuzzy_check( viennagrid::distance(line0, line1), std::sqrt(3.0) );

  std::cout << "Distance of line0 to line2... ";
  fuzzy_check( viennagrid::distance(line0, line2), 0.0 );

  std::cout << "Distance of line0 to line3... ";
  fuzzy_check( viennagrid::distance(line0, line3),
               height_from_edge_lengths(std::sqrt(5.0), std::sqrt(9.0), viennagrid::volume(line0)) );

  std::cout << "Distance of line0 to line4... ";
  double dist_04 = line_distance_via_cross_prod(mesh, line0, line4);
  fuzzy_check( viennagrid::distance(line0, line4), dist_04);

  std::cout << "Distance of line1 to line0... ";
  fuzzy_check( viennagrid::distance(line1, line0), std::sqrt(3.0) );

  std::cout << "Distance of line1 to line1... ";
  fuzzy_check( viennagrid::distance(line1, line1), 0.0 );

  std::cout << "Distance of line1 to line2... ";
  fuzzy_check( viennagrid::distance(line1, line2), 0.0 );

  std::cout << "Distance of line1 to line3... ";
  fuzzy_check( viennagrid::distance(line1, line3), std::sqrt(6.0) );

  std::cout << "Distance of line1 to line4... ";
  fuzzy_check( viennagrid::distance(line1, line4), std::sqrt(2.0) );

  std::cout << "Distance of line2 to line0... ";
  fuzzy_check( viennagrid::distance(line2, line0), 0.0 );

  std::cout << "Distance of line2 to line1... ";
  fuzzy_check( viennagrid::distance(line2, line1), 0.0 );

  std::cout << "Distance of line2 to line2... ";
  fuzzy_check( viennagrid::distance(line2, line2), 0.0 );

  std::cout << "Distance of line2 to line3... ";
  fuzzy_check( viennagrid::distance(line2, line3),
               height_from_edge_lengths(std::sqrt(6.0), std::sqrt(2.0), viennagrid::volume(line2)) );

  std::cout << "Distance of line2 to line4... ";
  PointType p_24_2 = (1.0 - 3.0/8.0) * viennagrid::point(mesh, viennagrid::elements<viennagrid::vertex_tag>(line2)[0])
                          + 3.0/8.0  * viennagrid::point(mesh, viennagrid::elements<viennagrid::vertex_tag>(line2)[1]);
  PointType p_24_4 = (1.0 - 1.0/4.0) * viennagrid::point(mesh, viennagrid::elements<viennagrid::vertex_tag>(line4)[0])
                          + 1.0/4.0  * viennagrid::point(mesh, viennagrid::elements<viennagrid::vertex_tag>(line4)[1]);
  double dist_24 = viennagrid::distance(p_24_2, p_24_4);
  fuzzy_check( viennagrid::distance(line2, line4), dist_24 );

  std::cout << "Distance of line3 to line0... ";
  fuzzy_check( viennagrid::distance(line3, line0),
               height_from_edge_lengths(std::sqrt(5.0), std::sqrt(9.0), viennagrid::volume(line0)) );

  std::cout << "Distance of line3 to line1... ";
  fuzzy_check( viennagrid::distance(line3, line1), std::sqrt(6.0) );

  std::cout << "Distance of line3 to line2... ";
  fuzzy_check( viennagrid::distance(line3, line2), height_from_edge_lengths(std::sqrt(6.0), std::sqrt(2.0), viennagrid::volume(line2)) );

  std::cout << "Distance of line3 to line3... ";
  fuzzy_check( viennagrid::distance(line3, line3), 0.0 );

  std::cout << "Distance of line3 to line4... ";
  double dist_34 = line_distance_via_cross_prod(mesh, line3, line4);
  fuzzy_check( viennagrid::distance(line3, line4), dist_34 );

  std::cout << "Distance of line4 to line0... ";
  fuzzy_check( viennagrid::distance(line4, line0), dist_04 );

  std::cout << "Distance of line4 to line1... ";
  fuzzy_check( viennagrid::distance(line4, line1), std::sqrt(2.0) );

  std::cout << "Distance of line4 to line2... ";
  fuzzy_check( viennagrid::distance(line4, line2), dist_24 );

  std::cout << "Distance of line4 to line3... ";
  fuzzy_check( viennagrid::distance(line4, line3), dist_34 );

  std::cout << "Distance of line4 to line4... ";
  fuzzy_check( viennagrid::distance(line4, line4), 0.0 );

}

//
// Triangular
//

inline void setup_mesh(viennagrid::triangular_3d_mesh & mesh)
{
  typedef viennagrid::triangular_3d_mesh                      MeshType;
  typedef viennagrid::triangle_tag                                      CellTag;

  typedef viennagrid::result_of::point<MeshType>::type          PointType;

  typedef viennagrid::result_of::handle<MeshType, viennagrid::vertex_tag>::type       VertexHandleType;

  typedef viennagrid::result_of::element<MeshType, CellTag>::type        CellType;

  const size_t s = 4;
  PointType p[s];
  VertexHandleType v[s];

  p[0] = PointType(2.0, 1.0, 2.0);
  p[1] = PointType(3.0, 2.0, 1.0);
  p[2] = PointType(3.0, 3.0, 3.0);
  p[3] = PointType(1.0, 2.0, 1.0);

  //upgrade to vertex:
  std::cout << "Adding vertices to mesh..." << std::endl;
  for (size_t i = 0; i < s; ++i)
  {
    v[i] = viennagrid::make_vertex( mesh, p[i] );
//     viennagrid::point( mesh, v[i] ) = p[i];
  }

  std::cout << "Adding cells to mesh..." << std::endl;
  VertexHandleType vertices[3];

  vertices[0] = v[0];
  vertices[1] = v[2];
  vertices[2] = v[3];
  viennagrid::make_element<CellType>( mesh, vertices, vertices+3 );

  vertices[0] = v[0];
  vertices[1] = v[1];
  vertices[2] = v[2];
  viennagrid::make_element<CellType>( mesh, vertices, vertices+3 );
}

inline void test(viennagrid::triangular_3d_mesh)
{
  typedef viennagrid::triangular_3d_mesh                      Mesh;
  typedef viennagrid::triangle_tag                                      CellTag;

  typedef viennagrid::result_of::point<Mesh>::type                PointType;
  typedef viennagrid::result_of::element<Mesh, viennagrid::vertex_tag>::type             VertexType;
  typedef viennagrid::result_of::element<Mesh, viennagrid::line_tag>::type             EdgeType;
  typedef viennagrid::result_of::element<Mesh, CellTag>::type  CellType;

  Mesh mesh;

  setup_mesh(mesh);

  PointType A(0, 0, 0);
  PointType B(1, 0, 2);
  PointType C(2, 0, 3);
  PointType D(3, 0, 4);
  PointType E(4, 0, 1);

  PointType F(0, 1, 1);
  PointType G(1, 1, 2);
  PointType H(3, 1, 1);
  PointType I(4, 1, 0);

  PointType J(0, 2, 4);
  PointType K(2, 2, 2);
  PointType K2(2, 2, 3);
  PointType L(5, 2, 2);

  PointType M(5, 3, 2);

  PointType N(0, 4, 1);
  PointType O(1, 4, 2);
  PointType P(4, 4, 3);

  PointType Q(2, 5, 2);
  PointType R(3, 5, 1);

  CellType t0 = viennagrid::elements<CellTag>(mesh)[0];
  CellType t1 = viennagrid::elements<CellTag>(mesh)[1];

  //
  // Distance checks for t0
  //
  VertexType const & v0_0 = viennagrid::elements<viennagrid::vertex_tag>(t0)[0];
  VertexType const & v0_1 = viennagrid::elements<viennagrid::vertex_tag>(t0)[1];
  VertexType const & v0_2 = viennagrid::elements<viennagrid::vertex_tag>(t0)[2];

  EdgeType const & e0_0 = viennagrid::elements<viennagrid::line_tag>(t0)[0];
  EdgeType const & e0_1 = viennagrid::elements<viennagrid::line_tag>(t0)[1];
  EdgeType const & e0_2 = viennagrid::elements<viennagrid::line_tag>(t0)[2];

  std::cout << "Distance of point A to triangle t0... ";
  fuzzy_check( viennagrid::distance(A, t0), viennagrid::distance(A, e0_1) );

  std::cout << "Distance of point B to triangle t0... ";
  fuzzy_check( viennagrid::distance(B, t0), viennagrid::distance(B, e0_1) );

  std::cout << "Distance of point C to triangle t0... ";
  fuzzy_check( viennagrid::distance(C, t0), viennagrid::distance(C, v0_0) );

  std::cout << "Distance of point D to triangle t0... ";
  fuzzy_check( viennagrid::distance(D, t0), viennagrid::distance(D, e0_0) );

  std::cout << "Distance of point E to triangle t0... ";
  fuzzy_check( viennagrid::distance(E, t0), viennagrid::distance(E, e0_0) );

  std::cout << "Distance of point F to triangle t0... ";
  fuzzy_check( viennagrid::distance(F, t0), viennagrid::distance(F, e0_1) );

  std::cout << "Distance of point G to triangle t0... ";
  fuzzy_check( viennagrid::distance(G, t0), viennagrid::distance(G, e0_1) );

  std::cout << "Distance of point H to triangle t0... ";
  fuzzy_check( viennagrid::distance(H, t0), viennagrid::distance(H, e0_0) );

  std::cout << "Distance of point I to triangle t0... ";
  fuzzy_check( viennagrid::distance(I, t0), viennagrid::distance(I, e0_0) );

  std::cout << "Distance of point J to triangle t0... ";
  fuzzy_check( viennagrid::distance(J, t0), height_for_tetrahedron(viennagrid::point(mesh, v0_0), viennagrid::point(mesh, v0_1), viennagrid::point(mesh, v0_2), J) );

  std::cout << "Distance of point K to triangle t0... ";
  fuzzy_check( viennagrid::distance(K, t0), 0.0 );

  std::cout << "Distance of point K2 to triangle t0... ";
  fuzzy_check( viennagrid::distance(K2, t0), height_for_tetrahedron(viennagrid::point(mesh, v0_0), viennagrid::point(mesh, v0_1), viennagrid::point(mesh, v0_2), K2) );

  std::cout << "Distance of point L to triangle t0... ";
  fuzzy_check( viennagrid::distance(L, t0), viennagrid::distance(L, e0_0) );

  std::cout << "Distance of point M to triangle t0... ";
  fuzzy_check( viennagrid::distance(M, t0), viennagrid::distance(M, v0_1) );

  std::cout << "Distance of point N to triangle t0... ";
  fuzzy_check( viennagrid::distance(N, t0), viennagrid::distance(N, e0_2) );

  std::cout << "Distance of point O to triangle t0... ";
  fuzzy_check( viennagrid::distance(O, t0), viennagrid::distance(O, e0_2) );

  std::cout << "Distance of point P to triangle t0... ";
  fuzzy_check( viennagrid::distance(P, t0), viennagrid::distance(P, v0_1) );

  std::cout << "Distance of point Q to triangle t0... ";
  fuzzy_check( viennagrid::distance(Q, t0), viennagrid::distance(Q, e0_2) );

  std::cout << "Distance of point R to triangle t0... ";
  fuzzy_check( viennagrid::distance(t0, R), viennagrid::distance(R, e0_2) );

  std::cout << std::endl;

  //
  // Distance checks for t1
  //
  VertexType const & v1_0 = viennagrid::elements<viennagrid::vertex_tag>(t1)[0];
  VertexType const & v1_1 = viennagrid::elements<viennagrid::vertex_tag>(t1)[1];
  VertexType const & v1_2 = viennagrid::elements<viennagrid::vertex_tag>(t1)[2];

  EdgeType const & e1_0 = viennagrid::elements<viennagrid::line_tag>(t1)[0];
  EdgeType const & e1_1 = viennagrid::elements<viennagrid::line_tag>(t1)[1];
  EdgeType const & e1_2 = viennagrid::elements<viennagrid::line_tag>(t1)[2];

  std::cout << "Distance of point A to triangle t1... ";
  fuzzy_check( viennagrid::distance(A, t1), viennagrid::distance(A, v1_0) );

  std::cout << "Distance of point B to triangle t1... ";
  fuzzy_check( viennagrid::distance(B, t1), viennagrid::distance(B, v1_0) );

  std::cout << "Distance of point C to triangle t1... ";
  fuzzy_check( viennagrid::distance(C, t1), viennagrid::distance(C, v1_0) );

  std::cout << "Distance of point D to triangle t1... ";
  fuzzy_check( viennagrid::distance(D, t1), viennagrid::distance(D, e1_1) );

  std::cout << "Distance of point E to triangle t1... ";
  fuzzy_check( viennagrid::distance(E, t1), viennagrid::distance(E, e1_0) );

  std::cout << "Distance of point F to triangle t1... ";
  fuzzy_check( viennagrid::distance(F, t1), viennagrid::distance(F, v1_0) );

  std::cout << "Distance of point G to triangle t1... ";
  fuzzy_check( viennagrid::distance(G, t1), viennagrid::distance(G, v1_0) );

  std::cout << "Distance of point H to triangle t1... ";
  fuzzy_check( viennagrid::distance(H, t1), viennagrid::distance(H, e1_0) );

  std::cout << "Distance of point I to triangle t1... ";
  fuzzy_check( viennagrid::distance(I, t1), viennagrid::distance(I, e1_0) );

  std::cout << "Distance of point J to triangle t1... ";
  fuzzy_check( viennagrid::distance(J, t1), viennagrid::distance(J, e1_1) );

  std::cout << "Distance of point K to triangle t1... ";
  fuzzy_check( viennagrid::distance(K, t1), height_for_tetrahedron(viennagrid::point(mesh, v1_0), viennagrid::point(mesh, v1_1), viennagrid::point(mesh, v1_2), K) );

  std::cout << "Distance of point K2 to triangle t1... ";
  fuzzy_check( viennagrid::distance(K2, t1), viennagrid::distance(K2, e1_1) );

  std::cout << "Distance of point L to triangle t1... ";
  fuzzy_check( viennagrid::distance(L, t1), viennagrid::distance(L, e1_2) );

  std::cout << "Distance of point M to triangle t1... ";
  fuzzy_check( viennagrid::distance(M, t1), viennagrid::distance(M, e1_2) );

  std::cout << "Distance of point N to triangle t1... ";
  fuzzy_check( viennagrid::distance(N, t1), height_for_tetrahedron(viennagrid::point(mesh, v1_0), viennagrid::point(mesh, v1_1), viennagrid::point(mesh, v1_2), N) );

  std::cout << "Distance of point O to triangle t1... ";
  fuzzy_check( viennagrid::distance(O, t1), height_for_tetrahedron(viennagrid::point(mesh, v1_0), viennagrid::point(mesh, v1_1), viennagrid::point(mesh, v1_2), O) );

  std::cout << "Distance of point P to triangle t1... ";
  fuzzy_check( viennagrid::distance(P, t1), viennagrid::distance(P, v1_2) );

  std::cout << "Distance of point Q to triangle t1... ";
  fuzzy_check( viennagrid::distance(Q, t1), viennagrid::distance(Q, e1_1) );

  std::cout << "Distance of point R to triangle t1... ";
  fuzzy_check( viennagrid::distance(R, t1), viennagrid::distance(R, e1_2) );

}

//
// Quadrilateral
//

inline void setup_mesh(viennagrid::quadrilateral_3d_mesh & mesh)
{
  typedef viennagrid::quadrilateral_3d_mesh                  MeshType;
  typedef viennagrid::quadrilateral_tag                                CellTag;

  typedef viennagrid::result_of::point<MeshType>::type          PointType;
  typedef viennagrid::result_of::handle<MeshType, viennagrid::vertex_tag>::type       VertexHandleType;
  typedef viennagrid::result_of::element<MeshType, CellTag>::type        CellType;

  const size_t s = 4;
  PointType p[s];
  VertexHandleType v[s];

  p[0] = PointType(2.0, 1.0, 2.0);
  p[1] = PointType(3.0, 2.0, 1.0);
  p[2] = PointType(1.0, 2.0, 1.0);
  p[3] = PointType(3.0, 3.0, 3.0);

  //upgrade to vertex:
  std::cout << "Adding vertices to mesh..." << std::endl;
  for (size_t i = 0; i < s; ++i)
  {
    v[i] = viennagrid::make_vertex( mesh,p[i] );
//     viennagrid::point( mesh, v[i] ) = p[i];
  }

  std::cout << "Adding cells to mesh..." << std::endl;
  viennagrid::make_element<CellType>( mesh, v, v+4 );
}

inline void test(viennagrid::quadrilateral_3d_mesh)
{
  typedef viennagrid::quadrilateral_3d_mesh                            Mesh;
  typedef viennagrid::quadrilateral_tag                                          CellTag;

  typedef viennagrid::result_of::point<Mesh>::type                PointType;
  typedef viennagrid::result_of::element<Mesh, viennagrid::vertex_tag>::type             VertexType;
  typedef viennagrid::result_of::element<Mesh, viennagrid::line_tag>::type             EdgeType;
  typedef viennagrid::result_of::element<Mesh, CellTag>::type  CellType;

  Mesh mesh;

  setup_mesh(mesh);

  PointType A(0, 0, 0);
  PointType B(1, 0, 2);
  PointType C(2, 0, 3);
  PointType D(3, 0, 4);
  PointType E(4, 0, 1);

  PointType F(0, 1, 1);
  PointType G(1, 1, 2);
  PointType H(3, 1, 1);
  PointType I(4, 1, 0);

  PointType J(0, 2, 4);
  PointType K(2, 2, 1);
  PointType K2(2, 2, 2);
  PointType L(5, 2, 2);

  PointType M(5, 3, 2);

  PointType N(0, 4, 1);
  PointType O(1, 4, 2);
  PointType P(4, 4, 3);

  PointType Q(2, 5, 2);
  PointType R(3, 5, 1);

  CellType & quad = viennagrid::elements<CellTag>(mesh)[0];

  //
  // Distance checks for quadrilateral
  //

  VertexType & v0 = viennagrid::elements<viennagrid::vertex_tag>(quad)[0];
  VertexType & v1 = viennagrid::elements<viennagrid::vertex_tag>(quad)[1];
  VertexType & v2 = viennagrid::elements<viennagrid::vertex_tag>(quad)[2];
  VertexType & v3 = viennagrid::elements<viennagrid::vertex_tag>(quad)[3];

  EdgeType const & e0 = viennagrid::elements<viennagrid::line_tag>(quad)[0];
  EdgeType const & e1 = viennagrid::elements<viennagrid::line_tag>(quad)[1];
  EdgeType const & e2 = viennagrid::elements<viennagrid::line_tag>(quad)[2];
  EdgeType const & e3 = viennagrid::elements<viennagrid::line_tag>(quad)[3];

//   EdgeType e_diag;
//   VertexType * diag_vertices[2];
//   diag_vertices[0] = &v1;
//   diag_vertices[1] = &v2;
//   e_diag.vertices(diag_vertices);

  std::cout << "Distance of point A to quadrilateral... ";
  fuzzy_check( viennagrid::distance(A, quad), viennagrid::distance(A, e1) );

  std::cout << "Distance of point B to quadrilateral... ";
  fuzzy_check( viennagrid::distance(B, quad), viennagrid::distance(e1, B) );

  std::cout << "Distance of point C to quadrilateral... ";
  fuzzy_check( viennagrid::distance(C, quad), viennagrid::distance(v0, C) );

  std::cout << "Distance of point D to quadrilateral... ";
  fuzzy_check( viennagrid::distance(D, quad), viennagrid::distance(D, e0) );

  std::cout << "Distance of point E to quadrilateral... ";
  fuzzy_check( viennagrid::distance(E, quad), viennagrid::distance(E, e0) );

  std::cout << "Distance of point F to quadrilateral... ";
  fuzzy_check( viennagrid::distance(F, quad), viennagrid::distance(F, e1) );

  std::cout << "Distance of point G to quadrilateral... ";
  fuzzy_check( viennagrid::distance(G, quad), viennagrid::distance(G, e1) );

  std::cout << "Distance of point H to quadrilateral... ";
  fuzzy_check( viennagrid::distance(H, quad), viennagrid::distance(H, e0) );

  std::cout << "Distance of point I to quadrilateral... ";
  fuzzy_check( viennagrid::distance(I, quad), viennagrid::distance(I, e0) );

  std::cout << "Distance of point J to quadrilateral... ";
  //fuzzy_check( viennagrid::distance(J, quad), height_for_tetrahedron(v0.point(), v1.point(), v2.point(), J) );
  fuzzy_check( viennagrid::distance(J, quad), viennagrid::distance(J, e3) );
  //fuzzy_check( viennagrid::distance(J, quad), height_for_tetrahedron(v0.point(), v1.point(), v2.point(), J) );

  std::cout << "Distance of point K to quadrilateral... ";
  fuzzy_check( viennagrid::distance(K, quad), 0.0 );

  std::cout << "Distance of point K2 to quadrilateral... ";
  fuzzy_check( viennagrid::distance(quad, K2), height_for_tetrahedron(viennagrid::point(mesh, v1), viennagrid::point(mesh, v3), viennagrid::point(mesh, v2), K2) );

  std::cout << "Distance of point L to quadrilateral... ";
  fuzzy_check( viennagrid::distance(L, quad), viennagrid::distance(L, e2) );

  std::cout << "Distance of point M to quadrilateral... ";
  fuzzy_check( viennagrid::distance(M, quad), viennagrid::distance(M, e2) );

  std::cout << "Distance of point N to quadrilateral... ";
  fuzzy_check( viennagrid::distance(N, quad), viennagrid::distance(N, e3) );

  std::cout << "Distance of point O to quadrilateral... ";
  fuzzy_check( viennagrid::distance(O, quad), viennagrid::distance(O, e3) );

  std::cout << "Distance of point P to quadrilateral... ";
  fuzzy_check( viennagrid::distance(P, quad), viennagrid::distance(P, v3) );

  std::cout << "Distance of point Q to quadrilateral... ";
  fuzzy_check( viennagrid::distance(Q, quad), viennagrid::distance(Q, e3) );

  std::cout << "Distance of point R to quadrilateral... ";
  fuzzy_check( viennagrid::distance(R, quad), height_for_tetrahedron(viennagrid::point(mesh, v1), viennagrid::point(mesh, v3), viennagrid::point(mesh, v2), R) );
}

//
// Tetrahedron
//

inline void setup_mesh(viennagrid::tetrahedral_3d_mesh & mesh)
{
  typedef viennagrid::tetrahedral_3d_mesh                      MeshType;
  typedef viennagrid::tetrahedron_tag                                    CellTag;

  typedef viennagrid::result_of::point<MeshType>::type          PointType;
  typedef viennagrid::result_of::handle<MeshType, viennagrid::vertex_tag>::type       VertexHandleType;

  typedef viennagrid::result_of::element<MeshType, CellTag>::type        CellType;

  const size_t s = 4;
  PointType p[s];
  VertexHandleType v[s];

  p[0] = PointType(2.0, 1.0, 1.0);
  p[1] = PointType(3.0, 3.0, 3.0);
  p[2] = PointType(1.0, 2.0, 2.0);
  p[3] = PointType(2.0, 2.0, 4.0);

  //upgrade to vertex:
  std::cout << "Adding vertices to mesh..." << std::endl;
  for (size_t i = 0; i < s; ++i)
  {
    v[i] = viennagrid::make_vertex( mesh, p[i] );
//     viennagrid::point( mesh, v[i] ) = p[i];
  }

  std::cout << "Adding cells to mesh..." << std::endl;
  viennagrid::make_element<CellType>( mesh, v, v+4 );
}

inline void test(viennagrid::tetrahedral_3d_mesh)
{
  typedef viennagrid::tetrahedral_3d_mesh                            Mesh;
  typedef viennagrid::tetrahedron_tag                                          CellTag;

  typedef viennagrid::result_of::point<Mesh>::type                PointType;
  typedef viennagrid::result_of::element<Mesh, viennagrid::vertex_tag>::type             VertexType;
  typedef viennagrid::result_of::element<Mesh, viennagrid::line_tag>::type             EdgeType;
  typedef viennagrid::result_of::element<Mesh, CellTag>::type  CellType;
  typedef viennagrid::result_of::facet_tag<CellType>::type FacetTag;
  typedef viennagrid::result_of::facet<CellType>::type    FacetType;

  Mesh mesh;

  setup_mesh(mesh);

  PointType A(2.0, 0.0, 1.0);  // v0 is closest
  PointType B(6.0, 4.0, 2.0);  // v1 is closest
  PointType C(0.0, 2.1, 1.8);  // v2 is closest
  PointType D(2.3, 1.8, 6.0);  // v3 is closest

  PointType E(3.0, 2.5, 2.3);   // e0 is closest
  PointType F(1.0, 1.0, 1.0);   // e1 is closest
  PointType G(2.1, 0.1, 3.1);   // e2 is closest
  PointType H(1.8, 3.9, 2.1);   // e3 is closest
  PointType I(3.1, 2.9, 3.8);   // e4 is closest
  PointType J(1.2, 1.8, 2.9);   // e5 is closest

  PointType K(2.5, 2.2, 1.5);   // f0 is closest
  PointType L(3.1, 2.1, 3.1);   // f1 is closest
  PointType M(1.2, 1.3, 3.5);   // f2 is closest
  PointType N(2.2, 3.5, 3.3);   // f3 is closest

  PointType O(1.9, 2.1, 3.1);   // inside tet
  PointType P(2.2, 2.5, 2.9);   // inside tet

  CellType & tet = viennagrid::elements<CellTag>(mesh)[0];

  //
  // Distance checks for quadrilateral
  //

  VertexType & v0 = viennagrid::elements<viennagrid::vertex_tag>(tet)[0];
  VertexType & v1 = viennagrid::elements<viennagrid::vertex_tag>(tet)[1];
  VertexType & v2 = viennagrid::elements<viennagrid::vertex_tag>(tet)[2];
  VertexType & v3 = viennagrid::elements<viennagrid::vertex_tag>(tet)[3];

  EdgeType const & e0 = viennagrid::elements<viennagrid::line_tag>(tet)[0];
  EdgeType const & e1 = viennagrid::elements<viennagrid::line_tag>(tet)[1];
  EdgeType const & e2 = viennagrid::elements<viennagrid::line_tag>(tet)[2];
  EdgeType const & e3 = viennagrid::elements<viennagrid::line_tag>(tet)[3];
  EdgeType const & e4 = viennagrid::elements<viennagrid::line_tag>(tet)[4];
  EdgeType const & e5 = viennagrid::elements<viennagrid::line_tag>(tet)[5];

  FacetType const & f0 = viennagrid::elements<FacetTag>(tet)[0];
  FacetType const & f1 = viennagrid::elements<FacetTag>(tet)[1];
  FacetType const & f2 = viennagrid::elements<FacetTag>(tet)[2];
  FacetType const & f3 = viennagrid::elements<FacetTag>(tet)[3];

  // vertices

  std::cout << "Distance of point A to tetrahedron... ";
  fuzzy_check( viennagrid::distance(A, tet), viennagrid::distance(A, v0) );

  std::cout << "Distance of point B to tetrahedron... ";
  fuzzy_check( viennagrid::distance(B, tet), viennagrid::distance(v1, B) );

  std::cout << "Distance of point C to tetrahedron... ";
  fuzzy_check( viennagrid::distance(C, tet), viennagrid::distance(C, v2) );

  std::cout << "Distance of point D to tetrahedron... ";
  fuzzy_check( viennagrid::distance(D, tet), viennagrid::distance(D, v3) );

  // edges

  std::cout << "Distance of point E to tetrahedron... ";
  fuzzy_check( viennagrid::distance(E, tet), viennagrid::distance(E, e0) );

  std::cout << "Distance of point F to tetrahedron... ";
  fuzzy_check( viennagrid::distance(F, tet), viennagrid::distance(e1, F) );

  std::cout << "Distance of point G to tetrahedron... ";
  fuzzy_check( viennagrid::distance(G, tet), viennagrid::distance(G, e2) );

  std::cout << "Distance of point H to tetrahedron... ";
  fuzzy_check( viennagrid::distance(H, tet), viennagrid::distance(H, e3) );

  std::cout << "Distance of point I to tetrahedron... ";
  fuzzy_check( viennagrid::distance(I, tet), viennagrid::distance(I, e4) );

  std::cout << "Distance of point J to tetrahedron... ";
  fuzzy_check( viennagrid::distance(J, tet), viennagrid::distance(J, e5) );

  //facets

  std::cout << "Distance of point K to tetrahedron... ";
  fuzzy_check( viennagrid::distance(K, tet), viennagrid::distance(K, f0) );

  std::cout << "Distance of point L to tetrahedron... ";
  fuzzy_check( viennagrid::distance(L, tet), viennagrid::distance(L, f1) );

  std::cout << "Distance of point M to tetrahedron... ";
  fuzzy_check( viennagrid::distance(M, tet), viennagrid::distance(f2, M) );

  std::cout << "Distance of point N to tetrahedron... ";
  fuzzy_check( viennagrid::distance(N, tet), viennagrid::distance(N, f3) );

  // inside

  std::cout << "Distance of point O to tetrahedron... ";
  fuzzy_check( viennagrid::distance(O, tet), 0.0 );

  std::cout << "Distance of point P to tetrahedron... ";
  fuzzy_check( viennagrid::distance(P, tet), 0.0 );

}

//
// Quadrilateral
//

inline void setup_mesh(viennagrid::hexahedral_3d_mesh & mesh)
{
  typedef viennagrid::hexahedral_3d_mesh                      MeshType;
  typedef viennagrid::hexahedron_tag                                    CellTag;

  typedef viennagrid::result_of::point<MeshType>::type          PointType;
  typedef viennagrid::result_of::handle<MeshType, viennagrid::vertex_tag>::type       VertexHandleType;

  typedef viennagrid::result_of::element<MeshType, CellTag>::type        CellType;

  const size_t s = 8;
  PointType p[s];
  VertexHandleType v[s];

  p[0] = PointType(1.0, 1.0, 1.0);
  p[1] = PointType(2.0, 0.9, 0.5);
  p[2] = PointType(0.9, 2.1, 0.8);
  p[3] = PointType(2.1, 2.0, 0.9);

  p[4] = PointType(0.9, 0.9, 2.1);
  p[5] = PointType(2.1, 1.0, 2.3);
  p[6] = PointType(1.0, 2.0, 2.2);
  p[7] = PointType(2.0, 2.1, 2.0);

  //upgrade to vertex:
  std::cout << "Adding vertices to mesh..." << std::endl;
  for (size_t i = 0; i < s; ++i)
  {
    v[i] = viennagrid::make_vertex( mesh, p[i] );
//     viennagrid::point( mesh, v[i] ) = p[i];
  }

  std::cout << "Adding cells to mesh..." << std::endl;
  viennagrid::make_element<CellType>( mesh, v, v+8 );
}

inline void test(viennagrid::hexahedral_3d_mesh)
{
  typedef viennagrid::hexahedral_3d_mesh                            Mesh;
  typedef viennagrid::hexahedron_tag                                          CellTag;

  typedef viennagrid::result_of::point<Mesh>::type                PointType;
  typedef viennagrid::result_of::element<Mesh, CellTag>::type  CellType;

  Mesh mesh;

  setup_mesh(mesh);

/*  PointType A(0, 0, 0);
  PointType B(1, 0, 2);
  PointType C(2, 0, 3);
  PointType D(3, 0, 4);
  PointType E(4, 0, 1);

  PointType F(0, 1, 1);
  PointType G(1, 1, 2);
  PointType H(3, 1, 1);
  PointType I(4, 1, 0);

  PointType J(0, 2, 4);
  PointType K(2, 2, 1);
  PointType K2(2, 2, 2);
  PointType L(5, 2, 2);

  PointType M(5, 3, 2);

  PointType N(0, 4, 1);
  PointType O(1, 4, 2);
  PointType P(4, 4, 3);

  PointType Q(2, 5, 2);
  PointType R(3, 5, 1); */

  CellType & hex = viennagrid::elements<CellTag>(mesh)[0];

  std::cout << "Checking a bunch of points in interior for distance 0... ";
  for (std::size_t i=0; i<=10; ++i)
  {
    for (std::size_t j=0; j<=10; ++j)
    {
      for (std::size_t k=0; k<=10; ++k)
      {
        PointType p(1.0 + i / 10.0, 1.0 + j / 10.0, 1.0 + k / 10.0);
        fuzzy_check( viennagrid::distance(p, hex), 0.0 );
      }
    }
  }

  //
  // Distance checks for hexahedral
  //

  // To come...

/*  VertexType & v0 = viennagrid::elements<viennagrid::vertex_tag>(quad)[0];
  VertexType & v1 = viennagrid::elements<viennagrid::vertex_tag>(quad)[1];
  VertexType & v2 = viennagrid::elements<viennagrid::vertex_tag>(quad)[2];
  VertexType & v3 = viennagrid::elements<viennagrid::vertex_tag>(quad)[3];

  EdgeType const & e0 = viennagrid::elements<viennagrid::line_tag>(quad)[0];
  EdgeType const & e1 = viennagrid::elements<viennagrid::line_tag>(quad)[1];
  EdgeType const & e2 = viennagrid::elements<viennagrid::line_tag>(quad)[2];
  EdgeType const & e3 = viennagrid::elements<viennagrid::line_tag>(quad)[3];

  EdgeType e_diag;
  VertexType * diag_vertices[2];
  diag_vertices[0] = &v1;
  diag_vertices[1] = &v2;
  e_diag.vertices(diag_vertices);

  std::cout << "Distance of point A to quadrilateral... ";
  fuzzy_check( viennagrid::distance(A, quad), viennagrid::distance(A, e1) );

  std::cout << "Distance of point B to quadrilateral... ";
  fuzzy_check( viennagrid::distance(B, quad), viennagrid::distance(e1, B) );

  std::cout << "Distance of point C to quadrilateral... ";
  fuzzy_check( viennagrid::distance(C, quad), viennagrid::distance(v0, C) );

  std::cout << "Distance of point D to quadrilateral... ";
  fuzzy_check( viennagrid::distance(D, quad), viennagrid::distance(D, e0) );

  std::cout << "Distance of point E to quadrilateral... ";
  fuzzy_check( viennagrid::distance(E, quad), viennagrid::distance(E, e0) );

  std::cout << "Distance of point F to quadrilateral... ";
  fuzzy_check( viennagrid::distance(F, quad), viennagrid::distance(F, e1) );

  std::cout << "Distance of point G to quadrilateral... ";
  fuzzy_check( viennagrid::distance(G, quad), viennagrid::distance(G, e1) );

  std::cout << "Distance of point H to quadrilateral... ";
  fuzzy_check( viennagrid::distance(H, quad), viennagrid::distance(H, e0) );

  std::cout << "Distance of point I to quadrilateral... ";
  fuzzy_check( viennagrid::distance(I, quad), viennagrid::distance(I, e0) );

  std::cout << "Distance of point J to quadrilateral... ";
  //fuzzy_check( viennagrid::distance(J, quad), height_for_tetrahedron(v0.point(), v1.point(), v2.point(), J) );
  fuzzy_check( viennagrid::distance(J, quad), viennagrid::distance(J, e3) );
  //fuzzy_check( viennagrid::distance(J, quad), height_for_tetrahedron(v0.point(), v1.point(), v2.point(), J) );

  std::cout << "Distance of point K to quadrilateral... ";
  fuzzy_check( viennagrid::distance(K, quad), 0.0 );

  std::cout << "Distance of point K2 to quadrilateral... ";
  fuzzy_check( viennagrid::distance(quad, K2), height_for_tetrahedron(v1.point(), v3.point(), v2.point(), K2) );

  std::cout << "Distance of point L to quadrilateral... ";
  fuzzy_check( viennagrid::distance(L, quad), viennagrid::distance(L, e2) );

  std::cout << "Distance of point M to quadrilateral... ";
  fuzzy_check( viennagrid::distance(M, quad), viennagrid::distance(M, e2) );

  std::cout << "Distance of point N to quadrilateral... ";
  fuzzy_check( viennagrid::distance(N, quad), viennagrid::distance(N, e3) );

  std::cout << "Distance of point O to quadrilateral... ";
  fuzzy_check( viennagrid::distance(O, quad), viennagrid::distance(O, e3) );

  std::cout << "Distance of point P to quadrilateral... ";
  fuzzy_check( viennagrid::distance(P, quad), viennagrid::distance(P, v3) );

  std::cout << "Distance of point Q to quadrilateral... ";
  fuzzy_check( viennagrid::distance(Q, quad), viennagrid::distance(Q, e3) );

  std::cout << "Distance of point R to quadrilateral... ";
  fuzzy_check( viennagrid::distance(R, quad), height_for_tetrahedron(v1.point(), v3.point(), v2.point(), R) );
  */
}

int main()
{
  std::cout << "*****************" << std::endl;
  std::cout << "* Test started! *" << std::endl;
  std::cout << "*****************" << std::endl;

  std::cout << "==== Testing line mesh in 3D ====" << std::endl;
  test(viennagrid::line_3d_mesh());

  std::cout << "==== Testing triangular mesh in 3D ====" << std::endl;
  test(viennagrid::triangular_3d_mesh());

  std::cout << "==== Testing quadrilateral mesh in 3D ====" << std::endl;
  test(viennagrid::quadrilateral_3d_mesh());

  std::cout << "==== Testing tetrahedral mesh in 3D ====" << std::endl;
  test(viennagrid::tetrahedral_3d_mesh());

  std::cout << "==== Testing hexahedral mesh in 3D ====" << std::endl;
  test(viennagrid::hexahedral_3d_mesh());

  std::cout << "*******************************" << std::endl;
  std::cout << "* Test finished successfully! *" << std::endl;
  std::cout << "*******************************" << std::endl;

  return EXIT_SUCCESS;
}


text:
namespace net.openstack.Providers.Rackspace.Objects.Request
{
    using Newtonsoft.Json;

    /// <summary>
    /// This models the JSON request used for the Revert Resized Server request.
    /// </summary>
    /// <seealso href="http://docs.openstack.org/api/openstack-compute/2/content/Revert_Resized_Server-d1e4024.html">Revert Resized Server (OpenStack Compute API v2 and Extensions Reference)</seealso>
    /// <threadsafety static="true" instance="false"/>
    [JsonObject(MemberSerialization.OptIn)]
    internal class RevertServerResizeRequest
    {
#pragma warning disable 414 // The field 'fieldName' is assigned but its value is never used
        [JsonProperty("revertResize")]
        private string _command = "none";
#pragma warning restore 414
    }
}

redpajama_set_name: RedPajamaGithub


text:
    <title>Magic, the Gathering. Comprehensive Rules</title>
    <link type="text/css" rel="stylesheet" media="all" href="stylesheet.css" />

Magic, the Gathering. Comprehensive Rules


text:
#include <carl_demos/sequential_tasks.h>

using namespace std;

SequentialTasks::SequentialTasks() :
    armClient("carl_moveit_wrapper/common_actions/arm_action"),
    armHomeClient("jaco_arm/home_arm"),
    obtainObjectClient("carl_demos/obtain_object"),
    moveCarlClient("move_carl")
{
  lookAtFrameClient = n.serviceClient<carl_dynamixel::LookAtFrame>("/asus_controller/look_at_frame");

  ROS_INFO("Waiting for action servers...");
  armClient.waitForServer();
  obtainObjectClient.waitForServer();
  moveCarlClient.waitForServer();
  armHomeClient.waitForServer();
  ROS_INFO("Initialized.");
}

void SequentialTasks::makeFruitBasket()
{
  ROS_INFO("*************************************************");
  ROS_INFO("Apple");
  ROS_INFO("*************************************************");
  obtainObject(-1, "apple", "kitchen_table_surface_link");

  ROS_INFO("*************************************************");
  ROS_INFO("Orange");
  ROS_INFO("*************************************************");
  obtainObject(-1, "orange", "kitchen_table_surface_link");

  ROS_INFO("*************************************************");
  ROS_INFO("Banana");
  ROS_INFO("*************************************************");
  obtainObject(-1, "banana", "kitchen_table_surface_link");
}

void SequentialTasks::packSchoolBag()
{
  /*
  //notebook
  obtainObject(carl_navigation::MoveCarlGoal::COFFEE_TABLE, "notebook", "coffee_table_surface_link");

  //look for glue
  checkSurface(carl_navigation::MoveCarlGoal::KITCHEN_TABLE, "kitchen_table_surface_link");

  //get feedback
  carl_navigation::MoveCarlGoal moveGoal;
  moveGoal.location = carl_navigation::MoveCarlGoal::INTERACTION_2;
  moveCarlClient.sendGoal(moveGoal);
  moveCarlClient.waitForResult(ros::Duration(60.0));
  //look at chair
  carl_dynamixel::LookAtFrame lookSrv;
  lookSrv.request.frame = "lazy_chair_2_surface_link";
  if (!lookAtFrameClient.call(lookSrv))
  {
    ROS_INFO("Could not call look at frame client!");
    return;
  }
  */

  //tape
  obtainObject(carl_navigation::MoveCarlGoal::KITCHEN_TABLE, "tape", "kitchen_table_surface_link");

  //look for pencil
  checkSurface(carl_navigation::MoveCarlGoal::COFFEE_TABLE, "coffee_table_surface_link");

  //get feedback
  carl_navigation::MoveCarlGoal moveGoal;
  moveGoal.location = carl_navigation::MoveCarlGoal::INTERACTION_1;
  moveCarlClient.sendGoal(moveGoal);
  moveCarlClient.waitForResult(ros::Duration(60.0));
  //look at chair
  carl_dynamixel::LookAtFrame lookSrv;
  lookSrv.request.frame = "lazy_chair_2_surface_link";
  if (!lookAtFrameClient.call(lookSrv))
  {
    ROS_INFO("Could not call look at frame client!");
    return;
  }

  /*
  //pens
  obtainObject(carl_navigation::MoveCarlGoal::COFFEE_TABLE, "pens", "coffee_table_surface_link");

  //ruler
  obtainObject(carl_navigation::MoveCarlGoal::KITCHEN_TABLE, "ruler", "kitchen_table_surface_link");

  //scissors
  obtainObject(carl_navigation::MoveCarlGoal::KITCHEN_TABLE, "scissors", "kitchen_table_surface_link");

  //look for apple
  checkSurface(carl_navigation::MoveCarlGoal::FRIDGE, "kitchen_counter_right_surface_link");

  //get feedback
  carl_navigation::MoveCarlGoal moveGoal;
  moveGoal.location = carl_navigation::MoveCarlGoal::INTERACTION_2;
  moveCarlClient.sendGoal(moveGoal);
  moveCarlClient.waitForResult(ros::Duration(60.0));
  //look at chair
  carl_dynamixel::LookAtFrame lookSrv;
  lookSrv.request.frame = "lazy_chair_2_surface_link";
  if (!lookAtFrameClient.call(lookSrv))
  {
    ROS_INFO("Could not call look at frame client!");
    return;
  }
  */

  /*
  //orange
  obtainObject(carl_navigation::MoveCarlGoal::FRIDGE, "kitchen_counter_right_surface_link");

  //return bag
  carl_navigation::MoveCarlGoal moveGoal;
  moveGoal.location = carl_navigation::MoveCarlGoal::INTERACTION_2;
  moveCarlClient.sendGoal(moveGoal);
  moveCarlClient.waitForResult(ros::Duration(60.0));
  */

  ROS_INFO("Finished.");
}

void SequentialTasks::checkSurface(int location, std::string surfaceLink)
{
  ROS_INFO("Navigating to new location...");
  //navigate to given location
  carl_navigation::MoveCarlGoal moveGoal;
  moveGoal.location = location;
  moveCarlClient.sendGoal(moveGoal);
  moveCarlClient.waitForResult(ros::Duration(60.0));
  ROS_INFO("Navigation complete.");

  ROS_INFO("Looking at surface...");
  //look at surface
  carl_dynamixel::LookAtFrame lookSrv;
  lookSrv.request.frame = surfaceLink;
  if (!lookAtFrameClient.call(lookSrv))
  {
    ROS_INFO("Could not call look at frame client!");
    return;
  }
  ROS_INFO("Looking at surface complete.");

  ROS_INFO("Retracting arm...");
  //retract arm
  rail_manipulation_msgs::ArmGoal retractGoal;
  retractGoal.action = rail_manipulation_msgs::ArmGoal::RETRACT;
  armClient.sendGoal(retractGoal);
  armClient.waitForResult(ros::Duration(20.0));
  bool success = armClient.getResult()->success;
  if (!success)
  {
    ROS_INFO("Could not ready arm after storing object.");
    return;
  }
  ROS_INFO("Arm ready.");

  ros::Duration(5.0).sleep();
}

void SequentialTasks::obtainObject(int location, string object, string surfaceLink)
{
  if (location != -1)
  {
    ROS_INFO("Navigating to new location...");
    //navigate to given location
    carl_navigation::MoveCarlGoal moveGoal;
    moveGoal.location = location;
    moveCarlClient.sendGoal(moveGoal);
    moveCarlClient.waitForResult(ros::Duration(60.0));
    ROS_INFO("Navigation complete.");

    ROS_INFO("Looking at surface...");
    //look at surface
    carl_dynamixel::LookAtFrame lookSrv;
    lookSrv.request.frame = surfaceLink;
    if (!lookAtFrameClient.call(lookSrv)) {
      ROS_INFO("Could not call look at frame client!");
      return;
    }
    ROS_INFO("Looking at surface complete.");
  }

  ROS_INFO("Obtaining object...");
  //obtain given object
  carl_demos::ObtainObjectGoal obtainGoal;
  obtainGoal.lift = true;
  obtainGoal.verify = false;
  obtainGoal.object_name = object;
  obtainObjectClient.sendGoal(obtainGoal);
  obtainObjectClient.waitForResult(ros::Duration(60.0));
  carl_demos::ObtainObjectResultConstPtr obtainResult = obtainObjectClient.getResult();
  if (!obtainResult->success)
  {
    ROS_INFO("Failed to obtain requested object.");
    return;
  }
  ROS_INFO("Object obtained.");

  ROS_INFO("Homing arm...");
  //ready arm
  wpi_jaco_msgs::HomeArmGoal homeGoal;
  homeGoal.retract = false;
  armHomeClient.sendGoal(homeGoal);
  armHomeClient.waitForResult(ros::Duration(20.0));
  bool success = armHomeClient.getResult()->success;
  if (!success)
  {
    ROS_INFO("Could not ready arm after storing object.");
    return;
  }
  ROS_INFO("Arm ready.");
}

int main(int argc, char **argv)
{
  ros::init(argc, argv, "sequential_tasks");

  SequentialTasks st;

  st.makeFruitBasket();

  ROS_INFO("Action teminated.");

  return EXIT_SUCCESS;
}


text:
package com.themillhousegroup.arallon

import org.specs2.mutable.Specification
import org.specs2.mock._
import scala.concurrent.Future
import scala.concurrent.Await
import scala.concurrent.duration.Duration
import org.joda.time.{ DateTimeZone, DateTime }
import com.typesafe.scalalogging.LazyLogging
import com.themillhousegroup.arallon.zones._

class ComparisonSpec extends Specification with LazyLogging {

  "Time comparisons" should {
    "Correctly detect 'equal' situations - local TZ" in {
      val earlierHere = TimeInZone.fromUTCMillis(149666777L)
      val laterHere = TimeInZone.fromUTCMillis(159666777L)

      earlierHere.isEqual(laterHere) must beFalse

      laterHere.isEqual(earlierHere) must beFalse

      laterHere.isEqual(laterHere) must beTrue
    }

    "Correctly detect 'equal' situations - across TZ" in {
      val instant = new DateTime()
      val inParis = TimeInZone[Paris](instant)
      val inSydney = TimeInZone[Sydney](instant)
      val inSydney2 = TimeInZone[Sydney](instant)
      val inUTC = TimeInZone.fromUTCMillis(inSydney.utcMillis)

      inParis.isEqual(inSydney) must beFalse // They don't refer to the same instant

      inSydney.isEqual(inSydney2) must beTrue

      logger.info(s"isEqual Comparing\n$inUTC\nwith\n$inSydney\n")
      inSydney.isEqual(inUTC) must beTrue
    }

    "Correctly detect 'before' situations - local TZ" in {
      val earlierHere = TimeInZone.fromUTCMillis(149666777L)
      val laterHere = TimeInZone.fromUTCMillis(159666777L)

      earlierHere.isBefore(laterHere) must beTrue

      laterHere.isBefore(earlierHere) must beFalse

      laterHere.isBefore(laterHere) must beFalse
    }

    "Correctly detect 'before' situations - across TZ" in {
      val instant = new DateTime()
      val inParis = TimeInZone[Paris](instant)
      val inSydney = TimeInZone[Sydney](instant)
      val inSydney2 = TimeInZone[Sydney](instant)
      val inUTC = TimeInZone.fromUTCMillis(inSydney.utcMillis)

      inSydney.isBefore(inParis) must beTrue // Sydney gets to 9am Monday Jan 1, 2020 before Paris does
      inParis.isBefore(inSydney) must beFalse

      inSydney.isBefore(inSydney2) must beFalse

      logger.info(s"before Comparing\n$inUTC\nwith\n$inSydney\n")

      inSydney.isBefore(inUTC) must beFalse
    }

    "Correctly detect 'after' situations - local TZ" in {
      val earlierHere = TimeInZone.fromUTCMillis(149666777L)
      val laterHere = TimeInZone.fromUTCMillis(159666777L)

      earlierHere.isAfter(laterHere) must beFalse

      laterHere.isAfter(earlierHere) must beTrue

      laterHere.isAfter(laterHere) must beFalse
    }

    "Correctly detect 'between' situations - local TZ" in {
      val firstHere = TimeInZone.fromUTCMillis(149666777L)
      val secondHere = TimeInZone.fromUTCMillis(159666777L)
      val thirdHere = TimeInZone.fromUTCMillis(169666777L)

      secondHere.isBetween(firstHere, thirdHere) must beTrue

      secondHere.isBetween(firstHere, secondHere) must beTrue

      secondHere.isBetween(secondHere, thirdHere) must beTrue

      firstHere.isBetween(firstHere, thirdHere) must beTrue

      firstHere.isBetween(secondHere, thirdHere) must beFalse

      thirdHere.isBetween(firstHere, secondHere) must beFalse
    }
  }
}


text:
title: Colors
page_title: Colors | RadTreeMap for ASP.NET AJAX Documentation
description: Colors
slug: treemap/functionality/colors
tags: colors
published: True
position: 1
---

# Colors

The following article demonstrates the usage of the **Colors** property of the **RadTreeMap**.

##

The **Colors** property of the **RadTreeMap** is a collection of type **System.Drawing.Color**, which provides the ability to set custom colors. The list of colors will be applied on each group of TreeMapItems. If the amount of predefined colors, exceeds the number of items, the coloration stars from the first color all over again.

In the example bellow, you could examine how several colors are assigned to the **Colors** collection of the RadTreeMap and in the **Figure 1**, you could observe how the control is visualized:

````ASPNET
<telerik:RadTreeMap runat="server" ID="TreeMap1"  Height="250" Width="400" AlgorithmType="Horizontal">
    <Items>
        <telerik:TreeMapItem Text="Parent Item">
            <Items>
                <telerik:TreeMapItem Text="Item 1" Value="6">
                    <Items>
                        <telerik:TreeMapItem Text="Sub Item 1.1" Value="2"></telerik:TreeMapItem>
                        <telerik:TreeMapItem Text="Sub Item 1.2" Value="2"></telerik:TreeMapItem>
                        <telerik:TreeMapItem Text="Sub Item 1.3" Value="1"></telerik:TreeMapItem>
                    </Items>
                </telerik:TreeMapItem>
                <telerik:TreeMapItem Text="Item 2" Value="4">
                    <Items>
                        <telerik:TreeMapItem Text="Sub Item 2.1" Value="5"></telerik:TreeMapItem>
                        <telerik:TreeMapItem Text="Sub Item 2.2" Value="5"></telerik:TreeMapItem>
                        <telerik:TreeMapItem Text="Sub Item 2.3" Value="3"></telerik:TreeMapItem>
                        <telerik:TreeMapItem Text="Sub Item 2.5" Value="2"></telerik:TreeMapItem>
                    </Items>
                </telerik:TreeMapItem>
                <telerik:TreeMapItem Text="Item 3" Value="3">
                    <Items>
                        <telerik:TreeMapItem Text="Sub Item 3.1" Value="2"></telerik:TreeMapItem>
                        <telerik:TreeMapItem Text="Sub Item 3.2" Value="2"></telerik:TreeMapItem>
                        <telerik:TreeMapItem Text="Sub Item 3.4" Value="1"></telerik:TreeMapItem>
                    </Items>
                </telerik:TreeMapItem>
            </Items>
        </telerik:TreeMapItem>
    </Items>
</telerik:RadTreeMap>
````

````C#
protected void Page_Load(object sender, EventArgs e)
{
    TreeMap1.Colors.Add(Color.Red);
    TreeMap1.Colors.Add(Color.Green);
    TreeMap1.Colors.Add(Color.Blue);

    // Another way to populate the Colors collection
    //TreeMap1.Colors.Add(ColorTranslator.FromHtml("Red"));
    //TreeMap1.Colors.Add(ColorTranslator.FromHtml("Green"));
    //TreeMap1.Colors.Add(ColorTranslator.FromHtml("Blue"));
}
````
````VB
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load

    TreeMap1.Colors.Add(Color.Red)
    TreeMap1.Colors.Add(Color.Green)
    TreeMap1.Colors.Add(Color.Blue)

    ' Another way to populate the Colors collection
    'TreeMap1.Colors.Add(ColorTranslator.FromHtml("Red"))
    'TreeMap1.Colors.Add(ColorTranslator.FromHtml("Green"))
    'TreeMap1.Colors.Add(ColorTranslator.FromHtml("Blue"))
End Sub
````

**Figure 1**: Demonstrates how the **RadTreeMap** is visualized, when custom colors are set.![functionality-colors](images/functionality-colors.png)

**Note** : The sub-items count of **Item 2** exceeds the amount of predefined colors. Therefore, **Sub Item 2.5** has the same color as **Sub Item 2.1**.


text:
using System.ComponentModel.Composition;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Text;
using Microsoft.VisualStudio.Utilities;

namespace GammaJul.ReSharper.EnhancedTooltip.VisualStudio {

	[Name(Name)]
	[Order(After = QuickInfoSourceProviderNames.VsSquiggle)]
	[Order(After = QuickInfoSourceProviderNames.VsDefault)]
	[Order(After = QuickInfoSourceProviderNames.VsRoslyn)]
	[Order(After = QuickInfoSourceProviderNames.VsLightBulb)]
	[Order(After = QuickInfoSourceProviderNames.VsSyntactic)]
	[Order(After = QuickInfoSourceProviderNames.VsSemantic)]
	[Order(After = QuickInfoSourceProviderNames.ReSharper)]
	[Order(After = VsSquiggleCollectorQuickInfoSourceProvider.Name)]
	[ContentType("text")]
	[Export(typeof(IQuickInfoSourceProvider))]
	public sealed class MainQuickInfoSourceProvider : QuickInfoSourceProviderBase {

		public const string Name = "EnhancedTooltip." + nameof(MainQuickInfoSourceProvider);

		protected override IQuickInfoSource CreateQuickInfoSource(ITextBuffer textBuffer)
			=> new MainQuickInfoSource(textBuffer);

	}

}


text:
.codehilite .hll { background-color: #222222 }
.codehilite .c { color: #000080 } /* Comment */
.codehilite .err { color: #cccccc; border: 1px solid #FF0000 } /* Error */
.codehilite .g { color: #cccccc } /* Generic */
.codehilite .k { color: #cdcd00 } /* Keyword */
.codehilite .l { color: #cccccc } /* Literal */
.codehilite .n { color: #cccccc } /* Name */
.codehilite .o { color: #3399cc } /* Operator */
.codehilite .x { color: #cccccc } /* Other */
.codehilite .p { color: #cccccc } /* Punctuation */
.codehilite .cm { color: #000080 } /* Comment.Multiline */
.codehilite .cp { color: #000080 } /* Comment.Preproc */
.codehilite .c1 { color: #000080 } /* Comment.Single */
.codehilite .cs { color: #cd0000; font-weight: bold } /* Comment.Special */
.codehilite .gd { color: #cd0000 } /* Generic.Deleted */
.codehilite .ge { color: #cccccc; font-style: italic } /* Generic.Emph */
.codehilite .gr { color: #FF0000 } /* Generic.Error */
.codehilite .gh { color: #000080; font-weight: bold } /* Generic.Heading */
.codehilite .gi { color: #00cd00 } /* Generic.Inserted */
.codehilite .go { color: #808080 } /* Generic.Output */
.codehilite .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
.codehilite .gs { color: #cccccc; font-weight: bold } /* Generic.Strong */
.codehilite .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
.codehilite .gt { color: #0040D0 } /* Generic.Traceback */
.codehilite .kc { color: #cdcd00 } /* Keyword.Constant */
.codehilite .kd { color: #00cd00 } /* Keyword.Declaration */
.codehilite .kn { color: #cd00cd } /* Keyword.Namespace */
.codehilite .kp { color: #cdcd00 } /* Keyword.Pseudo */
.codehilite .kr { color: #cdcd00 } /* Keyword.Reserved */
.codehilite .kt { color: #00cd00 } /* Keyword.Type */
.codehilite .ld { color: #cccccc } /* Literal.Date */
.codehilite .m { color: #cd00cd } /* Literal.Number */
.codehilite .s { color: #cd0000 } /* Literal.String */
.codehilite .na { color: #cccccc } /* Name.Attribute */
.codehilite .nb { color: #cd00cd } /* Name.Builtin */
.codehilite .nc { color: #00cdcd } /* Name.Class */
.codehilite .no { color: #cccccc } /* Name.Constant */
.codehilite .nd { color: #cccccc } /* Name.Decorator */
.codehilite .ni { color: #cccccc } /* Name.Entity */
.codehilite .ne { color: #666699; font-weight: bold } /* Name.Exception */
.codehilite .nf { color: #cccccc } /* Name.Function */
.codehilite .nl { color: #cccccc } /* Name.Label */
.codehilite .nn { color: #cccccc } /* Name.Namespace */
.codehilite .nx { color: #cccccc } /* Name.Other */
.codehilite .py { color: #cccccc } /* Name.Property */
.codehilite .nt { color: #cccccc } /* Name.Tag */
.codehilite .nv { color: #00cdcd } /* Name.Variable */
.codehilite .ow { color: #cdcd00 } /* Operator.Word */
.codehilite .w { color: #cccccc } /* Text.Whitespace */
.codehilite .mf { color: #cd00cd } /* Literal.Number.Float */
.codehilite .mh { color: #cd00cd } /* Literal.Number.Hex */
.codehilite .mi { color: #cd00cd } /* Literal.Number.Integer */
.codehilite .mo { color: #cd00cd } /* Literal.Number.Oct */
.codehilite .sb { color: #cd0000 } /* Literal.String.Backtick */
.codehilite .sc { color: #cd0000 } /* Literal.String.Char */
.codehilite .sd { color: #cd0000 } /* Literal.String.Doc */
.codehilite .s2 { color: #cd0000 } /* Literal.String.Double */
.codehilite .se { color: #cd0000 } /* Literal.String.Escape */
.codehilite .sh { color: #cd0000 } /* Literal.String.Heredoc */
.codehilite .si { color: #cd0000 } /* Literal.String.Interpol */
.codehilite .sx { color: #cd0000 } /* Literal.String.Other */
.codehilite .sr { color: #cd0000 } /* Literal.String.Regex */
.codehilite .s1 { color: #cd0000 } /* Literal.String.Single */
.codehilite .ss { color: #cd0000 } /* Literal.String.Symbol */
.codehilite .bp { color: #cd00cd } /* Name.Builtin.Pseudo */
.codehilite .vc { color: #00cdcd } /* Name.Variable.Class */
.codehilite .vg { color: #00cdcd } /* Name.Variable.Global */
.codehilite .vi { color: #00cdcd } /* Name.Variable.Instance */
.codehilite .il { color: #cd00cd } /* Literal.Number.Integer.Long */


text:
import { Component } from '@angular/core';

@Component({
  selector: 'block-element',
  templateUrl: './block-element.component.html',
  styleUrls: ['./block-element.component.css'],
  moduleId: __moduleName
})
export class BlockElementComponent {

  constructor() { }

}


text:
/**
 * 债券试算
 * @type {[type]}
 */
app.factory('netBondTrialService',['$http','$q','$uibModal','ProxyRequestService',function($http,$q, $uibModal,ProxyRequestService){

	return {
		/**
		 * /
		 * @param  {[type]} item [item为对象 ,{bondCd:'',bondid:''....}]
		 * @return {[type]}      [description]
		 */
		openCalculator(item){//计算器 弹窗
			this.$uibModal = $uibModal;
			this.dataCalculatorModal ={
				itemInfo:{},
			}
			let that =this;
			this.$uibModal.open({
				animation: true,
				component:'bondTrial',
				windowClass:'my-bond-trial',
				size: 'xs',//'lg',//'sm',
				resolve: {
					modalData:function(){
						if(item){
							that.dataCalculatorModal['itemInfo'] = item;
						}
						return that.dataCalculatorModal;
					}
				}
			}).result.then(function (selectedItem) {},that);
		},
		/**
		 * /模糊搜索
		 * @param  {[type]} obj [{keyword:''}根据关键词搜索]
		 * @return {[type]}     [description]
		 */
		fuzzyMatchingForBond(obj){
			// return ProxyRequestService.post('/ainas/bond/fuzzyMatchingForBond',{
			// 	keyword:obj.keyword
			// })
			let deferred = $q.defer();
			$http({
				method: 'POST',
				url: BONDCONFIG.getIP()+"ainas/bond/fuzzyMatchingForBond",
				data: JSON.stringify(obj),
				headers: BONDCONFIG.JH,
			}).then((response)=>{
				deferred.resolve(response);
			},(response)=>{
				deferred.resolve(response);
			});
			return deferred.promise;
		},
		/**
		 * /
		 * @param  {[type]} obj [description]
		 * @return {[type]}     [description]
		 */
		calSettlementDate(obj){
			// return ProxyRequestService.post('/ainas/web/calSettlementDateForWeb',{
			// 	bondid:obj.bondid,//债券id
			// 	dealDate:obj.dealDate,//交易日期
			// 	settlementDate:obj.settlementDate,//结算日期
			// 	cleanPrice: obj.cleanPrice,//净价
			// 	fullRate:obj.fullRate,//全价
			// 	clearSpeed:obj.clearSpeed,
			// 	yield:obj.yield,//收益率
			// 	dealNum:obj.dealNum,//数量
			// })
			let deferred = $q.defer();
			$http({
				method: 'POST',
				url: BONDCONFIG.getIP()+"ainas/web/calSettlementDateForWeb",
				data: JSON.stringify(obj),
				headers: BONDCONFIG.JH,
			}).then((response)=>{
				deferred.resolve(response);
			},(response)=>{
				deferred.resolve(response);
			});
			return deferred.promise;

		},
		/**
		 * /查询债券基本信息
		 * @param  {[type]} obj [description]
		 * @return {[type]}     [description]
		 */
		queryDetailBondBaseInfo(obj){
			// return ProxyRequestService.post('/ainas/web/queryDetailBondBaseInfo',{
			// 	bondid:obj.bondid,//债券id
			// })
			let deferred = $q.defer();
			$http({
				method: 'POST',
				url: BONDCONFIG.getIP()+"ainas/web/queryDetailBondBaseInfo",
				data: JSON.stringify(obj),
				headers: BONDCONFIG.JH,
			}).then((response)=>{
				// console.l og(response)
				deferred.resolve(response);
			},(response)=>{
				deferred.resolve(response);
			});
			return deferred.promise;
		},
		// 获取指标数据
		/**
		 * /
		 * @param  {[type]} obj  [description]
		 * @param  {[type]} name [根据 (净价)/(全价)/(收益率)]
		 * @return {[type]}      [description]
		 */
		calcIndicatorsForWeb(obj,name){
			let sendObj = {};
			sendObj.bondid = obj.bondid;
			sendObj.dealDate = obj.dealDate;
			sendObj.settlementDate = obj.settlementDate;
			if(name){
				sendObj[name] = obj[name];
			}else{
				sendObj.yield = obj.yield/100;
			}
			// return ProxyRequestService.post('/ainas/web/calcIndicatorsForWeb',sendObj)
			let deferred = $q.defer();
			$http({
				method: 'POST',
				url: BONDCONFIG.getIP()+"ainas/web/calcIndicatorsForWeb",
				data: JSON.stringify(sendObj),
				headers: BONDCONFIG.JH,
			}).then((response)=>{
				// console.l og(response)
				deferred.resolve(response);
			},(response)=>{
				deferred.resolve(response);
			});
			return deferred.promise;
		},
		calSettlementAmountYieldForCM(obj,name){//计算结算金额 和净价 收益率
			// let sendObj = {
			// 	bondid:obj.bondid,
			// 	dealDate:obj.dealDate,
			// 	clearSpeed:obj.clearSpeed,
			// 	dealNum:obj.dealNum ? obj.dealNum*10000 : '0',
			// 	yield:obj.yield/100,
			// };
			// return ProxyRequestService.post('/ainas/bond/calSettlementAmountYieldForCM',sendObj);
			let deferred = $q.defer();
			$http({
				method: 'POST',
				url: BONDCONFIG.getIP()+"ainas/bond/calSettlementAmountYieldForCM",
				data: JSON.stringify({
					bondid:obj.bondid,
					dealDate:obj.dealDate,
					clearSpeed:obj.clearSpeed,
					dealNum:obj.dealNum ? obj.dealNum*10000 : '0',
					yield:obj.yield/100,
				}),
				headers: BONDCONFIG.JH,
			}).then((response)=>{
				// console.l og(response)
				deferred.resolve(response);
			},(response)=>{
				deferred.resolve(response);
			});
			return deferred.promise;
		},
		/**
		 * /
		 * @param  {[type]} obj  [description]
		 * @param  {[type]} name [description]
		 * @return {[type]}      [description]
		 */
		calSettlementAmountCleanPriceForCM(obj,name){//计算结算金额 和净价 收益率
			// let sendObj ={
			// 	bondid:obj.bondid,
			// 	dealDate:obj.dealDate,
			// 	clearSpeed:obj.clearSpeed,
			// 	dealNum:obj.dealNum ? obj.dealNum*10000 : '0',
			// 	cleanPrice:obj.cleanPrice,
			// };
			// return ProxyRequestService.post('/ainas/bond/calSettlementAmountCleanPriceForCM',sendObj);
			let deferred = $q.defer();
			$http({
				method: 'POST',
				url: BONDCONFIG.getIP()+"ainas/bond/calSettlementAmountCleanPriceForCM",
				data: JSON.stringify({
					bondid:obj.bondid,
					dealDate:obj.dealDate,
					clearSpeed:obj.clearSpeed,
					dealNum:obj.dealNum ? obj.dealNum*10000 : '0',
					cleanPrice:obj.cleanPrice,
				}),
				headers: BONDCONFIG.JH,
			}).then((response)=>{
				// console.l og(response)
				deferred.resolve(response);
			},(response)=>{
				deferred.resolve(response);
			});
			return deferred.promise;
		}
	}
}]);


text:
'use strict';

/**
 * This Angular JS directive adds a simple button to a page that uses the exportService to export every widget on the page a group.
 *
 * @namespace neonDemo.directives
 * @constructor
 */
angular.module('neonDemo.directives')
.directive('exportWidgets', ['ConnectionService', 'ErrorNotificationService', 'ExportService',
    function(connectionService, errorNotificationService, exportService) {
    return {
        templateUrl: 'components/export/export.html',
        restrict: 'EA',
        link: function($scope) {
            var exportSuccess = function(queryResults) {
                window.location.assign("/neon/services/exportservice/generateZip/" + queryResults.data);
            };

            var exportFail = function(response) {
                if(response.responseJSON) {
                    $scope.errorMessage = errorNotificationService.showErrorMessage(undefined, response.responseJSON.error, response.responseJSON.stackTrace);
                }
            };

            $scope.exportAll = function() {
                XDATA.userALE.log({
                    activity: "perform",
                    action: "click",
                    elementId: "export-all-button",
                    elementType: "button",
                    elementGroup: "top",
                    source: "user",
                    tags: ["export"]
                });
                var connection = connectionService.getActiveConnection();
                if(!connection) {
                    //This is temporary. Come up with better code for if there isn't a connection.
                    return;
                }
                var data = {
                    // TODO Change this hardcoded value to something like a user ID.
                    name: "All_Widgets",
                    data: []
                };
                exportService.getWidgets().forEach(function(widget) {
                    var widgetObject = widget.callback();
                    for(var x = 0; x < widgetObject.data.length; x++) {
                        data.data.push(widgetObject.data[x]);
                    }
                });
                connection.executeExport(data, exportSuccess, exportFail, exportService.getFileFormat());
            };
        }
    };
}]);


text:
layout: video_sample
title: Prebid Video | Instream Example with  JW Player (Hosted)
description: An example of an instream pre-roll ad using Prebid.js and JW Player (Hosted).
videoType: pb-is-jw02
isVideo: true
sidebarType: 4
---

{{ page.title }}

{{page.description }}

Important:
			This example uses a test version of Prebid.js hosted on our CDN that is not recommended for production use. It includes all available adapters. Production implementations should build from source or customize the build using the Download page to make sure only the necessary bidder adapters are included.

Warning:
			Do not forget to exchange the placementId in the code examples with your own placementId!

Place this code in the page header.

<script async src="//acdn.adnxs.com/prebid/not-for-prod/prebid.js"></script>
<script type="text/javascript" src="http://ssl.p.jwpcdn.com/player/v/7.2.4/jwplayer.js"></script>
<script type="text/javascript">
	jwplayer.key = "YEUwUA9wRFeDcydr"; //Test Key - replace this with your own valid JWPlayer license key

</script>
<script>
	var pbjs = pbjs || {};
	pbjs.que = pbjs.que || [];

	// define invokeVideoPlayer in advance in case we get the bids back from prebid before the entire page loads

	var tempTag = false;
	var invokeVideoPlayer = function(url) {
	    tempTag = url;
	}

	var videoAdUnit = {
	    code: 'video1',
	    mediaTypes: {
	        video: {
	            playerSize: [640, 480],
	            context: 'instream'
	        }
	    },
	    bids: [{
	        bidder: 'appnexus',
	        params: {
	            placementId: 13232361, // Add your own placement id here

	            video: {
	                skipppable: true,
	                playback_method: ['auto_play_sound_off']
	            }
	        }
	    }]
	};

	pbjs.que.push(function() {
	    pbjs.addAdUnits(videoAdUnit); // add your ad units to the bid request

	    pbjs.setConfig({
	        debug: true,
	        cache: {
	            url: 'https://prebid.adnxs.com/pbc/v1/cache'
	        }
	    });

	    pbjs.requestBids({
	        bidsBackHandler: function(bids) {
	            var videoUrl = pbjs.adServers.dfp.buildVideoUrl({
	                adUnit: videoAdUnit,
	                params: {
	                    iu: '/19968336/prebid_cache_video_adunit',
	                    cust_params: {
	                        section: 'blog',
	                        anotherKey: 'anotherValue'
	                    },
	                    output: 'vast'
	                }
	            });
	            invokeVideoPlayer(videoUrl);
	        }
	    });
	});

</script>

Place this code in the page body.

<!--player div-->
<div id="playerContainerJW" style='width:640px; height:480px; border:1px solid black;'></div>
<script>
	var jwPlayerInstance = jwplayer("playerContainerJW");

	invokeVideoPlayer = function(url) {
	    jwPlayerInstance.setup({
	        "file": "http://mirrors.standaloneinstaller.com/video-sample/jellyfish-25-mbps-hd-hevc.mp4",
	        "width": 640,
	        "height": 480,
	        "autostart": true,
	        "mute": false,
	        "advertising": {
	            client: "vast",
	        }
	    });

	    jwPlayerInstance.on('beforePlay', function() {
	        jwPlayerInstance.playAd(url);
	    })
	}

	if (tempTag) {
	    invokeVideoPlayer(tempTag);
	    tempTag = false;
	}

</script>


text:
// tr_world.c

#include "tr_local.h"
#include "gl_shader.h"

/*
================
R_CullSurface

Tries to back face cull surfaces before they are lighted or
added to the sorting list.

This will also allow mirrors on both sides of a model without recursion.
================
*/
static bool R_CullSurface( surfaceType_t *surface, shader_t *shader, int planeBits )
{
	srfGeneric_t *gen;
	float        d;

	// allow culling to be disabled
	if ( r_nocull->integer )
	{
		return false;
	}

	// ydnar: made surface culling generic, inline with q3map2 surface classification
	if ( *surface == SF_GRID && r_nocurves->integer )
	{
		return true;
	}

	if ( *surface != SF_FACE && *surface != SF_TRIANGLES && *surface != SF_VBO_MESH && *surface != SF_GRID )
	{
		return true;
	}

	// get generic surface
	gen = ( srfGeneric_t * ) surface;

	// plane cull
	if ( *surface == SF_FACE && r_facePlaneCull->integer )
	{
		srfSurfaceFace_t *srf = ( srfSurfaceFace_t * )gen;
		d = DotProduct( tr.orientation.viewOrigin, srf->plane.normal ) - srf->plane.dist;

		// don't cull exactly on the plane, because there are levels of rounding
		// through the BSP, ICD, and hardware that may cause pixel gaps if an
		// epsilon isn't allowed here
		if ( shader->cullType == CT_FRONT_SIDED )
		{
			if ( d < -8.0f )
			{
				tr.pc.c_plane_cull_out++;
				return true;
			}
		}
		else if ( shader->cullType == CT_BACK_SIDED )
		{
			if ( d > 8.0f )
			{
				tr.pc.c_plane_cull_out++;
				return true;
			}
		}

		tr.pc.c_plane_cull_in++;
	}

	if ( planeBits )
	{
		cullResult_t cull;

		if ( tr.currentEntity != &tr.worldEntity )
		{
			cull = R_CullLocalBox( gen->bounds );
		}
		else
		{
			cull = R_CullBox( gen->bounds );
		}

		if ( cull == CULL_OUT )
		{
			tr.pc.c_box_cull_out++;
			return true;
		}
		else if ( cull == CULL_CLIP )
		{
			tr.pc.c_box_cull_clip++;
		}
		else
		{
			tr.pc.c_box_cull_in++;
		}
	}

	// must be visible
	return false;
}

static bool R_CullLightSurface( surfaceType_t *surface, shader_t *shader, trRefLight_t *light, byte *cubeSideBits )
{
	srfGeneric_t *gen;
	float        d;

	// allow culling to be disabled
	if ( r_nocull->integer )
	{
		return false;
	}

	// ydnar: made surface culling generic, inline with q3map2 surface classification
	if ( *surface == SF_GRID && r_nocurves->integer )
	{
		return true;
	}

	if ( *surface != SF_FACE && *surface != SF_TRIANGLES && *surface != SF_VBO_MESH && *surface != SF_GRID )
	{
		return true;
	}

	gen = ( srfGeneric_t * ) surface;

	// do a quick AABB cull
	if ( !BoundsIntersect( light->worldBounds[ 0 ], light->worldBounds[ 1 ], gen->bounds[ 0 ], gen->bounds[ 1 ] ) )
	{
		return true;
	}

	// do a more expensive and precise light frustum cull
	if ( !r_noLightFrustums->integer )
	{
		if ( R_CullLightWorldBounds( light, gen->bounds ) == CULL_OUT )
		{
			return true;
		}
	}

	// plane cull
	if ( *surface == SF_FACE && r_facePlaneCull->integer )
	{
		srfSurfaceFace_t *srf = ( srfSurfaceFace_t * )gen;
		if ( light->l.rlType == RL_DIRECTIONAL )
		{
			d = DotProduct( tr.sunDirection, srf->plane.normal );
		}
		else
		{
			d = DotProduct( light->origin, srf->plane.normal ) - srf->plane.dist;
		}
		// don't cull exactly on the plane, because there are levels of rounding
		// through the BSP, ICD, and hardware that may cause pixel gaps if an
		// epsilon isn't allowed here
		if ( shader->cullType == CT_FRONT_SIDED )
		{
			if ( d < -8.0f )
			{
				return true;
			}
		}
		else if ( shader->cullType == CT_BACK_SIDED )
		{
			if ( d > 8.0f )
			{
				return true;
			}
		}
	}

	if ( r_cullShadowPyramidFaces->integer )
	{
		*cubeSideBits = R_CalcLightCubeSideBits( light, gen->bounds );
	}

	return false;
}

/*
======================
R_AddInteractionSurface
======================
*/
static void R_AddInteractionSurface( bspSurface_t *surf, trRefLight_t *light, int interactionBits )
{
	byte              cubeSideBits = CUBESIDE_CLIPALL;
	bool          firstAddition = false;
	int               bits;

	if ( surf->lightCount != tr.lightCount )
	{
		surf->interactionBits = 0;
		surf->lightCount = tr.lightCount;
		firstAddition = true;
	}

	// only add interactions we haven't already added
	bits = interactionBits & ~surf->interactionBits;

	if ( !bits )
	{
		// already added these interactions
		return;
	}

	surf->interactionBits |= bits;

	//  skip all surfaces that don't matter for lighting only pass
	if ( surf->shader->isSky || ( !surf->shader->interactLight && surf->shader->noShadows ) )
	{
		return;
	}

	if ( R_CullLightSurface( surf->data, surf->shader, light, &cubeSideBits ) )
	{
		if ( !light->isStatic && firstAddition )
		{
			tr.pc.c_dlightSurfacesCulled++;
		}
		return;
	}

	R_AddLightInteraction( light, surf->data, surf->shader, cubeSideBits, ( interactionType_t ) bits );

	if ( firstAddition )
	{
		if ( light->isStatic )
		{
			tr.pc.c_slightSurfaces++;
		}
		else
		{
			tr.pc.c_dlightSurfaces++;
		}
	}
}

static void R_AddDecalSurface( bspSurface_t *surf, int decalBits )
{
	int i;

	// add decals
	if ( decalBits )
	{
		// ydnar: project any decals
		for ( i = 0; i < tr.refdef.numDecalProjectors; i++ )
		{
			if ( decalBits & ( 1 << i ) )
			{
				R_ProjectDecalOntoSurface( &tr.refdef.decalProjectors[ i ], surf, &tr.world->models[ 0 ] );
			}
		}
	}
}

/*
======================
R_AddWorldSurface
======================
*/
static bool R_AddWorldSurface( bspSurface_t *surf, int fogIndex, int planeBits )
{
	if ( surf->viewCount == tr.viewCountNoReset )
	{
		return false; // already in this view
	}

	surf->viewCount = tr.viewCountNoReset;

	// try to cull before lighting or adding
	if ( R_CullSurface( surf->data, surf->shader, planeBits ) )
	{
		return true;
	}

	R_AddDrawSurf( surf->data, surf->shader, surf->lightmapNum, fogIndex );
	return true;
}

/*
=============================================================

        BRUSH MODELS

=============================================================
*/

/*
=================
R_AddBSPModelSurfaces
=================
*/
void R_AddBSPModelSurfaces( trRefEntity_t *ent )
{
	bspModel_t *bspModel;
	model_t    *pModel;
	unsigned int i;
	vec3_t     v;
	vec3_t     transformed;
	vec3_t     boundsCenter;
	int        fogNum;

	pModel = R_GetModelByHandle( ent->e.hModel );
	bspModel = pModel->bsp;

	// copy local bounds
	for ( i = 0; i < 3; i++ )
	{
		ent->localBounds[ 0 ][ i ] = bspModel->bounds[ 0 ][ i ];
		ent->localBounds[ 1 ][ i ] = bspModel->bounds[ 1 ][ i ];
	}

	// setup world bounds for intersection tests
	ClearBounds( ent->worldBounds[ 0 ], ent->worldBounds[ 1 ] );

	for ( i = 0; i < 8; i++ )
	{
		v[ 0 ] = ent->localBounds[ i & 1 ][ 0 ];
		v[ 1 ] = ent->localBounds[( i >> 1 ) & 1 ][ 1 ];
		v[ 2 ] = ent->localBounds[( i >> 2 ) & 1 ][ 2 ];

		// transform local bounds vertices into world space
		R_LocalPointToWorld( v, transformed );

		AddPointToBounds( transformed, ent->worldBounds[ 0 ], ent->worldBounds[ 1 ] );
	}

	VectorAdd( ent->worldBounds[ 0 ], ent->worldBounds[ 1 ], boundsCenter );
	VectorScale( boundsCenter, 0.5f, boundsCenter );

	ent->cull = R_CullBox( ent->worldBounds );

	if ( ent->cull == CULL_OUT )
	{
		return;
	}

	// Tr3B: BSP inline models should always use vertex lighting
	R_SetupEntityLighting( &tr.refdef, ent, boundsCenter );

	fogNum = R_FogWorldBox( ent->worldBounds );

	for ( i = 0; i < bspModel->numSurfaces; i++ )
	{
		R_AddWorldSurface( bspModel->firstSurface + i, fogNum, FRUSTUM_CLIPALL );
	}
}

/*
=============================================================

        WORLD MODEL

=============================================================
*/

static void R_AddLeafSurfaces( bspNode_t *node, int decalBits, int planeBits )
{
	int          c;
	bspSurface_t **mark;
	bspSurface_t **view;

	tr.pc.c_leafs++;

	// add to z buffer bounds
	if ( node->mins[ 0 ] < tr.viewParms.visBounds[ 0 ][ 0 ] )
	{
		tr.viewParms.visBounds[ 0 ][ 0 ] = node->mins[ 0 ];
	}

	if ( node->mins[ 1 ] < tr.viewParms.visBounds[ 0 ][ 1 ] )
	{
		tr.viewParms.visBounds[ 0 ][ 1 ] = node->mins[ 1 ];
	}

	if ( node->mins[ 2 ] < tr.viewParms.visBounds[ 0 ][ 2 ] )
	{
		tr.viewParms.visBounds[ 0 ][ 2 ] = node->mins[ 2 ];
	}

	if ( node->maxs[ 0 ] > tr.viewParms.visBounds[ 1 ][ 0 ] )
	{
		tr.viewParms.visBounds[ 1 ][ 0 ] = node->maxs[ 0 ];
	}

	if ( node->maxs[ 1 ] > tr.viewParms.visBounds[ 1 ][ 1 ] )
	{
		tr.viewParms.visBounds[ 1 ][ 1 ] = node->maxs[ 1 ];
	}

	if ( node->maxs[ 2 ] > tr.viewParms.visBounds[ 1 ][ 2 ] )
	{
		tr.viewParms.visBounds[ 1 ][ 2 ] = node->maxs[ 2 ];
	}

	// add the individual surfaces
	mark = tr.world->markSurfaces + node->firstMarkSurface;
	c = node->numMarkSurfaces;
	view = tr.world->viewSurfaces + node->firstMarkSurface;

	while ( c-- )
	{
		// the surface may have already been added if it
		// spans multiple leafs
		if ( R_AddWorldSurface( *view, ( *view )->fogIndex, planeBits ) )
		{
			R_AddDecalSurface( *mark, decalBits );
		}

		( *mark )->viewCount = tr.viewCountNoReset;

		mark++;
		view++;
	}
}

/*
================
R_RecursiveWorldNode
================
*/
static void R_RecursiveWorldNode( bspNode_t *node, int planeBits, int decalBits )
{
	do
	{
		// if the node wasn't marked as potentially visible, exit
		if ( node->visCounts[ tr.visIndex ] != tr.visCounts[ tr.visIndex ] )
		{
			return;
		}

		if ( node->contents != -1 && !node->numMarkSurfaces )
		{
			// don't waste time dealing with this empty leaf
			return;
		}

		// if the bounding volume is outside the frustum, nothing
		// inside can be visible
		if ( !r_nocull->integer )
		{
			int i;
			int r;

			for ( i = 0; i < FRUSTUM_PLANES; i++ )
			{
				if ( planeBits & ( 1 << i ) )
				{
					r = BoxOnPlaneSide( node->mins, node->maxs, &tr.viewParms.frustums[ 0 ][ i ] );

					if ( r == 2 )
					{
						return; // culled
					}

					if ( r == 1 )
					{
						planeBits &= ~( 1 << i );  // all descendants will also be in front
					}
				}
			}
		}

		backEndData[ tr.smpFrame ]->traversalList[ backEndData[ tr.smpFrame ]->traversalLength++ ] = node;

		// ydnar: cull decals
		if ( decalBits )
		{
			int i;

			for ( i = 0; i < tr.refdef.numDecalProjectors; i++ )
			{
				if ( decalBits & ( 1 << i ) )
				{
					// test decal bounds against node bounds
					if ( tr.refdef.decalProjectors[ i ].shader == nullptr ||
					     !R_TestDecalBoundingBox( &tr.refdef.decalProjectors[ i ], node->mins, node->maxs ) )
					{
						decalBits &= ~( 1 << i );
					}
				}
			}
		}

		if ( node->contents != -1 )
		{
			break;
		}

		// recurse down the children, front side first
		R_RecursiveWorldNode( node->children[ 0 ], planeBits, decalBits );

		// tail recurse
		node = node->children[ 1 ];
	}
	while ( 1 );

	if ( node->numMarkSurfaces )
	{
		// ydnar: moved off to separate function
		R_AddLeafSurfaces( node, decalBits, planeBits );
	}
}

/*
================
R_RecursiveInteractionNode
================
*/
static void R_RecursiveInteractionNode( bspNode_t *node, trRefLight_t *light, int planeBits, int interactionBits )
{
	int i;
	int r;

	do
	{
		// surfaces that arn't potentially visible may still cast shadows
		// but we don't bother lighting them since there will be no visible effect
		if ( node->visCounts[ tr.visIndex ] != tr.visCounts[ tr.visIndex ] )
		{
			interactionBits &= ~IA_LIGHT;
		}

		// if the bounding volume is outside the frustum, nothing
		// inside can be visible OPTIMIZE: don't do this all the way to leafs?

		// Tr3B - even surfaces that belong to nodes that are outside of the view frustum
		// can cast shadows into the view frustum
		if ( !r_nocull->integer )
		{
			for ( i = 0; i < FRUSTUM_PLANES; i++ )
			{
				if ( planeBits & ( 1 << i ) )
				{
					r = BoxOnPlaneSide( node->mins, node->maxs, &tr.viewParms.frustums[ 0 ][ i ] );

					if ( r == 2 )
					{
						// this node cannot be lighted, but may cast shadows
						interactionBits &= ~IA_LIGHT;
						break;
					}

					if ( r == 1 )
					{
						planeBits &= ~( 1 << i );  // all descendants will also be in front
					}
				}
			}
		}

		// don't waste time on nodes with no interactions
		if ( !interactionBits )
		{
			return;
		}

		if ( node->contents != -1 )
		{
			break;
		}

		// node is just a decision point, so go down both sides
		// since we don't care about sort orders, just go positive to negative
		r = BoxOnPlaneSide( light->worldBounds[ 0 ], light->worldBounds[ 1 ], node->plane );

		switch ( r )
		{
			case 1:
				node = node->children[ 0 ];
				break;

			case 2:
				node = node->children[ 1 ];
				break;

			case 3:
			default:
				// recurse down the children, front side first
				R_RecursiveInteractionNode( node->children[ 0 ], light, planeBits, interactionBits );

				// tail recurse
				node = node->children[ 1 ];
				break;
		}
	}
	while ( 1 );

	{
		// leaf node, so add mark surfaces
		int          c;
		bspSurface_t *surf, **mark;

		// add the individual surfaces
		mark = tr.world->markSurfaces + node->firstMarkSurface;
		c = node->numMarkSurfaces;

		while ( c-- )
		{
			// the surface may have already been added if it
			// spans multiple leafs
			surf = *mark;
			R_AddInteractionSurface( surf, light, interactionBits );
			mark++;
		}
	}
}

/*
===============
R_PointInLeaf
===============
*/
static bspNode_t *R_PointInLeaf( const vec3_t p )
{
	bspNode_t *node;
	float     d;
	cplane_t  *plane;

	if ( !tr.world )
	{
		ri.Error( ERR_DROP, "R_PointInLeaf: bad model" );
	}

	node = tr.world->nodes;

	while ( 1 )
	{
		if ( node->contents != -1 )
		{
			break;
		}

		plane = node->plane;
		d = DotProduct( p, plane->normal ) - plane->dist;

		if ( d > 0 )
		{
			node = node->children[ 0 ];
		}
		else
		{
			node = node->children[ 1 ];
		}
	}

	return node;
}

/*
==============
R_ClusterPVS
==============
*/
static const byte *R_ClusterPVS( int cluster )
{
	if ( !tr.world || !tr.world->vis || cluster < 0 || cluster >= tr.world->numClusters )
	{
		return tr.world->novis;
	}

	return tr.world->vis + cluster * tr.world->clusterBytes;
}

/*
==============
R_ClusterPVVS
==============
*/
static const byte *R_ClusterPVVS( int cluster )
{
	if ( !tr.world || !tr.world->vis || cluster < 0 || cluster >= tr.world->numClusters )
	{
		return tr.world->novis;
	}

	return tr.world->visvis + cluster * tr.world->clusterBytes;
}

/*
=================
R_inPVS
=================
*/
bool R_inPVS( const vec3_t p1, const vec3_t p2 )
{
	bspNode_t  *leaf;
	const byte *vis;

	leaf = R_PointInLeaf( p1 );
	vis = R_ClusterPVS( leaf->cluster );
	leaf = R_PointInLeaf( p2 );

	if ( !( vis[ leaf->cluster >> 3 ] & ( 1 << ( leaf->cluster & 7 ) ) ) )
	{
		return false;
	}

	return true;
}

/*
=================
R_inPVVS
=================
*/
bool R_inPVVS( const vec3_t p1, const vec3_t p2 )
{
	bspNode_t  *leaf;
	const byte *vis;

	leaf = R_PointInLeaf( p1 );
	vis = R_ClusterPVVS( leaf->cluster );
	leaf = R_PointInLeaf( p2 );

	if ( !( vis[ leaf->cluster >> 3 ] & ( 1 << ( leaf->cluster & 7 ) ) ) )
	{
		return false;
	}

	return true;
}

/*
===============
R_MarkLeaves

Mark the leaves and nodes that are in the PVS for the current
cluster
===============
*/
static void R_MarkLeaves()
{
	const byte *vis;
	bspNode_t  *leaf, *parent;
	int        i;
	int        cluster;

	// lockpvs lets designers walk around to determine the
	// extent of the current pvs
	if ( r_lockpvs->integer )
	{
		return;
	}

	// current viewcluster
	leaf = R_PointInLeaf( tr.viewParms.pvsOrigin );
	cluster = leaf->cluster;

	// if the cluster is the same and the area visibility matrix
	// hasn't changed, we don't need to mark everything again
	if( tr.refdef.areamaskModified ) {
		// remark ALL cached visClusters
		for ( i = 0; i < MAX_VISCOUNTS; i++ ) {
			tr.visClusters[ i ] = -1;
		}
		tr.visIndex = 1;
	} else {
		for ( i = 0; i < MAX_VISCOUNTS; i++ ) {
			if ( tr.visClusters[ i ] == cluster ) {
				// if r_showcluster was just turned on, remark everything
				if ( !r_showcluster->modified )
				{
					if ( tr.visClusters[ i ] != tr.visClusters[ tr.visIndex ] && r_showcluster->integer )
					{
						ri.Printf( PRINT_ALL, "found cluster:%i  area:%i  index:%i\n", cluster, leaf->area, i );
					}

					tr.visIndex = i;
					return;
				}
			}
		}
		tr.visIndex = ( tr.visIndex + 1 ) % MAX_VISCOUNTS;
	}

	tr.visClusters[ tr.visIndex ] = cluster;
	tr.visCounts[ tr.visIndex ]++;

	if ( r_showcluster->modified || r_showcluster->integer )
	{
		r_showcluster->modified = false;

		if ( r_showcluster->integer )
		{
			ri.Printf( PRINT_ALL, "update cluster:%i  area:%i  index:%i\n", cluster, leaf->area, tr.visIndex );
		}
	}

	if ( r_novis->integer || tr.visClusters[ tr.visIndex ] == -1 )
	{
		for ( i = 0; i < tr.world->numnodes; i++ )
		{
			if ( tr.world->nodes[ i ].contents != CONTENTS_SOLID )
			{
				tr.world->nodes[ i ].visCounts[ tr.visIndex ] = tr.visCounts[ tr.visIndex ];
			}
		}

		return;
	}

	vis = R_ClusterPVS( tr.visClusters[ tr.visIndex ] );

	for ( i = 0, leaf = tr.world->nodes; i < tr.world->numnodes; i++, leaf++ )
	{
		if ( tr.world->vis )
		{
			cluster = leaf->cluster;

			if ( cluster >= 0 && cluster < tr.world->numClusters )
			{
				// check general pvs
				if ( !( vis[ cluster >> 3 ] & ( 1 << ( cluster & 7 ) ) ) )
				{
					continue;
				}
			}
		}

		// check for door connection
		if ( ( tr.refdef.areamask[ leaf->area >> 3 ] & ( 1 << ( leaf->area & 7 ) ) ) )
		{
			// not visible
			continue;
		}

		// ydnar: don't want to walk the entire bsp to add skybox surfaces
		if ( tr.refdef.rdflags & RDF_SKYBOXPORTAL )
		{
			// this only happens once, as game/cgame know the origin of the skybox
			// this also means the skybox portal cannot move, as this list is calculated once and never again
			if ( tr.world->numSkyNodes < WORLD_MAX_SKY_NODES )
			{
				tr.world->skyNodes[ tr.world->numSkyNodes++ ] = leaf;
			}

			R_AddLeafSurfaces( leaf, 0, FRUSTUM_CLIPALL );
			continue;
		}

		parent = leaf;

		do
		{
			if ( parent->visCounts[ tr.visIndex ] == tr.visCounts[ tr.visIndex ] )
			{
				break;
			}

			parent->visCounts[ tr.visIndex ] = tr.visCounts[ tr.visIndex ];
			parent = parent->parent;
		}
		while ( parent );
	}
}

/*
=============
R_AddWorldSurfaces
=============
*/
void R_AddWorldSurfaces()
{
	if ( !r_drawworld->integer )
	{
		return;
	}

	if ( tr.refdef.rdflags & RDF_NOWORLDMODEL )
	{
		return;
	}

	tr.currentEntity = &tr.worldEntity;

	// clear out the visible min/max
	ClearBounds( tr.viewParms.visBounds[ 0 ], tr.viewParms.visBounds[ 1 ] );

	// render sky or world?
	if ( tr.refdef.rdflags & RDF_SKYBOXPORTAL && tr.world->numSkyNodes > 0 )
	{
		int       i;
		bspNode_t **node;

		for ( i = 0, node = tr.world->skyNodes; i < tr.world->numSkyNodes; i++, node++ )
		{
			R_AddLeafSurfaces( *node, 0, FRUSTUM_CLIPALL );  // no decals on skybox nodes
		}
	}
	else
	{
		// determine which leaves are in the PVS / areamask
		R_MarkLeaves();

		// clear traversal list
		backEndData[ tr.smpFrame ]->traversalLength = 0;

		// update visbounds and add surfaces that weren't cached with VBOs
		R_RecursiveWorldNode( tr.world->nodes, FRUSTUM_CLIPALL, tr.refdef.decalBits );

		// ydnar: add decal surfaces
		R_AddDecalSurfaces( tr.world->models );
	}
}

/*
=============
R_AddWorldInteractions
=============
*/
void R_AddWorldInteractions( trRefLight_t *light )
{
	int interactionBits;

	if ( !r_drawworld->integer )
	{
		return;
	}

	if ( tr.refdef.rdflags & RDF_NOWORLDMODEL )
	{
		return;
	}

	tr.currentEntity = &tr.worldEntity;

	// perform frustum culling and add all the potentially visible surfaces
	tr.lightCount++;

	interactionBits = IA_DEFAULT;

	if ( light->restrictInteractionFirst >= 0 )
	{
		interactionBits = IA_DEFAULTCLIP;
	}

	if ( r_shadows->integer <= SHADOWING_BLOB || light->l.noShadows )
	{
		interactionBits = interactionBits & IA_LIGHT;
	}

	R_RecursiveInteractionNode( tr.world->nodes, light, FRUSTUM_CLIPALL, interactionBits );
}

/*
=============
R_AddPrecachedWorldInteractions
=============
*/
void R_AddPrecachedWorldInteractions( trRefLight_t *light )
{
	interactionType_t iaType = IA_DEFAULT;

	if ( !r_drawworld->integer )
	{
		return;
	}

	if ( tr.refdef.rdflags & RDF_NOWORLDMODEL )
	{
		return;
	}

	if ( !light->firstInteractionCache )
	{
		// this light has no interactions precached
		return;
	}

	tr.currentEntity = &tr.worldEntity;

	if ( ( r_vboShadows->integer || r_vboLighting->integer ) )
	{
		interactionCache_t *iaCache;
		interactionVBO_t   *iaVBO;
		srfVBOMesh_t       *srf;
		shader_t           *shader;
		bspSurface_t       *surface;

		// this can be shadow mapping or shadowless lighting
		for ( iaVBO = light->firstInteractionVBO; iaVBO; iaVBO = iaVBO->next )
		{
			if ( !iaVBO->vboLightMesh )
			{
				continue;
			}

			srf = iaVBO->vboLightMesh;
			shader = iaVBO->shader;

			switch ( light->l.rlType )
			{
				case RL_OMNI:
					R_AddLightInteraction( light, ( surfaceType_t * ) srf, shader, CUBESIDE_CLIPALL, IA_LIGHT );
					break;

				case RL_DIRECTIONAL:
				case RL_PROJ:
					R_AddLightInteraction( light, ( surfaceType_t * ) srf, shader, CUBESIDE_CLIPALL, IA_LIGHT );
					break;

				default:
					R_AddLightInteraction( light, ( surfaceType_t * ) srf, shader, CUBESIDE_CLIPALL, IA_DEFAULT );
					break;
			}
		}

		// add meshes for shadowmap generation if any
		for ( iaVBO = light->firstInteractionVBO; iaVBO; iaVBO = iaVBO->next )
		{
			if ( !iaVBO->vboShadowMesh )
			{
				continue;
			}

			srf = iaVBO->vboShadowMesh;
			shader = iaVBO->shader;

			R_AddLightInteraction( light, ( surfaceType_t * ) srf, shader, iaVBO->cubeSideBits, IA_SHADOW );
		}

		// add interactions that couldn't be merged into VBOs
		for ( iaCache = light->firstInteractionCache; iaCache; iaCache = iaCache->next )
		{
			if ( iaCache->redundant )
			{
				continue;
			}

			if ( iaCache->mergedIntoVBO )
			{
				continue;
			}

			surface = iaCache->surface;

			// Tr3B - this surface is maybe not in this view but it may still cast a shadow
			// into this view
			if ( surface->viewCount != tr.viewCountNoReset )
			{
				if ( r_shadows->integer < SHADOWING_ESM16 || light->l.noShadows )
				{
					continue;
				}
				else
				{
					iaType = IA_SHADOW;
				}
			}
			else
			{
				iaType = iaCache->type;
			}

			R_AddLightInteraction( light, surface->data, surface->shader, iaCache->cubeSideBits, iaType );
		}
	}
	else
	{
		interactionCache_t *iaCache;
		bspSurface_t       *surface;

		for ( iaCache = light->firstInteractionCache; iaCache; iaCache = iaCache->next )
		{
			if ( iaCache->redundant )
			{
				continue;
			}

			surface = iaCache->surface;

			// Tr3B - this surface is maybe not in this view but it may still cast a shadow
			// into this view
			if ( surface->viewCount != tr.viewCountNoReset )
			{
				if ( r_shadows->integer < SHADOWING_ESM16 || light->l.noShadows )
				{
					continue;
				}
				else
				{
					iaType = IA_SHADOW;
				}
			}
			else
			{
				iaType = iaCache->type;
			}

			R_AddLightInteraction( light, surface->data, surface->shader, iaCache->cubeSideBits, iaType );
		}
	}
}


text:
// This file is automatically generated.

package adila.db;

/*
 * Alcatel one_touch_4030_TLVE
 *
 * DEVICE: Beetle_GSM
 * MODEL: ALCATEL_one_touch_4030A
 */
final class beetle5fgsm_alcatel5fone5ftouch5f4030a {
    public static final String DATA = "Alcatel|one_touch_4030_TLVE|";
}