给出由以下语句组成的路径:
您如何将路径转换为//SERVICE
import { BehaviorSubject } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class ChangeService {
private checkEvent = new BehaviorSubject<boolean>(false);
check = this.checkEvent.asObservable();
constructor() {
}
onChangeCheck(data: boolean) {
this.checkEvent.next(data);
}
}
//COMPONENT WITH CHECKBOX
export class FirstComponent implements OnInit {
constructor(
private service: ChangeService
) { }
ngOnInit(): void {
}
onChange(event) {
this.service.onChangeCheck(event.checked);
}
}
//COMPONENT WITH TEXT
export class SecondComponent implements OnInit {
isVisibleText = false;
constructor(
private service: ChangeService
) { }
ngOnInit(): void {
this.service.check
.subscribe(checked => {
this.isVisibleText = checked;
});
}
}
的列表?
更具体。该路径可以是字形字符串轮廓的线性化的输出。考虑例如文本字符串“ xo”变成了这样的路径。这将导致3个脱节的闭合多边形:
如果我正确理解CGAL的文档,则可以将其作为两个CGAL::Polygon_with_holes_2
存储在CGAL中。但是,您如何使用上述三个多边形构造给定的路径呢?有便利功能吗?还是我必须检查所有路径多边形的交叉点?
答案 0 :(得分:0)
您可以使用following constructor来获取外部边界多边形(必须为逆时针方向)和孔的范围(也是import contextlib,sys
from io import StringIO
@contextlib.contextmanager
def stdoutIO(stdout=None):
old = sys.stdout
if stdout is None:
stdout = StringIO()
sys.stdout = stdout
yield stdout
sys.stdout = old
def run_code(override_kale_blocks):
compiled123 = []
for b123 in override_kale_blocks:
compiled123.append(compile(b123,"<string>","exec"))
with stdoutIO() as s:
for c123 in compiled123:
exec(c123)
return s.getvalue()
block0='''
import time
a=5
b=6
b=a+b
'''
block1='''
b=a+b
'''
block2="print(b)"
blocksleep='''
print('startsleep')
time.sleep(1)
print('donesleep')
'''
pc = (block0,blocksleep,block1,block2)
cb = []
print('before')
output= run_code(pc)
print(output)
print('after')
print("Hello World!\n")
对象但为顺时针方向)。
您可以使用一系列2D点构造一个Polygon_2
。