int convert_to_ifc(const gp_Ax2& a, IfcSchema::IfcAxis2Placement3D*& ax, bool advanced) {
	IfcSchema::IfcCartesianPoint* p;
	IfcSchema::IfcDirection *x, *z;
	if (!(convert_to_ifc(a.Location(), p, advanced) && convert_to_ifc(a.Direction(), z, advanced) && convert_to_ifc(a.XDirection(), x, advanced))) {
        ax = 0;
		return 0;
	}
	ax = new IfcSchema::IfcAxis2Placement3D(p, z, x);
	return 1;
}
Beispiel #2
0
static TopoDS_Solid MakeCylinder(const gp_Ax2& pos, double radius, double height)
{
	gp_Ax2 pos2 = pos;
	if(height<0)
	{
		pos2 = gp_Ax2(pos.Location(), -(pos.Direction()));
		height = fabs(height);
	}

	return BRepPrimAPI_MakeCylinder(pos2, radius, height);
}
//================================================================
// Function : DrawCurve                                 
// Purpose  : displays a given curve 2d
//================================================================
Handle_AIS_InteractiveObject OCCDemo_Presentation::drawCurve
                                  (const Handle_Geom2d_Curve& theCurve,
                                   const Quantity_Color& theColor,
                                   const Standard_Boolean toDisplay,
                                   const gp_Ax2& aPosition)
{
  // create 3D curve in plane
  Handle(Geom_Curve) aCurve3d;
  if (theCurve->IsKind(STANDARD_TYPE(Geom2d_OffsetCurve)))
  {
    Handle(Geom2d_OffsetCurve) aOffCurve =
      Handle(Geom2d_OffsetCurve)::DownCast(theCurve);
    Handle(Geom_Curve) aBasCurve3d =
      GeomAPI::To3d (aOffCurve->BasisCurve(), gp_Pln(aPosition));
    Standard_Real aDist = aOffCurve->Offset();
    aCurve3d = new Geom_OffsetCurve (aBasCurve3d, aDist, aPosition.Direction());
  }
  else
  {
    aCurve3d = GeomAPI::To3d (theCurve, gp_Pln(aPosition));
  }
  return drawCurve (aCurve3d, theColor, toDisplay);
}
Beispiel #4
0
void orthoview::set_projection(gp_Ax2 cs)
{
    gp_Ax2  actual_cs;
    gp_Dir  actual_X;

    // coord system & directions for desired projection
    X_dir = cs.XDirection();
    Y_dir = cs.YDirection();
    Z_dir = cs.Direction();

    // coord system of created view - same code as used in projection algos
    // actual_cs = gp_Ax2(gp_Pnt(0,0,0), gp_Dir(Z_dir.X(),Z_dir.Y(),Z_dir.Z()));

    // but as the file gets saved the projection direction gets rounded.
    // this can lead to choosing a different normal x-direction when the file
    // gets reloaded see issue #1909
    // we anticipate the actual_cs after reloading by rounding the Z_dir now
    const double x = round( Z_dir.X()  * 1e12 ) / 1e12;
    const double y = round( Z_dir.Y()  * 1e12 ) / 1e12;
    const double z = round( Z_dir.Z()  * 1e12 ) / 1e12;
    actual_cs = gp_Ax2(gp_Pnt(0,0,0), gp_Dir(x,y,z));

    actual_X = actual_cs.XDirection();

    // angle between desired projection and actual projection
    float rotation = X_dir.Angle(actual_X);

    if (rotation != 0 && abs(PI - rotation) > 0.05)
        if (!Z_dir.IsEqual(actual_X.Crossed(X_dir), 0.05))
            rotation = -rotation;

    calcCentre();

    //this_view->Direction.setValue(Z_dir.X(), Z_dir.Y(), Z_dir.Z());
    this_view->Direction.setValue(x,y,z);
    this_view->Rotation.setValue(180 * rotation / PI);
}
//!set up a hidden line remover and project a shape with it
void GeometryObject::projectShape(const TopoDS_Shape& input,
                                  const gp_Ax2 viewAxis)
{
    // Clear previous Geometry
    clear();

//*******
    gp_Dir x = viewAxis.XDirection();
    gp_Dir y = viewAxis.YDirection();
    gp_Dir z = viewAxis.Direction();
    Base::Vector3d vx(x.X(),x.Y(),x.Z());
    Base::Vector3d vy(y.X(),y.Y(),y.Z());
    Base::Vector3d vz(z.X(),z.Y(),z.Z());
//    Base::Console().Message("TRACE - GO::projectShape - %s viewAxis x: %s y: %s Z: %s\n",m_parentName.c_str(),
//                            DrawUtil::formatVector(vx).c_str(), DrawUtil::formatVector(vy).c_str(), DrawUtil::formatVector(vz).c_str());
//*******

    auto start = chrono::high_resolution_clock::now();

    Handle_HLRBRep_Algo brep_hlr = NULL;
    try {
        brep_hlr = new HLRBRep_Algo();
        brep_hlr->Add(input, m_isoCount);
        HLRAlgo_Projector projector( viewAxis );
        brep_hlr->Projector(projector);
        brep_hlr->Update();
        brep_hlr->Hide();
    }
    catch (...) {
        Standard_Failure::Raise("GeometryObject::projectShape - error occurred while projecting shape");
    }
    auto end   = chrono::high_resolution_clock::now();
    auto diff  = end - start;
    double diffOut = chrono::duration <double, milli> (diff).count();
    Base::Console().Log("TIMING - %s GO spent: %.3f millisecs in HLRBRep_Algo & co\n",m_parentName.c_str(),diffOut);

    try {
        HLRBRep_HLRToShape hlrToShape(brep_hlr);

        visHard    = hlrToShape.VCompound();
        visSmooth  = hlrToShape.Rg1LineVCompound();
        visSeam    = hlrToShape.RgNLineVCompound();
        visOutline = hlrToShape.OutLineVCompound();
        visIso     = hlrToShape.IsoLineVCompound();
        hidHard    = hlrToShape.HCompound();
        hidSmooth  = hlrToShape.Rg1LineHCompound();
        hidSeam    = hlrToShape.RgNLineHCompound();
        hidOutline = hlrToShape.OutLineHCompound();
        hidIso     = hlrToShape.IsoLineHCompound();

//need these 3d curves to prevent "zero edges" later
        BRepLib::BuildCurves3d(visHard);
        BRepLib::BuildCurves3d(visSmooth);
        BRepLib::BuildCurves3d(visSeam);
        BRepLib::BuildCurves3d(visOutline);
        BRepLib::BuildCurves3d(visIso);
        BRepLib::BuildCurves3d(hidHard);
        BRepLib::BuildCurves3d(hidSmooth);
        BRepLib::BuildCurves3d(hidSeam);
        BRepLib::BuildCurves3d(hidOutline);
        BRepLib::BuildCurves3d(hidIso);
    }
    catch (...) {
        Standard_Failure::Raise("GeometryObject::projectShape - error occurred while extracting edges");
    }

}
Beispiel #6
0
CCuboid::CCuboid(const gp_Ax2& pos, double x, double y, double z, const wxChar* title, const HeeksColor& col, float opacity)
:CSolid(BRepPrimAPI_MakeBox(gp_Ax2(pos.Location().XYZ() + gp_XYZ((x < 0) ? x:0.0, (y < 0) ? y:0.0, (z < 0) ? z:0.0), pos.Direction(), pos.XDirection()), fabs(x), fabs(y), fabs(z)), title, col, opacity)
, m_pos(pos), m_x(x), m_y(y), m_z(z)
{
}