Thu, 02/24/2005 - 16:31

hello,

I'm currently making an AIS_InteractiveObject-derived based on Geom_BSplineSurface.

I've managed to implement correctly the Compute method in order to display the surface, and now I need to implement the selection.

If I'm wrong, please correct me on this:

I've noticed that the Select3D package forces me to reduce the Geom_BSplineSurface to a set of Geom_Curve objects, because there is only Select3D_SensitiveCurve I could use.

So I've decided to "extract" the four bounding Geom_BSplineCurve objects from the Geom_BSplineSurface, and the only way I've found to do this is by taking the Poles, Weights, Multiplicities, ... surface data and use them to create the curves.

Unfortunately, for some reason, the construction of the curves throws a Standard_ConstructionError:

Handle(SelectMgr_EntityOwner) theOwner = new SelectMgr_EntityOwner(this,0);

TColgp_Array1OfPnt LUPoles(1,this->srf->NbUPoles());

TColStd_Array1OfReal LUWeights(1,this->srf->NbUPoles());

TColStd_Array1OfReal UKnots(1,this->srf->NbUKnots());

TColStd_Array1OfInteger UMults(1,this->srf->NbUKnots());

Standard_Integer nCont;

for(nCont = 1; nCont

LUPoles.SetValue(nCont,this->srf->Pole(nCont,1));

}

for(nCont = 1; nCont

LUWeights.SetValue(nCont,this->srf->Weight(nCont,1));

}

this->srf->UKnots(UKnots);

this->srf->UMultiplicities(UMults);

try {

Geom_BSplineCurve LCurve (

LUPoles,

LUWeights,

UKnots,

UMults,

this->srf->UDegree(),

this->srf->IsUPeriodic()

);

} catch (Standard_ConstructionError) {

// this error is thrown!!

};

aSelection->Add(new Select3D_SensitiveCurve(theOwner,&LCurve));

I've tried to check for the possible causes, and i've stated that

these conditions are satisfied:

- the Poles and Weights arrays have the same dimension and this dimension is greater than or equal to 2,

- the Knots and Multiplicities arrays have the same dimension and this dimension is greater than or equal to 2,

- the multiplicity coefficients are in the range 1 to Degree. However, on a non-periodic curve, the first and last multiplicities may be Degree + 1 (this is recommended if you want the curve to start and finish on the first and last poles),

- on a non-periodic curve, the number of poles is equal to the sum of the multiplicity coefficients, minus Degree, minus 1,

Any help?

Thanks

Thu, 02/24/2005 - 16:42

forget it: I'm a stupid :)

the arrays where 1-based, while the for cycles were 0-based.. how lame, sorry

Fri, 02/25/2005 - 09:34

U can extract any curve on a surface passing through u/v location using

the UIso and VIso function of the Geom_Surface class.

U can see the code in Test harness example ,

//=======================================================================

//function : iso

//purpose :

//=======================================================================

static Standard_Integer iso (Draw_Interpretor& di, Standard_Integer n, char** a)

{

if (n < 4) return 1;

Handle(Geom_Curve) C;

Standard_Real par = atof(a[3]);

Handle(Geom_Surface) GS = DrawTrSurf::GetSurface(a[2]);

if (!GS.IsNull()) {

if (*a[0] == 'u')

C = GS->UIso(par);

else

C = GS->VIso(par);

DrawTrSurf::Set(a[1],C);

}

return 0;

}

This should work for extracting the boundary curves tooooo.

Hope I am correct

- Prasad