本文整理汇总了C++中TopoDS_Shape::Orientation方法的典型用法代码示例。如果您正苦于以下问题:C++ TopoDS_Shape::Orientation方法的具体用法?C++ TopoDS_Shape::Orientation怎么用?C++ TopoDS_Shape::Orientation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TopoDS_Shape
的用法示例。
在下文中一共展示了TopoDS_Shape::Orientation方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: fetchAxisLink
bool Extrusion::fetchAxisLink(const App::PropertyLinkSub& axisLink, Base::Vector3d& basepoint, Base::Vector3d& dir)
{
if (!axisLink.getValue())
return false;
if (!axisLink.getValue()->isDerivedFrom(Part::Feature::getClassTypeId()))
throw Base::TypeError("AxisLink has no OCC shape");
Part::Feature* linked = static_cast<Part::Feature*>(axisLink.getValue());
TopoDS_Shape axEdge;
if (axisLink.getSubValues().size() > 0 && axisLink.getSubValues()[0].length() > 0){
axEdge = linked->Shape.getShape().getSubShape(axisLink.getSubValues()[0].c_str());
} else {
axEdge = linked->Shape.getValue();
}
if (axEdge.IsNull())
throw Base::ValueError("DirLink shape is null");
if (axEdge.ShapeType() != TopAbs_EDGE)
throw Base::TypeError("DirLink shape is not an edge");
BRepAdaptor_Curve crv(TopoDS::Edge(axEdge));
gp_Pnt startpoint;
gp_Pnt endpoint;
if (crv.GetType() == GeomAbs_Line){
startpoint = crv.Value(crv.FirstParameter());
endpoint = crv.Value(crv.LastParameter());
if (axEdge.Orientation() == TopAbs_REVERSED)
std::swap(startpoint, endpoint);
} else {
throw Base::TypeError("DirLink edge is not a line.");
}
basepoint.Set(startpoint.X(), startpoint.Y(), startpoint.Z());
gp_Vec vec = gp_Vec(startpoint, endpoint);
dir.Set(vec.X(), vec.Y(), vec.Z());
return true;
}
示例4: IsReversedSubMesh
bool SMESH_Algo::IsReversedSubMesh (const TopoDS_Face& theFace,
SMESHDS_Mesh* theMeshDS)
{
if ( theFace.IsNull() || !theMeshDS )
return false;
// find out orientation of a meshed face
int faceID = theMeshDS->ShapeToIndex( theFace );
TopoDS_Shape aMeshedFace = theMeshDS->IndexToShape( faceID );
bool isReversed = ( theFace.Orientation() != aMeshedFace.Orientation() );
const SMESHDS_SubMesh * aSubMeshDSFace = theMeshDS->MeshElements( faceID );
if ( !aSubMeshDSFace )
return isReversed;
// find element with node located on face and get its normal
const SMDS_FacePosition* facePos = 0;
int vertexID = 0;
gp_Pnt nPnt[3];
gp_Vec Ne;
bool normalOK = false;
SMDS_ElemIteratorPtr iteratorElem = aSubMeshDSFace->GetElements();
while ( iteratorElem->more() ) // loop on elements on theFace
{
const SMDS_MeshElement* elem = iteratorElem->next();
if ( elem && elem->NbNodes() > 2 ) {
SMDS_ElemIteratorPtr nodesIt = elem->nodesIterator();
const SMDS_FacePosition* fPos = 0;
int i = 0, vID = 0;
while ( nodesIt->more() ) { // loop on nodes
const SMDS_MeshNode* node
= static_cast<const SMDS_MeshNode *>(nodesIt->next());
if ( i == 3 ) i = 2;
nPnt[ i++ ].SetCoord( node->X(), node->Y(), node->Z() );
// check position
const SMDS_PositionPtr& pos = node->GetPosition();
if ( !pos ) continue;
if ( pos->GetTypeOfPosition() == SMDS_TOP_FACE ) {
fPos = dynamic_cast< const SMDS_FacePosition* >( pos.get() );
}
else if ( pos->GetTypeOfPosition() == SMDS_TOP_VERTEX ) {
vID = pos->GetShapeId();
}
}
if ( fPos || ( !normalOK && vID )) {
// compute normal
gp_Vec v01( nPnt[0], nPnt[1] ), v02( nPnt[0], nPnt[2] );
if ( v01.SquareMagnitude() > RealSmall() &&
v02.SquareMagnitude() > RealSmall() )
{
Ne = v01 ^ v02;
normalOK = ( Ne.SquareMagnitude() > RealSmall() );
}
// we need position on theFace or at least on vertex
if ( normalOK ) {
vertexID = vID;
if ((facePos = fPos))
break;
}
}
}
}
if ( !normalOK )
return isReversed;
// node position on face
double u,v;
if ( facePos ) {
u = facePos->GetUParameter();
v = facePos->GetVParameter();
}
else if ( vertexID ) {
TopoDS_Shape V = theMeshDS->IndexToShape( vertexID );
if ( V.IsNull() || V.ShapeType() != TopAbs_VERTEX )
return isReversed;
gp_Pnt2d uv = BRep_Tool::Parameters( TopoDS::Vertex( V ), theFace );
u = uv.X();
v = uv.Y();
}
else
{
return isReversed;
}
// face normal at node position
TopLoc_Location loc;
Handle(Geom_Surface) surf = BRep_Tool::Surface( theFace, loc );
if ( surf.IsNull() || surf->Continuity() < GeomAbs_C1 ) return isReversed;
gp_Vec d1u, d1v;
surf->D1( u, v, nPnt[0], d1u, d1v );
gp_Vec Nf = (d1u ^ d1v).Transformed( loc );
if ( theFace.Orientation() == TopAbs_REVERSED )
Nf.Reverse();
return Ne * Nf < 0.;
}
示例5: SortShapes
//=======================================================================
//function : SortShapes
//purpose :
//=======================================================================
void GEOMUtils::SortShapes (TopTools_ListOfShape& SL,
const Standard_Boolean isOldSorting)
{
#ifdef STD_SORT_ALGO
std::vector<TopoDS_Shape> aShapesVec;
aShapesVec.reserve(SL.Extent());
TopTools_ListIteratorOfListOfShape it (SL);
for (; it.More(); it.Next()) {
aShapesVec.push_back(it.Value());
}
SL.Clear();
CompareShapes shComp (isOldSorting);
std::stable_sort(aShapesVec.begin(), aShapesVec.end(), shComp);
//std::sort(aShapesVec.begin(), aShapesVec.end(), shComp);
std::vector<TopoDS_Shape>::const_iterator anIter = aShapesVec.begin();
for (; anIter != aShapesVec.end(); ++anIter) {
SL.Append(*anIter);
}
#else
// old implementation
Standard_Integer MaxShapes = SL.Extent();
TopTools_Array1OfShape aShapes (1,MaxShapes);
TColStd_Array1OfInteger OrderInd(1,MaxShapes);
TColStd_Array1OfReal MidXYZ (1,MaxShapes); //X,Y,Z;
TColStd_Array1OfReal Length (1,MaxShapes); //X,Y,Z;
// Computing of CentreOfMass
Standard_Integer Index;
GProp_GProps GPr;
gp_Pnt GPoint;
TopTools_ListIteratorOfListOfShape it(SL);
for (Index=1; it.More(); Index++)
{
TopoDS_Shape S = it.Value();
SL.Remove( it ); // == it.Next()
aShapes(Index) = S;
OrderInd.SetValue (Index, Index);
if (S.ShapeType() == TopAbs_VERTEX) {
GPoint = BRep_Tool::Pnt( TopoDS::Vertex( S ));
Length.SetValue( Index, (Standard_Real) S.Orientation());
}
else {
// 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();
Length.SetValue(Index, GPr.Mass());
}
MidXYZ.SetValue(Index, GPoint.X()*999.0 + GPoint.Y()*99.0 + GPoint.Z()*0.9);
//cout << Index << " L: " << Length(Index) << "CG: " << MidXYZ(Index) << endl;
}
// Sorting
Standard_Integer aTemp;
Standard_Boolean exchange, Sort = Standard_True;
Standard_Real tol = Precision::Confusion();
while (Sort)
{
Sort = Standard_False;
for (Index=1; Index < MaxShapes; Index++)
{
exchange = Standard_False;
Standard_Real dMidXYZ = MidXYZ(OrderInd(Index)) - MidXYZ(OrderInd(Index+1));
Standard_Real dLength = Length(OrderInd(Index)) - Length(OrderInd(Index+1));
if ( dMidXYZ >= tol ) {
// cout << "MidXYZ: " << MidXYZ(OrderInd(Index))<< " > " <<MidXYZ(OrderInd(Index+1))
// << " d: " << dMidXYZ << endl;
exchange = Standard_True;
}
else if ( Abs(dMidXYZ) < tol && dLength >= tol ) {
// cout << "Length: " << Length(OrderInd(Index))<< " > " <<Length(OrderInd(Index+1))
// << " d: " << dLength << endl;
exchange = Standard_True;
}
else if ( Abs(dMidXYZ) < tol && Abs(dLength) < tol &&
aShapes(OrderInd(Index)).ShapeType() <= TopAbs_FACE) {
// PAL17233
// equal values possible on shapes such as two halves of a sphere and
// a membrane inside the sphere
Bnd_Box box1,box2;
//.........这里部分代码省略.........
示例6: helper
//.........这里部分代码省略.........
if ( _hypMaxElementArea )
{
double maxArea = _hypMaxElementArea->GetMaxArea();
edgeLength = sqrt(2. * maxArea/sqrt(3.0));
}
if ( edgeLength < DBL_MIN )
edgeLength = occgeo.GetBoundingBox().Diam();
//cout << " edgeLength = " << edgeLength << endl;
netgen::mparam.maxh = edgeLength;
netgen::mparam.quad = _hypQuadranglePreference ? 1 : 0;
//ngMesh->SetGlobalH ( edgeLength );
// -------------------------
// Generate surface mesh
// -------------------------
char *optstr = 0;
int startWith = MESHCONST_MESHSURFACE;
int endWith = MESHCONST_OPTSURFACE;
int err = 1;
try {
#if (OCC_VERSION_MAJOR << 16 | OCC_VERSION_MINOR << 8 | OCC_VERSION_MAINTENANCE) > 0x060100
OCC_CATCH_SIGNALS;
#endif
#ifdef NETGEN_V5
err = netgen::OCCGenerateMesh(occgeo, ngMesh,netgen::mparam, startWith, endWith);
#else
err = netgen::OCCGenerateMesh(occgeo, ngMesh, startWith, endWith, optstr);
#endif
}
catch (Standard_Failure& ex) {
string comment = ex.DynamicType()->Name();
if ( ex.GetMessageString() && strlen( ex.GetMessageString() )) {
comment += ": ";
comment += ex.GetMessageString();
}
error(COMPERR_OCC_EXCEPTION, comment);
}
catch (NgException exc) {
error( SMESH_Comment("NgException: ") << exc.What() );
}
catch (...) {
error(COMPERR_EXCEPTION,"Exception in netgen::OCCGenerateMesh()");
}
// ----------------------------------------------------
// Fill the SMESHDS with the generated nodes and faces
// ----------------------------------------------------
int nbNodes = ngMesh->GetNP();
int nbFaces = ngMesh->GetNSE();
int nbInputNodes = nodeVec.size();
nodeVec.resize( nbNodes, 0 );
// add nodes
for ( int i = nbInputNodes + 1; i <= nbNodes; ++i )
{
const MeshPoint& ngPoint = ngMesh->Point(i);
SMDS_MeshNode * node = meshDS->AddNode(ngPoint(0), ngPoint(1), ngPoint(2));
nodeVec[ i-1 ] = node;
}
// create faces
bool reverse = ( aShape.Orientation() == TopAbs_REVERSED );
for ( int i = 1; i <= nbFaces ; ++i )
{
const Element2d& elem = ngMesh->SurfaceElement(i);
vector<const SMDS_MeshNode*> nodes( elem.GetNP() );
for (int j=1; j <= elem.GetNP(); ++j)
{
int pind = elem.PNum(j);
const SMDS_MeshNode* node = nodeVec.at(pind-1);
if ( reverse )
nodes[ nodes.size()-j ] = node;
else
nodes[ j-1 ] = node;
if ( node->GetPosition()->GetTypeOfPosition() == SMDS_TOP_3DSPACE )
{
const PointGeomInfo& pgi = elem.GeomInfoPi(j);
meshDS->SetNodeOnFace((SMDS_MeshNode*)node, faceID, pgi.u, pgi.v);
}
}
SMDS_MeshFace* face = 0;
if ( elem.GetType() == TRIG )
face = helper.AddFace(nodes[0],nodes[1],nodes[2]);
else
face = helper.AddFace(nodes[0],nodes[1],nodes[2],nodes[3]);
}
Ng_DeleteMesh((nglib::Ng_Mesh*)ngMesh);
Ng_Exit();
NETGENPlugin_Mesher::RemoveTmpFiles();
return !err;
}
示例7: BuildDraftSolid
//=======================================================================
//function : BuildDraftSolid
//purpose :
//=======================================================================
void GEOMAlgo_Builder::BuildDraftSolid (const TopoDS_Shape& theSolid,
TopoDS_Shape& theDraftSolid,
TopTools_ListOfShape& theLIF)
{
myErrorStatus=0;
//
NMTTools_PaveFiller* pPF=myPaveFiller;
const Handle(IntTools_Context)& aCtx= pPF->Context();
//
Standard_Boolean bToReverse;
Standard_Integer iFlag;
TopAbs_Orientation aOrF, aOrSh, aOrSd;
TopoDS_Iterator aIt1, aIt2;
TopTools_ListIteratorOfListOfShape aItS;
BRep_Builder aBB;
TopoDS_Shell aShD;
TopoDS_Shape aFSDx, aFx;
//
aOrSd=theSolid.Orientation();
theDraftSolid.Orientation(aOrSd);
//
aIt1.Initialize(theSolid);
for (; aIt1.More(); aIt1.Next()) {
const TopoDS_Shape& aSh=aIt1.Value();
if(aSh.ShapeType()!=TopAbs_SHELL) {
continue; // mb internal edges,vertices
}
//
aOrSh=aSh.Orientation();
aBB.MakeShell(aShD);
aShD.Orientation(aOrSh);
iFlag=0;
//
aIt2.Initialize(aSh);
for (; aIt2.More(); aIt2.Next()) {
const TopoDS_Shape& aF=aIt2.Value();
aOrF=aF.Orientation();
//
if (myImages.HasImage(aF)) {
const TopTools_ListOfShape& aLSp=myImages.Image(aF);
aItS.Initialize(aLSp);
for (; aItS.More(); aItS.Next()) {
aFx=aItS.Value();
//
if (mySameDomainShapes.Contains(aFx)) {
aFSDx=mySameDomainShapes.FindFromKey(aFx);
//
if (aOrF==TopAbs_INTERNAL) {
aFSDx.Orientation(aOrF);
theLIF.Append(aFSDx);
}
else {
bToReverse=GEOMAlgo_Tools3D::IsSplitToReverse(aFSDx, aF, aCtx);
if (bToReverse) {
aFSDx.Reverse();
}
//
iFlag=1;
aBB.Add(aShD, aFSDx);
}
}// if (mySameDomainShapes.Contains(aFx)) {
else {
aFx.Orientation(aOrF);
if (aOrF==TopAbs_INTERNAL) {
theLIF.Append(aFx);
}
else{
iFlag=1;
aBB.Add(aShD, aFx);
}
}
}
} //if (myImages.HasImage(aF)) {
//
else {
if (aOrF==TopAbs_INTERNAL) {
theLIF.Append(aF);
}
else{
iFlag=1;
aBB.Add(aShD, aF);
}
}
} //for (; aIt2.More(); aIt2.Next()) {
//
if (iFlag) {
aBB.Add(theDraftSolid, aShD);
}
} //for (; aIt1.More(); aIt1.Next()) {
}
示例8: MakeBlocks
//.........这里部分代码省略.........
}
//
// 3.2. Treatment of section edges (SE)
for (i=1; i<=aNbOld; ++i) {
const TopoDS_Shape& aE=tDS.Shape(i);
aType=aE.ShapeType();
if (aType!=TopAbs_EDGE) {
continue;
}
//
// block of section edge that we already have for this SE
BOPTools_PaveBlock& aPBSE=aMEPB.ChangeFromKey(aE);
//
// Corresponding FF-interference
iFF=aMapEI.FindFromKey(aE);
BOPTools_SSInterference& aFFi=aFFs(iFF);
BOPTools_SequenceOfCurves& aSCvs=aFFi.Curves();
//
BOPTools_Curve& aBC=aSCvs(1);
//
const BOPTools_ListOfPaveBlock& aLPB=aSSP(tDS.RefEdge(i));
aNbPB=aLPB.Extent();
//
if (!aNbPB) {
// no pave blocks -> use aPBSE and whole edge aE
BooleanOperations_AncestorsSeqAndSuccessorsSeq anASSeq;
//
nV1=aPBSE.Pave1().Index();
const TopoDS_Shape aV1=myDS->Shape(nV1);//mpv
nV2=aPBSE.Pave2().Index();
const TopoDS_Shape aV2=myDS->Shape(nV2);//mpv
//
anASSeq.SetNewSuccessor(nV1);
anASSeq.SetNewOrientation(aV1.Orientation());
anASSeq.SetNewSuccessor(nV2);
anASSeq.SetNewOrientation(aV2.Orientation());
//
myDS->InsertShapeAndAncestorsSuccessors(aE, anASSeq);
nE=myDS->NumberOfInsertedShapes();
//
aPBSE.SetEdge(nE);
aBC.AppendNewBlock(aPBSE);
//
continue;
}
//
nF1=aPBSE.Face1();
nF2=aPBSE.Face2();
//
const NMTTools_ListOfCommonBlock& aLCB=aCBP(tDS.RefEdge(i));
NMTTools_CommonBlockAPI aCBAPI(aLCB);
//
aIt.Initialize(aLPB);
for (; aIt.More(); aIt.Next()) {
BOPTools_PaveBlock aPB=aIt.Value();
//
const TopoDS_Face aF1=TopoDS::Face(myDS->Shape(nF1));
const TopoDS_Face aF2=TopoDS::Face(myDS->Shape(nF2));
//
if (aCBAPI.IsCommonBlock(aPB)) {
// it can be Common Block
Standard_Real aTolEx;
Handle(Geom2d_Curve) aC2D1, aC2D2;
TopoDS_Face aF1FWD, aF2FWD;
//
NMTTools_CommonBlock& aCB=aCBAPI.CommonBlock(aPB);