Shinya Kitaoka 810553
#pragma once
Shinya Kitaoka 810553
Toshihiro Shimizu 890ddd
#ifndef T_L2LAUTOCLOSER_H
Toshihiro Shimizu 890ddd
#define T_L2LAUTOCLOSER_H
Toshihiro Shimizu 890ddd
Shinya Kitaoka 262a92
#include <memory></memory>
Shinya Kitaoka 262a92
Toshihiro Shimizu 890ddd
#include "tgeometry.h"
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TVECTORIMAGE_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
e280ae
#ifdef _MSC_VER
Toshihiro Shimizu 890ddd
#pragma warning(disable : 4251)
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
// forward declaration
Toshihiro Shimizu 890ddd
class TStroke;
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//-----------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//! Line-to-line autocloser
Shinya Kitaoka 120a6e
class DVAPI TL2LAutocloser {
Shinya Kitaoka 120a6e
  class Imp;
Shinya Kitaoka 120a6e
  std::unique_ptr<imp> m_imp;</imp>
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 120a6e
  TL2LAutocloser();
Shinya Kitaoka 120a6e
  ~TL2LAutocloser();
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  struct Segment {
Shinya Kitaoka 120a6e
    //! the segments returned by the Line-to-line autocloser
Shinya Kitaoka 120a6e
    TStroke *stroke0, *stroke1;  // the two involved strokes
Shinya Kitaoka 120a6e
    double w0, w1;               // the w-parameters
Shinya Kitaoka 120a6e
    TThickPoint p0, p1;          // the related points
Shinya Kitaoka 120a6e
    double dist2;                // the (squared) points distance
Shinya Kitaoka 120a6e
  };
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! segments longer than sqrt(dist2) are not considered. the default is 50^2
Shinya Kitaoka 120a6e
  void setMaxDistance2(double dist2);
Shinya Kitaoka 120a6e
  double getMaxDistance2() const;
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! search line-to-line autoclosing segments.
Shinya Kitaoka 120a6e
  //! Note: it computes and caches some information about stroke0 and stroke1
Shinya Kitaoka 120a6e
  //! you are not supposed to change strokes between two subsequent calls to
Shinya Kitaoka 120a6e
  //! search()
Shinya Kitaoka 120a6e
  void search(std::vector<segment> &segments, TStroke *stroke0,</segment>
Shinya Kitaoka 120a6e
              TStroke *stroke1);
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! use this method if you have already computed the intersections
Shinya Kitaoka 120a6e
  void search(std::vector<segment> &segments, TStroke *stroke0,</segment>
Shinya Kitaoka 120a6e
              TStroke *stroke1, const std::vector<doublepair> &intersection);</doublepair>
Shinya Kitaoka 120a6e
Shinya Kitaoka 120a6e
  //! debug only. show the internal state related to the last performed search
Shinya Kitaoka 120a6e
  void draw();
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
private:
Shinya Kitaoka 120a6e
  // not implemented
Shinya Kitaoka 120a6e
  TL2LAutocloser(const TL2LAutocloser &);
Shinya Kitaoka 120a6e
  const TL2LAutocloser &operator=(const TL2LAutocloser &);
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
//---------------------------------------------------------------------------------------
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
#endif  // T_L2LAUTOCLOSER_H