本文整理汇总了C++中TopoDS_Edge类的典型用法代码示例。如果您正苦于以下问题:C++ TopoDS_Edge类的具体用法?C++ TopoDS_Edge怎么用?C++ TopoDS_Edge使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TopoDS_Edge类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: xp
void BRepOffsetAPI_MakeOffsetFix::AddWire(const TopoDS_Wire& Spine)
{
TopoDS_Wire wire = Spine;
int numEdges = 0;
TopExp_Explorer xp(wire, TopAbs_EDGE);
while (xp.More()) {
numEdges++;
xp.Next();
}
if (numEdges == 1) {
TopLoc_Location edgeLocation;
BRepBuilderAPI_MakeWire mkWire;
TopExp_Explorer xp(wire, TopAbs_EDGE);
while (xp.More()) {
// The trick is to reset the placement of an edge before
// passing it to BRepOffsetAPI_MakeOffset because then it
// will create the expected result.
// Afterwards apply the placement again on the result shape.
// See the method MakeWire()
TopoDS_Edge edge = TopoDS::Edge(xp.Current());
edgeLocation = edge.Location();
edge.Location(TopLoc_Location());
mkWire.Add(edge);
myLocations.push_back(std::make_pair(edge, edgeLocation));
xp.Next();
}
wire = mkWire.Wire();
}
mkOffset.AddWire(wire);
myResult.Nullify();
}
开发者ID:frankhardy,项目名称:FreeCAD,代码行数:33,代码来源:BRepOffsetAPI_MakeOffsetFix.cpp
示例2: replaceEndingPointsInternals
// sometimes, we ask to replace the ending points of the curve
// in gluing operations for example
void OCCEdge::replaceEndingPointsInternals(GVertex *g0, GVertex *g1)
{
TopoDS_Vertex aV1 = *((TopoDS_Vertex*)v0->getNativePtr());
TopoDS_Vertex aV2 = *((TopoDS_Vertex*)v1->getNativePtr());
TopoDS_Vertex aVR1 = *((TopoDS_Vertex*)g0->getNativePtr());
TopoDS_Vertex aVR2 = *((TopoDS_Vertex*)g1->getNativePtr());
// printf("%p %p --- %p %p replacing %d %d by %d %d in occedge %d\n",
// v0,v1,g0,g1,v0->tag(),v1->tag(),g0->tag(),g1->tag(),tag());
Standard_Boolean bIsDE = BRep_Tool::Degenerated(c);
TopoDS_Edge aEx = c;
aEx.Orientation(TopAbs_FORWARD);
Standard_Real t1=s0;
Standard_Real t2=s1;
aVR1.Orientation(TopAbs_FORWARD);
aVR2.Orientation(TopAbs_REVERSED);
if (bIsDE) {
Standard_Real aTol;
BRep_Builder aBB;
TopoDS_Edge E;
//TopAbs_Orientation anOrE;
//anOrE = c.Orientation();
aTol = BRep_Tool::Tolerance(c);
E = aEx;
E.EmptyCopy();
aBB.Add(E, aVR1);
aBB.Add(E, aVR2);
aBB.Range(E, t1, t2);
aBB.Degenerated(E, Standard_True);
aBB.UpdateEdge(E, aTol);
_replacement=E;
}
else {
#if (OCC_VERSION_MAJOR == 6) && (OCC_VERSION_MINOR < 6)
BOPTools_Tools::MakeSplitEdge(aEx, aVR1, t1, aVR2, t2, _replacement);
#else
BOPTools_AlgoTools::MakeSplitEdge(aEx, aVR1, t1, aVR2, t2, _replacement);
#endif
}
TopoDS_Edge temp = c;
c = _replacement;
_replacement = temp;
curve = BRep_Tool::Curve(c, s0, s1);
//build the reverse curve
c_rev = c;
c_rev.Reverse();
}
开发者ID:iyer-arvind,项目名称:gmsh,代码行数:54,代码来源:OCCEdge.cpp
示例3: IsValidEdge
bool Edgecluster::IsValidEdge(const TopoDS_Edge& edge)
{
if ( edge.IsNull() )
return false;
if ( BRep_Tool::Degenerated(edge) )
return false;
BRepAdaptor_Curve bac(edge);
Standard_Real fparam = bac.FirstParameter();
Standard_Real lparam = bac.LastParameter();
gp_Pnt fpoint = bac.Value(fparam);
gp_Pnt lpoint = bac.Value(lparam);
//do not test the distance first last in case of a full circle edge (fpoint == lastpoint)
//if ( fpoint.IsEqual(lpoint,1e-5 ) )
// return false;
gp_Pnt mpoint = bac.Value((fparam+lparam)*0.5);
Standard_Real dist = mpoint.Distance(lpoint);
if ( dist <= 1e-5 )
return false;
dist = mpoint.Distance(fpoint);
if ( dist <= 1e-5 )
return false;
return true;
}
开发者ID:ADVALAIN596,项目名称:FreeCAD_sf_master,代码行数:30,代码来源:edgecluster.cpp
示例4:
//=======================================================================
//function : GetEdgeOff
//purpose :
//=======================================================================
Standard_Boolean GEOMAlgo_Tools3D::GetEdgeOff(const TopoDS_Edge& theE1,
const TopoDS_Face& theF2,
TopoDS_Edge& theE2)
{
Standard_Boolean bFound;
TopAbs_Orientation aOr1, aOr1C, aOr2;
TopExp_Explorer anExp;
//
bFound=Standard_False;
aOr1=theE1.Orientation();
aOr1C=TopAbs::Reverse(aOr1);
//
anExp.Init(theF2, TopAbs_EDGE);
for (; anExp.More(); anExp.Next()) {
const TopoDS_Edge& aEF2=TopoDS::Edge(anExp.Current());
if (aEF2.IsSame(theE1)) {
aOr2=aEF2.Orientation();
if (aOr2==aOr1C) {
theE2=aEF2;
bFound=!bFound;
return bFound;
}
}
}
return bFound;
}
开发者ID:dbarbier,项目名称:pythonocc,代码行数:31,代码来源:GEOMAlgo_Tools3D.cpp
示例5: aDTS
//=======================================================================
//function :IsSplitToReverse
//purpose :
//=======================================================================
Standard_Boolean GEOMAlgo_Tools3D::IsSplitToReverse(const TopoDS_Edge& theSplit,
const TopoDS_Edge& theEdge,
IntTools_Context& theContext)
{
Standard_Boolean bRet, aFlag, bIsDegenerated;
Standard_Real aTE, aTS, aScPr, aTa, aTb, aT1, aT2;
TopAbs_Orientation aOrSr, aOrSp;
Handle(Geom_Curve) aCEdge, aCSplit;
gp_Vec aVE, aVS;
gp_Pnt aP;
//
bRet=Standard_False;
//
bIsDegenerated=(BRep_Tool::Degenerated(theSplit) ||
BRep_Tool::Degenerated(theEdge));
if (bIsDegenerated) {
return bRet;
}
//
aCEdge =BRep_Tool::Curve(theEdge , aT1, aT2);
aCSplit=BRep_Tool::Curve(theSplit, aTa, aTb);
//
if (aCEdge==aCSplit) {
aOrSr=theEdge.Orientation();
aOrSp=theSplit.Orientation();
bRet=(aOrSr!=aOrSp);
return bRet;
}
//
aTS=BOPTools_Tools2D::IntermediatePoint(aTa, aTb);
aCSplit->D0(aTS, aP);
aFlag=BOPTools_Tools2D::EdgeTangent(theSplit, aTS, aVS);
gp_Dir aDTS(aVS);
//
aFlag=theContext.ProjectPointOnEdge(aP, theEdge, aTE);
aFlag=BOPTools_Tools2D::EdgeTangent(theEdge, aTE, aVE);
gp_Dir aDTE(aVE);
//
aScPr=aDTS*aDTE;
bRet=(aScPr<0.);
//
return bRet;
}
开发者ID:dbarbier,项目名称:pythonocc,代码行数:47,代码来源:GEOMAlgo_Tools3D.cpp
示例6: ASSERT
TopoDS_Edge
StdMeshers_Hexa_3D::EdgeNotInFace(SMESH_Mesh & aMesh,
const TopoDS_Shape & aShape,
const TopoDS_Face & aFace,
const TopoDS_Vertex & aVertex,
const TopTools_IndexedDataMapOfShapeListOfShape & MS)
{
//MESSAGE("StdMeshers_Hexa_3D::EdgeNotInFace");
TopTools_IndexedDataMapOfShapeListOfShape MF;
TopExp::MapShapesAndAncestors(aFace, TopAbs_VERTEX, TopAbs_EDGE, MF);
const TopTools_ListOfShape & ancestorsInSolid = MS.FindFromKey(aVertex);
const TopTools_ListOfShape & ancestorsInFace = MF.FindFromKey(aVertex);
// SCRUTE(ancestorsInSolid.Extent());
// SCRUTE(ancestorsInFace.Extent());
ASSERT(ancestorsInSolid.Extent() == 6); // 6 (edges doublees)
ASSERT(ancestorsInFace.Extent() == 2);
TopoDS_Edge E;
E.Nullify();
TopTools_ListIteratorOfListOfShape its(ancestorsInSolid);
for (; its.More(); its.Next())
{
TopoDS_Shape ancestor = its.Value();
TopTools_ListIteratorOfListOfShape itf(ancestorsInFace);
bool isInFace = false;
for (; itf.More(); itf.Next())
{
TopoDS_Shape ancestorInFace = itf.Value();
if (ancestorInFace.IsSame(ancestor))
{
isInFace = true;
break;
}
}
if (!isInFace)
{
E = TopoDS::Edge(ancestor);
break;
}
}
return E;
}
开发者ID:Daedalus12,项目名称:FreeCAD_sf_master,代码行数:42,代码来源:StdMeshers_Hexa_3D.cpp
示例7: SamePnt2d
//=======================================================================
//function : SamePnt2d
//purpose :
//=======================================================================
static Standard_Boolean SamePnt2d(TopoDS_Vertex V,
TopoDS_Edge& E1,
TopoDS_Edge& E2,
TopoDS_Face& F)
{
Standard_Real f1,f2,l1,l2;
gp_Pnt2d P1,P2;
TopoDS_Shape aLocalF = F.Oriented(TopAbs_FORWARD);
TopoDS_Face FF = TopoDS::Face(aLocalF);
Handle(Geom2d_Curve) C1 = BRep_Tool::CurveOnSurface(E1,FF,f1,l1);
Handle(Geom2d_Curve) C2 = BRep_Tool::CurveOnSurface(E2,FF,f2,l2);
if (E1.Orientation () == TopAbs_FORWARD) P1 = C1->Value(f1);
else P1 = C1->Value(l1);
if (E2.Orientation () == TopAbs_FORWARD) P2 = C2->Value(l2);
else P2 = C2->Value(f2);
Standard_Real Tol = 100*BRep_Tool::Tolerance(V);
Standard_Real Dist = P1.Distance(P2);
return Dist < Tol;
}
开发者ID:hmeyer,项目名称:salome-geom,代码行数:24,代码来源:Partition_Loop.cpp
示例8: GetSortedNodesOnEdge
bool SMESH_Algo::GetSortedNodesOnEdge(const SMESHDS_Mesh* theMesh,
const TopoDS_Edge& theEdge,
const bool ignoreMediumNodes,
map< double, const SMDS_MeshNode* > & theNodes)
{
theNodes.clear();
if ( !theMesh || theEdge.IsNull() )
return false;
SMESHDS_SubMesh * eSubMesh = theMesh->MeshElements( theEdge );
if ( !eSubMesh || !eSubMesh->GetElements()->more() )
return false; // edge is not meshed
int nbNodes = 0;
set < double > paramSet;
if ( eSubMesh )
{
// loop on nodes of an edge: sort them by param on edge
SMDS_NodeIteratorPtr nIt = eSubMesh->GetNodes();
while ( nIt->more() )
{
const SMDS_MeshNode* node = nIt->next();
if ( ignoreMediumNodes ) {
SMDS_ElemIteratorPtr elemIt = node->GetInverseElementIterator();
if ( elemIt->more() && elemIt->next()->IsMediumNode( node ))
continue;
}
const SMDS_PositionPtr& pos = node->GetPosition();
if ( pos->GetTypeOfPosition() != SMDS_TOP_EDGE )
return false;
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
theNodes.insert( make_pair( epos->GetUParameter(), node ));
++nbNodes;
}
}
// add vertex nodes
TopoDS_Vertex v1, v2;
TopExp::Vertices(theEdge, v1, v2);
const SMDS_MeshNode* n1 = VertexNode( v1, (SMESHDS_Mesh*) theMesh );
const SMDS_MeshNode* n2 = VertexNode( v2, (SMESHDS_Mesh*) theMesh );
Standard_Real f, l;
BRep_Tool::Range(theEdge, f, l);
if ( v1.Orientation() != TopAbs_FORWARD )
std::swap( f, l );
if ( n1 && ++nbNodes )
theNodes.insert( make_pair( f, n1 ));
if ( n2 && ++nbNodes )
theNodes.insert( make_pair( l, n2 ));
return theNodes.size() == nbNodes;
}
开发者ID:Daedalus12,项目名称:FreeCAD_sf_master,代码行数:53,代码来源:SMESH_Algo.cpp
示例9: GetNodeParamOnEdge
bool SMESH_Algo::GetNodeParamOnEdge(const SMESHDS_Mesh* theMesh,
const TopoDS_Edge& theEdge,
vector< double > & theParams)
{
theParams.clear();
if ( !theMesh || theEdge.IsNull() )
return false;
SMESHDS_SubMesh * eSubMesh = theMesh->MeshElements( theEdge );
if ( !eSubMesh || !eSubMesh->GetElements()->more() )
return false; // edge is not meshed
//int nbEdgeNodes = 0;
set < double > paramSet;
if ( eSubMesh )
{
// loop on nodes of an edge: sort them by param on edge
SMDS_NodeIteratorPtr nIt = eSubMesh->GetNodes();
while ( nIt->more() )
{
const SMDS_MeshNode* node = nIt->next();
const SMDS_PositionPtr& pos = node->GetPosition();
if ( pos->GetTypeOfPosition() != SMDS_TOP_EDGE )
return false;
const SMDS_EdgePosition* epos =
static_cast<const SMDS_EdgePosition*>(node->GetPosition().get());
if ( !paramSet.insert( epos->GetUParameter() ).second )
return false; // equal parameters
}
}
// add vertex nodes params
TopoDS_Vertex V1,V2;
TopExp::Vertices( theEdge, V1, V2);
if ( VertexNode( V1, theMesh ) &&
!paramSet.insert( BRep_Tool::Parameter(V1,theEdge) ).second )
return false; // there are equal parameters
if ( VertexNode( V2, theMesh ) &&
!paramSet.insert( BRep_Tool::Parameter(V2,theEdge) ).second )
return false; // there are equal parameters
// fill the vector
theParams.resize( paramSet.size() );
set < double >::iterator par = paramSet.begin();
vector< double >::iterator vecPar = theParams.begin();
for ( ; par != paramSet.end(); ++par, ++vecPar )
*vecPar = *par;
return theParams.size() > 1;
}
开发者ID:Daedalus12,项目名称:FreeCAD_sf_master,代码行数:50,代码来源:SMESH_Algo.cpp
示例10: nextC1Edge
StdMeshers_FaceSide *
StdMeshers_CompositeSegment_1D::GetFaceSide(SMESH_Mesh& aMesh,
const TopoDS_Edge& anEdge,
const TopoDS_Face& aFace,
const bool ignoreMeshed)
{
list< TopoDS_Edge > edges;
edges.push_back( anEdge );
list <const SMESHDS_Hypothesis *> hypList;
SMESH_Algo* theAlgo = aMesh.GetGen()->GetAlgo( aMesh, anEdge );
if ( theAlgo ) hypList = theAlgo->GetUsedHypothesis(aMesh, anEdge, false);
for ( int forward = 0; forward < 2; ++forward )
{
TopoDS_Edge eNext = nextC1Edge( anEdge, aMesh, forward );
while ( !eNext.IsNull() ) {
if ( ignoreMeshed ) {
// eNext must not have computed mesh
if ( SMESHDS_SubMesh* sm = aMesh.GetMeshDS()->MeshElements(eNext) )
if ( sm->NbNodes() || sm->NbElements() )
break;
}
// eNext must have same hypotheses
SMESH_Algo* algo = aMesh.GetGen()->GetAlgo( aMesh, eNext );
if ( !algo ||
string(theAlgo->GetName()) != algo->GetName() ||
hypList != algo->GetUsedHypothesis(aMesh, eNext, false))
break;
if ( forward )
edges.push_back( eNext );
else
edges.push_front( eNext );
eNext = nextC1Edge( eNext, aMesh, forward );
}
}
return new StdMeshers_FaceSide( aFace, edges, &aMesh, true, false );
}
开发者ID:Daedalus12,项目名称:FreeCAD_sf_master,代码行数:37,代码来源:StdMeshers_CompositeSegment_1D.cpp
示例11: Perform
void Edgecluster::Perform(const TopoDS_Edge& edge)
{
if ( edge.IsNull() )
return;
TopoDS_Vertex V1,V2;
TopExp::Vertices(edge,V1,V2);
gp_Pnt P1 = BRep_Tool::Pnt(V1);
gp_Pnt P2 = BRep_Tool::Pnt(V2);
tEdgeVector emptyList;
std::pair<tMapPntEdge::iterator,bool> iter = m_vertices.insert(tMapPntEdgePair(P1,emptyList));
iter.first->second.push_back(edge);
iter = m_vertices.insert(tMapPntEdgePair(P2,emptyList));
iter.first->second.push_back(edge);
}
开发者ID:ADVALAIN596,项目名称:FreeCAD_sf_master,代码行数:16,代码来源:edgecluster.cpp
示例12: convert_to_ifc
int convert_to_ifc(const TopoDS_Edge& e, IfcSchema::IfcEdge*& edge, bool advanced) {
double a, b;
TopExp_Explorer exp(e, TopAbs_VERTEX);
if (!exp.More()) return 0;
TopoDS_Vertex v1 = TopoDS::Vertex(exp.Current());
exp.Next();
if (!exp.More()) return 0;
TopoDS_Vertex v2 = TopoDS::Vertex(exp.Current());
IfcSchema::IfcVertex *vertex1, *vertex2;
if (!(convert_to_ifc(v1, vertex1, advanced) && convert_to_ifc(v2, vertex2, advanced))) {
return 0;
}
Handle_Geom_Curve crv = BRep_Tool::Curve(e, a, b);
if (crv.IsNull()) {
return 0;
}
if (crv->DynamicType() == STANDARD_TYPE(Geom_Line) && !advanced) {
IfcSchema::IfcEdge* edge2 = new IfcSchema::IfcEdge(vertex1, vertex2);
edge = new IfcSchema::IfcOrientedEdge(edge2, true);
return 1;
} else {
IfcSchema::IfcCurve* curve;
if (!convert_to_ifc(crv, curve, advanced)) {
return 0;
}
/// @todo probably not correct
const bool sense = e.Orientation() == TopAbs_FORWARD;
IfcSchema::IfcEdge* edge2 = new IfcSchema::IfcEdgeCurve(vertex1, vertex2, curve, true);
edge = new IfcSchema::IfcOrientedEdge(edge2, sense);
return 1;
}
}
开发者ID:berndhahnebach,项目名称:IfcOpenShell,代码行数:37,代码来源:IfcGeomSerialisation.cpp
示例13: getBaseShape
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;
//.........这里部分代码省略.........
开发者ID:crobarcro,项目名称:FreeCAD,代码行数:101,代码来源:FeatureDraft.cpp
示例14: gp_Dir
const std::list<gp_Trsf> LinearPattern::getTransformations(const std::vector<App::DocumentObject*>)
{
std::string stdDirection = StdDirection.getValue();
float distance = Length.getValue();
if (distance < Precision::Confusion())
throw Base::Exception("Pattern length too small");
int occurrences = Occurrences.getValue();
if (occurrences < 2)
throw Base::Exception("At least two occurrences required");
bool reversed = Reversed.getValue();
gp_Dir dir;
double offset = distance / (occurrences - 1);
if (!stdDirection.empty()) {
// Note: The placement code commented out below had the defect of working always on the
// absolute X,Y,Z direction, not on the relative coordinate system of the Body feature.
// It requires positionBySupport() to be called in Transformed::Execute() AFTER
// the call to getTransformations()
// New code thanks to logari81
if (stdDirection == "X") {
//dir = Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(1,0,0));
dir = gp_Dir(1,0,0);
} else if (stdDirection == "Y") {
//dir = Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(0,1,0));
dir = gp_Dir(0,1,0);
} else if(stdDirection == "Z") {
//dir = Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(0,0,1));
dir = gp_Dir(0,0,1);
} else {
throw Base::Exception("Invalid direction (must be X, Y or Z)");
}
} else {
App::DocumentObject* refObject = Direction.getValue();
if (refObject == NULL)
throw Base::Exception("No direction specified");
if (!refObject->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
throw Base::Exception("Direction reference must be edge or face of a feature");
std::vector<std::string> subStrings = Direction.getSubValues();
if (subStrings.empty() || subStrings[0].empty())
throw Base::Exception("No direction reference specified");
Part::Feature* refFeature = static_cast<Part::Feature*>(refObject);
Part::TopoShape refShape = refFeature->Shape.getShape();
TopoDS_Shape ref = refShape.getSubShape(subStrings[0].c_str());
if (ref.ShapeType() == TopAbs_FACE) {
TopoDS_Face refFace = TopoDS::Face(ref);
if (refFace.IsNull())
throw Base::Exception("Failed to extract direction plane");
BRepAdaptor_Surface adapt(refFace);
if (adapt.GetType() != GeomAbs_Plane)
throw Base::Exception("Direction face must be planar");
dir = adapt.Plane().Axis().Direction();
//gp_Dir d = adapt.Plane().Axis().Direction();
//dir = Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(d.X(), d.Y(), d.Z()));
} else if (ref.ShapeType() == TopAbs_EDGE) {
TopoDS_Edge refEdge = TopoDS::Edge(ref);
if (refEdge.IsNull())
throw Base::Exception("Failed to extract direction edge");
BRepAdaptor_Curve adapt(refEdge);
if (adapt.GetType() != GeomAbs_Line)
throw Base::Exception("Direction edge must be a straight line");
//gp_Dir d = adapt.Line().Direction();
//dir = Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(d.X(), d.Y(), d.Z()));
dir = adapt.Line().Direction();
} else {
throw Base::Exception("Direction reference must be edge or face");
}
TopLoc_Location invObjLoc = this->getLocation().Inverted();
dir.Transform(invObjLoc.Transformation());
}
// get the support placement
// TODO: Check for NULL pointer
/*Part::Feature* supportFeature = static_cast<Part::Feature*>(originals.front());
if (supportFeature == NULL)
throw Base::Exception("Cannot work on invalid support shape");
Base::Placement supportPlacement = supportFeature->Placement.getValue();
dir *= supportPlacement;
gp_Vec direction(dir.getDirection().x, dir.getDirection().y, dir.getDirection().z);*/
gp_Vec direction(dir.X(), dir.Y(), dir.Z());
if (reversed)
direction.Reverse();
// Note: The original feature is NOT included in the list of transformations! Therefore
// we start with occurrence number 1, not number 0
std::list<gp_Trsf> transformations;
gp_Trsf trans;
transformations.push_back(trans); // identity transformation
for (int i = 1; i < occurrences; i++) {
trans.SetTranslation(direction * i * offset);
transformations.push_back(trans);
}
return transformations;
//.........这里部分代码省略.........
开发者ID:Daedalus12,项目名称:FreeCAD_sf_master,代码行数:101,代码来源:FeatureLinearPattern.cpp
示例15: exp
bool SMESH_MesherHelper::LoadNodeColumns(TParam2ColumnMap & theParam2ColumnMap,
const TopoDS_Face& theFace,
const TopoDS_Edge& theBaseEdge,
SMESHDS_Mesh* theMesh)
{
// get vertices of theBaseEdge
TopoDS_Vertex vfb, vlb, vft; // first and last, bottom and top vertices
TopoDS_Edge eFrw = TopoDS::Edge( theBaseEdge.Oriented( TopAbs_FORWARD ));
TopExp::Vertices( eFrw, vfb, vlb );
// find the other edges of theFace and orientation of e1
TopoDS_Edge e1, e2, eTop;
bool rev1, CumOri = false;
TopExp_Explorer exp( theFace, TopAbs_EDGE );
int nbEdges = 0;
for ( ; exp.More(); exp.Next() ) {
if ( ++nbEdges > 4 ) {
return false; // more than 4 edges in theFace
}
TopoDS_Edge e = TopoDS::Edge( exp.Current() );
if ( theBaseEdge.IsSame( e ))
continue;
TopoDS_Vertex vCommon;
if ( !TopExp::CommonVertex( theBaseEdge, e, vCommon ))
eTop = e;
else if ( vCommon.IsSame( vfb )) {
e1 = e;
vft = TopExp::LastVertex( e1, CumOri );
rev1 = vfb.IsSame( vft );
if ( rev1 )
vft = TopExp::FirstVertex( e1, CumOri );
}
else
e2 = e;
}
if ( nbEdges < 4 ) {
return false; // less than 4 edges in theFace
}
if ( e2.IsNull() && vfb.IsSame( vlb ))
e2 = e1;
// submeshes corresponding to shapes
SMESHDS_SubMesh* smFace = theMesh->MeshElements( theFace );
SMESHDS_SubMesh* smb = theMesh->MeshElements( theBaseEdge );
SMESHDS_SubMesh* smt = theMesh->MeshElements( eTop );
SMESHDS_SubMesh* sm1 = theMesh->MeshElements( e1 );
SMESHDS_SubMesh* sm2 = theMesh->MeshElements( e2 );
SMESHDS_SubMesh* smVfb = theMesh->MeshElements( vfb );
SMESHDS_SubMesh* smVlb = theMesh->MeshElements( vlb );
SMESHDS_SubMesh* smVft = theMesh->MeshElements( vft );
if (!smFace || !smb || !smt || !sm1 || !sm2 || !smVfb || !smVlb || !smVft ) {
RETURN_BAD_RESULT( "NULL submesh " <<smFace<<" "<<smb<<" "<<smt<<" "<<
sm1<<" "<<sm2<<" "<<smVfb<<" "<<smVlb<<" "<<smVft);
}
if ( smb->NbNodes() != smt->NbNodes() || sm1->NbNodes() != sm2->NbNodes() ) {
RETURN_BAD_RESULT(" Diff nb of nodes on opposite edges" );
}
if (smVfb->NbNodes() != 1 || smVlb->NbNodes() != 1 || smVft->NbNodes() != 1) {
RETURN_BAD_RESULT("Empty submesh of vertex");
}
// define whether mesh is quadratic
bool isQuadraticMesh = false;
SMDS_ElemIteratorPtr eIt = smFace->GetElements();
if ( !eIt->more() ) {
RETURN_BAD_RESULT("No elements on the face");
}
const SMDS_MeshElement* e = eIt->next();
isQuadraticMesh = e->IsQuadratic();
if ( sm1->NbNodes() * smb->NbNodes() != smFace->NbNodes() ) {
// check quadratic case
if ( isQuadraticMesh ) {
// what if there are quadrangles and triangles mixed?
// int n1 = sm1->NbNodes()/2;
// int n2 = smb->NbNodes()/2;
// int n3 = sm1->NbNodes() - n1;
// int n4 = smb->NbNodes() - n2;
// int nf = sm1->NbNodes()*smb->NbNodes() - n3*n4;
// if( nf != smFace->NbNodes() ) {
// MESSAGE( "Wrong nb face nodes: " <<
// sm1->NbNodes()<<" "<<smb->NbNodes()<<" "<<smFace->NbNodes());
// return false;
// }
}
else {
RETURN_BAD_RESULT( "Wrong nb face nodes: " <<
sm1->NbNodes()<<" "<<smb->NbNodes()<<" "<<smFace->NbNodes());
}
}
// IJ size
int vsize = sm1->NbNodes() + 2;
int hsize = smb->NbNodes() + 2;
if(isQuadraticMesh) {
vsize = vsize - sm1->NbNodes()/2 -1;
hsize = hsize - smb->NbNodes()/2 -1;
}
// load nodes from theBaseEdge
std::set<const SMDS_MeshNode*> loadedNodes;
//.........这里部分代码省略.........
开发者ID:5263,项目名称:FreeCAD,代码行数:101,代码来源:SMESH_MesherHelper.cpp
示例16: MESSAGE
//.........这里部分代码省略.........
pindMap.Add(i);
}
}
if (!node)
newNodeOnVertex = true;
}
if (!node)
node = meshDS->AddNode(ngPoint.X(), ngPoint.Y(), ngPoint.Z());
if (!node)
{
MESSAGE("Cannot create a mesh node");
if ( !comment.size() ) comment << "Cannot create a mesh node";
nbSeg = nbFac = nbVol = isOK = 0;
break;
}
nodeVec.at(i) = node;
if (newNodeOnVertex)
{
// point on vertex
meshDS->SetNodeOnVertex(node, aVert);
pindMap.Add(i);
}
}
// create mesh segments along geometric edges
NCollection_Map<Link> linkMap;
for (i = nbInitSeg+1; i <= nbSeg/* && isOK*/; ++i )
{
const netgen::Segment& seg = ngMesh->LineSegment(i);
Link link(seg.p1, seg.p2);
if (linkMap.Contains(link))
continue;
linkMap.Add(link);
TopoDS_Edge aEdge;
int pinds[3] = { seg.p1, seg.p2, seg.pmid };
int nbp = 0;
double param2 = 0;
for (int j=0; j < 3; ++j)
{
int pind = pinds[j];
if (pind <= 0) continue;
++nbp;
double param;
if (j < 2)
{
if (aEdge.IsNull())
{
int aGeomEdgeInd = seg.epgeominfo[j].edgenr;
if (aGeomEdgeInd > 0 && aGeomEdgeInd <= occgeo.emap.Extent())
aEdge = TopoDS::Edge(occgeo.emap(aGeomEdgeInd));
}
param = seg.epgeominfo[j].dist;
param2 += param;
}
else
param = param2 * 0.5;
if (pind <= nbInitNod || pindMap.Contains(pind))
continue;
if (!aEdge.IsNull())
{
meshDS->SetNodeOnEdge(nodeVec.at(pind), aEdge, param);
pindMap.Add(pind);
}
}
SMDS_MeshEdge* edge;
if (nbp < 3) // second order ?
开发者ID:Daedalus12,项目名称:FreeCAD_sf_master,代码行数:67,代码来源:NETGENPlugin_Mesher.cpp
示例17: plan
//.........这里部分代码省略.........
{
continue;
}
if ( std::find(alignODLs.begin(), alignODLs.end(), curODL) != alignODLs.end() )
{
continue;
}
if ( EODLT_PILLAR == curODL->GetType() && curODL == activePilar )
{
continue;
}
auto dis = curODL->GetBaseBndBox().Distance(activeTransitionBox.Transformed(curODL->GetAbsoluteTransform().Inverted()));
if ( dis > alignDis )
{
continue;
}
disMap.emplace(dis, curODL);
}
for ( auto& curODL : disMap )
{
alignODLs.push_back(curODL.second);
}
//锁定旋转
auto lockRotation = false;
//锁定位置
auto lockPosition = false;
//移动方向
TopoDS_Edge movingEdge;
for ( auto& curODL : alignODLs )
{
auto alignTransformation = curODL->GetAbsoluteTransform();
//如果锁定了旋转,则调整柱的box
auto activeRotationPillarBox = activePilar->GetBaseBndBox();
if ( lockRotation )
{
gp_Trsf tfsODL, tfsPillar;
tfsODL.SetRotation(alignTransformation.GetRotation());
tfsPillar.SetRotation(activePilar->GetRotation());
activeRotationPillarBox = activeRotationPillarBox.Transformed(tfsODL.Inverted() * tfsPillar);
}
Bnd_Box movingBox;
{
auto curBox = curODL->GetBaseBndBox();
Standard_Real xAlignMin,yAlignMin,zAlignMin,xAlignMax,yAlignMax,zAlignMax;
curBox.Get(xAlignMin, yAlignMin, zAlignMin, xAlignMax, yAlignMax, zAlignMax);
Standard_Real xPillarMin,yPillarMin,zPillarMin,xPillarMax,yPillarMax,zPillarMax;
activeRotationPillarBox.Get(xPillarMin, yPillarMin, zPillarMin, xPillarMax, yPillarMax, zPillarMax);
movingBox.Update(xAlignMin+xPillarMin, yAlignMin+yPillarMin, zAlignMin+zPillarMin,
xAlignMax+xPillarMax, yAlignMax+yPillarMax, zAlignMax+zPillarMax);
}
auto inODLPnt = newPnt.Transformed(curODL->GetAbsoluteTransform().Inverted());
开发者ID:litao1009,项目名称:SimpleRoom,代码行数:66,代码来源:RoomLayoutPillarController.cpp
示例18: GlueEdgesWithPCurves
//=======================================================================
//function : GlueEdgesWithPCurves
//purpose : Glues the pcurves of the sequence of edges
// and glues their 3d curves
//=======================================================================
static TopoDS_Edge GlueEdgesWithPCurves(const TopTools_SequenceOfShape& aChain,
const TopoDS_Vertex& FirstVertex,
const TopoDS_Vertex& LastVertex)
{
Standard_Integer i, j;
TopoDS_Edge FirstEdge = TopoDS::Edge(aChain(1));
//TColGeom2d_SequenceOfCurve PCurveSeq;
TColGeom_SequenceOfSurface SurfSeq;
//TopTools_SequenceOfShape LocSeq;
BRep_ListIteratorOfListOfCurveRepresentation itr( (Handle(BRep_TEdge)::DownCast(FirstEdge.TShape()))->Curves() );
for (; itr.More(); itr.Next())
{
Handle(BRep_CurveRepresentation) CurveRep = itr.Value();
if (CurveRep->IsCurveOnSurface())
{
//PCurveSeq.Append(CurveRep->PCurve());
SurfSeq.Append(CurveRep->Surface());
/*
TopoDS_Shape aLocShape;
aLocShape.Location(CurveRep->Location());
LocSeq.Append(aLocShape);
*/
}
}
Standard_Real fpar, lpar;
BRep_Tool::Range(FirstEdge, fpar, lpar);
TopoDS_Edge PrevEdge = FirstEdge;
TopoDS_Vertex CV;
Standard_Real MaxTol = 0.;
TopoDS_Edge ResEdge;
BRep_Builder BB;
Standard_Integer nb_curve = aChain.Length(); //number of curves
TColGeom_Array1OfBSplineCurve tab_c3d(0,nb_curve-1); //array of the curves
TColStd_Array1OfReal tabtolvertex(0,nb_curve-1); //(0,nb_curve-2); //array of the tolerances
TopoDS_Vertex PrevVertex = FirstVertex;
for (i = 1; i <= nb_curve; i++)
{
TopoDS_Edge anEdge = TopoDS::Edge(aChain(i));
TopoDS_Vertex VF, VL;
TopExp::Vertices(anEdge, VF, VL);
Standard_Boolean ToReverse = (!VF.IsSame(PrevVertex));
Standard_Real Tol1 = BRep_Tool::Tolerance(VF);
Standard_Real Tol2 = BRep_Tool::Tolerance(VL);
if (Tol1 > MaxTol)
MaxTol = Tol1;
if (Tol2 > MaxTol)
MaxTol = Tol2;
if (i > 1)
{
TopExp::CommonVertex(PrevEdge, anEdge, CV);
Standard_Real Tol = BRep_Tool::Tolerance(CV);
tabtolvertex(i-2) = Tol;
}
Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, fpar, lpar);
Handle(Geom_TrimmedCurve) aTrCurve = new Geom_TrimmedCurve(aCurve, fpar, lpar);
tab_c3d(i-1) = GeomConvert::CurveToBSplineCurve(aTrCurve);
GeomConvert::C0BSplineToC1BSplineCurve(tab_c3d(i-1), Precision::Confusion());
if (ToReverse)
tab_c3d(i-1)->Reverse();
PrevVertex = (ToReverse)? VF : VL;
PrevEdge = anEdge;
}
Handle(TColGeom_HArray1OfBSplineCurve) concatcurve; //array of the concatenated curves
Handle(TColStd_HArray1OfInteger) ArrayOfIndices; //array of the remining Vertex
GeomConvert::ConcatC1(tab_c3d,
tabtolvertex,
ArrayOfIndices,
concatcurve,
Standard_False,
Precision::Confusion()); //C1 concatenation
if (concatcurve->Length() > 1)
{
GeomConvert_CompCurveToBSplineCurve Concat(concatcurve->Value(concatcurve->Lower()));
for (i = concatcurve->Lower()+1; i <= concatcurve->Upper(); i++)
Concat.Add( concatcurve->Value(i), MaxTol, Standard_True );
concatcurve->SetValue(concatcurve->Lower(), Concat.BSplineCurve());
}
Handle(Geom_BSplineCurve) ResCurve = concatcurve->Value(concatcurve->Lower());
TColGeom2d_SequenceOfBoundedCurve ResPCurves;
TopLoc_Location aLoc;
for (j = 1; j <= SurfSeq.Length(); j++)
{
//.........这里部分代码省略.........
开发者ID:triggerfish1,项目名称:pythonocc,代码行数:101,代码来源:BlockFix_UnionEdges.cpp
示例19: if
//----------------------------------------------------------------
// Function: TopoDS_Shape level function to update the core Surface
// for any movement or Boolean operation of the body.
// Author: Jane Hu
//----------------------------------------------------------------
CubitStatus OCCSurface::update_OCC_entity(TopoDS_Face& old_surface,
TopoDS_Shape& new_surface,
BRepBuilderAPI_MakeShape *op,
TopoDS_Vertex* remo
|
请发表评论