Problem with B-spline and BRepPrimAPI_MakeRevol

I try to Build some shape,like:

void CGridGenDoc::Shape111()
{
int nPeriod = 3; // nPeriod¸öÖÜÆÚ
int nPP = 20; // ÿ¸öÖÜÆÚ·Ö³ÉnPP·Ý

int nLow = 0;
int nUp = nPeriod*nPP;

int nOffset = 3;

TColgp_Array1OfPnt SinCurve_Point(nLow, nUp);

for(int i=nLow; i {
double x = 0.0;
double z = 2*PI*i/nPP;
double y = sin(z)+nOffset;
SinCurve_Point.SetValue(i, gp_Pnt(x, y, z));
}

Handle(Geom_Curve) Point_to_C = GeomAPI_PointsToBSpline(SinCurve_Point).Curve();

gp_Pnt aPnt1(0, 0, 0);
gp_Pnt aPnt2(0, nOffset, 0);
gp_Pnt aPnt3(0, 0, 2*PI*nPeriod);
gp_Pnt aPnt4(0, nOffset, 2*PI*nPeriod);
TopoDS_Edge aEdge1 = BRepBuilderAPI_MakeEdge(aPnt1, aPnt2);
TopoDS_Edge aEdge2 = BRepBuilderAPI_MakeEdge(Point_to_C).Edge();
TopoDS_Edge aEdge3 = BRepBuilderAPI_MakeEdge(aPnt3, aPnt4);

gp_Ax1 axis = gp::OZ();
// Full revol
TopoDS_Shape R1 = BRepPrimAPI_MakeRevol(aEdge1,axis);
TopoDS_Shape R2 = BRepPrimAPI_MakeRevol(aEdge2,axis);
TopoDS_Shape R3 = BRepPrimAPI_MakeRevol(aEdge3,axis);

TopoDS_Shape R = BRepAlgoAPI_Fuse(R1,R2);
R = BRepAlgoAPI_Fuse(R,R3);

Handle(AIS_Shape) ais_shape = new AIS_Shape(R);
myAISContext->SetColor(ais_shape,Quantity_NOC_AZURE);
myAISContext->SetMaterial(ais_shape,Graphic3d_NOM_PLASTIC);
myAISContext->SetDisplayMode(ais_shape,1);
myAISContext->Display(ais_shape);
}

and try to generate grid

void CGridGenDoc::OnGridCube()
{
ofstream fout(_T("Grid.txt"));
for(myAISContext->InitCurrent(); myAISContext->MoreCurrent(); myAISContext->NextCurrent())
{
Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast(myAISContext->Current());
TopoDS_Shape shape=anAISShape->Shape();

Bnd_Box bs;
BRepBndLib::Add(shape, bs);
double Xmin, Ymin, Zmin, Xmax, Ymax, Zmax;
bs.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax);

gp_Pnt p0;
double dx = 0.5;
double dy = 0.5;
double dz = 0.5;
double halfdx = dx/2.0;
double halfdy = dy/2.0;
double halfdz = dz/2.0;
int Nx = int((Xmax-Xmin)/dx);
int Ny = int((Ymax-Ymin)/dy);
int Nz = int((Zmax-Zmin)/dz);

for(int i=0;i {
for(int j=0;j {
for(int k=0;k {
p0.SetX(Xmin+dx*i+halfdx);
p0.SetY(Ymin+dy*j+halfdy);
p0.SetZ(Zmin+dz*k+halfdz);
BRepClass3d_SolidClassifier classifier(shape,p0,1.0e-5);
if(classifier.State()==TopAbs_IN)
{
fout }
}
}
}

}
fout.close();
}

but I got some differences before generate grid and after.
Who can Help me?

hlqiao's picture

Add:I got some point out of the shape