EDF 2281 : code refactoring and first steps for a second constructor of the divided disk

This commit is contained in:
rnc 2012-07-19 16:06:35 +00:00
parent 871b694188
commit 91343094ce
3 changed files with 202 additions and 158 deletions

View File

@ -86,13 +86,40 @@ Standard_Integer GEOMImpl_DividedDiskDriver::Execute(TFunction_Logbook& log) con
TopoDS_Shape aShape; TopoDS_Shape aShape;
if (aType == DIVIDEDDISK_R_RATIO) {
// Getting data // Getting data
double R = aData.GetR(); double R = aData.GetR();
double Ratio = aData.GetRatio(); double Ratio = aData.GetRatio();
int theOrientation = aData.GetOrientation();
// Build reference disk (in the global coordinate system)
TopoDS_Shell S = MakeDisk( R, Ratio );
if (aType == DIVIDEDDISK_R_RATIO) {
int theOrientation = aData.GetOrientation();
aShape = TransformShape(S, theOrientation);
}
else if (aType == DIVIDEDDISK_R_VECTOR_PNT){
// other construction modes here
gp_Pnt P = gp::Origin();
gp_Dir V = gp::DZ();
aShape = TransformShape(S, P, V);
}
if (aShape.IsNull()) return 0;
aFunction->SetValue(aShape);
log.SetTouched(Label());
return 1;
}
//=======================================================================
//function : MakeDisk
//purpose :
//=======================================================================
TopoDS_Shell GEOMImpl_DividedDiskDriver::MakeDisk(double R, double Ratio) const
{
// Geometry // Geometry
gp_Dir ZDir(0,0,1); gp_Dir ZDir(0,0,1);
gp_Dir XDir(1,0,0); gp_Dir XDir(1,0,0);
@ -238,27 +265,15 @@ Standard_Integer GEOMImpl_DividedDiskDriver::Execute(TFunction_Logbook& log) con
E8=E9; E8=E9;
} }
aShape = TransformShape(S, theOrientation); return S;
}
else {
// other construction modes here
}
if (aShape.IsNull()) return 0;
aFunction->SetValue(aShape);
log.SetTouched(Label());
return 1;
} }
//======================================================================= //=======================================================================
//function : TrasformShape(int theOrientation) //function : TrasformShape(TopoDS_Shape aShape,int theOrientation)
//purpose : Perform shape transformation accordingly with specified //purpose : Perform shape transformation accordingly with specified
// orientation // orientation
//======================================================================= //=======================================================================
TopoDS_Shape GEOMImpl_DividedDiskDriver::TransformShape(TopoDS_Shape aShape, int theOrientation) const TopoDS_Shape GEOMImpl_DividedDiskDriver::TransformShape(TopoDS_Shape theShape, int theOrientation) const
{ {
gp_Dir N, Vx; gp_Dir N, Vx;
gp_Pnt theOrigin = gp::Origin(); gp_Pnt theOrigin = gp::Origin();
@ -287,10 +302,31 @@ TopoDS_Shape GEOMImpl_DividedDiskDriver::TransformShape(TopoDS_Shape aShape, int
gp_Ax3 aWPlane = gp_Ax3(theOrigin, N, Vx); gp_Ax3 aWPlane = gp_Ax3(theOrigin, N, Vx);
return WPlaneTransform(theShape, aWPlane);
}
//=======================================================================
//function : TrasformShape(TopoDS_Shape aShape, gp_Dir V, gp_Pnt P)
//purpose : Perform shape transformation accordingly with specified
// pnt and direction
//=======================================================================
TopoDS_Shape GEOMImpl_DividedDiskDriver::TransformShape(TopoDS_Shape theShape, gp_Pnt P, gp_Dir V) const
{
gp_Ax3 aWPlane( P, V );
return WPlaneTransform(theShape, aWPlane);
}
//=======================================================================
//function : WPlaneTransform
//purpose : Perform shape transformation accordingly with the given
// Working Plane
//=======================================================================
TopoDS_Shape GEOMImpl_DividedDiskDriver::WPlaneTransform(TopoDS_Shape theShape, gp_Ax3 theWPlane) const
{
gp_Trsf aTrans; gp_Trsf aTrans;
aTrans.SetTransformation(aWPlane); aTrans.SetTransformation(theWPlane);
aTrans.Invert(); aTrans.Invert();
BRepBuilderAPI_Transform aTransformation (aShape, aTrans, Standard_False); BRepBuilderAPI_Transform aTransformation (theShape, aTrans, Standard_False);
return aTransformation.Shape(); return aTransformation.Shape();
} }

View File

@ -27,6 +27,10 @@
class Handle_Standard_Type; class Handle_Standard_Type;
class GEOMImpl_DividedDiskDriver; class GEOMImpl_DividedDiskDriver;
class TopoDS_Shape; class TopoDS_Shape;
class TopoDS_Shell;
class gp_Pnt;
class gp_Dir;
class gp_Ax3;
Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_DividedDiskDriver); Standard_EXPORT Handle_Standard_Type& STANDARD_TYPE(GEOMImpl_DividedDiskDriver);
@ -120,6 +124,9 @@ public:
private: private:
TopoDS_Shape TransformShape (TopoDS_Shape aShape, int theOrientation) const; TopoDS_Shape TransformShape (TopoDS_Shape aShape, int theOrientation) const;
TopoDS_Shape TransformShape (TopoDS_Shape aShape, gp_Pnt P, gp_Dir V) const;
TopoDS_Shape WPlaneTransform (TopoDS_Shape aShape, gp_Ax3 theWPlane) const;
TopoDS_Shell MakeDisk (double R, double Ratio) const;
}; };
#endif // _GEOMImpl_DividedDiskDriver_HXX #endif // _GEOMImpl_DividedDiskDriver_HXX

View File

@ -337,5 +337,6 @@
#define TSHAPE_CHAMFER 2 #define TSHAPE_CHAMFER 2
#define TSHAPE_FILLET 3 #define TSHAPE_FILLET 3
#define DIVIDEDDISK_R_RATIO 1 #define DIVIDEDDISK_R_RATIO 1
#define DIVIDEDDISK_R_VECTOR_PNT 2
#define DIVIDEDCYLINDER_R_H 1 #define DIVIDEDCYLINDER_R_H 1
/*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/ /*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/