TopoDS_Shape CreateRectangle::executeCreation() const
	{
		try
		{
			gp_Pnt pt1(point);
			gp_Pnt pt2(point.X() + width, point.Y(), point.Z());
			gp_Pnt pt3(point.X() + width, point.Y() + height, point.Z());
			gp_Pnt pt4(point.X(), point.Y() + height, point.Z());

			Handle(Geom_TrimmedCurve) segment1 = GC_MakeSegment(pt1, pt2);
			Handle(Geom_TrimmedCurve) segment2 = GC_MakeSegment(pt2, pt3);
			Handle(Geom_TrimmedCurve) segment3 = GC_MakeSegment(pt3, pt4);
			Handle(Geom_TrimmedCurve) segment4 = GC_MakeSegment(pt4, pt1);

			TopoDS_Edge edge1 = BRepBuilderAPI_MakeEdge(segment1);
			TopoDS_Edge edge2 = BRepBuilderAPI_MakeEdge(segment2);
			TopoDS_Edge edge3 = BRepBuilderAPI_MakeEdge(segment3);
			TopoDS_Edge edge4 = BRepBuilderAPI_MakeEdge(segment4);

			TopoDS_Wire wire  = BRepBuilderAPI_MakeWire(edge1 , edge2 , edge3, edge4);

			BRepBuilderAPI_MakeFace makeFace(wire);
			return makeFace.Shape();
		}
		catch(const StdFail_NotDone& ex)
		{
			throw Common::Exception(QObject::tr("Create rectangle error"));
		}
	}
示例#2
0
people::people(QWidget *parent):QWidget(parent){
    ui.setupUi(this);
    ui.groupBox_card->hide();
    ui.tableWidget_people->setColumnHidden(0, true);
    ui.tableWidget_people->setColumnHidden(2, true);
    id = 0;
    crow = 0;

    load();

    connect(ui.toolButton_add, SIGNAL(clicked()), this, SLOT(add()));
    connect(ui.tableWidget_people, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(edit()));
    connect(ui.pushButton_close, SIGNAL(clicked()), ui.groupBox_card, SLOT(hide()));
    connect(ui.pushButton_save, SIGNAL(clicked()), this, SLOT(save()));
    connect(ui.toolButton_del, SIGNAL(clicked()), this, SLOT(del()));

    connect(ui.lineEdit_fam, SIGNAL(textEdited(QString)), this, SLOT(makeFace()));
    connect(ui.lineEdit_name, SIGNAL(textEdited(QString)), this, SLOT(makeFace()));
    connect(ui.lineEdit_otc, SIGNAL(textEdited(QString)), this, SLOT(makeFace()));
}
示例#3
0
void Subdivision::initMesh(const Vec2& A,const Vec2& B,
			   const Vec2& C,const Vec2& D)
{
    Vec2& a = A.clone();
    Vec2& b = B.clone();
    Vec2& c = C.clone();
    Vec2& d = D.clone();

    Edge *ea = makeEdge();
    ea->EndPoints(a, b);

    Edge *eb = makeEdge();
    splice(ea->Sym(), eb);
    eb->EndPoints(b, c);

    Edge *ec = makeEdge();
    splice(eb->Sym(), ec);
    ec->EndPoints(c, d);

    Edge *ed = makeEdge();
    splice(ec->Sym(), ed);
    ed->EndPoints(d, a);
    splice(ed->Sym(), ea);

    Edge *diag = makeEdge();
    splice(ed->Sym(),diag);
    splice(eb->Sym(),diag->Sym());
    diag->EndPoints(a,c);

    startingEdge = ea;

    first_face = NULL;

    makeFace(ea->Sym()).update(*this);
    makeFace(ec->Sym()).update(*this);

}
示例#4
0
文件: Grid.hpp 项目: uzgoren/girdap
  Block2(Vec3 n1, Vec3 n2, int_4 nx, int_4 ny):Grid(nx*ny*4) {  
    Vec3 del = (n2 - n1);  
    addVertex({
	 {n1[0], n1[1], n1[2]}
	,{n2[0], n1[1], n1[2]} 
	,{n2[0], n2[1], n1[2]} 
	,{n1[0], n2[1], n1[2]}
      }); 
    addCell({0,1,2,3});
    (*listCell.rbegin())->convertToSimpleBlock({nx,ny}); 
    setCurrentLevels(); 
    makeFace(); 
    //setQuadBoundary(); 
    cout << "Block2: Cells: " << listCell.size(); 
    cout << " Faces: " << nFace << endl; 
    addVec("u"); 
  }
示例#5
0
// Generate Triangles
void Brush::GenerateTriangles()
{
	Triangles.ClearDelete();

	vec2 curTex;
	vec3 curPosition;
	float textureSize = 0.2f;

	for (int i = 0; i < 8; i++)
		{
			curPosition = Position;
			if((i & 1) == 0) curPosition.x += Size.x;
			if((i & 2) == 0) curPosition.y += Size.y;
			if((i & 4) == 0) curPosition.z += Size.z;

			//brushIndices[i] = mapPositionDataLength;
			//mapPositionBuffer[mapPositionDataLength++] = curPos;

			brushPositions[i] = curPosition;

			//Generate Texture Coords
			for (int j = 0; j < 3; j++)
			{
				switch (j)
				{
				case 0:
					curTex = vec2(curPosition.x*textureSize,curPosition.z*textureSize);
					break;
				case 1:
					curTex = vec2(curPosition.x*textureSize,curPosition.y*textureSize);
					break;
				case 2:
					curTex = vec2(curPosition.z*textureSize,curPosition.y*textureSize);
					break;
				}

				//TextureIndices[i+j*8] = mapTextureDataLength;
				//mapTextureBuffer[mapTextureDataLength++] = curTex;

				brushTextureCoords[i+j*8] = curTex;
			}
		}

		//Tris
		makeFace(0,1,2,3,1);
		makeFace(5,4,7,6,1);

		makeFace(1,0,5,4,0);
		makeFace(2,3,6,7,0);

		makeFace(0,2,4,6,2);
		makeFace(3,1,7,5,2);
}
示例#6
0
std::vector<TopoDS_Face> TopoDSFaceAdaptor(
	std::vector<std::pair<CompoundSegment*,std::vector<CompoundSegment*> > > &data)
{
	std::vector<TopoDS_Face> faces;
	std::vector<std::pair<TopoDS_Wire,std::vector<TopoDS_Wire> > > wires;
	wires = TopoDSWireAdaptor(data);

	for(unsigned i=0; i < wires.size(); i++)
	{
		BRepBuilderAPI_MakeFace makeFace(wires[i].first);
		for(unsigned j=0; j < wires[i].second.size(); j++)
			makeFace.Add(wires[i].second[j]);

		faces.push_back(makeFace.Face());
	}

	return faces;
}
示例#7
0
文件: Grid.hpp 项目: htphuc/girdap
  Block2(initializer_list<double> n1, initializer_list<double > n2, int_4 nx, int_4 ny):Grid() {  
    Vec3 node1 = n1; 
    Vec3 node2 = n2; 
    Vec3 del = (node2 - node1);  
    meanD = min(del[0]/double(nx), del[1]/double(ny)); 
    addVertex({
	 {node1[0], node1[1], node1[2]}
	,{node2[0], node1[1], node1[2]} 
	,{node2[0], node2[1], node1[2]} 
	,{node1[0], node2[1], node1[2]}
      }); 
    addCell({0,1,2,3});
    (*listCell.rbegin())->convertToSimpleBlock({nx,ny}); 
    setCurrentLevels(); 
    makeFace(); 
    //setQuadBoundary(); 
    cout << "Block2: Cells: " << listCell.size(); 
    cout << " Faces: " << nFace << endl; 
    addVec("u"); //, "v", "w"});
  }
void ObjModel::processOBJLine(char line[MAX_OBJ_LINE_LEN])	{
	char *token;
	char linecpy[256];

	vector<float> tmpV;
	vector<float> tmpVT;
	vector<float> tmpVN;

	strcpy(linecpy, line);

	token = strtok(line, WHITESPACE);

	if( token == NULL )
		return;

	if( !strcmp(token, "v") )	{
		vec3_t input;
		sscanf(linecpy, "v %f %f %f", &input[0], &input[1], &input[2]);
		tmpV.push_back(input[0]);
		tmpV.push_back(input[1]);
		tmpV.push_back(input[2]);
		v.push_back(tmpV);
		// do bounding box check
		doMaxCheck(input[0], 'x');
		doMaxCheck(input[1], 'y');
		doMaxCheck(input[2], 'z');
	}
	else if( !strcmp(token, "vt") )	{
		vec2_t input;
		sscanf(linecpy, "vt %f %f", &input[0], &input[1]);
		tmpVT.push_back(input[0]);
		tmpVT.push_back(input[1]);
		vt.push_back(tmpVT);
	}
	else if( !strcmp(token, "vn") )	{
		vec3_t input;
		sscanf(linecpy, "vn %f %f %f", &input[0],& input[1], &input[2]);
		tmpVN.push_back(input[0]);
		tmpVN.push_back(input[1]);
		tmpVN.push_back(input[2]);
		vn.push_back(tmpVN);
	}
	else if( !strcmp(token, "f") )	{
		bool hasTex = false;

		// check face for textures
		if( !strstr(linecpy, "//") )	// if we don't find "//", then we have textures
			hasTex = true;

		switch(countCharOccur(linecpy, '/'))	{
			case 6:	// Polygons with 3 points
				vec3_t face[3];

				if( hasTex )	{
					sscanf(linecpy, "f %f/%f/%f %f/%f/%f %f/%f/%f",
							&face[0][0], &face[0][1], &face[0][2],
							&face[1][0], &face[1][1], &face[1][2],
							&face[2][0], &face[2][1], &face[2][2]);
				}
				else	{
					sscanf(linecpy, "f %f//%f %f//%f %f//%f",
							&face[0][0], &face[0][2],
							&face[1][0], &face[1][2],
							&face[2][0], &face[2][2]);

					// set to -1 so if we even try to index
					// we'll get an out of bounds here instead of
					// indexing the 0th place
					face[0][1] = -1;
					face[1][1] = -1;
					face[2][1] = -1;
				}

#ifdef OBJDEBUG
				cout << "3 pointed polygon (makeFace())" << endl;
				VectorPrint(face[0]);
				VectorPrint(face[1]);
				VectorPrint(face[2]);
				cout << "\n------------------------------" << endl;
#endif

				makeFace(face, 3, hasTex);
				break;

			case 8:	// Polygons with 4 points
				vec3_t sface[4];

				if( hasTex )	{
					sscanf(linecpy, "f %f/%f/%f %f/%f/%f %f/%f/%f %f/%f/%f",
						&sface[0][0], &sface[0][1], &sface[0][2],
						&sface[1][0], &sface[1][1], &sface[1][2],
						&sface[2][0], &sface[2][1], &sface[2][2],
						&sface[3][0], &sface[3][1], &sface[3][2]);

				}
				else	{
					sscanf(linecpy, "f %f//%f %f//%f %f//%f %f//%f",
							&sface[0][0], &sface[0][2],
							&sface[1][0], &sface[1][2],
							&sface[2][0], &sface[2][2],
							&sface[3][0], &sface[3][2]);


					// set to -1 so if we even try to index
					// we'll get an out of bounds here instead of
					// indexing the 0th place
					sface[0][1] = -1;
					sface[1][1] = -1;
					sface[2][1] = -1;
					sface[3][1] = -1;
				}

#ifdef OBJDEBUG
				cout << "4 pointed polygon (makeFace())" << endl;
				VectorPrint(sface[0]);
				VectorPrint(sface[1]);
				VectorPrint(sface[2]);
				VectorPrint(sface[3]);
				cout << "\n------------------------------" << endl;
#endif

				makeFace(sface, 4, hasTex);
				break;
		}
	}
	else if( !strcmp(token, "s") )	{
		// TODO Find out what this does
		// argument to this token is a string
		// "on" or "off" it appears.
	}
	else if( !strcmp(token, "usemtl") )	{
		token = strtok(NULL, WHITESPACE);
		strcpy(curMat, token);
	}
	else if( !strcmp( token, "mtllib") )	{
		token = strtok(NULL, WHITESPACE);
		loadMTLFile(token);
	}
	else if( !strcmp( token, "o") )	{
		// TODO implement face associate with an "object"
	}
	else	{
		cout << "Unrecognized OBJ Token: " << token << endl;
	}
}
示例#9
0
Edge *Subdivision::spoke(Vec2& x, Edge *e)
{
    Triangle *new_faces[4];
    int facedex = 0;

    //
    // NOTE: e is the edge returned by locate(x)
    //

    if ( (x == e->Org()) || (x == e->Dest()) ) {
        // point is already in the mesh
	//
#ifdef _INC_IOSTREAM
        std::cerr << "WARNING: Tried to reinsert point: " << x << std::endl;
	std::cerr << "         org: " << e->Org() << std::endl;
	std::cerr << "        dest: " << e->Dest() << std::endl;
#endif
        return NULL;
    }

    Edge *boundary_edge = NULL;

    Triangle *lface = e->Lface();
    lface->dontAnchor(e);
    new_faces[facedex++] = lface;

    if( onEdge(x,e) )
    {
	if( ccwBoundary(e) ) {
	    //
	    // e lies on the boundary
	    // Defer deletion until after new edges are added.
	    boundary_edge = e;
	}
	else {
	    Triangle *sym_lface = e->Sym()->Lface();
	    new_faces[facedex++] = sym_lface;
	    sym_lface->dontAnchor(e->Sym());


	    e = e->Oprev();
	    deleteEdge(e->Onext());
	}
    }
    else
    {
	// x lies within the Lface of e
    }

    Edge *base = makeEdge(e->Org(), x.clone());

    splice(base, e);

    startingEdge = base;
    do {
	base = connect(e, base->Sym());
	e = base->Oprev();
    } while( e->Lnext() != startingEdge );

    if( boundary_edge )
	deleteEdge(boundary_edge);

    // Update all the faces in our new spoked polygon.
    // If point x on perimeter, then don't add an exterior face


    base = boundary_edge ? startingEdge->Rprev() : startingEdge->Sym();
    do {
	if( facedex )
	    new_faces[--facedex]->reshape(base);
	else
	    makeFace(base);

	base = base->Onext();

    } while( base != startingEdge->Sym() );

    return startingEdge;
}
示例#10
0
int main(int argc, char *argv[]){
    FILE *arch;
    char line[100], *word[6];
    int count, x, y;
    //license
    license();
    
    if (argc < 3) { printf("I need the modelname too\n"); exit(1); }
    
    if (argc == 5) {
        printf("I did it\n");
        adjust = atof(argv[4]);
    }
    
    strcpy(modelname,argv[3]);
    
    //access obj file
    arch=fopen(argv[1],"r");
    if(arch==NULL){
        printf("Error: file not found or file unavailable\n\n");
        exit(1);
    }
    else{
        while(!feof(arch)){
            //read line
            fgets(line,100,arch);
            //parse tokens
            for(count=0; count<6; count++){
                word[count]=    count==0 ?    strtok(line," ") :    strtok(NULL," ");
                if(word[count]==NULL){
                    word[count-1]=strtok(word[count-1],"\n");
                    break;
                }
            }
            //process data
            if(word[0]!=NULL){
                if(strcmp(word[0],"v")==0){
                    newVertex(word);
                }
                else if(strcmp(word[0],"vt")==0){
                    newTexture(word);
                }
                else if(strcmp(word[0],"vn")==0){
                    newNormal(word);
                }
                else if(strcmp(word[0],"f")==0){
                    makeFace(word);
                }
                else{
                    //skip
                }
            }
        }
        fclose(arch);
        //save to file
        arch=fopen(argv[2],"w");
        if(arch==NULL){
            printf("Error: File creation unsuccessful\n\n");
        }
        else{
            fprintf(arch,"//Generated through PatchObj v.1.0 by Patricio Figueroa\n\n");
            dataDump(arch);
            fclose(arch);
        }
    }
    printf("Success!\n\n");
    return 0;
}