Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pt mesh #9

Merged
merged 8 commits into from
Mar 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions examples/geometry/curves/exampleAlphaThickSegment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,43 +72,44 @@ int main( )

//construction of an AlphaThickSegmentComputer2D from the freemanchain iterator
AlphaThickSegmentComputer2D anAlphaSegment(15), anAlphaSegment2(5), anAlphaSegment3(2);
anAlphaSegment.init(fc.begin());
while (anAlphaSegment.end() != fc.end() &&
anAlphaSegment.init(fc.begin());
while (anAlphaSegment.end() != fc.end() &&
anAlphaSegment.extendFront()) {
}
aBoard << anAlphaSegment;

anAlphaSegment2.init(fc.begin());
while (anAlphaSegment2.end() != fc.end() && anAlphaSegment2.extendFront()) {
}
aBoard << CustomStyle( anAlphaSegment2.className(), new CustomColors( DGtal::Color::Blue, DGtal::Color::None ) );
aBoard << anAlphaSegment2;

aBoard << anAlphaSegment;
// Example of thickness definition change: usin the euclidean thickness definition.
//! [exampleAlphaThickSegmentEuclDef]
AlphaThickSegmentComputer2D anAlphaSegment2Eucl(5, functions::Hull2D::EuclideanThickness);
//! [exampleAlphaThickSegmentEuclDef]

anAlphaSegment2Eucl.init(fc.begin());
while (anAlphaSegment2Eucl.end() != fc.end() &&
while (anAlphaSegment2Eucl.end() != fc.end() &&
anAlphaSegment2Eucl.extendFront()) {
}

aBoard << CustomStyle( anAlphaSegment2Eucl.className(),
new CustomColors( DGtal::Color(20, 250, 255), DGtal::Color::None ) );
aBoard << CustomStyle( anAlphaSegment2Eucl.className(),
new CustomColors( DGtal::Color(20, 250, 255), DGtal::Color::None ) );
aBoard << anAlphaSegment2Eucl;



anAlphaSegment2.init(fc.begin());
while (anAlphaSegment2.end() != fc.end() && anAlphaSegment2.extendFront()) {
}
aBoard << CustomStyle( anAlphaSegment2.className(), new CustomColors( DGtal::Color::Blue, DGtal::Color::None ) );
aBoard << anAlphaSegment2;



FCConstIterator fcIt = fc.begin();
while (anAlphaSegment3.extendFront(*fcIt)) {
fcIt++;
}


aBoard << CustomStyle( anAlphaSegment3.className(), new CustomColors( DGtal::Color::Green, DGtal::Color::None ) );
aBoard << CustomStyle( anAlphaSegment3.className(), new CustomColors( DGtal::Color::Green, DGtal::Color::None ) );
aBoard << anAlphaSegment3;



aBoard.saveEPS("exampleAlphaThickSegment.eps");

Expand Down
5 changes: 3 additions & 2 deletions examples/images/exampleArrayImageAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ void ArrayImageAdapter_example()
//! [ArrayImageAdapter_example]
using Space = SpaceND<2>;
using Domain = HyperRectDomain<Space>;
using Point = Domain::Point;
using Value = double;

const Domain domain{ {0, 1}, {4, 3} };
const Domain domain( Point(0, 1), Point(4, 3) );

Value* data = new Value[ domain.size() ];

Expand All @@ -73,7 +74,7 @@ void ArrayImageAdapter_example()
}

// Get a constant view on a sub-domain.
const Domain sub_domain{ {1, 1}, {3, 2} };
const Domain sub_domain( Point(1, 1), Point(3, 2) );
ArrayImageAdapter< Value const*, Domain > cst_image( data, domain, sub_domain );
// Alternative syntax using the helpers:
// auto const cst_image = makeArrayImageAdapterFromImage( image, sub_domain );
Expand Down
2 changes: 1 addition & 1 deletion examples/io/viewers/viewer3D-8bis-2Dimages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ int main( int argc, char** argv )
//! [ExampleViewer3D2DImagesExtractImagesNonSliceExtract]
// Extracting images from 3D embeder
DGtal::functors::Point2DEmbedderIn3D<DGtal::Z3i::Domain > embedder(imageVol.domain(),
ptCenter+DGtal::Z3i::RealPoint(200.0*cos(alpha),100.0*sin(alpha)),
ptCenter+DGtal::Z3i::Point(static_cast<int>(200.0*cos(alpha)),static_cast<int>(100.0*sin(alpha))),
DGtal::Z3i::RealPoint(cos(alpha),sin(alpha),cos(2.0*alpha)),
IMAGE_PATCH_WIDTH);
ImageAdapterExtractor extractedImage(imageVol, domainImage2D, embedder, idV);
Expand Down
136 changes: 134 additions & 2 deletions src/DGtal/base/BasicFunctors.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ namespace DGtal
/**
* Abs functor.
*/
template <class T>
template <class T = void>
struct Abs
{
inline
Expand Down Expand Up @@ -120,7 +120,7 @@ namespace DGtal
};

/**
* Unary minus functor.
* Multiplication by a scalar functor.
*/
template <class T>
struct MultiplicationByScalar
Expand All @@ -143,6 +143,138 @@ namespace DGtal
T myValue;
};

/** @brief Functor that rounds to the nearest integer.
*
* @tparam T Type to be rounded. If not specified (void), the type is deduced at evaluation.
*/
template < typename T = void >
struct Round
{
inline
auto operator() ( const T & value ) const
-> decltype(std::round(value))
{
return std::round( value );
}
};

/** @brief Functor that rounds to the nearest integer.
*
* This specialization deduces the value type at evaluation.
*
* @see Round
*/
template <>
struct Round<void>
{
template < typename T >
inline
auto operator() ( const T & value ) const
-> decltype(std::round(value))
{
return std::round( value );
}
};

/** @brief Functor that rounds down.
*
* @tparam T Type to be rounded. If not specified (void), the type is deduced at evaluation.
*/
template < typename T = void >
struct Floor
{
inline
auto operator() ( const T & value ) const
-> decltype(std::floor(value))
{
return std::floor( value );
}
};

/** @brief Functor that rounds down.
*
* This specialization deduces the value type at evaluation.
*
* @see Floor
*/
template <>
struct Floor<void>
{
template < typename T >
inline
auto operator() ( const T & value ) const
-> decltype(std::floor(value))
{
return std::floor( value );
}
};

/** @brief Functor that rounds up.
*
* @tparam T Type to be rounded. If not specified (void), the type is deduced at evaluation.
*/
template < typename T = void >
struct Ceil
{
inline
auto operator() ( const T & value ) const
-> decltype(std::ceil(value))
{
return std::ceil( value );
}
};

/** @brief Functor that rounds up.
*
* This specialization deduces the value type at evaluation.
*
* @see Ceil
*/
template <>
struct Ceil<void>
{
template < typename T >
inline
auto operator() ( const T & value ) const
-> decltype(std::ceil(value))
{
return std::ceil( value );
}
};

/** @brief Functor that rounds towards zero.
*
* @tparam T Type to be rounded. If not specified (void), the type is deduced at evaluation.
*/
template < typename T = void >
struct Trunc
{
inline
auto operator() ( const T & value ) const
-> decltype(std::trunc(value))
{
return std::trunc( value );
}
};

/** @brief Functor that rounds towards zero.
*
* This specialization deduces the value type at evaluation.
*
* @see Trunc
*/
template <>
struct Trunc<void>
{
template < typename T >
inline
auto operator() ( const T & value ) const
-> decltype(std::trunc(value))
{
return std::trunc( value );
}
};

///////////////////////////////////////////////////////////////////////////////
// Some basic unary functors that may be useful
//////////////////////////////////////////////////////////////////////////////
Expand Down
8 changes: 4 additions & 4 deletions src/DGtal/geometry/curves/AlphaThickSegmentComputer.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class AlphaThickSegmentComputer

typedef typename InputPointContainer::iterator Iterator;
typedef TConstIterator ConstIterator;
typedef ParallelStrip< SpaceND< 2, DGtal::int32_t > ,true,true> Primitive;
typedef ParallelStrip< SpaceND< 2, DGtal::int32_t > ,true,true> Primitive;

/**
* Type of embedded points
Expand Down Expand Up @@ -663,9 +663,9 @@ class AlphaThickSegmentComputer
* @param[out] ptProjected the projected point.
* @return true if ptProjected is inside the segment [A,B].
**/
template<typename TPointD>
bool projectOnStraightLine(const TPointD & ptA, const TPointD & ptB,
const TPointD & ptC, PointD & ptProjected) const;
template<typename TPoint, typename TPointD>
bool projectOnStraightLine(const TPoint & ptA, const TPoint & ptB,
const TPoint & ptC, TPointD & ptProjected) const;


/**
Expand Down
Loading