Program Listing for File triangle.hxx¶
↰ Return to documentation for file (src/acme/triangle.hxx
)
/*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* The ACME project *
* *
* Copyright (c) 2020, Davide Stocco and Enrico Bertolazzi. *
* *
* The ACME project and its components are supplied under the terms of *
* the open source BSD 2-Clause License. The contents of the ACME *
* project and its components may not be copied or disclosed except in *
* accordance with the terms of the BSD 2-Clause License. *
* *
* URL: https://opensource.org/licenses/BSD-2-Clause *
* *
* Davide Stocco *
* Department of Industrial Engineering *
* University of Trento *
* e-mail: davide.stocco@unitn.it *
* *
* Enrico Bertolazzi *
* Department of Industrial Engineering *
* University of Trento *
* e-mail: enrico.bertolazzi@unitn.it *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*/
#pragma once
#ifndef INCLUDE_ACME_TRIANGLE_HXX
#define INCLUDE_ACME_TRIANGLE_HXX
#include "aabb.hxx"
#include "point.hxx"
#include "plane.hxx"
#include "segment.hxx"
namespace acme
{
/*\
| _ _ _
| | |_ _ __(_) __ _ _ __ __ _| | ___
| | __| '__| |/ _` | '_ \ / _` | |/ _ \
| | |_| | | | (_| | | | | (_| | | __/
| \__|_| |_|\__,_|_| |_|\__, |_|\___|
| |___/
\*/
class triangle : public entity
{
private:
point m_vertex[3] = {NAN_POINT, NAN_POINT, NAN_POINT};
public:
triangle(triangle const &) = default;
triangle(triangle &&) = default;
triangle & operator=(const triangle &) = default;
triangle & operator=(triangle &&) = default;
~triangle(void) override = default;
triangle(void);
triangle(
real vertex0_x,
real vertex0_y,
real vertex0_z,
real vertex1_x,
real vertex1_y,
real vertex1_z,
real vertex2_x,
real vertex2_y,
real vertex2_z
);
triangle(
point const & vertex0,
point const & vertex1,
point const & vertex2
);
triangle(
point const vertex[3]
);
bool
isApprox(
triangle const & triangle_in,
real tolerance = EPSILON
) const;
point const &
vertex(
integer i
) const;
point &
vertex(
integer i
);
point const &
operator[](
integer i
) const;
point &
operator[](
integer i
);
point
centroid(void)
const;
segment
edge(
integer i
) const;
vec3
normal(void)
const;
void
swap(
integer i,
integer j
);
real
perimeter(void)
const;
real
area(void)
const;
void
barycentric(
point const & point_in,
real & u,
real & v,
real & w
) const;
plane
layingPlane(void)
const;
void
translate(
vec3 const & vector_in
) override;
void
transform(
affine const & affine_in
) override;
bool
isInside(
point const & point_in,
real tolerance = EPSILON
) const;
bool
isDegenerated(
real tolerance = EPSILON
) const override;
inline
integer
level(void)
const override
{
return integer(7);
}
inline
std::string
type(void)
const override
{
return "triangle";
}
inline
bool
isNone(void)
const override
{
return false;
}
inline
bool
isPoint(void)
const override
{
return false;
}
inline
bool
isLine(void)
const override
{
return false;
}
inline
bool
isRay(void)
const override
{
return false;
}
inline
bool
isPlane(void)
const override
{
return false;
}
inline
bool
isSegment(void)
const override
{
return false;
}
inline
bool
isTriangle(void)
const override
{
return true;
}
inline
bool
isDisk(void)
const override
{
return false;
}
inline
bool
isBall(void)
const override
{
return false;
}
inline
bool
isClampable(void)
const override
{
return true;
}
inline
bool
isNonClampable(void)
const override
{
return false;
}
bool
clamp(
vec3 & min,
vec3 & max
) const override;
bool
clamp(
real & min_x,
real & min_y,
real & min_z,
real & max_x,
real & max_y,
real & max_z
) const override;
}; // class triangle
static triangle const & NAN_TRIANGLE = * new triangle(NAN_POINT, NAN_POINT, NAN_POINT);
static triangle & DUMMY_TRIANGLE = * new triangle(NAN_POINT, NAN_POINT, NAN_POINT);
} // namespace acme
#endif