t = 'P1\r\n'
tochki = []
p = GetPanel("Укажите панель")
c = p.Contour.MakeCopy()
cMin = c.Min
c.Move(-c.Min.x+2, -c.Min.y+2)
h = Math.round(c.Height)+4
w = Math.round(c.Width)+4
t = t + h + ' ' + w + '\r\n'
mas=[]
for (iw = 0; iw < w; iw++) {
mas[iw] = [];
for (ih = 0; ih < h; ih++) {
/*
Point = NewPoint(iw, ih)
//ClosestPoint = c.ClosestPoint(Point);
if (yestiTochkaVMassive(Point, tochki)) {
t = t + '1 '
} else {
t = t + '0 '
}
*/
mas[iw][ih] = '0'
}
}
for(ic=0;ic< c.Count;ic++){
elc = c[ic]
TochkiChastey(elc, p)
}
for (it = 0; it < tochki.length; it++) {
point = tochki[it]
//system.log(JSON.stringify(point))
iw = Math.round(point.x)
ih = Math.round(point.y)
// system.log(iw+' -- '+ih)
mas[iw][ih] = '1'
radiusTocki=2
hMax=ih+radiusTocki
if(hMax>h)
{hMax=h}
hMin=ih-radiusTocki
if(hMin<0)
{hMin=0}
wMax=iw+radiusTocki
if(wMax>w)
{wMax=w}
wMin=iw-radiusTocki
if(wMin<0)
{wMin=0}
for (iwR = wMin; iwR < wMax; iwR++) {
for (ihR = hMin; ihR < hMax; ihR++) {
//system.log(iwR)
mas[iwR][ihR] = '1'
}
}
}
for (iw = 0; iw < mas.length; iw++) {
// mas_iw = mas[iw];
for (ih = 0; ih < mas[iw].length; ih++) {
t = t + mas[iw][ih] + ' '
}
t = t + '\r\n'
}
system.askWriteTextFile('BMP', t)
function TochkiChastey(elc, p) {
//TochkiElementa(elc)
if (elc.ElType == 1) {
TochkiLinii(elc, p, tochki)
} else if (elc.ElType == 2) {
TochkiDugi(elc, p, tochki)
} else if (elc.ElType == 3) {
TochkiKruga(elc, p, tochki)
}
//system.log("точек " + tochki.length)
}
function TochkiKruga(elc, p, tochki) {
dlina = elc.ObjLength()
lp1= elc.Center
lp2= NewPoint(lp1.x+elc.CirRadius+10, lp1.y)
c2 = NewContour()
l = c2.AddLine(lp1,lp2)
// ug1 = 0
// ug2 = 360
ArcAngle =360
//system.log( ArcAngle)
//system.log(ug1)
//system.log(ug2)
// c2.Rotate(lp1.x,lp1.y,ug1)
//c.Addition(c2)
// napravleniye = 1
shag= ArcAngle/dlina
//system.log(JSON.stringify(peresArray))
// if(!peresArray){napravleniye = -1}
//a= []
for (is=1;is< dlina-1;is++)
{
c2.Rotate(lp1.x,lp1.y,shag)
pos = geometry.Intersect(elc, c2[0])[0]
// if(pos===undefined){continue}
pos = okruglitTocku(pos)
tochki.push(pos)
//c.Addition(c2)
}
}
function TochkiDugi(elc, p, tochki) {
// system.log(elc)
dlina = elc.ObjLength()
/*
ccir = NewContour()
ccir.AddCircle(0, 0, elc.ArcRadius())
dlina = ccir[0].ObjLength()
*/
lp1= elc.Center
lp2= NewPoint(lp1.x+elc.ArcRadius()+10, lp1.y)
c2 = NewContour()
l = c2.AddLine(lp1,lp2)
ug1 = elc.Pos1Angle()*(180/Math.PI)
ug2 = elc.Pos2Angle()*(180/Math.PI)
ArcAngle =elc. ArcAngle() *(180/Math.PI)
//system.log( ArcAngle)
//system.log(ug1)
//system.log(ug2)
c2.Rotate(lp1.x,lp1.y,ug1)
peresArray = geometry.Intersect(elc, c2)
//c.Addition(c2)
napravleniye = 1
shag= ArcAngle/dlina
c3 = c2.MakeCopy()
c3.Rotate(lp1.x,lp1.y,shag)
peresArray=[]
peresArray = geometry.Intersect(elc, c3[0])
//system.log(JSON.stringify(peresArray))
if(!peresArray){
napravleniye = -1
//system.log(peresArray+'-----Пересекаются')
c3.Rotate(lp1.x,lp1.y,shag*(-2))
// c3.Rotate(lp1.x,lp1.y,shag*(-1))
peresArray = geometry.Intersect(elc, c3[0])
// system.log(peresArray+'-----Пересекаются')
}
//a= []
for (is=1;is< dlina-1;is++)
{
c2.Rotate(lp1.x,lp1.y,shag*(napravleniye))
pos = geometry.Intersect(elc, c2[0])[0]
if(pos===undefined){continue}
pos = okruglitTocku(pos)
tochki.push(pos)
//c.Addition(c2)
}
}
function TochkiLinii(elc, p, tochki) {
//system.log(elc)
dlina = elc.ObjLength()
tochki.push(elc.Pos1)
tochki.push(elc.Pos2)
NormDir =elc.NormDir()
lp1= elc.Pos1
lp2= NewPoint(lp1.x+NormDir.x, lp1.y+NormDir.y)
c2= NewContour()
l = c2.AddLine(lp1,lp2)
/*
system.log( JSON.stringify(lp1))
system.log( JSON.stringify(lp2))
system.log(JSON.stringify(NormDir) )
*/
//system.log(ug2)
// c2.Move(NormDir)
//c.Addition(c2)
// c.Add(c2[0].MakeCopy())
//shag= 1
for (is=1;is< dlina-1;is++)
{
l.Move(NormDir)
// c.Add(l.MakeCopy())
//pos = geometry.Intersect(elc, c2[0])[0]
//if(!(pos=== undefined ))
//{
pos=l.Pos2
tochki.push(pos)
//}
//c.Addition(c2)
}
}
function tockuV_mass(point)
{
point = okruglitTocku(point)
iw = point.x
ih = point.y
mas[iw][ih] = '1'
}
function okruglitTocku(tochka) {
//system.log(JSON.stringify( tochka))
x= Math.round(tochka.x)
y= Math.round(tochka.y)
tochka= NewPoint(x, y)
return tochka
}
[свернуть]