我有一个关于如何在pythonOCC中使用样条线的两部分问题.
首先,我知道我可以创建样条曲线
array = []
array.append(gp_Pnt2d (0,0))
array.append(gp_Pnt2d (1,2))
array.append(gp_Pnt2d (2,3))
array.append(gp_Pnt2d (4,3))
array.append(gp_Pnt2d (5,5))
pt2d_list = point2d_list_to_TColgp_Array1OfPnt2d(array)
SPL1 = Geom2dAPI_PointsToBSpline(pt2d_list).Curve()
display.DisplayShape(make_edge2d(SPL1) , update=True)
Run Code Online (Sandbox Code Playgroud)
我希望bspline可以通过计算得出
BSPL1 = Geom2dAPI_PointsToBSpline(pt2d_list)
Run Code Online (Sandbox Code Playgroud)
但我怎么得到:
如何删除或添加bspline的结?
其次,在pythonOCC中加载CAD绘图.stp文件时,如下所示:
from OCC import TopoDS, StlAPI
shape = TopoDS.TopoDS_Shape()
stl_reader = StlAPI.StlAPI_Reader()
stl_reader.Read(shape,str(filename))
display.DisplayShape(shape)
Run Code Online (Sandbox Code Playgroud)
如何从knot,bspline和coefficient等形状中获取数据.
在CUDA中有任何方法可以知道指针是否指向设备或主机的内存.
这样做的一个例子可能是:
int *dev_c, *host_c;
cudaMalloc( (void**)&dev_c, sizeof(int) );
host_c = (int*) malloc(sizeof(int));
Run Code Online (Sandbox Code Playgroud)
我当然可以看一下这个名字,但有没有办法看广告指针dev_c和host_c并说,host_c指向广告主机,dev_c指向广告设备.
我在python中有一个类,我有一个包含邻居的dict,以及一个pri_list包含21个类实例的列表,但如果我遍历邻居,我会得到重复的密钥或None.
print type(self.neighbors)
print str(self.id) + " " + str(self.neighbors)
print ""
for n in self.neighbors:
print str(pri_list[n].id) + " " + str(pri_list[n].neighbors)
pri_list[n].neighbors.update({self.id:self.neighbors[n]})
print str(pri_list[n].id) + " " + str(pri_list[n].neighbors)
Run Code Online (Sandbox Code Playgroud)
导致
<type 'dict'>
21 {22: 34.348765355132869, 23: 0, 19: 0.049076419727497315, 20: 36.087031068160286}
22 {21: 34.348765355132869, 23: 34.602568871995345, 8: 0.2351466696454737, 17: 0, 20: 0}
22 {21: 34.348765355132869, 23: 34.602568871995345, 8: 0.2351466696454737, 17: 0, 20: 0}
23 {21: 0, 22: 34.602568871995345, 8: 26.643673903936367, 17: 36.80385613689073}
23 {21: …Run Code Online (Sandbox Code Playgroud) CUDA NPP库支持使用nppiFilter_8u_C1R命令过滤图像,但不断出现错误.启动boxFilterNPP示例代码并没有问题.
eStatusNPP = nppiFilterBox_8u_C1R(oDeviceSrc.data(), oDeviceSrc.pitch(),
oDeviceDst.data(), oDeviceDst.pitch(),
oSizeROI, oMaskSize, oAnchor);
Run Code Online (Sandbox Code Playgroud)
但是,如果我将其更改为使用nppiFilter_8u_C1R,则eStatusNPP将返回错误-24(NPP_TEXTURE_BIND_ERROR).下面的代码是我对原始boxFilterNPP样本所做的更改.
NppiSize oMaskSize = {5,5};
npp::ImageCPU_32s_C1 hostKernel(5,5);
for(int x = 0 ; x < 5; x++){
for(int y = 0 ; y < 5; y++){
hostKernel.pixels(x,y)[0].x = 1;
}
}
npp::ImageNPP_32s_C1 pKernel(hostKernel);
Npp32s nDivisor = 1;
eStatusNPP = nppiFilter_8u_C1R(oDeviceSrc.data(), oDeviceSrc.pitch(),
oDeviceDst.data(), oDeviceDst.pitch(),
oSizeROI,
pKernel.data(),
oMaskSize, oAnchor,
nDivisor);
Run Code Online (Sandbox Code Playgroud)
这已在CUDA 4.2和5.0上尝试过,结果相同.
当oMaskSize = {1,1}时,代码以预期结果运行
用于CUDA构建的NPP库是仅使用freeImage还是我可以使用其他结构或仅使用unsigned char*image作为NPP函数中的输入.
我提出这个问题的原因是NPP的所有样本都有freeImage的大包装器.
我已经仔细研究了NVIDIA Performance Primitives(NPP),但是只提到了一个图像,而不是特别使用哪种图像格式.
如果你有一个如何在没有freeImage的情况下使用NPP的例子,或者只是没有从磁盘加载图像,那么我会谨慎开心.
如果在Delphi XE3中使用BeginThread,则该函数被阻止.这是为什么?
我试过在下面创建我的问题的最小版本.在可以按下2个按钮的情况下,如果按下按钮btn1,btn1的标题应该变为'nooo'.如果按btn2,则btn1标题更改为'yesss'.
当按下btn1时,我也使用始终循环的BeginThread启动一个线程.
问题是,btn1.Caption:='nooo'; 自BeginThread阻止以来永远不会受到限制.我到达了btn1.Caption:='nooo';
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm1 = class(TForm)
btn1: TButton;
btn2: TButton;
procedure btn1Click(Sender: TObject);
procedure btn2Click(Sender: TObject);
private
function test() : Integer;
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function TForm1.test() : Integer;
begin
while True do
begin
Sleep(Random(1000) * 2);
end;
Result := 0;
end;
procedure TForm1.btn1Click(Sender: TObject);
var
id: LongWord;
begin
BeginThread(nil, …Run Code Online (Sandbox Code Playgroud) 这段代码给了我输出:
The sqrt of 1.234 is: 1.52276 why is this diffrent from: 1.11086 1.11086
Run Code Online (Sandbox Code Playgroud)
为什么?
#include <iostream>
using namespace std;
template<typename T>
T sqrt(T x)
{
return x*x;
}
template<typename T>
void print_sqrt(T x)
{
double tmp = sqrt(x);
cout << "The sqrt of " << x << " is: " << sqrt<double>(x) << " why is this diffrent from: " << sqrt(x) << " " << tmp << endl;
}
int main()
{
print_sqrt<double>(1.234);
system("pause");
}
Run Code Online (Sandbox Code Playgroud) cuda ×3
c++ ×2
npp ×2
python ×2
cad ×1
convolution ×1
delphi ×1
opencascade ×1
spline ×1
templates ×1