Exemple #1
0
void graph2_1::paintEvent(QPaintEvent *)
{
    /***********�����α߿���������**************/
    QPainter *painter=new QPainter(this);
    painter->setRenderHint(QPainter::Antialiasing,true);
    painter->drawRect(10,10,380,230);
    QPoint beginPoint(50,200);
    QPoint xEndPoint(xEndX,xEndY);
    QPoint yEndPoint(yEndX,yEndY);
    painter->drawLine(beginPoint,xEndPoint);
    painter->drawLine(beginPoint,yEndPoint);

    //*****************����������ͷ*********/
    int xOffset=13;
    brush.setColor(Qt::black);
    brush.setStyle(Qt::SolidPattern);
    painter->setBrush(brush);

    QPoint xarrowRightPoint(xEndX+xOffset,xEndY);
    QPoint xarrowTopPoint(xEndX,-xOffset*tan(PI/6)+xEndY);
    QPoint xarrowBotPoint(xEndX,xOffset*tan(PI/6)+xEndY);
    static const QPoint xarrowPoints[3] = {
    xarrowRightPoint,xarrowTopPoint,xarrowBotPoint,
    };
    painter->drawPolygon(xarrowPoints,3);

    QPoint yarrowTopPoint(yEndX,yEndY-xOffset);
    QPoint yarrowRightPoint(xOffset*tan(PI/6)+yEndX,yEndY);
    QPoint yarrowLeftPoint(-xOffset*tan(PI/6)+yEndX,yEndY);
    static const QPoint yarrowPoints[3] = {
    yarrowTopPoint,yarrowLeftPoint,yarrowRightPoint,
    };
    painter->drawPolygon(yarrowPoints,3);
    painter->setBrush(Qt::NoBrush);

    /************��ע������**********/
    painter->drawText(xEndX,xEndY+20,tr("HZ"));
    //painter->rotate(270);
    painter->drawText(yEndY,yEndX+20,tr("dB"));
    //painter->rotate(90);


    /*************************/
    QVector<qreal> dashes;
    qreal space = 3;
    dashes << 5 << space << 5 << space;
    pen.setDashPattern(dashes);
    pen.setWidth(2);
    pen.setColor(Qt::blue);
    painter->setPen(pen);

    QPoint point5(90,200);
    QPoint point6(100,155);
    QPoint point7(250,110);
    QPoint point8(300,80);

    painter->drawPath(drawBezierCurve(point5,point6));
    painter->drawPath(drawBezierCurve(point6,point7));
    painter->drawPath(drawBezierCurve(point7,point8));
}
void MyPrimitive::GenerateTube(float a_fOuterRadius, float a_fInnerRadius, float a_fHeight, int a_nSubdivisions, vector3 a_v3Color)
{
	if (a_nSubdivisions < 3)
		a_nSubdivisions = 3;
	if (a_nSubdivisions > 360)
		a_nSubdivisions = 360;

	Release();
	Init();

	for (int i = 0; i < a_nSubdivisions; i++)
	{
		float ang = (2 * PI) / a_nSubdivisions;

		vector3 point0(a_fOuterRadius*cos((i + 1)*ang), a_fHeight, a_fOuterRadius*sin((i + 1)*ang)); //1
		vector3 point1(a_fOuterRadius*cos(i*ang), 0, a_fOuterRadius*sin(i*ang)); //2
		vector3 point2(a_fOuterRadius*cos(i*ang), a_fHeight, a_fOuterRadius*sin(i*ang)); //0
		vector3 point3(a_fOuterRadius*cos((i + 1)*ang), 0, a_fOuterRadius*sin((i + 1)*ang)); //3

		vector3 point4(a_fInnerRadius*cos((i + 1)*ang), a_fHeight, a_fInnerRadius*sin((i + 1)*ang)); //1
		vector3 point5(a_fInnerRadius*cos(i*ang), 0, a_fInnerRadius*sin(i*ang)); //2
		vector3 point6(a_fInnerRadius*cos(i*ang), a_fHeight, a_fInnerRadius*sin(i*ang)); //0
		vector3 point7(a_fInnerRadius*cos((i + 1)*ang), 0, a_fInnerRadius*sin((i + 1)*ang)); //3

		AddQuad(point4, point0, point6, point2); //Top
		AddQuad(point0, point3, point2, point1); //Outer
		AddQuad(point7, point5, point3, point1); //Bottom
		AddQuad(point5, point7, point6,point4 ); // Inner
		
	}

	//Your code ends here
	CompileObject(a_v3Color);
}
Exemple #3
0
BaseIF* makeVane(const Real&     thick,
                 const RealVect& normal,
                 const Real&     innerRadius,
                 const Real&     outerRadius,
                 const Real&     offset,
                 const Real&     height)
{
  RealVect zero(D_DECL(0.0,0.0,0.0));
  RealVect xAxis(D_DECL(1.0,0.0,0.0));
  bool inside = true;

  Vector<BaseIF*> vaneParts;

  // Each side of the vane (infinite)
  RealVect normal1(normal);
  RealVect point1(D_DECL(offset+height/2.0,-thick/2.0,0.0));
  PlaneIF plane1(normal1,point1,inside);

  vaneParts.push_back(&plane1);

  RealVect normal2(-normal);
  RealVect point2(D_DECL(offset+height/2.0,thick/2.0,0.0));
  PlaneIF plane2(normal2,point2,inside);

  vaneParts.push_back(&plane2);

  // Make sure we only get something to the right of the origin
  RealVect normal3(D_DECL(0.0,0.0,1.0));
  RealVect point3(D_DECL(0.0,0.0,0.0));
  PlaneIF plane3(normal3,point3,inside);

  vaneParts.push_back(&plane3);

  // Cut off the top and bottom
  RealVect normal4(D_DECL(1.0,0.0,0.0));
  RealVect point4(D_DECL(offset,0.0,0.0));
  PlaneIF plane4(normal4,point4,inside);

  vaneParts.push_back(&plane4);

  RealVect normal5(D_DECL(-1.0,0.0,0.0));
  RealVect point5(D_DECL(offset+height,0.0,0.0));
  PlaneIF plane5(normal5,point5,inside);

  vaneParts.push_back(&plane5);

  // The outside of the inner cylinder
  TiltedCylinderIF inner(innerRadius,xAxis,zero,!inside);

  vaneParts.push_back(&inner);

  // The inside of the outer cylinder
  TiltedCylinderIF outer(outerRadius,xAxis,zero,inside);

  vaneParts.push_back(&outer);

  IntersectionIF* vane = new IntersectionIF(vaneParts);

  return vane;
}
void MyPrimitive::GenerateCube(float a_mSize, vector3 a_vColor)
{
	//If the size is less than this make it this large
	if (a_mSize < 0.01f)
		a_mSize = 0.01f;

	//Clean up Memory
	Release();
	Init();

	float fValue = 0.5f * a_mSize;
	//3--2
	//|  |
	//0--1
	vector3 point0(-fValue, -fValue, fValue); //0
	vector3 point1(fValue, -fValue, fValue); //1
	vector3 point2(fValue, fValue, fValue); //2
	vector3 point3(-fValue, fValue, fValue); //3

	//7--6
	//|  |
	//4--5
	vector3 point4(-fValue, -fValue, -fValue); //4
	vector3 point5(fValue, -fValue, -fValue); //5
	vector3 point6(fValue, fValue, -fValue); //6
	vector3 point7(-fValue, fValue, -fValue); //7

	//F
	AddQuad(point0, point1, point3, point2);

	//B
	AddQuad(point5, point4, point6, point7);

	//L
	AddQuad(point4, point0, point7, point3);

	//R
	AddQuad(point1, point5, point2, point6);

	//U
	AddQuad(point3, point2, point7, point6);

	//D
	AddQuad(point4, point5, point0, point1);

	//Compile the object in this color and assign it this name
	CompileObject(a_vColor);
}
void MyPrimitive::GenerateCube(float a_fSize, vector3 a_v3Color)
{
	if (a_fSize < 0.01f)
		a_fSize = 0.01f;

	Release();
	Init();

	float fValue = 0.5f * a_fSize;
	//3--2
	//|  |
	//0--1
	vector3 point0(-fValue, -fValue, fValue); //0
	vector3 point1(fValue, -fValue, fValue); //1
	vector3 point2(fValue, fValue, fValue); //2
	vector3 point3(-fValue, fValue, fValue); //3

	vector3 point4(-fValue, -fValue, -fValue); //4
	vector3 point5(fValue, -fValue, -fValue); //5
	vector3 point6(fValue, fValue, -fValue); //6
	vector3 point7(-fValue, fValue, -fValue); //7

											  //F
	AddQuad(point0, point1, point3, point2);

	//B
	AddQuad(point5, point4, point6, point7);

	//L
	AddQuad(point4, point0, point7, point3);

	//R
	AddQuad(point1, point5, point2, point6);

	//U
	AddQuad(point3, point2, point7, point6);

	//D
	AddQuad(point4, point5, point0, point1);

	CompileObject(a_v3Color);
}
void MyPrimitive::GenerateCylinder(float a_fRadius, float a_fHeight, int a_nSubdivisions, vector3 a_v3Color)
{
	if (a_nSubdivisions < 3)
		a_nSubdivisions = 3;
	if (a_nSubdivisions > 360)
		a_nSubdivisions = 360;

	Release();
	Init();

	//Your code starts here
	float fValue = 0.5f;
	//3--2
	//|  |
	//0--1
	//vector3 point0(-fValue, -fValue, fValue); //0
	//vector3 point1(fValue, -fValue, fValue); //1
	//vector3 point2(fValue, fValue, fValue); //2
	//vector3 point3(-fValue, fValue, fValue); //3
	//
	//AddQuad(point0, point1, point3, point2);
		vector3 point0(0, 0, 0); 
		vector3 point1(0, a_fHeight, 0); 
	for (int i = 0; i < a_nSubdivisions; i++)
	{
		float ang = (2 * PI) / a_nSubdivisions;

		
		vector3 point2(a_fRadius*cos(i*ang), 0, a_fRadius*sin(i*ang)); //0
		vector3 point3(a_fRadius*cos((i + 1)*ang), 0, a_fRadius*sin((i + 1)*ang)); //3


		vector3 point4(a_fRadius*cos(i*ang), a_fHeight, a_fRadius*sin(i*ang)); //0
		vector3 point5(a_fRadius*cos((i + 1)*ang), a_fHeight, a_fRadius*sin((i + 1)*ang)); //3

		AddQuad(point1, point3, point2, point4);
		AddQuad(point1, point4, point5, point3);
	}
	//Your code ends here
	CompileObject(a_v3Color);
}
void MyPrimitive::GenerateSphere(float a_fRadius, int a_nSubdivisions, vector3 a_v3Color)
{
	//Sets minimum and maximum of subdivisions
	if (a_nSubdivisions < 1)
	{
		GenerateCube(a_fRadius * 2, a_v3Color);
		return;
	}
	if (a_nSubdivisions > 6)
		a_nSubdivisions = 6;

	Release();
	Init();

	//Your code starts here
	float a_fHeight;
	vector3 point0(0, 0, 0);
	vector3 point1(0, a_fHeight, 0);
	for (int i = 0; i < a_nSubdivisions; i++)
	{
		float ang = (2 * PI) / a_nSubdivisions;


		vector3 point2(a_fRadius*cos(i*ang), 0, a_fRadius*sin(i*ang)); //0
		vector3 point3(a_fRadius*cos((i + 1)*ang), 0, a_fRadius*sin((i + 1)*ang)); //3


		vector3 point4(a_fRadius*cos(i*ang), a_fHeight, a_fRadius*sin(i*ang)); //0
		vector3 point5(a_fRadius*cos((i + 1)*ang), a_fHeight, a_fRadius*sin((i + 1)*ang)); //3

		AddQuad(point1, point3, point2, point4);
		AddQuad(point1, point4, point5, point3);
	}



	//Your code ends here
	CompileObject(a_v3Color);
}
BaseIF* makeVane(const Real&     thick,
                 const RealVect& normal,
                 const Real&     innerRadius,
                 const Real&     outerRadius,
                 const Real&     offset,
                 const Real&     height,
                 const Real&     angle)
{
  RealVect zeroVect(D_DECL(0.0,0.0,0.0));
  RealVect xAxis(D_DECL(1.0,0.0,0.0));
  bool inside = true;

  Vector<BaseIF*> vaneParts;

  Real sinTheta = sin(angle);
#if CH_SPACEDIM == 3
  Real cosTheta = cos(angle);

  // Each side of the vane (infinite)
  // rotate the normal around x-axis
  RealVect normal1(D_DECL(normal[0],cosTheta*normal[1]-sinTheta*normal[2],sinTheta*normal[1]+cosTheta*normal[2]));
  // rotate point on top of vane around x-axis
  RealVect point(D_DECL(offset+height/2.0,-thick/2.0,0.0));
  RealVect point1(D_DECL(point[0],cosTheta*point[1]-sinTheta*point[2],sinTheta*point[1]+cosTheta*point[2]));
  PlaneIF plane1(normal1,point1,inside);

  vaneParts.push_back(&plane1);

  RealVect normal2(-normal1);
  // rotate point on bottom (-point[2] of vane around x-axis
  RealVect point2(D_DECL(point[0],-cosTheta*point[1]-sinTheta*point[2],-sinTheta*point[1]+cosTheta*point[2]));
  PlaneIF plane2(normal2,point2,inside);

  vaneParts.push_back(&plane2);
#endif

  // Make sure we only get something to the right of the origin
  RealVect normal3(D_DECL(0.0,-sinTheta,cosTheta));
  RealVect point3(D_DECL(0.0,0.0,0.0));
  PlaneIF plane3(normal3,point3,inside);

  vaneParts.push_back(&plane3);

  // Cut off the top and bottom
  RealVect normal4(D_DECL(1.0,0.0,0.0));
  RealVect point4(D_DECL(offset,0.0,0.0));
  PlaneIF plane4(normal4,point4,inside);

  vaneParts.push_back(&plane4);

  RealVect normal5(D_DECL(-1.0,0.0,0.0));
  RealVect point5(D_DECL(offset+height,0.0,0.0));
  PlaneIF plane5(normal5,point5,inside);

  vaneParts.push_back(&plane5);

  // The outside of the inner cylinder
  TiltedCylinderIF inner(innerRadius,xAxis,zeroVect,!inside);

  vaneParts.push_back(&inner);

  // The inside of the outer cylinder
  TiltedCylinderIF outer(outerRadius,xAxis,zeroVect,inside);

  vaneParts.push_back(&outer);

  IntersectionIF* vane = new IntersectionIF(vaneParts);

  return vane;
}
BOOL ray_prism(const LLVector3 &ray_point, const LLVector3 &ray_direction,
               const LLVector3 &prism_center, const LLVector3 &prism_scale, const LLQuaternion &prism_rotation,
               LLVector3 &intersection, LLVector3 &intersection_normal)
{
    //      (0)              Z
    //      /| \             .
    //    (1)|  \           /|\  _.Y
    //     | \   \           |   /|
    //     | |\   \          |  /
    //     | | \(0)\         | /
    //     | |  \   \        |/
    //     | |   \   \      (*)----> X
    //     |(3)---\---(2)
    //     |/      \  /
    //    (4)-------(5)

    // need to calculate the points of the prism so we can run ray tests with each face
    F32 x = prism_scale.mV[VX];
    F32 y = prism_scale.mV[VY];
    F32 z = prism_scale.mV[VZ];

    F32 tx = x * 2.0f / 3.0f;
    F32 ty = y * 0.5f;
    F32 tz = z * 2.0f / 3.0f;

    LLVector3 point0(tx-x,  ty, tz);
    LLVector3 point1(tx-x, -ty, tz);
    LLVector3 point2(tx,    ty, tz-z);
    LLVector3 point3(tx-x,  ty, tz-z);
    LLVector3 point4(tx-x, -ty, tz-z);
    LLVector3 point5(tx,   -ty, tz-z);

    // transform these points into absolute frame
    point0 = (point0 * prism_rotation) + prism_center;
    point1 = (point1 * prism_rotation) + prism_center;
    point2 = (point2 * prism_rotation) + prism_center;
    point3 = (point3 * prism_rotation) + prism_center;
    point4 = (point4 * prism_rotation) + prism_center;
    point5 = (point5 * prism_rotation) + prism_center;

    // test ray intersection for each face
    BOOL b_hit = FALSE;
    LLVector3 face_intersection, face_normal;
    F32 distance_squared = 0.0f;
    F32 temp;

    // face 0
    if (ray_direction * ( (point0 - point2) % (point5 - point2)) < 0.0f  &&
            ray_quadrangle(ray_point, ray_direction, point5, point2, point0, intersection, intersection_normal))
    {
        distance_squared = (ray_point - intersection).magVecSquared();
        b_hit = TRUE;
    }

    // face 1
    if (ray_direction * ( (point0 - point3) % (point2 - point3)) < 0.0f  &&
            ray_triangle(ray_point, ray_direction, point2, point3, point0, face_intersection, face_normal))
    {
        if (TRUE == b_hit)
        {
            temp = (ray_point - face_intersection).magVecSquared();
            if (temp < distance_squared)
            {
                distance_squared = temp;
                intersection = face_intersection;
                intersection_normal = face_normal;
            }
        }
        else
        {
            distance_squared = (ray_point - face_intersection).magVecSquared();
            intersection = face_intersection;
            intersection_normal = face_normal;
            b_hit = TRUE;
        }
    }

    // face 2
    if (ray_direction * ( (point1 - point4) % (point3 - point4)) < 0.0f  &&
            ray_quadrangle(ray_point, ray_direction, point3, point4, point1, face_intersection, face_normal))
    {
        if (TRUE == b_hit)
        {
            temp = (ray_point - face_intersection).magVecSquared();
            if (temp < distance_squared)
            {
                distance_squared = temp;
                intersection = face_intersection;
                intersection_normal = face_normal;
            }
        }
        else
        {
            distance_squared = (ray_point - face_intersection).magVecSquared();
            intersection = face_intersection;
            intersection_normal = face_normal;
            b_hit = TRUE;
        }
    }

    // face 3
    if (ray_direction * ( (point5 - point4) % (point1 - point4)) < 0.0f  &&
            ray_triangle(ray_point, ray_direction, point1, point4, point5, face_intersection, face_normal))
    {
        if (TRUE == b_hit)
        {
            temp = (ray_point - face_intersection).magVecSquared();
            if (temp < distance_squared)
            {
                distance_squared = temp;
                intersection = face_intersection;
                intersection_normal = face_normal;
            }
        }
        else
        {
            distance_squared = (ray_point - face_intersection).magVecSquared();
            intersection = face_intersection;
            intersection_normal = face_normal;
            b_hit = TRUE;
        }
    }

    // face 4
    if (ray_direction * ( (point4 - point5) % (point2 - point5)) < 0.0f  &&
            ray_quadrangle(ray_point, ray_direction, point2, point5, point4, face_intersection, face_normal))
    {
        if (TRUE == b_hit)
        {
            temp = (ray_point - face_intersection).magVecSquared();
            if (temp < distance_squared)
            {
                distance_squared = temp;
                intersection = face_intersection;
                intersection_normal = face_normal;
            }
        }
        else
        {
            distance_squared = (ray_point - face_intersection).magVecSquared();
            intersection = face_intersection;
            intersection_normal = face_normal;
            b_hit = TRUE;
        }
    }

    return b_hit;
}
extern Features::StudioSpline* CreateStudioSplineByPoints(Features::PointFeature *pointFeature1, Features::PointFeature *pointFeature2, Features::PointFeature *pointFeature3)
{
	Session *theSession = Session::GetSession();
	Part *workPart(theSession->Parts()->Work());

	NXObject *nullNXObject(NULL);

	Features::StudioSplineBuilderEx *studioSplineBuilderEx1;
	studioSplineBuilderEx1 = workPart->Features()->CreateStudioSplineBuilderEx(nullNXObject);

	// ----------------------------------------------
	//   Dialog Begin Point
	// ----------------------------------------------    
	Point *point1(dynamic_cast<Point *>(pointFeature1->FindObject("POINT 1")));
	Xform *nullXform(NULL);
	Point *point2;
	point2 = workPart->Points()->CreatePoint(point1, nullXform, SmartObject::UpdateOptionWithinModeling);

	Features::GeometricConstraintData *geometricConstraintData1;
	geometricConstraintData1 = studioSplineBuilderEx1->ConstraintManager()->CreateGeometricConstraintData();

	geometricConstraintData1->SetPoint(point2);

	studioSplineBuilderEx1->ConstraintManager()->Append(geometricConstraintData1);

	studioSplineBuilderEx1->Evaluate();

	// ----------------------------------------------
	//   Dialog Begin Point
	// ----------------------------------------------
	Point *point3(dynamic_cast<Point *>(pointFeature2->FindObject("POINT 1")));
	Point *point4;
	point4 = workPart->Points()->CreatePoint(point3, nullXform, SmartObject::UpdateOptionWithinModeling);

	Features::GeometricConstraintData *geometricConstraintData2;
	geometricConstraintData2 = studioSplineBuilderEx1->ConstraintManager()->CreateGeometricConstraintData();

	geometricConstraintData2->SetPoint(point4);

	studioSplineBuilderEx1->ConstraintManager()->Append(geometricConstraintData2);

	studioSplineBuilderEx1->Evaluate();

	// ----------------------------------------------
	//   Dialog Begin Point
	// ----------------------------------------------
	Point *point5(dynamic_cast<Point *>(pointFeature3->FindObject("POINT 1")));
	Point *point6;
	point6 = workPart->Points()->CreatePoint(point5, nullXform, SmartObject::UpdateOptionWithinModeling);

	Features::GeometricConstraintData *geometricConstraintData3;
	geometricConstraintData3 = studioSplineBuilderEx1->ConstraintManager()->CreateGeometricConstraintData();

	geometricConstraintData3->SetPoint(point6);

	studioSplineBuilderEx1->ConstraintManager()->Append(geometricConstraintData3);

	studioSplineBuilderEx1->Evaluate();

	NXObject *nXObject1;
	nXObject1 = studioSplineBuilderEx1->Commit();

	studioSplineBuilderEx1->Destroy();

	return (Features::StudioSpline*)nXObject1;
}
Exemple #11
0
void execute(char *cmdline, char **argv)
{
  char *cmd = cmdline;
  if(strlen(cmd) > 4)
  {
    if(strncmp(cmd, "res=", 4)==0)
    {
      point5(cmdline);
      return;
    }
  }

  if(strlen(cmdline)<=0)
    return;

  // 0 for stdout; 1 for redirect; 2 for pipeline
  int out_type = 0;

  char *childcmd[2];
  childcmd[0] = cmdline;

  while(*cmdline != '>' && *cmdline != '|' &&
      *cmdline != '$' &&
      *cmdline != '\0' && *cmdline != '\n')
  {
    cmdline++;
  }
  if(*cmdline=='>')
  {
    out_type = 1;
    *cmdline++ = '\0';
    childcmd[1] = cmdline;
  }
  else if(*cmdline=='|')
  {
    out_type = 2;
    *cmdline++ = '\0';
    childcmd[1] = cmdline;
  }
  else if(*cmdline=='$')
  {
    if(strncmp(cmdline, "$(", 2)==0)
    {
      out_type = 3;
      *cmdline++ = '\0';
      childcmd[1] = cmdline;
    }
  }

  int n = strlen(childcmd[0]) - 1;
  while(n>0)
  {
    if(childcmd[0][n]==' ')
    {
      childcmd[0][n]='\0';
    }
    else
      break;
    n--;
  }

  while(*childcmd[1] != '\0')
  {
    if(*childcmd[1]==' ')
      childcmd[1]++;
    else
      break;
  }

  parse_cmdline(childcmd[0], argv);

  int ret = handle_builtin(argv);
  if(ret==0)
    return;

  pid_t childpid;
  int status, options = 0;

  childpid = fork();
  if (childpid == -1)
  {
    perror("Cannot proceed. fork() error");
    exit(1);
  }
  else if (childpid == 0)
  {
    // This is child's process.
    if(out_type==0)
    {
      childexec(argv);
    }
    else if(out_type==1)
    {// output redirection here
      int fd;
      close(STDOUT);
      fd = open(childcmd[1], O_APPEND);
      if(fd<0)
      {
        fd = creat(childcmd[1], 0666);
        if(fd<0)
        {
          perror("create file failed");
          exit(-1);
        }
      }
      dup(fd);
      childexec(argv);
      close(fd);
    }
    else if(out_type==2)
    {// pipeline here
      int fd[2];
      pipe(&fd[0]);
      if(fork()!=0)
      {
        close(fd[0]);
        close(STDOUT);
        dup(fd[1]);
        childexec(argv);
        close(fd[1]);
      }
      else
      {
        close(fd[1]);
        close(STDIN);
        dup(fd[0]);
        parse_cmdline(childcmd[1], argv);
        childexec(argv);
        close(fd[0]);
      }
      puts("\n");
    }
    else if(out_type==3)
    {
      childcmd[1]++;
      size_t len = strlen(childcmd[1]);
      childcmd[1][len-1] = '\0';

      printf("childcmd[0]:%s\n", childcmd[0]);
      printf("childcmd[1]:%s\n", childcmd[1]);

      int fd[2];
      pipe(fd);
      if(fork()!=0)
      {
        close(fd[1]);
        close(STDIN);
        dup(fd[0]);
        childexecline(childcmd[0]);
        close(fd[0]);
      }
      else
        exec_pipelines(childcmd[1], fd,argv);
      /*
      parse_cmdline(childcmd[1], argv);

      int fd[2];
      pipe(&fd[0]);
      if(fork()!=0)
      {
        close(fd[0]);
        close(STDOUT);
        dup(fd[1]);
        childexec(argv);
        close(fd[1]);
      }
      else
      {
        close(fd[1]);
        close(STDIN);
        dup(fd[0]);
        parse_cmdline(childcmd[0], argv);
        childexec(argv);
        close(fd[0]);
      }
      */
      puts("\n");
    }
  }
  else
  {
    waitpid(childpid, &status, options);
    if (!WIFEXITED(status))
      printf("Parent: child has not terminated normally.\n");
  }
}