 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
b.zimmermann Guest
|
Posted: Fri Jul 18, 2003 2:49 pm Post subject: "opposite of CreatePolygonRgn" |
|
|
Hi!
Is there a kind of counterpart for CreatePolygonRgn or selfwritten function?
Problem: GetRegionData returns RGNDATA that consists of rectangles, i need
an array of points (aka TPoint).
(Nope it´s not the same, using those rectangles vertices for
CreatePolygonRgn fails ;-()
Thanxs,
B.
|
|
| Back to top |
|
 |
Poster Guest
|
Posted: Fri Jul 18, 2003 8:32 pm Post subject: Re: "opposite of CreatePolygonRgn" |
|
|
Hi, not sure what u want but if you want an array of points within a region then try this :
var R: TRect;
x,y: Integer;
A: Array of array of TPoint;
Rgn: HRGN;
begin
Rgn := //construct region
R := GetRgnBox(Rgn) //.... check the help
for x := R.left to R.Right -1 do
for y := R.Top to R.Bottom -1 do
if PtInRegion(Rgn,X,Y) then A[x,y] := Point(X,Y);
end;
Else this might not be helpful at all.
"b.zimmermann" <bazi (AT) online (DOT) de> wrote:
| Quote: | Hi!
Is there a kind of counterpart for CreatePolygonRgn or selfwritten function?
Problem: GetRegionData returns RGNDATA that consists of rectangles, i need
an array of points (aka TPoint).
(Nope it´s not the same, using those rectangles vertices for
CreatePolygonRgn fails ;-()
Thanxs,
B.
|
|
|
| Back to top |
|
 |
b.zimmermann Guest
|
Posted: Sat Jul 19, 2003 10:24 am Post subject: Re: "opposite of CreatePolygonRgn" |
|
|
Hi again
& thanxs, but that´s not really what i´m looking for ;-(
I try to be more precise:
with an array of TPoint you can create a region (CreatePolygonRgn),
but there is no (Win API) function to get an array of TPoint back from the
created region.
with GetRegionData you receive an array of Rectangles that make up the
region.
it would be necessary to receive the original array of TPoints...
Hope that i made myself clear ?-)
B.
"Poster" <no (AT) email (DOT) yet> schrieb im Newsbeitrag
news:3f18594f$1 (AT) newsgroups (DOT) borland.com...
| Quote: |
Hi, not sure what u want but if you want an array of points within a
region then try this :
var R: TRect;
x,y: Integer;
A: Array of array of TPoint;
Rgn: HRGN;
begin
Rgn := //construct region
R := GetRgnBox(Rgn) //.... check the help
for x := R.left to R.Right -1 do
for y := R.Top to R.Bottom -1 do
if PtInRegion(Rgn,X,Y) then A[x,y] := Point(X,Y);
end;
Else this might not be helpful at all.
"b.zimmermann" <bazi (AT) online (DOT) de> wrote:
Hi!
Is there a kind of counterpart for CreatePolygonRgn or selfwritten
function?
Problem: GetRegionData returns RGNDATA that consists of rectangles, i
need
an array of points (aka TPoint).
(Nope it´s not the same, using those rectangles vertices for
CreatePolygonRgn fails ;-()
Thanxs,
B.
|
|
|
| Back to top |
|
 |
Alex Weidauer Guest
|
Posted: Mon Jul 21, 2003 6:54 pm Post subject: Re: "opposite of CreatePolygonRgn" |
|
|
Hi can you explain your problem a little bit more.
Do you need a Region to define a area or what do you mean
with counterpart for CreatePolygonRgn.
I have some objects for this like this
//---------------------------------------------------------------------
{Definition of the 2 dimensionsl point object with double prec. }
TXYPoint = Class(TObject)
Private
{Internal Flag}
fFlag:Integer;
{Internal x-Coordinate (Rechtswert) west to east. }
fX: TDouble;
{Internal y-Cordinate (Hochwert) soutrh to nort. }
fY: TDouble;
Public
{ Standard constructor. }
Constructor Create;
{ Constructor with given point coordinates. }
Constructor CreateByCoord(aX, aY: TDouble);
{ Construktor by given point (as a copy). }
Constructor CreateByPoint(aPoint: TXYPoint);
{ Standard destructor. }
Destructor Destroy; Override;
{ Point class to string conversation with formatting string
defined by CONST CXYPointTkn. }
Function ToStr: String;
{ Make a copy of the data of X. }
Procedure Assign(aPoint: TXYPoint);
{ Binary writing. }
Procedure Write(Port: TWriter);
{ Binary reading. }
Procedure Read(Port: TReader);
{ Textual writing. }
Procedure List(Port: TStrings);
{ Affine transformation. }
Procedure Transform(TRFM: TAffinTransform);
{ Read from a string defined by CONST CXYPointTkn.
EofLine search for ';' after the string else search for ','}
Property X:TDouble Read fX Write fX;
{The y-Cordinate (Hochwert) soutrh to nort. }
Property Y:TDouble Read fY Write fY;
{ Set the Internal Flag }
Property Flag:TInteger Read fFlag Write fFlag;
End;
//---------------------------------------------------------------------
//------------------------------------------------------------------------------
// XYPointListContainer for Vector Objects
// © - XII/2001 TriplexWare; Written by A.Weidauer
//------------------------------------------------------------------------------
{
@abstract(Representation for a 2 dimensional polygon object.)
@author (Alexander Weidauer [email]alex.weidauer (AT) huckfinn (DOT) de[/email])
@created (December 2001)
@lastmod (December 2001)
The Unit delivers the modell for a 2 dimensional polygon object as well as
some service routines to compare and transform the object geomtrically.}
Unit uXYPointList;
//------------------------------------------------------------------------------
Interface
//------------------------------------------------------------------------------
Uses
SysUtils,
Classes, // Base Classes FCL/VLC Library Delphi
Math, // Mathmatical Routines
uDefs, // Type and Constatntdeclarations
uXYPoint; // Base Container for GeoPoints
//------------------------------------------------------------------------------
Const
{ String constant for the token in interpreting modus. }
CXYPointListTK = 'TXYPointList';
//------------------------------------------------------------------------------
Type
{ Error constants for some checks:
xyplETOk - Everything is fine.
xyplETSelfCutting - Polygon cuts themself.
xyplETHangingNodes - Polygon has hanging nodes.
xyplETDoubleNodes - Polygon has TDouble nodes.
xyplETPoorNodes - Polygon is poor formed (0 or 1 element).
}
TXYPointListTopError = (xyplETOk,
xyplETSelfCutting,
xyplETHangingNodes,
xyplETDoubleNodes,
xyplETPoorNodes,
xyplET_NIL);
{Definition of the 2 dimensionsl polygon object with TDouble prec. }
TXYPointList = Class(TObject)
Private
{internal counter for number of points}
fMaxPoint :TInt32;
{ The point container will be emmbedded linear
by the properties. }
fData :TList;
{ flag for clean topography }
fClean :TBoolean;
Public
{ Standard constructor }
Constructor Create;
{ Standard constructor }
Constructor CreateByPoints(aPointList: TXYPointList);
{ Standard desstructor }
Destructor Destroy; Override;
{ Clear the current list }
Procedure Clear;
{ Append a point at the end of the current list }
Procedure Add(aPoint: TXYPoint);
{ Insert a point at the index of the current list }
Procedure Insert(Index: TInt32; aPoint: TXYPoint);
{ Delete a point at the index of the current list }
Procedure Delete(Index: TInt32);
{ Substitute a point at the index of the current list }
Procedure Put(Index: TInt32; aPoint: TXYPoint); Virtual;
{ Get the data of point at the index of the current list }
Function Get(Index: TInt32): TXYPoint; Virtual;
{ Extent of the Polygon. }
Procedure Extent(aMin, aMax: TXYPoint);
{ Affine transformation of a point and recalculation
of it's
extention }
Procedure Transform(Trfm: TAffinTransform;
Var aMin, aMax: TXYPoint);
{ Length of a polygon. }
Function PolyLength: TDouble;
{ Binary writing of the polygon }
Procedure Write(Port: TWriter);
{ Binary reading of the polygon }
Procedure Read(Port: TReader);
{ Textrual writing to a stringlist.}
Procedure List(Port: TStrings);
{ Position of the geometrical center (in german
Schwerpunkt). }
Function HeavyPoint: TXYPoint;
{ Create a copy of aPolygon }
Procedure Assign(aPointList: TXYPointList);
{ Check topographical errors. }
Function CheckTopography(Var
IndexA,IndexB,IndexC:TInt32):TXYPointListTopError;
{ Linear encapsulation of the polygonset.
The index starts with 1 and ends with Maxpoints. }
Property Points[index: TInt32]: TXYPoint Read Get Write Put;
{ Number of elements of a Polygonset. }
Property MaxPoint: TInt32 Read fMaxPoint;
End;
Send me a mail if this fits.
b.zimmermann schrieb:
| Quote: | Hi!
Is there a kind of counterpart for CreatePolygonRgn or selfwritten function?
Problem: GetRegionData returns RGNDATA that consists of rectangles, i need
an array of points (aka TPoint).
(Nope it´s not the same, using those rectangles vertices for
CreatePolygonRgn fails ;-()
Thanxs,
B.
|
|
|
| Back to top |
|
 |
b.zimmermann Guest
|
Posted: Tue Jul 22, 2003 3:16 am Post subject: Re: "opposite of CreatePolygonRgn" |
|
|
Hi,
i´ve got a region and i want the array of TPoints that make up the region.
That way i can have the best of both worlds, that is the Win API functions
for regions (CombineRgn, etc.) and myself written functions for arrays of
TPoint.
B.
"Alex Weidauer" <alex.weidauer (AT) huckfinn (DOT) de> schrieb im Newsbeitrag
news:3F1C36DC.4090800 (AT) huckfinn (DOT) de...
| Quote: | Hi can you explain your problem a little bit more.
Do you need a Region to define a area or what do you mean
with counterpart for CreatePolygonRgn.
I have some objects for this like this
//---------------------------------------------------------------------
{Definition of the 2 dimensionsl point object with double prec. }
TXYPoint = Class(TObject)
Private
{Internal Flag}
fFlag:Integer;
{Internal x-Coordinate (Rechtswert) west to east. }
fX: TDouble;
{Internal y-Cordinate (Hochwert) soutrh to nort. }
fY: TDouble;
Public
{ Standard constructor. }
Constructor Create;
{ Constructor with given point coordinates. }
Constructor CreateByCoord(aX, aY: TDouble);
{ Construktor by given point (as a copy). }
Constructor CreateByPoint(aPoint: TXYPoint);
{ Standard destructor. }
Destructor Destroy; Override;
{ Point class to string conversation with formatting string
defined by CONST CXYPointTkn. }
Function ToStr: String;
{ Make a copy of the data of X. }
Procedure Assign(aPoint: TXYPoint);
{ Binary writing. }
Procedure Write(Port: TWriter);
{ Binary reading. }
Procedure Read(Port: TReader);
{ Textual writing. }
Procedure List(Port: TStrings);
{ Affine transformation. }
Procedure Transform(TRFM: TAffinTransform);
{ Read from a string defined by CONST CXYPointTkn.
EofLine search for ';' after the string else search for
','}
Property X:TDouble Read fX Write fX;
{The y-Cordinate (Hochwert) soutrh to nort. }
Property Y:TDouble Read fY Write fY;
{ Set the Internal Flag }
Property Flag:TInteger Read fFlag Write fFlag;
End;
//---------------------------------------------------------------------
//-------------------------------------------------------------------------- |
----
| Quote: | // XYPointListContainer for Vector Objects
// © - XII/2001 TriplexWare; Written by A.Weidauer
//-------------------------------------------------------------------------- |
----
| Quote: |
{
@abstract(Representation for a 2 dimensional polygon object.)
@author (Alexander Weidauer [email]alex.weidauer (AT) huckfinn (DOT) de[/email])
@created (December 2001)
@lastmod (December 2001)
The Unit delivers the modell for a 2 dimensional polygon object as well
as
some service routines to compare and transform the object geomtrically.}
Unit uXYPointList;
//-------------------------------------------------------------------------- |
----
| Quote: | Interface
//-------------------------------------------------------------------------- |
----
| Quote: | Uses
SysUtils,
Classes, // Base Classes FCL/VLC Library Delphi
Math, // Mathmatical Routines
uDefs, // Type and Constatntdeclarations
uXYPoint; // Base Container for GeoPoints
//-------------------------------------------------------------------------- |
----
| Quote: | Const
{ String constant for the token in interpreting modus. }
CXYPointListTK = 'TXYPointList';
//-------------------------------------------------------------------------- |
----
| Quote: | Type
{ Error constants for some checks:
xyplETOk - Everything is fine.
xyplETSelfCutting - Polygon cuts themself.
xyplETHangingNodes - Polygon has hanging nodes.
xyplETDoubleNodes - Polygon has TDouble nodes.
xyplETPoorNodes - Polygon is poor formed (0 or 1 element).
}
TXYPointListTopError = (xyplETOk,
xyplETSelfCutting,
xyplETHangingNodes,
xyplETDoubleNodes,
xyplETPoorNodes,
xyplET_NIL);
{Definition of the 2 dimensionsl polygon object with TDouble prec. }
TXYPointList = Class(TObject)
Private
{internal counter for number of points}
fMaxPoint :TInt32;
{ The point container will be emmbedded linear
by the properties. }
fData :TList;
{ flag for clean topography }
fClean :TBoolean;
Public
{ Standard constructor }
Constructor Create;
{ Standard constructor }
Constructor CreateByPoints(aPointList: TXYPointList);
{ Standard desstructor }
Destructor Destroy; Override;
{ Clear the current list }
Procedure Clear;
{ Append a point at the end of the current list }
Procedure Add(aPoint: TXYPoint);
{ Insert a point at the index of the current list }
Procedure Insert(Index: TInt32; aPoint: TXYPoint);
{ Delete a point at the index of the current list }
Procedure Delete(Index: TInt32);
{ Substitute a point at the index of the current list }
Procedure Put(Index: TInt32; aPoint: TXYPoint); Virtual;
{ Get the data of point at the index of the current
list }
Function Get(Index: TInt32): TXYPoint; Virtual;
{ Extent of the Polygon. }
Procedure Extent(aMin, aMax: TXYPoint);
{ Affine transformation of a point and recalculation
of it's
extention }
Procedure Transform(Trfm: TAffinTransform;
Var aMin, aMax: TXYPoint);
{ Length of a polygon. }
Function PolyLength: TDouble;
{ Binary writing of the polygon }
Procedure Write(Port: TWriter);
{ Binary reading of the polygon }
Procedure Read(Port: TReader);
{ Textrual writing to a stringlist.}
Procedure List(Port: TStrings);
{ Position of the geometrical center (in german
Schwerpunkt). }
Function HeavyPoint: TXYPoint;
{ Create a copy of aPolygon }
Procedure Assign(aPointList: TXYPointList);
{ Check topographical errors. }
Function CheckTopography(Var
IndexA,IndexB,IndexC:TInt32):TXYPointListTopError;
{ Linear encapsulation of the polygonset.
The index starts with 1 and ends with Maxpoints. }
Property Points[index: TInt32]: TXYPoint Read Get Write Put;
{ Number of elements of a Polygonset. }
Property MaxPoint: TInt32 Read fMaxPoint;
End;
Send me a mail if this fits.
b.zimmermann schrieb:
Hi!
Is there a kind of counterpart for CreatePolygonRgn or selfwritten
function?
Problem: GetRegionData returns RGNDATA that consists of rectangles, i
need
an array of points (aka TPoint).
(Nope it´s not the same, using those rectangles vertices for
CreatePolygonRgn fails ;-()
Thanxs,
B.
|
|
|
| Back to top |
|
 |
Liel Man Guest
|
Posted: Tue Jul 22, 2003 5:12 am Post subject: Re: "opposite of CreatePolygonRgn" |
|
|
Hi,
Do you have any preliminary knowledge of the shape of the region you wish to
test, or can it be any shape what so ever?
If it can be any type of shape (for example, the figure of the digit "8")
then it is almost impossible to "reverse engineer" the region to the array
of points that created it, but, if you have some data regarding the nature
of the region (like, that it has no holes in it), then it is possible to
outline the region's contour (which is what I think you're trying to do...).
Liel
"b.zimmermann" <bazi (AT) online (DOT) de> wrote
| Quote: | Hi!
Is there a kind of counterpart for CreatePolygonRgn or selfwritten
function?
Problem: GetRegionData returns RGNDATA that consists of rectangles, i
need
an array of points (aka TPoint).
(Nope it´s not the same, using those rectangles vertices for
CreatePolygonRgn fails ;-()
Thanxs,
B.
|
|
|
| Back to top |
|
 |
b.zimmermann Guest
|
Posted: Tue Jul 22, 2003 9:43 am Post subject: Re: "opposite of CreatePolygonRgn" |
|
|
Hi,
there is no knowledge of the shape since it could be the result of
CombineRgn with (RGN_AND / RGN_DIFF / RGN_OR / RGN_XOR as CombineMode set).
Now I´ve got 2 options:
1. find a unit that supports something like CombineRgn for 2 arrays of
TPoint
2. find a unit that supports scaling, rotating, skewing for regions (with
win95 support)
I guess i´m lost ?-)
Thanxs,
B.
"Liel Man" <liel (AT) il (DOT) quest.com> schrieb im Newsbeitrag
news:3f1cc7b7 (AT) newsgroups (DOT) borland.com...
| Quote: | Hi,
Do you have any preliminary knowledge of the shape of the region you wish
to
test, or can it be any shape what so ever?
If it can be any type of shape (for example, the figure of the digit "8")
then it is almost impossible to "reverse engineer" the region to the array
of points that created it, but, if you have some data regarding the nature
of the region (like, that it has no holes in it), then it is possible to
outline the region's contour (which is what I think you're trying to
do...).
Liel
"b.zimmermann" <bazi (AT) online (DOT) de> wrote in message
news:3f1808a8 (AT) newsgroups (DOT) borland.com...
Hi!
Is there a kind of counterpart for CreatePolygonRgn or selfwritten
function?
Problem: GetRegionData returns RGNDATA that consists of rectangles, i
need
an array of points (aka TPoint).
(Nope it´s not the same, using those rectangles vertices for
CreatePolygonRgn fails ;-()
Thanxs,
B.
|
|
|
| Back to top |
|
 |
WPA van Deursen Guest
|
Posted: Tue Jul 22, 2003 11:10 am Post subject: Re: "opposite of CreatePolygonRgn" |
|
|
b.zimmermann wrote:
| Quote: | Hi,
there is no knowledge of the shape since it could be the result of
CombineRgn with (RGN_AND / RGN_DIFF / RGN_OR / RGN_XOR as CombineMode set).
|
You are looking for some raster-to-vector converter here. Something
like: Start with one of the pixels that is at the boundary of the region
(that is has a non-region pixel as one of his neighbors). This is your
first point in your TPoint array. Check all direct neighbors of this
point which is also a boundary point. This is the next point in your
array. Check direct neighbors of this one, until you hit your first
pixel again. No code, and the whole thing starts to become very complex
if you have complex regions.
| Quote: |
Now I´ve got 2 options:
1. find a unit that supports something like CombineRgn for 2 arrays of
TPoint
|
These are called boolean operations on polygons. Google will give you
the links, although many are in C++
Success!!
Willem
| Quote: | 2. find a unit that supports scaling, rotating, skewing for regions (with
win95 support)
I guess i´m lost ?-)
Thanxs,
B.
"Liel Man" <liel (AT) il (DOT) quest.com> schrieb im Newsbeitrag
news:3f1cc7b7 (AT) newsgroups (DOT) borland.com...
Hi,
Do you have any preliminary knowledge of the shape of the region you wish
to
test, or can it be any shape what so ever?
If it can be any type of shape (for example, the figure of the digit "8")
then it is almost impossible to "reverse engineer" the region to the array
of points that created it, but, if you have some data regarding the nature
of the region (like, that it has no holes in it), then it is possible to
outline the region's contour (which is what I think you're trying to
do...).
Liel
"b.zimmermann" <bazi (AT) online (DOT) de> wrote in message
news:3f1808a8 (AT) newsgroups (DOT) borland.com...
Hi!
Is there a kind of counterpart for CreatePolygonRgn or selfwritten
function?
Problem: GetRegionData returns RGNDATA that consists of rectangles, i
need
an array of points (aka TPoint).
(Nope it´s not the same, using those rectangles vertices for
CreatePolygonRgn fails ;-()
Thanxs,
B.
|
--
Willem van Deursen
The Netherlands
[email]wvandeursen_nospam (AT) nospam_carthago (DOT) nl[/email]
replace _nospam@nospam_ for @ to get a valid email address
|
|
| Back to top |
|
 |
Poster Guest
|
Posted: Tue Jul 22, 2003 6:44 pm Post subject: Re: "opposite of CreatePolygonRgn" |
|
|
What the Function below does is self explanatory. The regions are constructed from all the black pixels. Let me know if this helped.
function RgnFromBitmap(Bit: TBitmap): HRGN;
var W,H,X,Y, StartX: Integer;
MRgn : HRGN;
begin
Result := 0;
W := Bit.Width;
H := Bit.Height;
for Y := 0 to H - 1 do
begin
X := 0;
while X < W do
begin
while Bit.Canvas.Pixels[X,Y] <> clBlack do
begin
Inc(X);
if X = W then break;
end;
if X = W then break;
StartX := X;
while Bit.Canvas.Pixels[X,Y] = clBlack do
begin
if X = W then break;
Inc(X);
end;
if Result = 0 then
Result := CreateRectRgn(StartX, Y, X, Y + 1)
else
begin
MRgn := CreateRectRgn(StartX, Y, X, Y + 1);
if MRgn <> 0 then
begin
CombineRgn(Result, Result, MRgn, RGN_OR);
DeleteObject(MRgn);
end;
end;
end;
end;
end;
|
|
| Back to top |
|
 |
b.zimmermann Guest
|
Posted: Tue Jul 22, 2003 7:10 pm Post subject: Re: "opposite of CreatePolygonRgn" |
|
|
Hi & thanxs for your answer,
but since i´m messing around with regions quite a lot lately this is my
third Bitmap2Region function i come across ;-)
Like i "said" before i need an array of TPoints made of a given region.
B.
"Poster" <no (AT) email (DOT) yet> schrieb im Newsbeitrag
news:3f1d861e$1 (AT) newsgroups (DOT) borland.com...
| Quote: |
What the Function below does is self explanatory. The regions are
constructed from all the black pixels. Let me know if this helped.
function RgnFromBitmap(Bit: TBitmap): HRGN;
var W,H,X,Y, StartX: Integer;
MRgn : HRGN;
begin
Result := 0;
W := Bit.Width;
H := Bit.Height;
for Y := 0 to H - 1 do
begin
X := 0;
while X < W do
begin
while Bit.Canvas.Pixels[X,Y] <> clBlack do
begin
Inc(X);
if X = W then break;
end;
if X = W then break;
StartX := X;
while Bit.Canvas.Pixels[X,Y] = clBlack do
begin
if X = W then break;
Inc(X);
end;
if Result = 0 then
Result := CreateRectRgn(StartX, Y, X, Y + 1)
else
begin
MRgn := CreateRectRgn(StartX, Y, X, Y + 1);
if MRgn <> 0 then
begin
CombineRgn(Result, Result, MRgn, RGN_OR);
DeleteObject(MRgn);
end;
end;
end;
end;
end;
|
|
|
| Back to top |
|
 |
Alex Weidauer Guest
|
Posted: Tue Jul 22, 2003 11:13 pm Post subject: Re: "opposite of CreatePolygonRgn" |
|
|
Hi you should google for
gpc general polygon clipping from ALan Murta
http://www.cs.man.ac.uk/aig/staff/alan/software/
There is alsoa Delphi port from Stephan Schedel
Be Alex
b.zimmermann schrieb:
| Quote: | Hi,
i´ve got a region and i want the array of TPoints that make up the region.
That way i can have the best of both worlds, that is the Win API functions
for regions (CombineRgn, etc.) and myself written functions for arrays of
TPoint.
B.
"Alex Weidauer" <alex.weidauer (AT) huckfinn (DOT) de> schrieb im Newsbeitrag
news:3F1C36DC.4090800 (AT) huckfinn (DOT) de...
Hi can you explain your problem a little bit more.
Do you need a Region to define a area or what do you mean
with counterpart for CreatePolygonRgn.
I have some objects for this like this
//---------------------------------------------------------------------
{Definition of the 2 dimensionsl point object with double prec. }
TXYPoint = Class(TObject)
Private
{Internal Flag}
fFlag:Integer;
{Internal x-Coordinate (Rechtswert) west to east. }
fX: TDouble;
{Internal y-Cordinate (Hochwert) soutrh to nort. }
fY: TDouble;
Public
{ Standard constructor. }
Constructor Create;
{ Constructor with given point coordinates. }
Constructor CreateByCoord(aX, aY: TDouble);
{ Construktor by given point (as a copy). }
Constructor CreateByPoint(aPoint: TXYPoint);
{ Standard destructor. }
Destructor Destroy; Override;
{ Point class to string conversation with formatting string
defined by CONST CXYPointTkn. }
Function ToStr: String;
{ Make a copy of the data of X. }
Procedure Assign(aPoint: TXYPoint);
{ Binary writing. }
Procedure Write(Port: TWriter);
{ Binary reading. }
Procedure Read(Port: TReader);
{ Textual writing. }
Procedure List(Port: TStrings);
{ Affine transformation. }
Procedure Transform(TRFM: TAffinTransform);
{ Read from a string defined by CONST CXYPointTkn.
EofLine search for ';' after the string else search for
','}
Property X:TDouble Read fX Write fX;
{The y-Cordinate (Hochwert) soutrh to nort. }
Property Y:TDouble Read fY Write fY;
{ Set the Internal Flag }
Property Flag:TInteger Read fFlag Write fFlag;
End;
//---------------------------------------------------------------------
//--------------------------------------------------------------------------
----
// XYPointListContainer for Vector Objects
// © - XII/2001 TriplexWare; Written by A.Weidauer
//--------------------------------------------------------------------------
----
{
@abstract(Representation for a 2 dimensional polygon object.)
@author (Alexander Weidauer [email]alex.weidauer (AT) huckfinn (DOT) de[/email])
@created (December 2001)
@lastmod (December 2001)
The Unit delivers the modell for a 2 dimensional polygon object as well
as
some service routines to compare and transform the object geomtrically.}
Unit uXYPointList;
//--------------------------------------------------------------------------
----
Interface
//--------------------------------------------------------------------------
----
Uses
SysUtils,
Classes, // Base Classes FCL/VLC Library Delphi
Math, // Mathmatical Routines
uDefs, // Type and Constatntdeclarations
uXYPoint; // Base Container for GeoPoints
//--------------------------------------------------------------------------
----
Const
{ String constant for the token in interpreting modus. }
CXYPointListTK = 'TXYPointList';
//--------------------------------------------------------------------------
----
Type
{ Error constants for some checks:
xyplETOk - Everything is fine.
xyplETSelfCutting - Polygon cuts themself.
xyplETHangingNodes - Polygon has hanging nodes.
xyplETDoubleNodes - Polygon has TDouble nodes.
xyplETPoorNodes - Polygon is poor formed (0 or 1 element).
}
TXYPointListTopError = (xyplETOk,
xyplETSelfCutting,
xyplETHangingNodes,
xyplETDoubleNodes,
xyplETPoorNodes,
xyplET_NIL);
{Definition of the 2 dimensionsl polygon object with TDouble prec. }
TXYPointList = Class(TObject)
Private
{internal counter for number of points}
fMaxPoint :TInt32;
{ The point container will be emmbedded linear
by the properties. }
fData :TList;
{ flag for clean topography }
fClean :TBoolean;
Public
{ Standard constructor }
Constructor Create;
{ Standard constructor }
Constructor CreateByPoints(aPointList: TXYPointList);
{ Standard desstructor }
Destructor Destroy; Override;
{ Clear the current list }
Procedure Clear;
{ Append a point at the end of the current list }
Procedure Add(aPoint: TXYPoint);
{ Insert a point at the index of the current list }
Procedure Insert(Index: TInt32; aPoint: TXYPoint);
{ Delete a point at the index of the current list }
Procedure Delete(Index: TInt32);
{ Substitute a point at the index of the current list }
Procedure Put(Index: TInt32; aPoint: TXYPoint); Virtual;
{ Get the data of point at the index of the current
list }
Function Get(Index: TInt32): TXYPoint; Virtual;
{ Extent of the Polygon. }
Procedure Extent(aMin, aMax: TXYPoint);
{ Affine transformation of a point and recalculation
of it's
extention }
Procedure Transform(Trfm: TAffinTransform;
Var aMin, aMax: TXYPoint);
{ Length of a polygon. }
Function PolyLength: TDouble;
{ Binary writing of the polygon }
Procedure Write(Port: TWriter);
{ Binary reading of the polygon }
Procedure Read(Port: TReader);
{ Textrual writing to a stringlist.}
Procedure List(Port: TStrings);
{ Position of the geometrical center (in german
Schwerpunkt). }
Function HeavyPoint: TXYPoint;
{ Create a copy of aPolygon }
Procedure Assign(aPointList: TXYPointList);
{ Check topographical errors. }
Function CheckTopography(Var
IndexA,IndexB,IndexC:TInt32):TXYPointListTopError;
{ Linear encapsulation of the polygonset.
The index starts with 1 and ends with Maxpoints. }
Property Points[index: TInt32]: TXYPoint Read Get Write Put;
{ Number of elements of a Polygonset. }
Property MaxPoint: TInt32 Read fMaxPoint;
End;
Send me a mail if this fits.
b.zimmermann schrieb:
Hi!
Is there a kind of counterpart for CreatePolygonRgn or selfwritten
function?
Problem: GetRegionData returns RGNDATA that consists of rectangles, i
need
an array of points (aka TPoint).
(Nope it´s not the same, using those rectangles vertices for
CreatePolygonRgn fails ;-()
Thanxs,
B.
|
|
|
| Back to top |
|
 |
Alex Weidauer Guest
|
Posted: Tue Jul 22, 2003 11:21 pm Post subject: Re: "opposite of CreatePolygonRgn" |
|
|
Hi,
I start in the same way with TPoint arrays,
but the WinAPI functions are not consequent
in point manipulations. There are no delete
functions or add or insert functions.
the second thing ist that Win95 dont now
world transforms and TXForm operates with
Single types that is fine enough fror monitor
realated bitmaps but not for larger raster
objectslike satellite images p.h. 32000x32000
pix. So I the sended objects an a related
TDrawer to manage polygon things.
If you are interested it is free stuff,
the drawer too. Feel free and send me a mail.
Bye Alex
b.zimmermann schrieb:
| Quote: | Hi,
i´ve got a region and i want the array of TPoints that make up the region.
That way i can have the best of both worlds, that is the Win API functions
for regions (CombineRgn, etc.) and myself written functions for arrays of
TPoint.
B.
"Alex Weidauer" <alex.weidauer (AT) huckfinn (DOT) de> schrieb im Newsbeitrag
news:3F1C36DC.4090800 (AT) huckfinn (DOT) de...
Hi can you explain your problem a little bit more.
Do you need a Region to define a area or what do you mean
with counterpart for CreatePolygonRgn.
I have some objects for this like this
//---------------------------------------------------------------------
{Definition of the 2 dimensionsl point object with double prec. }
TXYPoint = Class(TObject)
Private
{Internal Flag}
fFlag:Integer;
{Internal x-Coordinate (Rechtswert) west to east. }
fX: TDouble;
{Internal y-Cordinate (Hochwert) soutrh to nort. }
fY: TDouble;
Public
{ Standard constructor. }
Constructor Create;
{ Constructor with given point coordinates. }
Constructor CreateByCoord(aX, aY: TDouble);
{ Construktor by given point (as a copy). }
Constructor CreateByPoint(aPoint: TXYPoint);
{ Standard destructor. }
Destructor Destroy; Override;
{ Point class to string conversation with formatting string
defined by CONST CXYPointTkn. }
Function ToStr: String;
{ Make a copy of the data of X. }
Procedure Assign(aPoint: TXYPoint);
{ Binary writing. }
Procedure Write(Port: TWriter);
{ Binary reading. }
Procedure Read(Port: TReader);
{ Textual writing. }
Procedure List(Port: TStrings);
{ Affine transformation. }
Procedure Transform(TRFM: TAffinTransform);
{ Read from a string defined by CONST CXYPointTkn.
EofLine search for ';' after the string else search for
','}
Property X:TDouble Read fX Write fX;
{The y-Cordinate (Hochwert) soutrh to nort. }
Property Y:TDouble Read fY Write fY;
{ Set the Internal Flag }
Property Flag:TInteger Read fFlag Write fFlag;
End;
//---------------------------------------------------------------------
//--------------------------------------------------------------------------
----
// XYPointListContainer for Vector Objects
// © - XII/2001 TriplexWare; Written by A.Weidauer
//--------------------------------------------------------------------------
----
{
@abstract(Representation for a 2 dimensional polygon object.)
@author (Alexander Weidauer [email]alex.weidauer (AT) huckfinn (DOT) de[/email])
@created (December 2001)
@lastmod (December 2001)
The Unit delivers the modell for a 2 dimensional polygon object as well
as
some service routines to compare and transform the object geomtrically.}
Unit uXYPointList;
//--------------------------------------------------------------------------
----
Interface
//--------------------------------------------------------------------------
----
Uses
SysUtils,
Classes, // Base Classes FCL/VLC Library Delphi
Math, // Mathmatical Routines
uDefs, // Type and Constatntdeclarations
uXYPoint; // Base Container for GeoPoints
//--------------------------------------------------------------------------
----
Const
{ String constant for the token in interpreting modus. }
CXYPointListTK = 'TXYPointList';
//--------------------------------------------------------------------------
----
Type
{ Error constants for some checks:
xyplETOk - Everything is fine.
xyplETSelfCutting - Polygon cuts themself.
xyplETHangingNodes - Polygon has hanging nodes.
xyplETDoubleNodes - Polygon has TDouble nodes.
xyplETPoorNodes - Polygon is poor formed (0 or 1 element).
}
TXYPointListTopError = (xyplETOk,
xyplETSelfCutting,
xyplETHangingNodes,
xyplETDoubleNodes,
xyplETPoorNodes,
xyplET_NIL);
{Definition of the 2 dimensionsl polygon object with TDouble prec. }
TXYPointList = Class(TObject)
Private
{internal counter for number of points}
fMaxPoint :TInt32;
{ The point container will be emmbedded linear
by the properties. }
fData :TList;
{ flag for clean topography }
fClean :TBoolean;
Public
{ Standard constructor }
Constructor Create;
{ Standard constructor }
Constructor CreateByPoints(aPointList: TXYPointList);
{ Standard desstructor }
Destructor Destroy; Override;
{ Clear the current list }
Procedure Clear;
{ Append a point at the end of the current list }
Procedure Add(aPoint: TXYPoint);
{ Insert a point at the index of the current list }
Procedure Insert(Index: TInt32; aPoint: TXYPoint);
{ Delete a point at the index of the current list }
Procedure Delete(Index: TInt32);
{ Substitute a point at the index of the current list }
Procedure Put(Index: TInt32; aPoint: TXYPoint); Virtual;
{ Get the data of point at the index of the current
list }
Function Get(Index: TInt32): TXYPoint; Virtual;
{ Extent of the Polygon. }
Procedure Extent(aMin, aMax: TXYPoint);
{ Affine transformation of a point and recalculation
of it's
extention }
Procedure Transform(Trfm: TAffinTransform;
Var aMin, aMax: TXYPoint);
{ Length of a polygon. }
Function PolyLength: TDouble;
{ Binary writing of the polygon }
Procedure Write(Port: TWriter);
{ Binary reading of the polygon }
Procedure Read(Port: TReader);
{ Textrual writing to a stringlist.}
Procedure List(Port: TStrings);
{ Position of the geometrical center (in german
Schwerpunkt). }
Function HeavyPoint: TXYPoint;
{ Create a copy of aPolygon }
Procedure Assign(aPointList: TXYPointList);
{ Check topographical errors. }
Function CheckTopography(Var
IndexA,IndexB,IndexC:TInt32):TXYPointListTopError;
{ Linear encapsulation of the polygonset.
The index starts with 1 and ends with Maxpoints. }
Property Points[index: TInt32]: TXYPoint Read Get Write Put;
{ Number of elements of a Polygonset. }
Property MaxPoint: TInt32 Read fMaxPoint;
End;
Send me a mail if this fits.
b.zimmermann schrieb:
Hi!
Is there a kind of counterpart for CreatePolygonRgn or selfwritten
function?
Problem: GetRegionData returns RGNDATA that consists of rectangles, i
need
an array of points (aka TPoint).
(Nope it´s not the same, using those rectangles vertices for
CreatePolygonRgn fails ;-()
Thanxs,
B.
|
|
|
| Back to top |
|
 |
Alex Weidauer Guest
|
Posted: Tue Jul 22, 2003 11:25 pm Post subject: Re: "opposite of CreatePolygonRgn" |
|
|
Hi I see see the post behind
Ok raster to vector you can download from my page
http://www.triplexware.huckfinn.de/contweber.html
and affine transformation (rotating,scaling skewing etc) too.
Bye Alex
b.zimmermann schrieb:
| Quote: | Hi,
i´ve got a region and i want the array of TPoints that make up the region.
That way i can have the best of both worlds, that is the Win API functions
for regions (CombineRgn, etc.) and myself written functions for arrays of
TPoint.
B.
"Alex Weidauer" <alex.weidauer (AT) huckfinn (DOT) de> schrieb im Newsbeitrag
news:3F1C36DC.4090800 (AT) huckfinn (DOT) de...
Hi can you explain your problem a little bit more.
Do you need a Region to define a area or what do you mean
with counterpart for CreatePolygonRgn.
I have some objects for this like this
//---------------------------------------------------------------------
{Definition of the 2 dimensionsl point object with double prec. }
TXYPoint = Class(TObject)
Private
{Internal Flag}
fFlag:Integer;
{Internal x-Coordinate (Rechtswert) west to east. }
fX: TDouble;
{Internal y-Cordinate (Hochwert) soutrh to nort. }
fY: TDouble;
Public
{ Standard constructor. }
Constructor Create;
{ Constructor with given point coordinates. }
Constructor CreateByCoord(aX, aY: TDouble);
{ Construktor by given point (as a copy). }
Constructor CreateByPoint(aPoint: TXYPoint);
{ Standard destructor. }
Destructor Destroy; Override;
{ Point class to string conversation with formatting string
defined by CONST CXYPointTkn. }
Function ToStr: String;
{ Make a copy of the data of X. }
Procedure Assign(aPoint: TXYPoint);
{ Binary writing. }
Procedure Write(Port: TWriter);
{ Binary reading. }
Procedure Read(Port: TReader);
{ Textual writing. }
Procedure List(Port: TStrings);
{ Affine transformation. }
Procedure Transform(TRFM: TAffinTransform);
{ Read from a string defined by CONST CXYPointTkn.
EofLine search for ';' after the string else search for
','}
Property X:TDouble Read fX Write fX;
{The y-Cordinate (Hochwert) soutrh to nort. }
Property Y:TDouble Read fY Write fY;
{ Set the Internal Flag }
Property Flag:TInteger Read fFlag Write fFlag;
End;
//---------------------------------------------------------------------
//--------------------------------------------------------------------------
----
// XYPointListContainer for Vector Objects
// © - XII/2001 TriplexWare; Written by A.Weidauer
//--------------------------------------------------------------------------
----
{
@abstract(Representation for a 2 dimensional polygon object.)
@author (Alexander Weidauer [email]alex.weidauer (AT) huckfinn (DOT) de[/email])
@created (December 2001)
@lastmod (December 2001)
The Unit delivers the modell for a 2 dimensional polygon object as well
as
some service routines to compare and transform the object geomtrically.}
Unit uXYPointList;
//--------------------------------------------------------------------------
----
Interface
//--------------------------------------------------------------------------
----
Uses
SysUtils,
Classes, // Base Classes FCL/VLC Library Delphi
Math, // Mathmatical Routines
uDefs, // Type and Constatntdeclarations
uXYPoint; // Base Container for GeoPoints
//--------------------------------------------------------------------------
----
Const
{ String constant for the token in interpreting modus. }
CXYPointListTK = 'TXYPointList';
//--------------------------------------------------------------------------
----
Type
{ Error constants for some checks:
xyplETOk - Everything is fine.
xyplETSelfCutting - Polygon cuts themself.
xyplETHangingNodes - Polygon has hanging nodes.
xyplETDoubleNodes - Polygon has TDouble nodes.
xyplETPoorNodes - Polygon is poor formed (0 or 1 element).
}
TXYPointListTopError = (xyplETOk,
xyplETSelfCutting,
xyplETHangingNodes,
xyplETDoubleNodes,
xyplETPoorNodes,
xyplET_NIL);
{Definition of the 2 dimensionsl polygon object with TDouble prec. }
TXYPointList = Class(TObject)
Private
{internal counter for number of points}
fMaxPoint :TInt32;
{ The point container will be emmbedded linear
by the properties. }
fData :TList;
{ flag for clean topography }
fClean :TBoolean;
Public
{ Standard constructor }
Constructor Create;
{ Standard constructor }
Constructor CreateByPoints(aPointList: TXYPointList);
{ Standard desstructor }
Destructor Destroy; Override;
{ Clear the current list }
Procedure Clear;
{ Append a point at the end of the current list }
Procedure Add(aPoint: TXYPoint);
{ Insert a point at the index of the current list }
Procedure Insert(Index: TInt32; aPoint: TXYPoint);
{ Delete a point at the index of the current list }
Procedure Delete(Index: TInt32);
{ Substitute a point at the index of the current list }
Procedure Put(Index: TInt32; aPoint: TXYPoint); Virtual;
{ Get the data of point at the index of the current
list }
Function Get(Index: TInt32): TXYPoint; Virtual;
{ Extent of the Polygon. }
Procedure Extent(aMin, aMax: TXYPoint);
{ Affine transformation of a point and recalculation
of it's
extention }
Procedure Transform(Trfm: TAffinTransform;
Var aMin, aMax: TXYPoint);
{ Length of a polygon. }
Function PolyLength: TDouble;
{ Binary writing of the polygon }
Procedure Write(Port: TWriter);
{ Binary reading of the polygon }
Procedure Read(Port: TReader);
{ Textrual writing to a stringlist.}
Procedure List(Port: TStrings);
{ Position of the geometrical center (in german
Schwerpunkt). }
Function HeavyPoint: TXYPoint;
{ Create a copy of aPolygon }
Procedure Assign(aPointList: TXYPointList);
{ Check topographical errors. }
Function CheckTopography(Var
IndexA,IndexB,IndexC:TInt32):TXYPointListTopError;
{ Linear encapsulation of the polygonset.
The index starts with 1 and ends with Maxpoints. }
Property Points[index: TInt32]: TXYPoint Read Get Write Put;
{ Number of elements of a Polygonset. }
Property MaxPoint: TInt32 Read fMaxPoint;
End;
Send me a mail if this fits.
b.zimmermann schrieb:
Hi!
Is there a kind of counterpart for CreatePolygonRgn or selfwritten
function?
Problem: GetRegionData returns RGNDATA that consists of rectangles, i
need
an array of points (aka TPoint).
(Nope it´s not the same, using those rectangles vertices for
CreatePolygonRgn fails ;-()
Thanxs,
B.
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|