2016-05-17 03:04:11 +12:00
|
|
|
#pragma once
|
|
|
|
|
2016-03-19 06:57:51 +13:00
|
|
|
#ifndef T_L2LAUTOCLOSER_H
|
|
|
|
#define T_L2LAUTOCLOSER_H
|
|
|
|
|
2016-04-14 22:15:09 +12:00
|
|
|
#include <memory>
|
|
|
|
|
2016-03-19 06:57:51 +13:00
|
|
|
#include "tgeometry.h"
|
|
|
|
|
|
|
|
#undef DVAPI
|
|
|
|
#undef DVVAR
|
|
|
|
#ifdef TVECTORIMAGE_EXPORTS
|
|
|
|
#define DVAPI DV_EXPORT_API
|
|
|
|
#define DVVAR DV_EXPORT_VAR
|
|
|
|
#else
|
|
|
|
#define DVAPI DV_IMPORT_API
|
|
|
|
#define DVVAR DV_IMPORT_VAR
|
|
|
|
#endif
|
|
|
|
|
2017-05-09 00:13:29 +12:00
|
|
|
#ifdef _MSC_VER
|
2016-03-19 06:57:51 +13:00
|
|
|
#pragma warning(disable : 4251)
|
|
|
|
#endif
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
// forward declaration
|
2016-03-19 06:57:51 +13:00
|
|
|
class TStroke;
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
//! Line-to-line autocloser
|
2016-06-15 18:43:10 +12:00
|
|
|
class DVAPI TL2LAutocloser {
|
|
|
|
class Imp;
|
|
|
|
std::unique_ptr<Imp> m_imp;
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
public:
|
2016-06-15 18:43:10 +12:00
|
|
|
TL2LAutocloser();
|
|
|
|
~TL2LAutocloser();
|
|
|
|
|
|
|
|
struct Segment {
|
|
|
|
//! the segments returned by the Line-to-line autocloser
|
|
|
|
TStroke *stroke0, *stroke1; // the two involved strokes
|
|
|
|
double w0, w1; // the w-parameters
|
|
|
|
TThickPoint p0, p1; // the related points
|
|
|
|
double dist2; // the (squared) points distance
|
|
|
|
};
|
|
|
|
|
|
|
|
//! segments longer than sqrt(dist2) are not considered. the default is 50^2
|
|
|
|
void setMaxDistance2(double dist2);
|
|
|
|
double getMaxDistance2() const;
|
|
|
|
|
|
|
|
//! search line-to-line autoclosing segments.
|
|
|
|
//! Note: it computes and caches some information about stroke0 and stroke1
|
|
|
|
//! you are not supposed to change strokes between two subsequent calls to
|
|
|
|
//! search()
|
|
|
|
void search(std::vector<Segment> &segments, TStroke *stroke0,
|
|
|
|
TStroke *stroke1);
|
|
|
|
|
|
|
|
//! use this method if you have already computed the intersections
|
|
|
|
void search(std::vector<Segment> &segments, TStroke *stroke0,
|
|
|
|
TStroke *stroke1, const std::vector<DoublePair> &intersection);
|
|
|
|
|
|
|
|
//! debug only. show the internal state related to the last performed search
|
|
|
|
void draw();
|
2016-03-19 06:57:51 +13:00
|
|
|
|
|
|
|
private:
|
2016-06-15 18:43:10 +12:00
|
|
|
// not implemented
|
|
|
|
TL2LAutocloser(const TL2LAutocloser &);
|
|
|
|
const TL2LAutocloser &operator=(const TL2LAutocloser &);
|
2016-03-19 06:57:51 +13:00
|
|
|
};
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------------------
|
|
|
|
|
2016-06-15 18:43:10 +12:00
|
|
|
#endif // T_L2LAUTOCLOSER_H
|