本文整理汇总了C++中TopoDS_Shape::ShapeType方法的典型用法代码示例。如果您正苦于以下问题:C++ TopoDS_Shape::ShapeType方法的具体用法?C++ TopoDS_Shape::ShapeType怎么用?C++ TopoDS_Shape::ShapeType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TopoDS_Shape
的用法示例。
在下文中一共展示了TopoDS_Shape::ShapeType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Execute
//=======================================================================
//function : Execute
//purpose :
//=======================================================================
Standard_Integer GEOMImpl_CylinderDriver::Execute(TFunction_Logbook& log) const
{
if (Label().IsNull()) return 0;
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
GEOMImpl_ICylinder aCI (aFunction);
Standard_Integer aType = aFunction->GetType();
gp_Pnt aP;
gp_Vec aV;
if (aType == CYLINDER_R_H) {
aP = gp::Origin();
aV = gp::DZ();
}
else if (aType == CYLINDER_PNT_VEC_R_H) {
Handle(GEOM_Function) aRefPoint = aCI.GetPoint();
Handle(GEOM_Function) aRefVector = aCI.GetVector();
TopoDS_Shape aShapePnt = aRefPoint->GetValue();
TopoDS_Shape aShapeVec = aRefVector->GetValue();
if (aShapePnt.IsNull() || aShapeVec.IsNull()) {
Standard_NullObject::Raise("Cylinder creation aborted: point or vector is not defined");
}
if (aShapePnt.ShapeType() != TopAbs_VERTEX ||
aShapeVec.ShapeType() != TopAbs_EDGE) {
Standard_TypeMismatch::Raise("Cylinder creation aborted: point or vector shapes has wrong type");
}
aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt));
TopoDS_Edge anE = TopoDS::Edge(aShapeVec);
TopoDS_Vertex V1, V2;
TopExp::Vertices(anE, V1, V2, Standard_True);
if (V1.IsNull() || V2.IsNull()) {
Standard_NullObject::Raise("Cylinder creation aborted: vector is not defined");
}
aV = gp_Vec(BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2));
}
else {
return 0;
}
if (aCI.GetH() < 0.0) aV.Reverse();
gp_Ax2 anAxes (aP, aV);
BRepPrimAPI_MakeCylinder MC (anAxes, aCI.GetR(), Abs(aCI.GetH()));
MC.Build();
if (!MC.IsDone()) {
StdFail_NotDone::Raise("Cylinder can't be computed from the given parameters");
}
TopoDS_Shape aShape = MC.Shape();
if (aShape.IsNull()) return 0;
aFunction->SetValue(aShape);
log.SetTouched(Label());
return 1;
}
示例2: if
//=======================================================================
//function : ShapeToDouble
//purpose : used by CompareShapes::operator()
//=======================================================================
std::pair<double, double> GEOMUtils::ShapeToDouble (const TopoDS_Shape& S, bool isOldSorting)
{
// Computing of CentreOfMass
gp_Pnt GPoint;
double Len;
if (S.ShapeType() == TopAbs_VERTEX) {
GPoint = BRep_Tool::Pnt(TopoDS::Vertex(S));
Len = (double)S.Orientation();
}
else {
GProp_GProps GPr;
// BEGIN: fix for Mantis issue 0020842
if (isOldSorting) {
BRepGProp::LinearProperties(S, GPr);
}
else {
if (S.ShapeType() == TopAbs_EDGE || S.ShapeType() == TopAbs_WIRE) {
BRepGProp::LinearProperties(S, GPr);
}
else if (S.ShapeType() == TopAbs_FACE || S.ShapeType() == TopAbs_SHELL) {
BRepGProp::SurfaceProperties(S, GPr);
}
else {
BRepGProp::VolumeProperties(S, GPr);
}
}
// END: fix for Mantis issue 0020842
GPoint = GPr.CentreOfMass();
Len = GPr.Mass();
}
double dMidXYZ = GPoint.X() * 999.0 + GPoint.Y() * 99.0 + GPoint.Z() * 0.9;
return std::make_pair(dMidXYZ, Len);
}
示例3: if
const TopoDS_Shape& BRepOffsetAPI_MakeOffsetFix::Shape()
{
if (myResult.IsNull()) {
TopoDS_Shape result = mkOffset.Shape();
if (result.ShapeType() == TopAbs_WIRE) {
MakeWire(result);
}
else if (result.ShapeType() == TopAbs_COMPOUND) {
BRep_Builder builder;
TopoDS_Compound comp;
builder.MakeCompound(comp);
TopExp_Explorer xp(result, TopAbs_WIRE);
while (xp.More()) {
TopoDS_Wire wire = TopoDS::Wire(xp.Current());
MakeWire(wire);
builder.Add(comp, wire);
xp.Next();
}
result = comp;
}
myResult = result;
}
return myResult;
}
示例4: AddPointOnEdge
//=======================================================================
//function : AddPointOnEdge
//purpose :
//=======================================================================
Standard_Boolean GEOMImpl_HealingDriver::AddPointOnEdge (GEOMImpl_IHealing* theHI,
const TopoDS_Shape& theOriginalShape,
TopoDS_Shape& theOutShape) const
{
Standard_Boolean isByParameter = theHI->GetIsByParameter();
Standard_Integer anIndex = theHI->GetIndex();
Standard_Real aValue = theHI->GetDevideEdgeValue();
ShHealOper_EdgeDivide aHealer (theOriginalShape);
Standard_Boolean aResult = Standard_False;
if (anIndex == -1) { // apply algorythm for the whole shape which is EDGE
if (theOriginalShape.ShapeType() == TopAbs_EDGE)
aResult = aHealer.Perform(TopoDS::Edge(theOriginalShape), aValue, isByParameter);
} else {
TopTools_IndexedMapOfShape aShapes;
TopExp::MapShapes(theOriginalShape, aShapes);
TopoDS_Shape aEdgeShape = aShapes.FindKey(anIndex);
if (aEdgeShape.ShapeType() == TopAbs_EDGE)
aResult = aHealer.Perform(TopoDS::Edge(aEdgeShape), aValue, isByParameter);
}
if (aResult)
theOutShape = aHealer.GetResultShape();
else
raiseNotDoneExeption( aHealer.GetErrorStatus() );
return aResult;
}
示例5: surface
const Base::Vector3d Constraint::getDirection(const App::PropertyLinkSub &direction)
{
App::DocumentObject* obj = direction.getValue();
std::vector<std::string> names = direction.getSubValues();
if (names.size() == 0)
return Base::Vector3d(0,0,0);
std::string subName = names.front();
Part::Feature* feat = static_cast<Part::Feature*>(obj);
TopoDS_Shape sh = feat->Shape.getShape().getSubShape(subName.c_str());
gp_Dir dir;
if (sh.ShapeType() == TopAbs_FACE) {
BRepAdaptor_Surface surface(TopoDS::Face(sh));
if (surface.GetType() == GeomAbs_Plane) {
dir = surface.Plane().Axis().Direction();
} else {
return Base::Vector3d(0,0,0); // "Direction must be a planar face or linear edge"
}
} else if (sh.ShapeType() == TopAbs_EDGE) {
BRepAdaptor_Curve line(TopoDS::Edge(sh));
if (line.GetType() == GeomAbs_Line) {
dir = line.Line().Direction();
} else {
return Base::Vector3d(0,0,0); // "Direction must be a planar face or linear edge"
}
}
Base::Vector3d the_direction(dir.X(), dir.Y(), dir.Z());
the_direction.Normalize();
return the_direction;
}
示例6: DocumentObjectExecReturn
App::DocumentObjectExecReturn *Loft::execute(void)
{
if (Sections.getSize() == 0)
return new App::DocumentObjectExecReturn("No sections linked.");
try {
TopTools_ListOfShape profiles;
const std::vector<App::DocumentObject*>& shapes = Sections.getValues();
std::vector<App::DocumentObject*>::const_iterator it;
for (it = shapes.begin(); it != shapes.end(); ++it) {
if (!(*it)->isDerivedFrom(Part::Feature::getClassTypeId()))
return new App::DocumentObjectExecReturn("Linked object is not a shape.");
TopoDS_Shape shape = static_cast<Part::Feature*>(*it)->Shape.getValue();
if (shape.IsNull())
return new App::DocumentObjectExecReturn("Linked shape is invalid.");
// Extract first element of a compound
if (shape.ShapeType() == TopAbs_COMPOUND) {
TopoDS_Iterator it(shape);
for (; it.More(); it.Next()) {
if (!it.Value().IsNull()) {
shape = it.Value();
break;
}
}
}
if (shape.ShapeType() == TopAbs_FACE) {
TopoDS_Wire faceouterWire = ShapeAnalysis::OuterWire(TopoDS::Face(shape));
profiles.Append(faceouterWire);
}
else if (shape.ShapeType() == TopAbs_WIRE) {
BRepBuilderAPI_MakeWire mkWire(TopoDS::Wire(shape));
profiles.Append(mkWire.Wire());
}
else if (shape.ShapeType() == TopAbs_EDGE) {
BRepBuilderAPI_MakeWire mkWire(TopoDS::Edge(shape));
profiles.Append(mkWire.Wire());
}
else if (shape.ShapeType() == TopAbs_VERTEX) {
profiles.Append(shape);
}
else {
return new App::DocumentObjectExecReturn("Linked shape is not a vertex, edge, wire nor face.");
}
}
Standard_Boolean isSolid = Solid.getValue() ? Standard_True : Standard_False;
Standard_Boolean isRuled = Ruled.getValue() ? Standard_True : Standard_False;
Standard_Boolean isClosed = Closed.getValue() ? Standard_True : Standard_False;
TopoShape myShape;
this->Shape.setValue(myShape.makeLoft(profiles, isSolid, isRuled,isClosed));
return App::DocumentObject::StdReturn;
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
return new App::DocumentObjectExecReturn(e->GetMessageString());
}
}
示例7: GetPosition
//=======================================================================
//function : GetPosition
//purpose :
//=======================================================================
gp_Ax3 GEOMUtils::GetPosition (const TopoDS_Shape& theShape)
{
gp_Ax3 aResult;
if (theShape.IsNull())
return aResult;
// Axes
aResult.Transform(theShape.Location().Transformation());
if (theShape.ShapeType() == TopAbs_FACE) {
Handle(Geom_Surface) aGS = BRep_Tool::Surface(TopoDS::Face(theShape));
if (!aGS.IsNull() && aGS->IsKind(STANDARD_TYPE(Geom_Plane))) {
Handle(Geom_Plane) aGPlane = Handle(Geom_Plane)::DownCast(aGS);
gp_Pln aPln = aGPlane->Pln();
aResult = aPln.Position();
// In case of reverse orinetation of the face invert the plane normal
// (the face's normal does not mathc the plane's normal in this case)
if(theShape.Orientation() == TopAbs_REVERSED)
{
gp_Dir Vx = aResult.XDirection();
gp_Dir N = aResult.Direction().Mirrored(Vx);
gp_Pnt P = aResult.Location();
aResult = gp_Ax3(P, N, Vx);
}
}
}
// Origin
gp_Pnt aPnt;
TopAbs_ShapeEnum aShType = theShape.ShapeType();
if (aShType == TopAbs_VERTEX) {
aPnt = BRep_Tool::Pnt(TopoDS::Vertex(theShape));
}
else {
if (aShType == TopAbs_COMPOUND) {
aShType = GetTypeOfSimplePart(theShape);
}
GProp_GProps aSystem;
if (aShType == TopAbs_EDGE || aShType == TopAbs_WIRE)
BRepGProp::LinearProperties(theShape, aSystem);
else if (aShType == TopAbs_FACE || aShType == TopAbs_SHELL)
BRepGProp::SurfaceProperties(theShape, aSystem);
else
BRepGProp::VolumeProperties(theShape, aSystem);
aPnt = aSystem.CentreOfMass();
}
aResult.SetLocation(aPnt);
return aResult;
}
示例8: Execute
//=======================================================================
//function : Execute
//purpose :
//=======================================================================
Standard_Integer GEOMImpl_TorusDriver::Execute(TFunction_Logbook& log) const
{
if (Label().IsNull()) return 0;
Handle(GEOM_Function) aFunction = GEOM_Function::GetFunction(Label());
GEOMImpl_ITorus aCI (aFunction);
Standard_Integer aType = aFunction->GetType();
TopoDS_Shape aShape;
if (aType == TORUS_RR) {
aShape = BRepPrimAPI_MakeTorus(aCI.GetRMajor(), aCI.GetRMinor()).Shape();
} else if (aType == TORUS_PNT_VEC_RR) {
Handle(GEOM_Function) aRefPoint = aCI.GetCenter();
Handle(GEOM_Function) aRefVector = aCI.GetVector();
TopoDS_Shape aShapePnt = aRefPoint->GetValue();
TopoDS_Shape aShapeVec = aRefVector->GetValue();
if (aShapePnt.ShapeType() != TopAbs_VERTEX) {
Standard_TypeMismatch::Raise("Torus Center must be a vertex");
}
if (aShapeVec.ShapeType() != TopAbs_EDGE) {
Standard_TypeMismatch::Raise("Torus Axis must be an edge");
}
gp_Pnt aP = BRep_Tool::Pnt(TopoDS::Vertex(aShapePnt));
TopoDS_Edge anE = TopoDS::Edge(aShapeVec);
TopoDS_Vertex V1, V2;
TopExp::Vertices(anE, V1, V2, Standard_True);
if (V1.IsNull() || V2.IsNull()) {
Standard_ConstructionError::Raise("Bad edge for the Torus Axis given");
}
gp_Vec aV (BRep_Tool::Pnt(V1), BRep_Tool::Pnt(V2));
if (aV.Magnitude() < Precision::Confusion()) {
Standard_ConstructionError::Raise
("End vertices of edge, defining the Torus Axis, are too close");
}
gp_Ax2 anAxes (aP, aV);
BRepPrimAPI_MakeTorus MT (anAxes, aCI.GetRMajor(), aCI.GetRMinor());
if (!MT.IsDone()) MT.Build();
if (!MT.IsDone()) StdFail_NotDone::Raise("Torus construction algorithm has failed");
aShape = MT.Shape();
} else {
}
if (aShape.IsNull()) return 0;
aFunction->SetValue(aShape);
log.SetTouched(Label());
return 1;
}
示例9: CloseContour
//=======================================================================
//function : CloseContour
//purpose :
//=======================================================================
Standard_Boolean GEOMImpl_HealingDriver::CloseContour (GEOMImpl_IHealing* theHI,
const TopoDS_Shape& theOriginalShape,
TopoDS_Shape& theOutShape) const
{
Standard_Boolean isByVertex = theHI->GetIsCommonVertex();
Handle(TColStd_HArray1OfInteger) aWires = theHI->GetWires();
ShHealOper_CloseContour aHealer (theOriginalShape);
Standard_Boolean aResult = Standard_False;
if ( aWires.IsNull() ) {
if ( theOriginalShape.ShapeType() == TopAbs_WIRE )
aResult = aHealer.Perform(TopoDS::Wire(theOriginalShape), isByVertex, !isByVertex);
}
else {
TopTools_SequenceOfShape aShapesWires;
TopTools_IndexedMapOfShape aShapes;
TopExp::MapShapes(theOriginalShape, aShapes);
for (int i = 1; i <= aWires->Length(); i++) {
int indexOfWire = aWires->Value(i);
TopoDS_Shape aWire = aShapes.FindKey(indexOfWire);
aShapesWires.Append(aWire);
}
aResult = aHealer.Perform( aShapesWires, isByVertex, !isByVertex );
}
if (aResult)
theOutShape = aHealer.GetResultShape();
else
raiseNotDoneExeption( aHealer.GetErrorStatus() );
return aResult;
}
示例10: SALOME_Exception
void StdMeshers_ProjectionSource1D::SetSourceEdge(const TopoDS_Shape& edge)
throw ( SALOME_Exception )
{
if ( edge.IsNull() )
throw SALOME_Exception(LOCALIZED("Null edge is not allowed"));
if ( edge.ShapeType() != TopAbs_EDGE && edge.ShapeType() != TopAbs_COMPOUND )
throw SALOME_Exception(LOCALIZED("Wrong shape type"));
if ( !_sourceEdge.IsSame( edge ) )
{
_sourceEdge = edge;
NotifySubMeshesHypothesisModification();
}
}
示例11: switch
//=======================================================================
// function: IsSplitToReverse
// purpose:
//=======================================================================
Standard_Boolean GEOMAlgo_Tools3D::IsSplitToReverse(const TopoDS_Shape& theSp,
const TopoDS_Shape& theSr,
IntTools_Context& theCtx)
{
Standard_Boolean bRet;
TopAbs_ShapeEnum aType;
//
bRet=Standard_False;
//
aType=theSp.ShapeType();
switch (aType) {
case TopAbs_EDGE: {
const TopoDS_Edge& aESp=TopoDS::Edge(theSp);
const TopoDS_Edge& aESr=TopoDS::Edge(theSr);
bRet=GEOMAlgo_Tools3D::IsSplitToReverse(aESp, aESr, theCtx);
}
break;
//
case TopAbs_FACE: {
const TopoDS_Face& aFSp=TopoDS::Face(theSp);
const TopoDS_Face& aFSr=TopoDS::Face(theSr);
bRet=GEOMAlgo_Tools3D::IsSplitToReverse(aFSp, aFSr, theCtx);
}
break;
//
default:
break;
}
return bRet;
}
示例12: canExtrude
bool DlgExtrusion::canExtrude(const TopoDS_Shape& shape) const
{
if (shape.IsNull())
return false;
TopAbs_ShapeEnum type = shape.ShapeType();
if (type == TopAbs_VERTEX || type == TopAbs_EDGE ||
type == TopAbs_WIRE || type == TopAbs_FACE ||
type == TopAbs_SHELL)
return true;
if (type == TopAbs_COMPOUND) {
TopExp_Explorer xp;
xp.Init(shape,TopAbs_SOLID);
while (xp.More()) {
return false;
}
xp.Init(shape,TopAbs_COMPSOLID);
while (xp.More()) {
return false;
}
return true;
}
return false;
}
示例13: allow
bool allow(App::Document*pDoc, App::DocumentObject*pObj, const char*sSubName)
{
this->canSelect = false;
if (!pObj->isDerivedFrom(Part::Feature::getClassTypeId()))
return false;
if (!sSubName || sSubName[0] == '\0')
return false;
std::string element(sSubName);
if (element.substr(0,4) != "Edge")
return false;
Part::Feature* fea = static_cast<Part::Feature*>(pObj);
try {
TopoDS_Shape sub = fea->Shape.getShape().getSubShape(sSubName);
if (!sub.IsNull() && sub.ShapeType() == TopAbs_EDGE) {
const TopoDS_Edge& edge = TopoDS::Edge(sub);
BRepAdaptor_Curve adapt(edge);
if (adapt.GetType() == GeomAbs_Line) {
gp_Lin line = adapt.Line();
this->loc = line.Location();
this->dir = line.Direction();
this->canSelect = true;
return true;
}
}
}
catch (...) {
}
return false;
}
示例14: PyInit
// constructor method
int TopoShapeVertexPy::PyInit(PyObject* args, PyObject* /*kwd*/)
{
double x=0.0,y=0.0,z=0.0;
PyObject *object;
bool success = false;
if (PyArg_ParseTuple(args, "|ddd", &x,&y,&z)) {
// do nothing here
success = true;
}
if (!success) {
PyErr_Clear(); // set by PyArg_ParseTuple()
if (PyArg_ParseTuple(args,"O!",&(Base::VectorPy::Type), &object)) {
// Note: must be static_cast, not reinterpret_cast
Base::Vector3d* ptr = static_cast<Base::VectorPy*>(object)->getVectorPtr();
x = ptr->x;
y = ptr->y;
z = ptr->z;
success = true;
}
}
if (!success) {
PyErr_Clear(); // set by PyArg_ParseTuple()
if (PyArg_ParseTuple(args,"O!",&(PyTuple_Type), &object)) {
try {
Py::Tuple tuple(object);
x = Py::Float(tuple.getItem(0));
y = Py::Float(tuple.getItem(1));
z = Py::Float(tuple.getItem(2));
success = true;
}
catch (const Py::Exception&) {
return -1;
}
}
}
if (!success) {
PyErr_Clear(); // set by PyArg_ParseTuple()
if (PyArg_ParseTuple(args,"O!",&(Part::TopoShapePy::Type), &object)) {
TopoShape* ptr = static_cast<TopoShapePy*>(object)->getTopoShapePtr();
TopoDS_Shape shape = ptr->_Shape;
if (!shape.IsNull() && shape.ShapeType() == TopAbs_VERTEX) {
TopoShapeVertexPy::PointerType vert = reinterpret_cast<TopoShapeVertexPy::PointerType>(_pcTwinPointer);
vert->_Shape = ptr->_Shape;
return 0;
}
}
}
if (!success) {
PyErr_SetString(PyExc_TypeError, "Either three floats, tuple, vector or vertex expected");
return -1;
}
TopoShapeVertexPy::PointerType ptr = reinterpret_cast<TopoShapeVertexPy::PointerType>(_pcTwinPointer);
BRepBuilderAPI_MakeVertex aBuilder(gp_Pnt(x,y,z));
TopoDS_Shape s = aBuilder.Vertex();
ptr->_Shape = s;
return 0;
}
示例15: IsQuadraticSubMesh
bool SMESH_MesherHelper::IsQuadraticSubMesh(const TopoDS_Shape& aSh)
{
SMESHDS_Mesh* meshDS = GetMeshDS();
// we can create quadratic elements only if all elements
// created on subshapes of given shape are quadratic
// also we have to fill myNLinkNodeMap
myCreateQuadratic = true;
mySeamShapeIds.clear();
myDegenShapeIds.clear();
TopAbs_ShapeEnum subType( aSh.ShapeType()==TopAbs_FACE ? TopAbs_EDGE : TopAbs_FACE );
SMDSAbs_ElementType elemType( subType==TopAbs_FACE ? SMDSAbs_Face : SMDSAbs_Edge );
int nbOldLinks = myNLinkNodeMap.size();
TopExp_Explorer exp( aSh, subType );
for (; exp.More() && myCreateQuadratic; exp.Next()) {
if ( SMESHDS_SubMesh * subMesh = meshDS->MeshElements( exp.Current() )) {
if ( SMDS_ElemIteratorPtr it = subMesh->GetElements() ) {
while(it->more()) {
const SMDS_MeshElement* e = it->next();
if ( e->GetType() != elemType || !e->IsQuadratic() ) {
myCreateQuadratic = false;
break;
}
else {
// fill NLinkNodeMap
switch ( e->NbNodes() ) {
case 3:
AddNLinkNode(e->GetNode(0),e->GetNode(1),e->GetNode(2)); break;
case 6:
AddNLinkNode(e->GetNode(0),e->GetNode(1),e->GetNode(3));
AddNLinkNode(e->GetNode(1),e->GetNode(2),e->GetNode(4));
AddNLinkNode(e->GetNode(2),e->GetNode(0),e->GetNode(5)); break;
case 8:
AddNLinkNode(e->GetNode(0),e->GetNode(1),e->GetNode(4));
AddNLinkNode(e->GetNode(1),e->GetNode(2),e->GetNode(5));
AddNLinkNode(e->GetNode(2),e->GetNode(3),e->GetNode(6));
AddNLinkNode(e->GetNode(3),e->GetNode(0),e->GetNode(7));
break;
default:
myCreateQuadratic = false;
break;
}
}
}
}
}
}
if ( nbOldLinks == myNLinkNodeMap.size() )
myCreateQuadratic = false;
if(!myCreateQuadratic) {
myNLinkNodeMap.clear();
}
SetSubShape( aSh );
return myCreateQuadratic;
}