/** * @todo: it would be nice if this algorithm would support * some progress bar interface */ void CTiglFusePlane::Perform() { if (_hasPerformed) { return; } CTiglUIDManager& uidManager = _myconfig.GetUIDManager(); CTiglAbstractPhysicalComponent* rootComponent = uidManager.GetRootComponent(); if (!rootComponent) { LOG(ERROR) << "Root component of plane not found. Cannot create fused plane."; return; } _result = FuseWithChilds(rootComponent); CCPACSFarField& farfield = _myconfig.GetFarField(); if (farfield.GetFieldType() != NONE && (_mymode == FULL_PLANE_TRIMMED_FF || _mymode == HALF_PLANE_TRIMMED_FF)) { PNamedShape ff = farfield.GetLoft(); BOPCol_ListOfShape aLS; aLS.Append(_result->Shape()); aLS.Append(ff->Shape()); BOPAlgo_PaveFiller dsfill; dsfill.SetArguments(aLS); dsfill.Perform(); CTrimShape trim1(_result, ff, dsfill, INCLUDE); PNamedShape resulttrimmed = trim1.NamedShape(); CTrimShape trim2(ff, _result, dsfill, EXCLUDE); _farfield = trim2.NamedShape(); _result = resulttrimmed; // trim intersections with far field ListPNamedShape::iterator intIt = _intersections.begin(); ListPNamedShape newInts; for (; intIt != _intersections.end(); ++intIt) { PNamedShape inters = *intIt; if (!inters) { continue; } TopoDS_Shape sh = inters->Shape(); sh = BRepAlgoAPI_Common(sh, ff->Shape()); if (! sh.IsNull()) { inters->SetShape(sh); newInts.push_back(inters); } } _intersections = newInts; } if (_result) { _result->SetName(_myconfig.GetUID().c_str()); _result->SetShortName("AIRCRAFT"); } _hasPerformed = true; }
PNamedShape CCPACSControlSurfaceDevice::getTransformedFlapShape() { PNamedShape deviceShape = getFlapShape()->DeepCopy(); gp_Trsf T = GetFlapTransform(); BRepBuilderAPI_Transform form(deviceShape->Shape(), T); deviceShape->SetShape(form.Shape()); // store the transformation property. Required e.g. for VTK metadata gp_GTrsf gT(T); CTiglTransformation tiglTrafo(gT); unsigned int nFaces = deviceShape->GetFaceCount(); for (unsigned int iFace = 0; iFace < nFaces; ++iFace) { CFaceTraits ft = deviceShape->GetFaceTraits(iFace); ft.SetTransformation(tiglTrafo); deviceShape->SetFaceTraits(iFace, ft); } return deviceShape; }
PNamedShape CTiglFusePlane::FuseWithChilds(CTiglAbstractPhysicalComponent* parent) { assert(parent != NULL); PNamedShape parentShape (parent->GetLoft()); if (parentShape) { if (_mymode == FULL_PLANE || _mymode == FULL_PLANE_TRIMMED_FF) { PNamedShape rootShapeMirr = parent->GetMirroredLoft(); parentShape = CMergeShapes(parentShape, rootShapeMirr); } } CTiglAbstractPhysicalComponent::ChildContainerType childs = parent->GetChildren(false); CTiglAbstractPhysicalComponent::ChildContainerType::iterator childIt; if (childs.size() == 0) { return parentShape; } ListPNamedShape childShapes; for (childIt = childs.begin(); childIt != childs.end(); ++childIt) { CTiglAbstractPhysicalComponent* child = *childIt; if (!child) { continue; } PNamedShape childShape = FuseWithChilds(child); childShapes.push_back(childShape); } CFuseShapes fuser(parentShape, childShapes); PNamedShape result = fuser.NamedShape(); // trim previous intersections ListPNamedShape::iterator intIt = _intersections.begin(); ListPNamedShape newInts; for (; intIt != _intersections.end(); ++intIt) { PNamedShape inters = *intIt; if (!inters) { continue; } TopoDS_Shape sh = inters->Shape(); if (parentShape) { sh = BRepAlgoAPI_Cut(sh, parentShape->Shape()); } if (!sh.IsNull()) { inters->SetShape(sh); newInts.push_back(inters); } } _intersections = newInts; // insert intersections ListPNamedShape::const_iterator it = fuser.Intersections().begin(); for (; it != fuser.Intersections().end(); it++) { if (*it) { _intersections.push_back(*it); } } return result; }