Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F98341424
geom_helper_functions.hh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Jan 12, 06:48
Size
4 KB
Mime Type
text/x-c++
Expires
Tue, Jan 14, 06:48 (1 d, 17 h)
Engine
blob
Format
Raw Data
Handle
23517410
Attached To
rAKA akantu
geom_helper_functions.hh
View Options
/**
* @file geom_helper_functions.hh
*
* @author Lucas Frérot <lucas.frerot@epfl.ch>
*
* @date creation: Wed Mar 4 2015
* @date last modification: Thu Mar 5 2015
*
* @brief Helper functions for the computational geometry algorithms
*
* @section LICENSE
*
* Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef _AKANTU_GEOM_HELPER_FUNCTIONS_HH__
#define _AKANTU_GEOM_HELPER_FUNCTIONS_HH__
#include "aka_common.hh"
#include "aka_math.hh"
#include "tree_type_helper.hh"
//#include <CGAL/squared_distance_3.h>
#include "mesh_geom_common.hh"
__BEGIN_AKANTU__
/// Fuzzy compare of two points
template
<
class
Point
>
bool
comparePoints
(
const
Point
&
a
,
const
Point
&
b
)
{
//std::cout << "CGAL::squared_distance(a,b) = " << CGAL::squared_distance(a,b) << std::endl;
/* std::cout << "xa = " << CGAL::to_double(a.x()) << ", ya = " << CGAL::to_double(a.y())
<< ", xb = " << CGAL::to_double(b.x()) << ", yb = " << CGAL::to_double(b.y()) << std::endl;
Real tol = 0.0000000001 ;
std::cout << "|xa-xb| = " << abs( CGAL::to_double(a.x()-b.x()) / tol )*tol
<< ", |ya-yb| = " << abs( CGAL::to_double(a.y() - b.y()) / tol )*tol << std::endl;
bool cdt2 = ( abs(CGAL::to_double(a.x()) - CGAL::to_double(b.x())) < tol ) &&
( abs(CGAL::to_double(a.y()) - CGAL::to_double(b.y())) < tol ) &&
( abs(CGAL::to_double(a.z()) - CGAL::to_double(b.z())) < tol );
bool cdt3 = Math::are_float_equal(CGAL::to_double(a.x()), CGAL::to_double(b.x())) &&
Math::are_float_equal(CGAL::to_double(a.y()), CGAL::to_double(b.y())) &&
Math::are_float_equal(CGAL::to_double(a.z()), CGAL::to_double(b.z()));
std::cout << "CGAL::compare_xyz(a,b) = " << CGAL::compare_xyz(a,b)
<< ", cdt2 = " << cdt2 << ", cdt3 = " << cdt3 << std::endl;
return ( CGAL::compare_xyz(a,b)==0 ) ;*/
return
Math
::
are_float_equal
(
CGAL
::
to_double
(
a
.
x
()),
CGAL
::
to_double
(
b
.
x
()))
&&
Math
::
are_float_equal
(
CGAL
::
to_double
(
a
.
y
()),
CGAL
::
to_double
(
b
.
y
()))
&&
Math
::
are_float_equal
(
CGAL
::
to_double
(
a
.
z
()),
CGAL
::
to_double
(
b
.
z
()));
}
/// Fuzzy compare of two segments
template
<
class
K
>
inline
bool
compareSegments
(
const
CGAL
::
Segment_3
<
K
>
&
a
,
const
CGAL
::
Segment_3
<
K
>
&
b
)
{
return
(
comparePoints
(
a
.
source
(),
b
.
source
())
&&
comparePoints
(
a
.
target
(),
b
.
target
()))
||
(
comparePoints
(
a
.
source
(),
b
.
target
())
&&
comparePoints
(
a
.
target
(),
b
.
source
()));
}
typedef
Cartesian
K
;
/// Compare segment pairs
inline
bool
compareSegmentPairs
(
const
std
::
pair
<
K
::
Segment_3
,
UInt
>
&
a
,
const
std
::
pair
<
K
::
Segment_3
,
UInt
>
&
b
)
{
return
compareSegments
(
a
.
first
,
b
.
first
);
}
/// Pair ordering operator based on first member
struct
segmentPairsLess
{
inline
bool
operator
()(
const
std
::
pair
<
K
::
Segment_3
,
UInt
>
&
a
,
const
std
::
pair
<
K
::
Segment_3
,
UInt
>
&
b
)
{
return
CGAL
::
compare_lexicographically
(
a
.
first
.
min
(),
b
.
first
.
min
())
||
CGAL
::
compare_lexicographically
(
a
.
first
.
max
(),
b
.
first
.
max
());
}
};
/* -------------------------------------------------------------------------- */
/* Predicates */
/* -------------------------------------------------------------------------- */
/// Predicate used to determine if two segments are equal
class
IsSameSegment
{
public
:
IsSameSegment
(
const
K
::
Segment_3
&
segment
)
:
segment
(
segment
)
{}
bool
operator
()(
const
std
::
pair
<
K
::
Segment_3
,
UInt
>
&
test_pair
)
{
return
compareSegments
(
segment
,
test_pair
.
first
);
}
protected
:
const
K
::
Segment_3
segment
;
};
__END_AKANTU__
#endif
// _AKANTU_GEOM_HELPER_FUNCTIONS_HH__
Event Timeline
Log In to Comment