本文整理汇总了C++中Handle_Geom_Curve::IsKind方法的典型用法代码示例。如果您正苦于以下问题:C++ Handle_Geom_Curve::IsKind方法的具体用法?C++ Handle_Geom_Curve::IsKind怎么用?C++ Handle_Geom_Curve::IsKind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Handle_Geom_Curve
的用法示例。
在下文中一共展示了Handle_Geom_Curve::IsKind方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: vIso
PyObject* GeometrySurfacePy::vIso(PyObject * args)
{
double v;
if (!PyArg_ParseTuple(args, "d", &v))
return 0;
try {
Handle_Geom_Surface surf = Handle_Geom_Surface::DownCast
(getGeometryPtr()->handle());
Handle_Geom_Curve c = surf->VIso(v);
if (c->IsKind(STANDARD_TYPE(Geom_Line))) {
Handle_Geom_Line aLine = Handle_Geom_Line::DownCast(c);
GeomLineSegment* line = new GeomLineSegment();
Handle_Geom_TrimmedCurve this_curv = Handle_Geom_TrimmedCurve::DownCast
(line->handle());
Handle_Geom_Line this_line = Handle_Geom_Line::DownCast
(this_curv->BasisCurve());
this_line->SetLin(aLine->Lin());
return new LinePy(line);
}
else {
return Py::new_reference_to(makeGeometryCurvePy(c));
}
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
PyErr_SetString(PartExceptionOCCError, e->GetMessageString());
return 0;
}
}
示例2: asObject
const Py::Object makeGeometryCurvePy(const Handle_Geom_Curve& c)
{
if (c->IsKind(STANDARD_TYPE(Geom_Circle))) {
Handle_Geom_Circle circ = Handle_Geom_Circle::DownCast(c);
return Py::asObject(new CirclePy(new GeomCircle(circ)));
}
else if (c->IsKind(STANDARD_TYPE(Geom_Ellipse))) {
Handle_Geom_Ellipse ell = Handle_Geom_Ellipse::DownCast(c);
return Py::asObject(new EllipsePy(new GeomEllipse(ell)));
}
else if (c->IsKind(STANDARD_TYPE(Geom_Hyperbola))) {
Handle_Geom_Hyperbola hyp = Handle_Geom_Hyperbola::DownCast(c);
return Py::asObject(new HyperbolaPy(new GeomHyperbola(hyp)));
}
else if (c->IsKind(STANDARD_TYPE(Geom_Line))) {
Handle_Geom_Line lin = Handle_Geom_Line::DownCast(c);
return Py::asObject(new GeometryCurvePy(new GeomLine(lin)));
}
else if (c->IsKind(STANDARD_TYPE(Geom_OffsetCurve))) {
Handle_Geom_OffsetCurve oc = Handle_Geom_OffsetCurve::DownCast(c);
return Py::asObject(new OffsetCurvePy(new GeomOffsetCurve(oc)));
}
else if (c->IsKind(STANDARD_TYPE(Geom_Parabola))) {
Handle_Geom_Parabola par = Handle_Geom_Parabola::DownCast(c);
return Py::asObject(new ParabolaPy(new GeomParabola(par)));
}
else if (c->IsKind(STANDARD_TYPE(Geom_TrimmedCurve))) {
Handle_Geom_TrimmedCurve trc = Handle_Geom_TrimmedCurve::DownCast(c);
return Py::asObject(new GeometryCurvePy(new GeomTrimmedCurve(trc)));
}
/*else if (c->IsKind(STANDARD_TYPE(Geom_BoundedCurve))) {
Handle_Geom_BoundedCurve bc = Handle_Geom_BoundedCurve::DownCast(c);
return Py::asObject(new GeometryCurvePy(new GeomBoundedCurve(bc)));
}*/
else if (c->IsKind(STANDARD_TYPE(Geom_BezierCurve))) {
Handle_Geom_BezierCurve bezier = Handle_Geom_BezierCurve::DownCast(c);
return Py::asObject(new BezierCurvePy(new GeomBezierCurve(bezier)));
}
else if (c->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) {
Handle_Geom_BSplineCurve bspline = Handle_Geom_BSplineCurve::DownCast(c);
return Py::asObject(new BSplineCurvePy(new GeomBSplineCurve(bspline)));
}
std::string err = "Unhandled curve type ";
err += c->DynamicType()->Name();
throw Py::TypeError(err);
}
示例3: DocumentObjectExecReturn
App::DocumentObjectExecReturn *Draft::execute(void)
{
// Get parameters
// Base shape
Part::TopoShape TopShape;
try {
TopShape = getBaseShape();
} catch (Base::Exception& e) {
return new App::DocumentObjectExecReturn(e.what());
}
// Faces where draft should be applied
// Note: Cannot be const reference currently because of BRepOffsetAPI_DraftAngle::Remove() bug, see below
std::vector<std::string> SubVals = Base.getSubValuesStartsWith("Face");
if (SubVals.size() == 0)
return new App::DocumentObjectExecReturn("No faces specified");
// Draft angle
double angle = Angle.getValue() / 180.0 * M_PI;
// Pull direction
gp_Dir pullDirection;
App::DocumentObject* refDirection = PullDirection.getValue();
if (refDirection != NULL) {
if (refDirection->getTypeId().isDerivedFrom(PartDesign::Line::getClassTypeId())) {
PartDesign::Line* line = static_cast<PartDesign::Line*>(refDirection);
Base::Vector3d d = line->getDirection();
pullDirection = gp_Dir(d.x, d.y, d.z);
} else if (refDirection->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId())) {
std::vector<std::string> subStrings = PullDirection.getSubValues();
if (subStrings.empty() || subStrings[0].empty())
throw Base::Exception("No pull direction reference specified");
Part::Feature* refFeature = static_cast<Part::Feature*>(refDirection);
Part::TopoShape refShape = refFeature->Shape.getShape();
TopoDS_Shape ref = refShape.getSubShape(subStrings[0].c_str());
if (ref.ShapeType() == TopAbs_EDGE) {
TopoDS_Edge refEdge = TopoDS::Edge(ref);
if (refEdge.IsNull())
throw Base::Exception("Failed to extract pull direction reference edge");
BRepAdaptor_Curve adapt(refEdge);
if (adapt.GetType() != GeomAbs_Line)
throw Base::Exception("Pull direction reference edge must be linear");
pullDirection = adapt.Line().Direction();
} else {
throw Base::Exception("Pull direction reference must be an edge or a datum line");
}
} else {
throw Base::Exception("Pull direction reference must be an edge of a feature or a datum line");
}
TopLoc_Location invObjLoc = this->getLocation().Inverted();
pullDirection.Transform(invObjLoc.Transformation());
}
// Neutral plane
gp_Pln neutralPlane;
App::DocumentObject* refPlane = NeutralPlane.getValue();
if (refPlane == NULL) {
// Try to guess a neutral plane from the first selected face
// Get edges of first selected face
TopoDS_Shape face = TopShape.getSubShape(SubVals[0].c_str());
TopTools_IndexedMapOfShape mapOfEdges;
TopExp::MapShapes(face, TopAbs_EDGE, mapOfEdges);
bool found = false;
for (int i = 1; i <= mapOfEdges.Extent(); i++) {
// Note: What happens if mapOfEdges(i) is the degenerated edge of a cone?
// But in that case the draft is not possible anyway!
BRepAdaptor_Curve c(TopoDS::Edge(mapOfEdges(i)));
gp_Pnt p1 = c.Value(c.FirstParameter());
gp_Pnt p2 = c.Value(c.LastParameter());
if (c.IsClosed()) {
// Edge is a circle or a circular arc (other types are not allowed for drafting)
neutralPlane = gp_Pln(p1, c.Circle().Axis().Direction());
found = true;
break;
} else {
// Edge is linear
// Find midpoint of edge and create auxiliary plane through midpoint normal to edge
gp_Pnt pm = c.Value((c.FirstParameter() + c.LastParameter()) / 2.0);
Handle_Geom_Plane aux = new Geom_Plane(pm, gp_Dir(p2.X() - p1.X(), p2.Y() - p1.Y(), p2.Z() - p1.Z()));
// Intersect plane with face. Is there no easier way?
BRepAdaptor_Surface adapt(TopoDS::Face(face), Standard_False);
Handle_Geom_Surface sf = adapt.Surface().Surface();
GeomAPI_IntSS intersector(aux, sf, Precision::Confusion());
if (!intersector.IsDone())
continue;
Handle_Geom_Curve icurve = intersector.Line(1);
if (!icurve->IsKind(STANDARD_TYPE(Geom_Line)))
continue;
// TODO: How to extract the line from icurve without creating an edge first?
TopoDS_Edge edge = BRepBuilderAPI_MakeEdge(icurve);
BRepAdaptor_Curve c(edge);
neutralPlane = gp_Pln(pm, c.Line().Direction());
found = true;
break;
//.........这里部分代码省略.........