PNamedShape CTiglAbstractGeometricComponent::GetMirroredLoft(void) { if (mySymmetryAxis == TIGL_NO_SYMMETRY) { PNamedShape nullShape; nullShape.reset(); return nullShape; } gp_Ax2 mirrorPlane; if (mySymmetryAxis == TIGL_X_Z_PLANE) { mirrorPlane = gp_Ax2(gp_Pnt(0,0,0),gp_Dir(0.,1.,0.)); } else if (mySymmetryAxis == TIGL_X_Y_PLANE) { mirrorPlane = gp_Ax2(gp_Pnt(0,0,0),gp_Dir(0.,0.,1.)); } else if (mySymmetryAxis == TIGL_Y_Z_PLANE) { mirrorPlane = gp_Ax2(gp_Pnt(0,0,0),gp_Dir(1.,0.,0.)); } gp_Trsf theTransformation; theTransformation.SetMirror(mirrorPlane); BRepBuilderAPI_Transform myBRepTransformation(GetLoft()->Shape(), theTransformation); std::string mirrorName = GetLoft()->Name(); mirrorName += "M"; std::string mirrorShortName = GetLoft()->ShortName(); mirrorShortName += "M"; TopoDS_Shape mirroredShape = myBRepTransformation.Shape(); PNamedShape mirroredPNamedShape(new CNamedShape(*GetLoft())); mirroredPNamedShape->SetShape(mirroredShape); mirroredPNamedShape->SetName(mirrorName.c_str()); mirroredPNamedShape->SetShortName(mirrorShortName.c_str()); return mirroredPNamedShape; }
bool CTiglAbstractGeometricComponent::GetIsOn(const gp_Pnt& pnt) { const TopoDS_Shape& segmentShape = GetLoft()->Shape(); // fast check with bounding box Bnd_Box boundingBox; BRepBndLib::Add(segmentShape, boundingBox); Standard_Real xmin, xmax, ymin, ymax, zmin, zmax; boundingBox.Get(xmin, ymin, zmin, xmax, ymax, zmax); if (pnt.X() < xmin || pnt.X() > xmax || pnt.Y() < ymin || pnt.Y() > ymax || pnt.Z() < zmin || pnt.Z() > zmax) { return false; } double tolerance = 0.03; // 3cm BRepClass3d_SolidClassifier classifier; classifier.Load(segmentShape); classifier.Perform(pnt, tolerance); if ((classifier.State() == TopAbs_IN) || (classifier.State() == TopAbs_ON)) { return true; } else { return false; } }
// Returns the surface area of this fuselage double CCPACSFuselage::GetSurfaceArea(void) { const TopoDS_Shape& fusedSegments = GetLoft()->Shape(); // Calculate surface area GProp_GProps System; BRepGProp::SurfaceProperties(fusedSegments, System); double myArea = System.Mass(); return myArea; }
// Returns the volume of this fuselage double CCPACSFuselage::GetVolume(void) { const TopoDS_Shape& fusedSegments = GetLoft()->Shape(); // Calculate volume GProp_GProps System; BRepGProp::VolumeProperties(fusedSegments, System); double myVolume = System.Mass(); return myVolume; }
// Returns the point where the distance between the selected fuselage and the ground is at minimum. // The Fuselage could be turned with a given angle at at given axis, specified by a point and a direction. gp_Pnt CCPACSFuselage::GetMinumumDistanceToGround(gp_Ax1 RAxis, double angle) { TopoDS_Shape fusedFuselage = GetLoft()->Shape(); // now rotate the fuselage gp_Trsf myTrsf; myTrsf.SetRotation(RAxis, angle * M_PI / 180.); BRepBuilderAPI_Transform xform(fusedFuselage, myTrsf); fusedFuselage = xform.Shape(); // build cutting plane for intersection // We move the "ground" to "-1000" to be sure it is _under_ the fuselage gp_Pnt p1(-1.0e7, -1.0e7, -1000); gp_Pnt p2( 1.0e7, -1.0e7, -1000); gp_Pnt p3( 1.0e7, 1.0e7, -1000); gp_Pnt p4(-1.0e7, 1.0e7, -1000); Handle(Geom_TrimmedCurve) shaft_line1 = GC_MakeSegment(p1,p2); Handle(Geom_TrimmedCurve) shaft_line2 = GC_MakeSegment(p2,p3); Handle(Geom_TrimmedCurve) shaft_line3 = GC_MakeSegment(p3,p4); Handle(Geom_TrimmedCurve) shaft_line4 = GC_MakeSegment(p4,p1); TopoDS_Edge shaft_edge1 = BRepBuilderAPI_MakeEdge(shaft_line1); TopoDS_Edge shaft_edge2 = BRepBuilderAPI_MakeEdge(shaft_line2); TopoDS_Edge shaft_edge3 = BRepBuilderAPI_MakeEdge(shaft_line3); TopoDS_Edge shaft_edge4 = BRepBuilderAPI_MakeEdge(shaft_line4); TopoDS_Wire shaft_wire = BRepBuilderAPI_MakeWire(shaft_edge1, shaft_edge2, shaft_edge3, shaft_edge4); TopoDS_Face shaft_face = BRepBuilderAPI_MakeFace(shaft_wire); // calculate extrema BRepExtrema_DistShapeShape extrema(fusedFuselage, shaft_face); extrema.Perform(); return extrema.PointOnShape1(1); }