19 #ifndef _WX_POLYVERH__
20 #define _WX_POLYVERH__
22 #include "wx/geometry.h"
35 A2DARTBASEDLLEXP
bool InArc(
double angle,
double start,
double end,
bool clockwise );
66 friend inline Hit
operator | ( Hit a, Hit b ) {
return ( Hit )( ( int )a | (
int ) b ); }
96 a2dHit() { memset(
this, 0,
sizeof( *
this ) ); }
103 m_distance = distance;
107 bool IsHit()
const {
return m_hit != hit_none; }
111 bool IsFillHit()
const {
return ( m_hit & hit_fill ) != 0; }
113 bool IsInsideHit()
const {
return ( m_hit & hit_fill ) != 0 || ( m_hit & hit_stroke ) != 0 && m_stroke1 == stroke1_inside; }
120 bool IsChildHit()
const {
return ( m_hit & hit_child ) != 0; }
125 bool IsVertexHit()
const {
return ( IsStrokeHit() && m_stroke2 == stroke2_vertex ) != 0 ; }
130 return ( IsStrokeHit() &&
131 ( m_stroke2 == stroke2_edgehor || m_stroke2 == stroke2_edgevert || m_stroke2 == stroke2_edgeother ) ) != 0 ;
166 #ifdef CLASS_MEM_MANAGEMENT
172 void*
operator new(
size_t bytes )
174 return sm_memManager.
Allocate( bytes );
183 void operator delete(
void* space,
size_t bytes )
185 sm_memManager.Deallocate( space, bytes );
187 #endif //CLASS_MEM_MANAGEMENT
207 inline bool GetArc()
const {
return m_arc; }
210 inline int GetPointCount()
const {
return m_pntCnt;}
212 inline bool GetBin()
const {
return m_bin; }
214 inline void SetBin(
bool bin ) { m_bin = bin; }
221 void SetPoint(
a2dPoint2D pos ) { m_x = pos.m_x; m_y = pos.m_y; }
244 unsigned int m_pntCnt: 2;
251 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
280 bool SmrtPtrRelease()
283 wxASSERT_MSG( m_refcount >= 0, wxT(
"a2dLineSegment Own/Release not matched (extra Release calls)" ) );
284 if ( m_refcount <= 0 )
299 #if defined(WXART2D_USINGDLL)
303 #if defined(WXART2D_USINGDLL)
305 template class A2DARTBASEDLLEXP std::allocator<class a2dSmrtPtr<class a2dLineSegment> >;
306 template class A2DARTBASEDLLEXP std::allocator< std::_List_nod<class a2dSmrtPtr<class a2dLineSegment>, std::allocator<class a2dSmrtPtr<class a2dLineSegment> > >::_Node >;
307 template class A2DARTBASEDLLEXP std::allocator< std::_List_ptr<class a2dSmrtPtr<class a2dLineSegment>, std::allocator<class a2dSmrtPtr<class a2dLineSegment> > >::_Nodeptr >;
308 template class A2DARTBASEDLLEXP std::list<class a2dSmrtPtr<class a2dLineSegment> >::iterator;
309 template class A2DARTBASEDLLEXP std::list<class a2dSmrtPtr<class a2dLineSegment> >;
315 class a2dLineSegmentProperty;
321 a2dPolyHandle::PROPID_linesegment.SetPropertyObjectToObject(
322 handle,
new a2dLineSegmentProperty( a2dPolyHandle::PROPID_linesegment, seg ) );
324 a2dLineSegment* segment = a2dHandle::PROPID_linesegment.GetPropertyValuePtr( handle );
332 a2dLineSegmentProperty();
334 a2dLineSegmentProperty(
const a2dPropertyIdLineSegment&
id,
a2dLineSegment* segment );
336 a2dLineSegmentProperty(
const a2dLineSegmentProperty& other );
342 virtual ~a2dLineSegmentProperty();
346 static a2dLineSegmentProperty* CreatePropertyFromString(
const a2dPropertyIdLineSegment&
id,
const wxString& value );
350 #if wxART2D_USE_CVGIO
353 #endif //wxART2D_USE_CVGIO
355 DECLARE_DYNAMIC_CLASS( a2dLineSegmentProperty )
383 a2dArcSegment(
double x1 = 0,
double y1 = 0,
double x2 = 0,
double y2 = 0 );
432 bool CalcR(
const a2dLineSegment& prev,
double& radius,
double& center_x,
double& center_y,
double& beginrad,
double& midrad,
double& endrad,
double& phit )
const;
445 void CalcMidPoint(
const a2dLineSegment& prev,
double center_x,
double center_y,
double radius,
bool clockwise );
456 void SetMidPoint(
const a2dLineSegment& prev,
double xm,
double ym );
477 #include <wx/listimpl.cpp>
515 a2dLineSegmentPtr GetPreviousAround( wxUint32 index )
const;
518 a2dLineSegmentPtr GetNextAround( wxUint32 index )
const;
520 inline a2dLineSegmentPtr Item( wxUint32 index ) {
return this->operator[]( index ); }
522 inline a2dLineSegmentPtr Item( wxUint32 index )
const {
return this->operator[]( index ); }
524 void RemoveAt(
size_t index );
529 double Length()
const;
532 void AddPoint(
const a2dPoint2D& point,
bool atEnd =
true );
535 void AddPoint(
double x,
double y,
bool atEnd =
true );
538 void SetPointAdjustArcs(
unsigned int n,
double x,
double y,
bool polygon );
541 void SetPointAdjustArcs( a2dLineSegmentPtr seg,
double x,
double y,
bool polygon );
545 double CalcArea()
const;
548 void ConvertToLines(
double aberation = 0 );
555 bool HasArcs()
const;
570 a2dVpath* ConvertToVpath(
bool arc,
bool closed =
false );
587 bool RemoveRedundant(
bool polygon );
590 a2dVertexList* GetRedundant(
bool polygon,
double smallest = 0 );
605 a2dVertexList(
const a2dVertexList& other );
611 a2dVertexList& operator=(
const a2dVertexList& other );
616 bool HasArcs()
const;
619 a2dVertexList::iterator GetPreviousAround( a2dVertexList::iterator iter );
622 a2dVertexList::iterator GetNextAround( a2dVertexList::iterator iter );
625 a2dVertexList::const_iterator GetPreviousAround( a2dVertexList::const_iterator iter )
const;
628 a2dVertexList::const_iterator GetNextAround( a2dVertexList::const_iterator iter )
const;
631 void MakeBegin( a2dVertexList::iterator iter );
640 void Insert(
unsigned int index, a2dLineSegmentPtr segin );
643 void SetPointAdjustArcs(
unsigned int n,
double x,
double y,
bool polygon );
645 void SetPointAdjustArcs( a2dLineSegmentPtr segin,
double x,
double y,
bool polygon );
648 void ConvertToLines(
double aberation = 0 );
655 void ConvertToLines(
double dphi,
int minseg );
659 double CalcArea()
const;
666 bool DirectionIsClockWise();
668 bool CheckForOneCircle(
a2dPoint2D& middle,
double& radius );
684 void InsertArc( a2dVertexList::iterator& iter,
int n,
double center_x,
double center_y );
690 void ConvertPolylineToArc(
double aber,
double Rmin,
double Rmax );
692 void ConvertPolygonToArc(
double aber,
double Rmin,
double Rmax );
712 int TestArc( a2dVertexList::iterator& iter,
double aber,
double Rmin,
double Rmax ,
a2dPoint2D& center_p_old );
722 a2dVertexList* ConvertSplinedPolygon(
double Aber )
const;
725 a2dVertexList* ConvertSplinedPolyline(
double Aber )
const;
727 void ConvertIntoSplinedPolygon(
double Aber );
729 void ConvertIntoSplinedPolyline(
double Aber );
732 a2dVertexList* ConvertToContour(
double distance,
a2dPATH_END_TYPE pathtype,
bool asPolygon =
false );
735 a2dVpath* ConvertToVpath(
bool arc,
bool closed =
false );
738 void Contour(
double distance,
a2dPATH_END_TYPE pathtype,
bool asPolygon =
false );
741 void AddPoint(
const a2dPoint2D& point,
bool atEnd =
true );
744 void AddPoint(
double x,
double y,
bool atEnd =
true );
756 void CreateArc(
const a2dPoint2D& center,
const a2dPoint2D& begin,
const a2dPoint2D& end,
double radius,
bool clock,
double aber,
bool addAtFront );
767 void CreateArc(
const a2dPoint2D& center,
const a2dLine& incoming,
const a2dPoint2D& end,
double radius,
double aber,
bool addAtFront );
779 void OffsetContour_rounded(
const a2dLine& currentline,
const a2dLine& nextline,
double factor,
bool addAtFront );
782 bool RemoveRedundant(
bool polygon );
785 a2dVertexList* GetRedundant(
bool polygon,
double smallest = 0 );
815 a2dVertexList* SmrtPtrOwn() { m_refcount++;
return this; }
820 bool SmrtPtrRelease()
823 wxASSERT_MSG( m_refcount >= 0, wxT(
"a2dLineSegment Own/Release not matched (extra Release calls)" ) );
824 if ( m_refcount <= 0 )
838 typedef a2dVertexList::iterator a2dVertexListIter;
904 inline bool GetBin()
const {
return m_bin; }
907 inline void SetBin(
bool bin ) { m_bin = bin; }
952 bool SmrtPtrRelease()
955 wxASSERT_MSG( m_refcount >= 0, wxT(
"a2dVpathSegment Own/Release not matched (extra Release calls)" ) );
956 if ( m_refcount <= 0 )
1019 virtual double Length( a2dVpathSegmentPtr prev );
1022 void PositionAt( a2dVpathSegmentPtr prev,
double t,
double& xt,
double& yt );
1087 virtual double Length( a2dVpathSegmentPtr prev );
1090 void PositionAt( a2dVpathSegmentPtr prev,
double t,
double& xt,
double& yt );
1180 bool CalcR( a2dVpathSegmentPtr prev,
double& radius,
double& center_x,
double& center_y,
double& beginrad,
double& midrad,
double& endrad,
double& phit );
1183 virtual double Length( a2dVpathSegmentPtr prev );
1211 class A2DARTBASEDLLEXP a2dVpath :
public std::vector<a2dVpathSegmentPtr>
1219 a2dVpath(
a2dVertexArray& vertexArray,
bool moveToFirst =
true ,
bool closeLast =
false );
1222 a2dVpath( a2dVertexList& vertexList,
bool moveToFirst =
true ,
bool closeLast =
false );
1228 a2dVpath& operator=(
const a2dVpath& other );
1234 bool IsPolygon(
bool allowArc =
true );
1237 bool IsPolyline(
bool allowArc =
true );
1243 void Add(
a2dVertexArray& vertexArray,
bool moveToFirst =
true ,
bool closeLast =
false );
1246 void Add( a2dVertexList& vertexList,
bool moveToFirst =
true ,
bool closeLast =
false );
1248 inline a2dVpathSegmentPtr Item( wxUint32 index ) {
return this->operator[]( index ); }
1250 inline a2dVpathSegmentPtr Item( wxUint32 index )
const {
return this->operator[]( index ); }
1252 void RemoveAt(
size_t index );
1261 void MoveTo(
double x,
double y );
1269 void LineTo(
double x,
double y,
bool withStroke =
true );
1279 void QBCurveTo(
double x1,
double y1,
double x2,
double y2,
bool withStroke =
true );
1287 void QBCurveTo(
double x1,
double y1,
bool withStroke =
true );
1299 void CBCurveTo(
double x1,
double y1,
double x2,
double y2,
double x3,
double y3,
bool withStroke =
true );
1312 void CBCurveTo(
double x1,
double y1,
double x3,
double y3,
bool withStroke =
true );
1323 void ArcTo(
double x1,
double y1,
double x2,
double y2,
bool withStroke =
true );
1334 void ArcTo(
double xc,
double yc,
double angle,
bool withStroke =
true );
1349 void ArcTo(
double xc,
double yc,
double x1,
double y1,
double x2,
double y2,
bool withStroke =
true );
1357 void Close(
bool withStroke =
true );
1360 void ConvertToLines();
1364 void ConvertToPolygon( a2dListOfa2dVertexList& addTo,
bool arc =
true );
1390 void SingleContour( a2dVpath& converted,
unsigned int start,
unsigned int segments,
double distance,
a2dPATH_END_TYPE pathtype );
1396 double dx = a.m_x - b.m_x;
1397 double dy = a.m_y - b.m_y;
1399 return dx * dx + dy * dy;
1419 bool CalcR(
double begin_x,
double begin_y,
double middle_x,
double middle_y,
double end_x,
double end_y,
1440 bool CalcR(
double begin_x,
double begin_y,
double middle_x,
double middle_y,
double end_x,
double end_y,
1441 double& radius,
double& center_x,
double& center_y,
double& beginrad,
double& midrad,
double& endrad,
double& phit );
wxPoint2DDouble a2dPoint2D
this to define if coordinate numbers are integer or doubles
bool IsStrokeHit() const
true if this is a stroke hit (parent or child/member stroke)
a2dSmrtPtr< a2dVpathSegment > a2dVpathSegmentPtr
smart pointer to path segment
a2dPATH_END_TYPE
defines the way a polyline with a contour width is ended.
(In) Visible property that can be added to Docview Objects.
unsigned int m_index
For edge/vertex hits the index of the edge / vertex.
void SetSegType(a2dSegType type)
Set the type of the segment.
a2dSegType GetSegType()
get the type of the segment
Simple Memory manager for some objects which often create and destroy to replace OS-system calls...
fundamental classes used by all other modules.
Stroke1
How the point is on the stroke ( in stroke perpendicular direction )
a2dDocumentRenderStyle operator|(a2dDocumentRenderStyle a, a2dDocumentRenderStyle b)
OR-ing a2dDocumentRenderStyle is allowed.
static a2dHit stock_nohit
Stock object for no hit.
static a2dHit stock_strokeinside
Stock object for an inner stroke hit on objects without vertices/edges (like circles) ...
bool IsHit() const
true if this is a hit
double m_y3
control point 2
double m_x3
control point 2
Input and output handler for the XmlSer format.
double m_x2
x2 x of arc midpoint
double ClclDistSqrPntPnt(const a2dPoint2D &a, const a2dPoint2D &b)
Calculate the square distance between two points.
bool IsChildHit() const
true if this is child hit
A trivial base class for a2dSmrtPtr. Non-template class, so that it can.
double ClclDistSqrPntLine(const a2dPoint2D &p, const a2dPoint2D &p1, const a2dPoint2D &p2)
Calculate the square distance between a point and a line.
bool IsDirectFillHit() const
true if this is a direct fill hit (not a member or child object fill hit )
float m_distance
For margin hits, the distance from the stroke center in fractions of the margin.
Arc Segment in a2dVertexList.
vertex array of line and arc segments.
this segmnet is part of a hole
a2dAffineMatrix a2dIDENTITY_MATRIX
global a2dAffineMatrix to set/pass the identity matrix.
double m_y2
control point 1
a2dPATHSEG_END GetClose() const
is this segment the closing a part since the last move
not specific or part of outer contour
bool GetBin() const
used in processing
vertex list of line and arc segments.
bool IsDirectStrokeHit() const
true if this is a direct stroke hit (not a member or child object stroke hit )
a2dHit(Hit hit, Stroke1 stroke1, Stroke2 stroke2, unsigned int index, float distance)
Standard constructor.
a2dSmrtPtr< a2dLineSegment > a2dLineSegmentPtr
smart pointer to line segment
void SetBin(bool bin)
used in processing
void SetClose(a2dPATHSEG_END close)
set this segment is closing a part since the last move
a2dPATHSEG
how do we move to the point of the segment
bool IsEdgeHit() const
true if this is a stroke hit on an edge
classes for initializing the artbase modules, and set paths to be used for fonts etc.
double m_y2
second control point
bool IsVertexHit() const
true if hit on stroke at a vertex
bounding class for optimizing drawing speed.
Normal straight line segment in a2dVpath.
void * Allocate(size_t bytes)
function for allocating memory block by size bytes
bool IsInsideHit() const
true if this is a fill hit or an inside stroke hit (parent or child/member)
Normal straight line segment in a2dVertexList and a2dVertexArray.
void Add(a2dVpathSegment *seg)
add a segment
Input and output handler for the XmlSer format.
double m_x2
control point 1
A 2x3 affine matrix class for 2D transformations.
double m_y2
y2 y of arc midpoint
a2dSegType
defines the type of a segment in a a2dLineSegment
bool IsMemberdHit() const
true if this is member object hit (e.g. line begin/end object)
double m_x
x endpoint of line
struct for how a single object on one layer was hit
double m_y
y endpoint of line
a2dPATHSEG GetType() const
easy way to test type of segment
static a2dHit stock_strokeoutside
Stock object for an outer stroke hit on objects without vertices/edges (like circles) ...
double m_y1
y endpoint of line
bool InArc(double angle, double start, double end, bool clockwise)
a2dPATHSEG_END
end of a segment type
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
static a2dHit stock_fill
Stock object for a fill hit.
double m_x1
x endpoint of line
bool CalcR(double begin_x, double begin_y, double middle_x, double middle_y, double end_x, double end_y, double &radius, a2dPoint2D ¢er_p)
Calculation of center for the Arc.
This template class is for property ids with a known data type.
links an outside contour with a hole
Stroke2
How the point is on the stroke ( in stroke parallel direction )
bool IsFillHit() const
true if this is a fill hit (parent or child/member fill)
a2dHit()
Default constructor.
CloneOptions
options for cloning
double m_x2
second control point
a2dPoint2D GetMidPoint() const
get middle on arc segment between end and start
basic 2 point line class for intersection and contouring routines.