本文整理汇总了C++中TopLoc_Location类的典型用法代码示例。如果您正苦于以下问题:C++ TopLoc_Location类的具体用法?C++ TopLoc_Location怎么用?C++ TopLoc_Location使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TopLoc_Location类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OCCTesselation
OCCTesselation *OCCEdge::tesselate(double angular, double curvature)
{
OCCTesselation *ret = new OCCTesselation();
try {
Standard_Real start, end;
OCCStruct3f vert;
TopLoc_Location loc = this->getEdge().Location();
gp_Trsf location = loc.Transformation();
const Handle(Geom_Curve)& curve = BRep_Tool::Curve(this->getEdge(), start, end);
const GeomAdaptor_Curve& aCurve(curve);
GCPnts_TangentialDeflection TD(aCurve, start, end, angular, curvature);
for (Standard_Integer i = 1; i <= TD.NbPoints(); i++)
{
gp_Pnt pnt = TD.Value(i).Transformed(location);
vert.x = (float)pnt.X();
vert.y = (float)pnt.Y();
vert.z = (float)pnt.Z();
ret->vertices.push_back(vert);
}
ret->ranges.push_back(0);
ret->ranges.push_back(ret->vertices.size());
} catch(Standard_Failure &err) {
return NULL;
}
return ret;
}
示例2: ubTreeFiller
void PointOnFacesProjector::prepare(const TopoDS_Shape& faces)
{
d->clear();
// Build the UB tree for binary search of points
internal::UBTreeOfNodeIndicesFiller_t ubTreeFiller(d->m_ubTree, Standard_False);
for (TopExp_Explorer exp(faces, TopAbs_FACE); exp.More(); exp.Next()) {
const TopoDS_Face face = TopoDS::Face(exp.Current());
if (!face.IsNull()) {
TopLoc_Location loc;
const Handle_Poly_Triangulation& triangulation = BRep_Tool::Triangulation(face, loc);
if (!triangulation.IsNull()) {
d->insertMapping(triangulation, face);
const gp_Trsf& trsf = loc.Transformation();
const TColgp_Array1OfPnt& nodes = triangulation->Nodes();
for (int i = nodes.Lower(); i <= nodes.Upper(); ++i) {
const gp_Pnt iNode(nodes(i).Transformed(trsf));
Bnd_Box ibb;
ibb.Set(iNode);
ubTreeFiller.Add(std::make_pair(i, triangulation), ibb);
}
}
}
}
ubTreeFiller.Fill();
}
示例3: ax2
App::DocumentObjectExecReturn *Mirroring::execute(void)
{
App::DocumentObject* link = Source.getValue();
if (!link)
return new App::DocumentObjectExecReturn("No object linked");
if (!link->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
return new App::DocumentObjectExecReturn("Linked object is not a Part object");
Part::Feature *source = static_cast<Part::Feature*>(link);
Base::Vector3f base = Base.getValue();
Base::Vector3f norm = Normal.getValue();
try {
const TopoDS_Shape& shape = source->Shape.getValue();
gp_Ax2 ax2(gp_Pnt(base.x,base.y,base.z), gp_Dir(norm.x,norm.y,norm.z));
gp_Trsf mat;
mat.SetMirror(ax2);
TopLoc_Location loc = shape.Location();
gp_Trsf placement = loc.Transformation();
mat = placement * mat;
BRepBuilderAPI_Transform mkTrf(shape, mat);
this->Shape.setValue(mkTrf.Shape());
return App::DocumentObject::StdReturn;
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
return new App::DocumentObjectExecReturn(e->GetMessageString());
}
}
示例4: ScanCascadeShapes
void ChCascadeDoc::ScanCascadeShapes(callback_CascadeDoc& mcallback) {
TopLoc_Location rootloc;
rootloc.Identity();
Handle(XCAFDoc_ShapeTool) shapeTool = XCAFDoc_DocumentTool::ShapeTool((*doc)->Main());
TDF_LabelSequence root_labels;
shapeTool->GetFreeShapes(root_labels);
for (Standard_Integer i = 1; i <= root_labels.Length(); i++) {
TDF_Label label = root_labels.Value(i);
int level = 0;
recurse_CascadeDoc(label, shapeTool, rootloc, level, mcallback);
}
}
示例5: FromChronoToCascade
void ChCascadeDoc::FromChronoToCascade(const ChFrame<>& from_coord, TopLoc_Location& to_coord) {
const ChVector<>& mpos = from_coord.GetPos();
gp_Vec mtr(mpos.x(), mpos.y(), mpos.z());
const ChMatrix33<>& from_mat = from_coord.GetA();
((gp_Trsf)(to_coord.Transformation()))
.SetValues(from_mat(0, 0), from_mat(0, 1), from_mat(0, 2), mpos.x(), from_mat(1, 0), from_mat(1, 1),
from_mat(1, 2), mpos.y(), from_mat(2, 0), from_mat(2, 1), from_mat(2, 2), mpos.z()); //0, 0);
}
示例6: OCC2VTK
void
GEOM_ShadingFace::
OCC2VTK(const TopoDS_Face& theFace,
vtkPolyData* thePolyData,
vtkPoints* thePts)
{
TopLoc_Location aLoc;
Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(theFace,aLoc);
if(aPoly.IsNull())
return;
else{
gp_Trsf myTransf;
Standard_Boolean identity = true;
if(!aLoc.IsIdentity()){
identity = false;
myTransf = aLoc.Transformation();
}
Standard_Integer i;
int aNbOfNodes = thePts->GetNumberOfPoints();
const TColgp_Array1OfPnt& Nodes = aPoly->Nodes();
Standard_Integer nbNodesInFace = aPoly->NbNodes();
for(i = 1; i <= nbNodesInFace; i++) {
gp_Pnt P = Nodes(i);
if(!identity)
P.Transform(myTransf);
thePts->InsertNextPoint(P.X(),P.Y(),P.Z());
}
const Poly_Array1OfTriangle& Triangles = aPoly->Triangles();
Standard_Integer nbTriInFace = aPoly->NbTriangles();
for(i = 1; i <= nbTriInFace; i++){
// Get the triangle
Standard_Integer N1,N2,N3;
Triangles(i).Get(N1,N2,N3);
N1 += aNbOfNodes - 1;
N2 += aNbOfNodes - 1;
N3 += aNbOfNodes - 1;
vtkIdType anIds[3] = {N1, N2, N3};
thePolyData->InsertNextCell(VTK_TRIANGLE,3,anIds);
}
}
}
示例7: FromCascadeToChrono
void ChCascadeDoc::FromCascadeToChrono(const TopLoc_Location& from_coord, ChFrame<>& to_coord) {
gp_XYZ mtr = from_coord.Transformation().TranslationPart();
to_coord.SetPos(ChVector<>(mtr.X(), mtr.Y(), mtr.Z()));
gp_Mat mro = from_coord.Transformation().VectorialPart();
ChMatrix33<> to_mat;
to_mat(0, 0) = mro(1, 1);
to_mat(0, 1) = mro(1, 2);
to_mat(0, 2) = mro(1, 3);
to_mat(1, 0) = mro(2, 1);
to_mat(1, 1) = mro(2, 2);
to_mat(1, 2) = mro(2, 3);
to_mat(2, 0) = mro(3, 1);
to_mat(2, 1) = mro(3, 2);
to_mat(2, 2) = mro(3, 3);
to_coord.SetRot(to_mat);
}
示例8: OCCTesselation
OCCTesselation *OCCWire::tesselate(double angular, double curvature)
{
OCCTesselation *ret = new OCCTesselation();
try {
Standard_Real start, end;
OCCStruct3f dtmp;
// explore wire edges in connected order
int lastSize = 0;
BRepTools_WireExplorer exWire;
for (exWire.Init(this->getWire()); exWire.More(); exWire.Next()) {
const TopoDS_Edge& edge = exWire.Current();
TopLoc_Location loc = edge.Location();
gp_Trsf location = loc.Transformation();
const Handle(Geom_Curve)& curve = BRep_Tool::Curve(edge, start, end);
const GeomAdaptor_Curve& aCurve(curve);
GCPnts_TangentialDeflection TD(aCurve, start, end, angular, curvature);
ret->ranges.push_back(ret->vertices.size());
for (Standard_Integer i = 1; i <= TD.NbPoints(); i++)
{
gp_Pnt pnt = TD.Value(i).Transformed(location);
dtmp.x = (float)pnt.X();
dtmp.y = (float)pnt.Y();
dtmp.z = (float)pnt.Z();
ret->vertices.push_back(dtmp);
}
ret->ranges.push_back(ret->vertices.size() - lastSize);
lastSize = ret->vertices.size();
}
} catch(Standard_Failure &err) {
return NULL;
}
return ret;
}
示例9: FromChronoToCascade
void ChCascadeDoc::FromChronoToCascade(const ChFrame<>& from_coord, TopLoc_Location& to_coord)
{
ChVector<> mpos = ((ChFrame<>&)from_coord).GetPos();
gp_Vec mtr(mpos.x, mpos.y, mpos.z);
ChMatrix33<>* from_mat = ((ChFrame<>&)from_coord).GetA();
((gp_Trsf)(to_coord.Transformation()) ).SetValues(
(*from_mat)(0,0) ,(*from_mat)(0,1), (*from_mat)(0,2), mpos.x ,
(*from_mat)(1,0) ,(*from_mat)(1,1), (*from_mat)(1,2), mpos.y ,
(*from_mat)(2,0) ,(*from_mat)(2,1), (*from_mat)(2,2), mpos.z ,
0,0);
}
示例10: ForShape
virtual bool ForShape(TopoDS_Shape& mshape, TopLoc_Location& mloc, char* mname, int mlevel, TDF_Label& mlabel)
{
for (int i=0; i<mlevel; i++) GetLog()<< " ";
GetLog() << "-Name :" << mname;
if (mlevel==0) GetLog() << " (root)";
GetLog() << "\n";
for (int i=0; i<mlevel; i++) GetLog()<< " ";
gp_XYZ mtr = mloc.Transformation().TranslationPart();
GetLog() << " pos at: "<< mtr.X() <<" "<< mtr.Y() << " "<<mtr.Z() <<" (absolute) \n";
for (int i=0; i<mlevel; i++) GetLog()<< " ";
gp_XYZ mtr2 = mshape.Location().Transformation().TranslationPart();
GetLog() << " pos at: "<< mtr2.X() <<" "<< mtr2.Y() << " "<<mtr2.Z() <<" (.Location)\n";
return true;
}
示例11: edgeConstruct
void ShapeGeometryBuilder::edgeConstruct(const TopoDS_Edge &edgeIn)
{
TopoDS_Face face = TopoDS::Face(edgeToFace.FindFromKey(edgeIn).First());
if (face.IsNull())
throw std::runtime_error("face is null in edge construction");
TopLoc_Location location;
Handle(Poly_Triangulation) triangulation;
triangulation = BRep_Tool::Triangulation(face, location);
const Handle(Poly_PolygonOnTriangulation) &segments =
BRep_Tool::PolygonOnTriangulation(edgeIn, triangulation, location);
if (segments.IsNull())
throw std::runtime_error("edge triangulation is null in edge construction");
gp_Trsf transformation;
bool identity = true;
if(!location.IsIdentity())
{
identity = false;
transformation = location.Transformation();
}
const TColStd_Array1OfInteger& indexes = segments->Nodes();
const TColgp_Array1OfPnt& nodes = triangulation->Nodes();
osg::Vec3Array *vertices = dynamic_cast<osg::Vec3Array *>(edgeGeometry->getVertexArray());
osg::Vec4Array *colors = dynamic_cast<osg::Vec4Array *>(edgeGeometry->getColorArray());
osg::ref_ptr<osg::DrawElementsUInt> indices = new osg::DrawElementsUInt
(GL_LINE_STRIP, indexes.Length());
osg::BoundingSphere bSphere;
for (int index(indexes.Lower()); index < indexes.Upper() + 1; ++index)
{
gp_Pnt point = nodes(indexes(index));
if(!identity)
point.Transform(transformation);
vertices->push_back(osg::Vec3(point.X(), point.Y(), point.Z()));
colors->push_back(edgeGeometry->getColor());
(*indices)[index - 1] = vertices->size() - 1;
if (!bSphere.valid()) //for first one.
{
bSphere.center() = vertices->back();
bSphere.radius() = 0.0;
}
else
bSphere.expandBy(vertices->back());
}
edgeGeometry->addPrimitiveSet(indices.get());
boost::uuids::uuid id = seerShape->findShapeIdRecord(edgeIn).id;
std::size_t lastPrimitiveIndex = edgeGeometry->getNumPrimitiveSets() - 1;
if (!idPSetWrapperEdge->hasId(id))
{
IdPSetRecord record;
record.id = id;
record.primitiveSetIndex = lastPrimitiveIndex;
record.bSphere = bSphere;
idPSetWrapperEdge->idPSetContainer.insert(record);
}
else
//ensure that edges have the same primitive index between lod calls.
//asserts here prior to having lod implemented is probably duplicate ids
//for different geometry.
assert(lastPrimitiveIndex == idPSetWrapperEdge->findPSetFromId(id));
}
示例12: copy
App::DocumentObjectExecReturn *Revolution::execute(void)
{
App::DocumentObject* link = Sketch.getValue();
if (!link)
return new App::DocumentObjectExecReturn("No sketch linked");
if (!link->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId()))
return new App::DocumentObjectExecReturn("Linked object is not a Sketch or Part2DObject");
Part::Part2DObject* pcSketch=static_cast<Part::Part2DObject*>(link);
TopoDS_Shape shape = pcSketch->Shape.getShape()._Shape;
if (shape.IsNull())
return new App::DocumentObjectExecReturn("Linked shape object is empty");
// this is a workaround for an obscure OCC bug which leads to empty tessellations
// for some faces. Making an explicit copy of the linked shape seems to fix it.
// The error only happens when re-computing the shape.
if (!this->Shape.getValue().IsNull()) {
BRepBuilderAPI_Copy copy(shape);
shape = copy.Shape();
if (shape.IsNull())
return new App::DocumentObjectExecReturn("Linked shape object is empty");
}
TopExp_Explorer ex;
std::vector<TopoDS_Wire> wires;
for (ex.Init(shape, TopAbs_WIRE); ex.More(); ex.Next()) {
wires.push_back(TopoDS::Wire(ex.Current()));
}
if (wires.empty()) // there can be several wires
return new App::DocumentObjectExecReturn("Linked shape object is not a wire");
// get the Sketch plane
Base::Placement SketchPlm = pcSketch->Placement.getValue();
// get reference axis
App::DocumentObject *pcReferenceAxis = ReferenceAxis.getValue();
const std::vector<std::string> &subReferenceAxis = ReferenceAxis.getSubValues();
if (pcReferenceAxis && pcReferenceAxis == pcSketch) {
bool hasValidAxis=false;
Base::Axis axis;
if (subReferenceAxis[0] == "V_Axis") {
hasValidAxis = true;
axis = pcSketch->getAxis(Part::Part2DObject::V_Axis);
}
else if (subReferenceAxis[0] == "H_Axis") {
hasValidAxis = true;
axis = pcSketch->getAxis(Part::Part2DObject::H_Axis);
}
else if (subReferenceAxis[0].size() > 4 && subReferenceAxis[0].substr(0,4) == "Axis") {
int AxId = std::atoi(subReferenceAxis[0].substr(4,4000).c_str());
if (AxId >= 0 && AxId < pcSketch->getAxisCount()) {
hasValidAxis = true;
axis = pcSketch->getAxis(AxId);
}
}
if (hasValidAxis) {
axis *= SketchPlm;
Base::Vector3d base=axis.getBase();
Base::Vector3d dir=axis.getDirection();
Base.setValue(base.x,base.y,base.z);
Axis.setValue(dir.x,dir.y,dir.z);
}
}
// get revolve axis
Base::Vector3f b = Base.getValue();
gp_Pnt pnt(b.x,b.y,b.z);
Base::Vector3f v = Axis.getValue();
gp_Dir dir(v.x,v.y,v.z);
// get the support of the Sketch if any
App::DocumentObject* pcSupport = pcSketch->Support.getValue();
Part::Feature *SupportObject = 0;
if (pcSupport && pcSupport->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
SupportObject = static_cast<Part::Feature*>(pcSupport);
TopoDS_Shape aFace = makeFace(wires);
if (aFace.IsNull())
return new App::DocumentObjectExecReturn("Creating a face from sketch failed");
// Rotate the face by half the angle to get revolution symmetric to sketch plane
if (Midplane.getValue()) {
gp_Trsf mov;
mov.SetRotation(gp_Ax1(pnt, dir), Base::toRadians<double>(Angle.getValue()) * (-1.0) / 2.0);
TopLoc_Location loc(mov);
aFace.Move(loc);
}
this->positionBySketch();
TopLoc_Location invObjLoc = this->getLocation().Inverted();
pnt.Transform(invObjLoc.Transformation());
dir.Transform(invObjLoc.Transformation());
// Reverse angle if selected
double angle = Base::toRadians<double>(Angle.getValue());
if (Reversed.getValue() && !Midplane.getValue())
angle *= (-1.0);
try {
//.........这里部分代码省略.........
示例13: faceConstruct
void ShapeGeometryBuilder::faceConstruct(const TopoDS_Face &faceIn)
{
TopLoc_Location location;
Handle(Poly_Triangulation) triangulation;
triangulation = BRep_Tool::Triangulation(faceIn, location);
if (triangulation.IsNull())
throw std::runtime_error("null triangulation in face construction");
bool signalOrientation(false);
if (faceIn.Orientation() == TopAbs_FORWARD)
signalOrientation = true;
gp_Trsf transformation;
bool identity = true;
if(!location.IsIdentity())
{
identity = false;
transformation = location.Transformation();
}
//vertices.
const TColgp_Array1OfPnt& nodes = triangulation->Nodes();
osg::Vec3Array *vertices = dynamic_cast<osg::Vec3Array *>(faceGeometry->getVertexArray());
osg::Vec3Array *normals = dynamic_cast<osg::Vec3Array *>(faceGeometry->getNormalArray());
osg::Vec4Array *colors = dynamic_cast<osg::Vec4Array *>(faceGeometry->getColorArray());
std::size_t offset = vertices->size();
for (int index(nodes.Lower()); index < nodes.Upper() + 1; ++index)
{
gp_Pnt point = nodes.Value(index);
if(!identity)
point.Transform(transformation);
vertices->push_back(osg::Vec3(point.X(), point.Y(), point.Z()));
normals->push_back(osg::Vec3(0.0, 0.0, 0.0));
colors->push_back(faceGeometry->getColor());
}
const Poly_Array1OfTriangle& triangles = triangulation->Triangles();
osg::ref_ptr<osg::DrawElementsUInt> indices = new osg::DrawElementsUInt
(GL_TRIANGLES, triangulation->NbTriangles() * 3);
for (int index(triangles.Lower()); index < triangles.Upper() + 1; ++index)
{
int N1, N2, N3;
triangles(index).Get(N1, N2, N3);
int factor = (index - 1) * 3;
if (!signalOrientation)
{
(*indices)[factor] = N3 - 1 + offset;
(*indices)[factor + 1] = N2 - 1 + offset;
(*indices)[factor + 2] = N1 - 1 + offset;
}
else
{
(*indices)[factor] = N1 - 1 + offset;
(*indices)[factor + 1] = N2 - 1 + offset;
(*indices)[factor + 2] = N3 - 1 + offset;
}
//store primitiveset index and vertex indes into map.
PSetVertexRecord record;
record.primitiveSetIndex = faceGeometry->getNumPrimitiveSets();
record.vertexIndex = (*indices)[factor];
pSetTriangleWrapper->pSetVertexContainer.insert(record);
record.vertexIndex = (*indices)[factor + 1];
pSetTriangleWrapper->pSetVertexContainer.insert(record);
record.vertexIndex = (*indices)[factor + 2];
pSetTriangleWrapper->pSetVertexContainer.insert(record);
//now that we are combining faces into one geometry, osgUtil SmoothingVisitor
//wants to 'average' out normals across faces. so we go back to manual calculation
//of surface normals.
osg::Vec3 pointOne(vertices->at((*indices)[factor]));
osg::Vec3 pointTwo(vertices->at((*indices)[factor + 1]));
osg::Vec3 pointThree(vertices->at((*indices)[factor + 2]));
osg::Vec3 axisOne(pointTwo - pointOne);
osg::Vec3 axisTwo(pointThree - pointOne);
osg::Vec3 currentNormal(axisOne ^ axisTwo);
if (currentNormal.isNaN())
continue;
currentNormal.normalize();
osg::Vec3 tempNormal;
tempNormal = (*normals)[(*indices)[factor]];
tempNormal += currentNormal;
tempNormal.normalize();
(*normals)[(*indices)[factor]] = tempNormal;
tempNormal = (*normals)[(*indices)[factor + 1]];
tempNormal += currentNormal;
tempNormal.normalize();
(*normals)[(*indices)[factor + 1]] = tempNormal;
//.........这里部分代码省略.........
示例14: getSketchWires
App::DocumentObjectExecReturn *Revolution::execute(void)
{
// Validate parameters
double angle = Angle.getValue();
if (angle < Precision::Confusion())
return new App::DocumentObjectExecReturn("Angle of revolution too small");
if (angle > 360.0)
return new App::DocumentObjectExecReturn("Angle of revolution too large");
angle = Base::toRadians<double>(angle);
// Reverse angle if selected
if (Reversed.getValue() && !Midplane.getValue())
angle *= (-1.0);
std::vector<TopoDS_Wire> wires;
try {
wires = getSketchWires();
} catch (const Base::Exception& e) {
return new App::DocumentObjectExecReturn(e.what());
}
TopoDS_Shape support;
try {
support = getSupportShape();
} catch (const Base::Exception&) {
// ignore, because support isn't mandatory
support = TopoDS_Shape();
}
// update Axis from ReferenceAxis
updateAxis();
// get revolve axis
Base::Vector3d b = Base.getValue();
gp_Pnt pnt(b.x,b.y,b.z);
Base::Vector3d v = Axis.getValue();
gp_Dir dir(v.x,v.y,v.z);
try {
TopoDS_Shape sketchshape = makeFace(wires);
if (sketchshape.IsNull())
return new App::DocumentObjectExecReturn("Creating a face from sketch failed");
// Rotate the face by half the angle to get Revolution symmetric to sketch plane
if (Midplane.getValue()) {
gp_Trsf mov;
mov.SetRotation(gp_Ax1(pnt, dir), Base::toRadians<double>(Angle.getValue()) * (-1.0) / 2.0);
TopLoc_Location loc(mov);
sketchshape.Move(loc);
}
this->positionBySketch();
TopLoc_Location invObjLoc = this->getLocation().Inverted();
pnt.Transform(invObjLoc.Transformation());
dir.Transform(invObjLoc.Transformation());
support.Move(invObjLoc);
sketchshape.Move(invObjLoc);
// Check distance between sketchshape and axis - to avoid failures and crashes
if (checkLineCrossesFace(gp_Lin(pnt, dir), TopoDS::Face(sketchshape)))
return new App::DocumentObjectExecReturn("Revolve axis intersects the sketch");
// revolve the face to a solid
BRepPrimAPI_MakeRevol RevolMaker(sketchshape, gp_Ax1(pnt, dir), angle);
if (RevolMaker.IsDone()) {
TopoDS_Shape result = RevolMaker.Shape();
result = refineShapeIfActive(result);
// set the additive shape property for later usage in e.g. pattern
this->AddShape.setValue(result);
// if the sketch has a support fuse them to get one result object (PAD!)
if (!support.IsNull()) {
// Let's call algorithm computing a fuse operation:
BRepAlgoAPI_Fuse mkFuse(support, result);
// Let's check if the fusion has been successful
if (!mkFuse.IsDone())
throw Base::Exception("Fusion with support failed");
result = mkFuse.Shape();
result = refineShapeIfActive(result);
}
this->Shape.setValue(result);
}
else
return new App::DocumentObjectExecReturn("Could not revolve the sketch!");
return App::DocumentObject::StdReturn;
}
catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught();
if (std::string(e->GetMessageString()) == "TopoDS::Face")
return new App::DocumentObjectExecReturn("Could not create face from sketch.\n"
"Intersecting sketch entities or multiple faces in a sketch are not allowed.");
else
return new App::DocumentObjectExecReturn(e->GetMessageString());
}
catch (Base::Exception& e) {
return new App::DocumentObjectExecReturn(e.what());
}
//.........这里部分代码省略.........
示例15: recurse_CascadeDoc
static bool recurse_CascadeDoc(TDF_Label label,
Handle_XCAFDoc_ShapeTool& shapeTool,
TopLoc_Location& parentloc,
int level,
ChCascadeDoc::callback_CascadeDoc& mcallback) {
TDF_LabelSequence child_labels;
Standard_Boolean is_assembly;
is_assembly = shapeTool->GetComponents(label, child_labels, 0);
char mstring[200] = "no name";
Standard_PCharacter mchastr = mstring;
// access name
Handle_TDataStd_Name N;
if (label.FindAttribute(TDataStd_Name::GetID(), N)) {
N->Get().ToUTF8CString(mchastr);
}
TDF_Label reflabel;
Standard_Boolean isref = shapeTool->GetReferredShape(label, reflabel);
if (isref) // ..maybe it references some shape: the name is stored there...
{
Handle_TDataStd_Name N;
if (reflabel.FindAttribute(TDataStd_Name::GetID(), N)) {
N->Get().ToUTF8CString(mchastr);
}
}
TopLoc_Location mloc = shapeTool->GetLocation(label);
TopLoc_Location absloc = parentloc.Multiplied(mloc);
// access shape and position
TopoDS_Shape rShape;
rShape = shapeTool->GetShape(label);
if (!rShape.IsNull()) {
// === call the callback! ===
if (!mcallback.ForShape(rShape, absloc, mstring, level, label))
return false; // (skip children recursion if returned false)
}
// Recurse all children !!!
if (is_assembly) {
for (Standard_Integer j = 1; j <= child_labels.Length(); j++) {
TDF_Label clabel = child_labels.Value(j);
recurse_CascadeDoc(clabel, shapeTool, absloc, (level + 1), mcallback);
}
}
// If it is a reference, Recurse all children of reference
if (isref) {
TDF_LabelSequence refchild_labels;
Standard_Boolean refis_assembly;
refis_assembly = shapeTool->GetComponents(reflabel, refchild_labels, 0);
for (Standard_Integer j = 1; j <= refchild_labels.Length(); j++) {
TDF_Label clabel = refchild_labels.Value(j);
recurse_CascadeDoc(clabel, shapeTool, absloc, (level + 1), mcallback);
}
}
return true;
}