本文整理汇总了C++中Handle_Geom_Curve::IsNull方法的典型用法代码示例。如果您正苦于以下问题:C++ Handle_Geom_Curve::IsNull方法的具体用法?C++ Handle_Geom_Curve::IsNull怎么用?C++ Handle_Geom_Curve::IsNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Handle_Geom_Curve
的用法示例。
在下文中一共展示了Handle_Geom_Curve::IsNull方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toShape
PyObject* GeometryCurvePy::toShape(PyObject *args)
{
Handle_Geom_Geometry g = getGeometryPtr()->handle();
Handle_Geom_Curve c = Handle_Geom_Curve::DownCast(g);
try {
if (!c.IsNull()) {
double u,v;
u=c->FirstParameter();
v=c->LastParameter();
if (!PyArg_ParseTuple(args, "|dd", &u,&v))
return 0;
BRepBuilderAPI_MakeEdge mkBuilder(c, u, v);
TopoDS_Shape sh = mkBuilder.Shape();
return new TopoShapeEdgePy(new TopoShape(sh));
}
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
return 0;
}
示例2: PyInit
// constructor method
int SurfaceOfExtrusionPy::PyInit(PyObject* args, PyObject* /*kwd*/)
{
PyObject* pGeom;
PyObject* pDir;
if (!PyArg_ParseTuple(args, "O!O!",
&(GeometryPy::Type), &pGeom,
&(Base::VectorPy::Type),&pDir))
return -1;
GeometryPy* pcGeo = static_cast<GeometryPy*>(pGeom);
Handle_Geom_Curve curve = Handle_Geom_Curve::DownCast
(pcGeo->getGeometryPtr()->handle());
if (curve.IsNull()) {
PyErr_SetString(PyExc_TypeError, "geometry is not a curve");
return -1;
}
try {
Base::Vector3d dir = static_cast<Base::VectorPy*>(pDir)->value();
Handle_Geom_SurfaceOfLinearExtrusion curve2 = new Geom_SurfaceOfLinearExtrusion(curve,
gp_Dir(dir.x,dir.y,dir.z));
getGeomSurfaceOfExtrusionPtr()->setHandle(curve2);
return 0;
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return -1;
}
}
示例3: parameter
PyObject* GeometryCurvePy::parameter(PyObject *args)
{
Handle_Geom_Geometry g = getGeometryPtr()->handle();
Handle_Geom_Curve c = Handle_Geom_Curve::DownCast(g);
try {
if (!c.IsNull()) {
PyObject *p;
if (!PyArg_ParseTuple(args, "O!", &(Base::VectorPy::Type), &p))
return 0;
Base::Vector3d v = Py::Vector(p, false).toVector();
gp_Pnt pnt(v.x,v.y,v.z);
GeomAPI_ProjectPointOnCurve ppc(pnt, c);
double val = ppc.LowerDistanceParameter();
return Py::new_reference_to(Py::Float(val));
}
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
return 0;
}
示例4: intersect
PyObject* GeometryCurvePy::intersect(PyObject *args)
{
Handle_Geom_Curve curve = Handle_Geom_Curve::DownCast(getGeometryPtr()->handle());
try {
if (!curve.IsNull()) {
PyObject *p;
double prec = Precision::Confusion();
try {
if (PyArg_ParseTuple(args, "O!|d", &(Part::GeometryCurvePy::Type), &p, &prec))
return intersectCC(args);
} catch(...) {}
PyErr_Clear();
if (PyArg_ParseTuple(args, "O!|d", &(Part::GeometrySurfacePy::Type), &p, &prec))
return intersectCS(args);
else
return 0;
}
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PyExc_Exception, e->GetMessageString());
return 0;
}
PyErr_SetString(PyExc_Exception, "Geometry is not a curve");
return 0;
}
示例5: toBSpline
PyObject* GeometryCurvePy::toBSpline(PyObject * args)
{
Handle_Geom_Geometry g = getGeometryPtr()->handle();
Handle_Geom_Curve c = Handle_Geom_Curve::DownCast(g);
try {
if (!c.IsNull()) {
double u,v;
u=c->FirstParameter();
v=c->LastParameter();
if (!PyArg_ParseTuple(args, "|dd", &u,&v))
return 0;
ShapeConstruct_Curve scc;
Handle_Geom_BSplineCurve spline = scc.ConvertToBSpline(c, u, v, Precision::Confusion());
if (spline.IsNull())
Standard_NullValue::Raise("Conversion to B-Spline failed");
return new BSplineCurvePy(new GeomBSplineCurve(spline));
}
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
return 0;
}
示例6: length
PyObject* GeometryCurvePy::length(PyObject *args)
{
Handle_Geom_Geometry g = getGeometryPtr()->handle();
Handle_Geom_Curve c = Handle_Geom_Curve::DownCast(g);
try {
if (!c.IsNull()) {
double u=c->FirstParameter();
double v=c->LastParameter();
double t=Precision::Confusion();
if (!PyArg_ParseTuple(args, "|ddd", &u,&v,&t))
return 0;
GeomAdaptor_Curve adapt(c);
double len = GCPnts_AbscissaPoint::Length(adapt,u,v,t);
return PyFloat_FromDouble(len);
}
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
return 0;
}
示例7: tangent
PyObject* GeometryCurvePy::tangent(PyObject *args)
{
Handle_Geom_Geometry g = getGeometryPtr()->handle();
Handle_Geom_Curve c = Handle_Geom_Curve::DownCast(g);
try {
if (!c.IsNull()) {
double u;
if (!PyArg_ParseTuple(args, "d", &u))
return 0;
gp_Dir dir;
Py::Tuple tuple(1);
GeomLProp_CLProps prop(c,u,1,Precision::Confusion());
if (prop.IsTangentDefined()) {
prop.Tangent(dir);
tuple.setItem(0, Py::Vector(Base::Vector3d(dir.X(),dir.Y(),dir.Z())));
}
return Py::new_reference_to(tuple);
}
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
return 0;
}
示例8: parameterAtDistance
PyObject* GeometryCurvePy::parameterAtDistance(PyObject *args)
{
Handle_Geom_Geometry g = getGeometryPtr()->handle();
Handle_Geom_Curve c = Handle_Geom_Curve::DownCast(g);
try {
if (!c.IsNull()) {
double abscissa;
double u = 0;
if (!PyArg_ParseTuple(args, "d|d", &abscissa,&u))
return 0;
GeomAdaptor_Curve adapt(c);
GCPnts_AbscissaPoint abscissaPoint(adapt,abscissa,u);
double parm = abscissaPoint.Parameter();
return PyFloat_FromDouble(parm);
}
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
return 0;
}
示例9: convert_to_ifc
int convert_to_ifc(const TopoDS_Wire& wire, IfcSchema::IfcLoop*& loop, bool advanced) {
bool polygonal = true;
for (TopExp_Explorer exp(wire, TopAbs_EDGE); exp.More(); exp.Next()) {
double a, b;
Handle_Geom_Curve crv = BRep_Tool::Curve(TopoDS::Edge(exp.Current()), a, b);
if (crv.IsNull()) {
continue;
}
if (crv->DynamicType() != STANDARD_TYPE(Geom_Line)) {
polygonal = false;
break;
}
}
if (!polygonal && !advanced) {
return 0;
} else if (polygonal && !advanced) {
IfcSchema::IfcCartesianPoint::list::ptr points(new IfcSchema::IfcCartesianPoint::list);
BRepTools_WireExplorer exp(wire);
IfcSchema::IfcCartesianPoint* p;
for (; exp.More(); exp.Next()) {
if (convert_to_ifc(exp.CurrentVertex(), p, advanced)) {
points->push(p);
} else {
return 0;
}
}
loop = new IfcSchema::IfcPolyLoop(points);
return 1;
} else {
IfcSchema::IfcOrientedEdge::list::ptr edges(new IfcSchema::IfcOrientedEdge::list);
BRepTools_WireExplorer exp(wire);
for (; exp.More(); exp.Next()) {
IfcSchema::IfcEdge* edge;
// With advanced set to true convert_to_ifc(TopoDS_Edge&) will always create an IfcOrientedEdge
if (!convert_to_ifc(exp.Current(), edge, true)) {
double a, b;
if (BRep_Tool::Curve(TopoDS::Edge(exp.Current()), a, b).IsNull()) {
continue;
} else {
return 0;
}
}
edges->push(edge->as<IfcSchema::IfcOrientedEdge>());
}
loop = new IfcSchema::IfcEdgeLoop(edges);
return 1;
}
}
示例10: intersectCS
PyObject* GeometryCurvePy::intersectCS(PyObject *args)
{
Handle_Geom_Curve curve = Handle_Geom_Curve::DownCast(getGeometryPtr()->handle());
try {
if (!curve.IsNull()) {
PyObject *p;
double prec = Precision::Confusion();
if (!PyArg_ParseTuple(args, "O!|d", &(Part::GeometrySurfacePy::Type), &p, &prec))
return 0;
Handle_Geom_Surface surf = Handle_Geom_Surface::DownCast(static_cast<GeometryPy*>(p)->getGeometryPtr()->handle());
GeomAPI_IntCS intersector(curve, surf);
if (!intersector.IsDone()) {
PyErr_SetString(PyExc_Exception, "Intersection of curve and surface failed");
return 0;
}
Py::List points;
for (int i = 1; i <= intersector.NbPoints(); i++) {
gp_Pnt p = intersector.Point(i);
points.append(Py::Object(new PointPy(new GeomPoint(Base::Vector3d(p.X(), p.Y(), p.Z())))));
}
Py::List segments;
for (int i = 1; i <= intersector.NbSegments(); i++) {
Handle_Geom_Curve seg = intersector.Segment(i);
segments.append(makeGeometryCurvePy(seg));
}
Py::Tuple tuple(2);
tuple.setItem(0, points);
tuple.setItem(1, segments);
return Py::new_reference_to(tuple);
}
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PyExc_Exception, e->GetMessageString());
return 0;
}
PyErr_SetString(PyExc_Exception, "Geometry is not a curve");
return 0;
}
示例11: setBasisCurve
void SurfaceOfExtrusionPy::setBasisCurve(Py::Object arg)
{
PyObject* p = arg.ptr();
if (PyObject_TypeCheck(p, &(GeometryPy::Type))) {
GeometryPy* pcGeo = static_cast<GeometryPy*>(p);
Handle_Geom_Curve curve = Handle_Geom_Curve::DownCast
(pcGeo->getGeometryPtr()->handle());
if (curve.IsNull()) {
throw Py::TypeError("geometry is not a curve");
}
try {
Handle_Geom_SurfaceOfLinearExtrusion curve2 = Handle_Geom_SurfaceOfLinearExtrusion::DownCast
(getGeometryPtr()->handle());
curve2->SetBasisCurve(curve);
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
throw Py::Exception(e->GetMessageString());
}
}
}
示例12: value
PyObject* GeometryCurvePy::value(PyObject *args)
{
Handle_Geom_Geometry g = getGeometryPtr()->handle();
Handle_Geom_Curve c = Handle_Geom_Curve::DownCast(g);
try {
if (!c.IsNull()) {
double u;
if (!PyArg_ParseTuple(args, "d", &u))
return 0;
gp_Pnt p = c->Value(u);
return new Base::VectorPy(Base::Vector3d(p.X(),p.Y(),p.Z()));
}
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
return 0;
}
示例13: PyInit
// constructor method
int TopoShapeEdgePy::PyInit(PyObject* args, PyObject* /*kwd*/)
{
PyObject *pcObj, *pcObj2;
double first=DBL_MAX, last=DBL_MAX;
if (PyArg_ParseTuple(args, "O!|dd", &(Part::GeometryPy::Type), &pcObj, &first, &last)) {
Geometry* geom = static_cast<GeometryPy*>(pcObj)->getGeometryPtr();
Handle_Geom_Curve curve = Handle_Geom_Curve::DownCast(geom->handle());
if (curve.IsNull()) {
PyErr_SetString(PyExc_Exception, "geometry is not a curve type");
return -1;
}
if (first==DBL_MAX)
first = curve->FirstParameter();
if (last==DBL_MAX)
last = curve->LastParameter();
try {
BRepBuilderAPI_MakeEdge mkEdge(curve, first, last);
getTopoShapePtr()->_Shape = mkEdge.Edge();
return 0;
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PyExc_Exception, e->GetMessageString());
return -1;
}
}
PyErr_Clear();
if (PyArg_ParseTuple(args, "O!", &(Part::TopoShapePy::Type), &pcObj)) {
TopoShape* shape = static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr();
if (shape && !shape->_Shape.IsNull() && shape->_Shape.ShapeType() == TopAbs_EDGE) {
this->getTopoShapePtr()->_Shape = shape->_Shape;
return 0;
}
else {
PyErr_SetString(PyExc_TypeError, "Shape is not an edge");
return -1;
}
}
PyErr_Clear();
if (PyArg_ParseTuple(args, "O!O!", &(Part::TopoShapeVertexPy::Type), &pcObj,
&(Part::TopoShapeVertexPy::Type), &pcObj2)) {
TopoShape* shape1 = static_cast<TopoShapePy*>(pcObj)->getTopoShapePtr();
TopoShape* shape2 = static_cast<TopoShapePy*>(pcObj2)->getTopoShapePtr();
const TopoDS_Vertex& v1 = TopoDS::Vertex(shape1->_Shape);
const TopoDS_Vertex& v2 = TopoDS::Vertex(shape2->_Shape);
try {
BRepBuilderAPI_MakeEdge mkEdge(v1, v2);
getTopoShapePtr()->_Shape = mkEdge.Edge();
return 0;
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PyExc_Exception, e->GetMessageString());
return -1;
}
}
PyErr_SetString(PyExc_Exception, "Curve or shape expected");
return -1;
}
示例14: discretize
PyObject* GeometryCurvePy::discretize(PyObject *args, PyObject *kwds)
{
try {
Handle_Geom_Geometry g = getGeometryPtr()->handle();
Handle_Geom_Curve c = Handle_Geom_Curve::DownCast(g);
if (c.IsNull()) {
PyErr_SetString(PartExceptionOCCError, "Geometry is not a curve");
return 0;
}
GeomAdaptor_Curve adapt(c);
bool uniformAbscissaPoints = false;
bool uniformAbscissaDistance = false;
int numPoints = -1;
double distance = -1;
double first = adapt.FirstParameter();
double last = adapt.LastParameter();
// use no kwds
PyObject* dist_or_num;
if (PyArg_ParseTuple(args, "O", &dist_or_num)) {
if (PyInt_Check(dist_or_num)) {
numPoints = PyInt_AsLong(dist_or_num);
uniformAbscissaPoints = true;
}
else if (PyFloat_Check(dist_or_num)) {
distance = PyFloat_AsDouble(dist_or_num);
uniformAbscissaDistance = true;
}
else {
PyErr_SetString(PyExc_TypeError, "Either int or float expected");
return 0;
}
}
else {
// use Number kwds
static char* kwds_numPoints[] = {"Number","First","Last",NULL};
PyErr_Clear();
if (PyArg_ParseTupleAndKeywords(args, kwds, "i|dd", kwds_numPoints, &numPoints, &first, &last)) {
uniformAbscissaPoints = true;
}
else {
// use Abscissa kwds
static char* kwds_Distance[] = {"Distance","First","Last",NULL};
PyErr_Clear();
if (PyArg_ParseTupleAndKeywords(args, kwds, "d|dd", kwds_Distance, &distance, &first, &last)) {
uniformAbscissaDistance = true;
}
}
}
if (uniformAbscissaPoints || uniformAbscissaDistance) {
GCPnts_UniformAbscissa discretizer;
if (uniformAbscissaPoints)
discretizer.Initialize (adapt, numPoints, first, last);
else
discretizer.Initialize (adapt, distance, first, last);
if (discretizer.IsDone () && discretizer.NbPoints () > 0) {
Py::List points;
int nbPoints = discretizer.NbPoints ();
for (int i=1; i<=nbPoints; i++) {
gp_Pnt p = adapt.Value (discretizer.Parameter (i));
points.append(Py::Vector(Base::Vector3d(p.X(),p.Y(),p.Z())));
}
return Py::new_reference_to(points);
}
else {
PyErr_SetString(PartExceptionOCCError, "Discretization of curve failed");
return 0;
}
}
// use Deflection kwds
static char* kwds_Deflection[] = {"Deflection","First","Last",NULL};
PyErr_Clear();
double deflection;
if (PyArg_ParseTupleAndKeywords(args, kwds, "d|dd", kwds_Deflection, &deflection, &first, &last)) {
GCPnts_UniformDeflection discretizer(adapt, deflection, first, last);
if (discretizer.IsDone () && discretizer.NbPoints () > 0) {
Py::List points;
int nbPoints = discretizer.NbPoints ();
for (int i=1; i<=nbPoints; i++) {
gp_Pnt p = discretizer.Value (i);
points.append(Py::Vector(Base::Vector3d(p.X(),p.Y(),p.Z())));
}
return Py::new_reference_to(points);
}
else {
PyErr_SetString(PartExceptionOCCError, "Discretization of curve failed");
return 0;
}
}
// use TangentialDeflection kwds
static char* kwds_TangentialDeflection[] = {"Angular","Curvature","First","Last","Minimum",NULL};
PyErr_Clear();
double angular;
//.........这里部分代码省略.........