本文整理汇总了C++中part::TopoShape::getShape方法的典型用法代码示例。如果您正苦于以下问题:C++ TopoShape::getShape方法的具体用法?C++ TopoShape::getShape怎么用?C++ TopoShape::getShape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类part::TopoShape
的用法示例。
在下文中一共展示了TopoShape::getShape方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DocumentObjectExecReturn
App::DocumentObjectExecReturn *Thickness::execute(void)
{
// Base shape
Part::TopoShape TopShape;
try {
TopShape = getBaseShape();
} catch (Base::Exception& e) {
return new App::DocumentObjectExecReturn(e.what());
}
TopTools_ListOfShape closingFaces;
const std::vector<std::string>& subStrings = Base.getSubValues();
for (std::vector<std::string>::const_iterator it = subStrings.begin(); it != subStrings.end(); ++it) {
TopoDS_Face face = TopoDS::Face(TopShape.getSubShape(it->c_str()));
closingFaces.Append(face);
}
bool reversed = Reversed.getValue();
double thickness = (reversed ? -1. : 1. )*Value.getValue();
double tol = Precision::Confusion();
short mode = (short)Mode.getValue();
short join = (short)Join.getValue();
//we do not offer tangent join type
if(join == 1)
join = 2;
if (fabs(thickness) > 2*tol)
this->Shape.setValue(getSolid(TopShape.makeThickSolid(closingFaces, thickness, tol, false, false, mode, join)));
else
this->Shape.setValue(getSolid(TopShape.getShape()));
return App::DocumentObject::StdReturn;
}
示例2: buildPipePath
void Pipe::buildPipePath(const Part::TopoShape& shape, const std::vector< std::string >& subedge, TopoDS_Shape& path) {
if (!shape.getShape().IsNull()) {
try {
if (!subedge.empty()) {
//if(SpineTangent.getValue())
//getContiniusEdges(shape, subedge);
BRepBuilderAPI_MakeWire mkWire;
for (std::vector<std::string>::const_iterator it = subedge.begin(); it != subedge.end(); ++it) {
TopoDS_Shape subshape = shape.getSubShape(it->c_str());
mkWire.Add(TopoDS::Edge(subshape));
}
path = mkWire.Wire();
}
else if (shape.getShape().ShapeType() == TopAbs_EDGE) {
path = shape.getShape();
}
else if (shape.getShape().ShapeType() == TopAbs_WIRE) {
BRepBuilderAPI_MakeWire mkWire(TopoDS::Wire(shape.getShape()));
path = mkWire.Wire();
}
else if (shape.getShape().ShapeType() == TopAbs_COMPOUND) {
TopoDS_Iterator it(shape.getShape());
for (; it.More(); it.Next()) {
if (it.Value().IsNull())
throw Base::Exception("In valid element in spine.");
if ((it.Value().ShapeType() != TopAbs_EDGE) &&
(it.Value().ShapeType() != TopAbs_WIRE)) {
throw Base::Exception("Element in spine is neither an edge nor a wire.");
}
}
Handle(TopTools_HSequenceOfShape) hEdges = new TopTools_HSequenceOfShape();
Handle(TopTools_HSequenceOfShape) hWires = new TopTools_HSequenceOfShape();
for (TopExp_Explorer xp(shape.getShape(), TopAbs_EDGE); xp.More(); xp.Next())
hEdges->Append(xp.Current());
ShapeAnalysis_FreeBounds::ConnectEdgesToWires(hEdges, Precision::Confusion(), Standard_True, hWires);
int len = hWires->Length();
if (len != 1)
throw Base::Exception("Spine is not connected.");
path = hWires->Value(1);
}
else {
throw Base::Exception("Spine is neither an edge nor a wire.");
}
}
catch (Standard_Failure) {
throw Base::Exception("Invalid spine.");
}
}
}
示例3: DocumentObjectExecReturn
App::DocumentObjectExecReturn *Body::execute(void)
{
/*
Base::Console().Error("Body '%s':\n", getNameInDocument());
App::DocumentObject* tip = Tip.getValue();
Base::Console().Error(" Tip: %s\n", (tip == NULL) ? "None" : tip->getNameInDocument());
std::vector<App::DocumentObject*> model = Model.getValues();
Base::Console().Error(" Model:\n");
for (std::vector<App::DocumentObject*>::const_iterator m = model.begin(); m != model.end(); m++) {
if (*m == NULL) continue;
Base::Console().Error(" %s", (*m)->getNameInDocument());
if (Body::isSolidFeature(*m)) {
App::DocumentObject* baseFeature = static_cast<PartDesign::Feature*>(*m)->BaseFeature.getValue();
Base::Console().Error(", Base: %s\n", baseFeature == NULL ? "None" : baseFeature->getNameInDocument());
} else {
Base::Console().Error("\n");
}
}
*/
App::DocumentObject* tip = Tip.getValue();
Part::TopoShape tipShape;
if ( tip ) {
if ( !tip->getTypeId().isDerivedFrom ( PartDesign::Feature::getClassTypeId() )
&& tip != BaseFeature.getValue () ) {
return new App::DocumentObjectExecReturn ( "Linked object is not a PartDesign feature" );
}
// get the shape of the tip
tipShape = static_cast<Part::Feature *>(tip)->Shape.getShape();
if ( tipShape.getShape().IsNull () ) {
return new App::DocumentObjectExecReturn ( "Tip shape is empty" );
}
// We should hide here the transformation of the baseFeature
tipShape.transformShape (tipShape.getTransform(), true );
} else {
tipShape = Part::TopoShape();
}
Shape.setValue ( tipShape );
return App::DocumentObject::StdReturn;
}
示例4: checkLineCrossesFace
//.........这里部分代码省略.........
} else {
Extrema_POnCurv p1, p2;
intersector.Points(i, p1, p2);
intersectionpoints.push_back(p1.Value());
intersections++;
}
}
}
}
}
// Note: We might check this inside the loop but then we have to rely on TopExp_Explorer
// returning the wire's edges in adjacent order (because of the coincident line checking)
if (intersections > 1) {
// Check that we don't touch the sketchface just in two identical vertices
if ((intersectionpoints.size() == 2) &&
(intersectionpoints[0].IsEqual(intersectionpoints[1], Precision::Confusion())))
return false;
else
return true;
}
return false;
#endif
}
void ProfileBased::remapSupportShape(const TopoDS_Shape& newShape)
{
TopTools_IndexedMapOfShape faceMap;
TopExp::MapShapes(newShape, TopAbs_FACE, faceMap);
// here we must reset the placement otherwise the geometric matching doesn't work
Part::TopoShape shape = this->Shape.getValue();
TopoDS_Shape sh = shape.getShape();
sh.Location(TopLoc_Location());
shape.setShape(sh);
std::vector<App::DocumentObject*> refs = this->getInList();
for (std::vector<App::DocumentObject*>::iterator it = refs.begin(); it != refs.end(); ++it) {
std::vector<App::Property*> props;
(*it)->getPropertyList(props);
for (std::vector<App::Property*>::iterator jt = props.begin(); jt != props.end(); ++jt) {
if (!(*jt)->isDerivedFrom(App::PropertyLinkSub::getClassTypeId()))
continue;
App::PropertyLinkSub* link = static_cast<App::PropertyLinkSub*>(*jt);
if (link->getValue() != this)
continue;
std::vector<std::string> subValues = link->getSubValues();
std::vector<std::string> newSubValues;
for (std::vector<std::string>::iterator it = subValues.begin(); it != subValues.end(); ++it) {
std::string shapetype;
if (it->size() > 4 && it->substr(0,4) == "Face") {
shapetype = "Face";
}
else if (it->size() > 4 && it->substr(0,4) == "Edge") {
shapetype = "Edge";
}
else if (it->size() > 6 && it->substr(0,6) == "Vertex") {
shapetype = "Vertex";
}
else {
newSubValues.push_back(*it);
continue;
}