How to check the Handle is available or invalid?

hello everyone:
my programm as follow:

double fir, lst;
TopoDS_Edge aEdge = ...;
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, fir, lst);
Handle(Standard_Type) edgeType = aCurve->DynamicType();

my question is how can i check "aCurve" is a available or NULL Handle,
it is crush sometime in "aCurve->DynamicType();"

sergey zaritchny's picture

Hi tudousi,
The handle may be checked to be null by its method IsNull().
See paragraph "2.2. Programming with Handles" of "Foundation Classes User's Guide"
Regards

aeo153's picture

Hi sergey zaritchny, thank you for your reply, but IsNull() is not a member of Geom_Curve,
and use "if ( aCurve == NULL ) { ... }" also cann't work.

Best Regards

P Dolbey's picture

aCurve is an instance of Handle_Geom_Curve, not Geom_Curve, so it will have an IsNull method.

Pete

EricThompson's picture

You have to use aCurve.IsNull(), not aCurve->IsNull()

aeo153's picture

yes, you are right, my bug was fixed, thank you.