PyObject *PyRendererAgg_draw_markers(PyRendererAgg *self, PyObject *args, PyObject *kwds)
{
    GCAgg gc;
    py::PathIterator marker_path;
    agg::trans_affine marker_path_trans;
    py::PathIterator path;
    agg::trans_affine trans;
    PyObject *faceobj = NULL;
    agg::rgba face;

    if (!PyArg_ParseTuple(args,
                          "O&O&O&O&O&|O:draw_markers",
                          &convert_gcagg,
                          &gc,
                          &convert_path,
                          &marker_path,
                          &convert_trans_affine,
                          &marker_path_trans,
                          &convert_path,
                          &path,
                          &convert_trans_affine,
                          &trans,
                          &faceobj)) {
        return NULL;
    }

    if (!convert_face(faceobj, gc, &face)) {
        return NULL;
    }

    CALL_CPP("draw_markers",
             (self->x->draw_markers(gc, marker_path, marker_path_trans, path, trans, face)));

    Py_RETURN_NONE;
}
예제 #2
0
bool IfcGeom::Kernel::convert(const IfcSchema::IfcCompositeProfileDef* l, TopoDS_Shape& face) {
	// BRepBuilderAPI_MakeFace mf;

	TopoDS_Compound compound;
	BRep_Builder builder;
	builder.MakeCompound(compound);

	IfcSchema::IfcProfileDef::list::ptr profiles = l->Profiles();
	//bool first = true;
	for (IfcSchema::IfcProfileDef::list::it it = profiles->begin(); it != profiles->end(); ++it) {
		TopoDS_Face f;
		if (convert_face(*it, f)) {
			builder.Add(compound, f);
			/* TopExp_Explorer exp(f, TopAbs_WIRE);
			for (; exp.More(); exp.Next()) {
				const TopoDS_Wire& wire = TopoDS::Wire(exp.Current());
				if (first) {
					mf.Init(BRepBuilderAPI_MakeFace(wire));
				} else {
					mf.Add(wire);
				}
				first = false;
			} */
		}
	}

	face = compound;
	return !face.IsNull();
}
예제 #3
0
	void StencilScopeOGL::applySettings(const StencilSettings& settings)
	{
		if(settings.enabled()) {
			glEnable(GL_STENCIL_TEST);
			glStencilOpSeparate(convert_face(settings.face()), 
				convert_stencil_op(settings.sfail()),
				convert_stencil_op(settings.dpfail()),
				convert_stencil_op(settings.dppass()));
			glStencilFuncSeparate(convert_face(settings.face()), 
				convert_func(settings.func()),
				settings.ref(),
				settings.ref_mask());
			glStencilMaskSeparate(convert_face(settings.face()), settings.mask());
		} else {
			glDisable(GL_STENCIL_TEST);
			glStencilMask(0);
		}
	}
예제 #4
0
bool IfcGeom::Kernel::convert(const IfcSchema::IfcDerivedProfileDef* l, TopoDS_Shape& face) {
	TopoDS_Face f;
	gp_Trsf2d trsf2d;
	if (convert_face(l->ParentProfile(), f) && IfcGeom::Kernel::convert(l->Operator(), trsf2d)) {
		gp_Trsf trsf = trsf2d;
		face = TopoDS::Face(BRepBuilderAPI_Transform(f, trsf));
		return true;
	} else {
		return false;
	}
}
예제 #5
0
bool IfcGeom::Kernel::convert(const IfcSchema::IfcExtrudedAreaSolid* l, TopoDS_Shape& shape) {
	const double height = l->Depth() * getValue(GV_LENGTH_UNIT);
	if (height < getValue(GV_PRECISION)) {
		Logger::Message(Logger::LOG_ERROR, "Non-positive extrusion height encountered for:", l->entity);
		return false;
	}

	TopoDS_Shape face;
	if ( !convert_face(l->SweptArea(),face) ) return false;

	gp_Trsf trsf;
	IfcGeom::Kernel::convert(l->Position(),trsf);

	gp_Dir dir;
	convert(l->ExtrudedDirection(),dir);

	shape.Nullify();

	if (face.ShapeType() == TopAbs_COMPOUND) {
		
		// For compounds (most likely the result of a IfcCompositeProfileDef) 
		// create a compound solid shape.
		
		TopExp_Explorer exp(face, TopAbs_FACE);
		
		TopoDS_CompSolid compound;
		BRep_Builder builder;
		builder.MakeCompSolid(compound);
		
		int num_faces_extruded = 0;
		for (; exp.More(); exp.Next(), ++num_faces_extruded) {
			builder.Add(compound, BRepPrimAPI_MakePrism(exp.Current(), height*dir));
		}

		if (num_faces_extruded) {
			shape = compound;
		}

	}
	
	if (shape.IsNull()) {	
		shape = BRepPrimAPI_MakePrism(face, height*dir);
	}

	// IfcSweptAreaSolid.Position (trsf) is an IfcAxis2Placement3D
	// and therefore has a unit scale factor
	shape.Move(trsf);

	return ! shape.IsNull();
}
예제 #6
0
bool IfcGeom::Kernel::convert(const IfcSchema::IfcSurfaceOfLinearExtrusion* l, TopoDS_Shape& shape) {
    TopoDS_Wire wire;
    if ( !convert_wire(l->SweptCurve(), wire) ) {
        TopoDS_Face face;
        if ( !convert_face(l->SweptCurve(),face) ) return false;
        TopExp_Explorer exp(face, TopAbs_WIRE);
        wire = TopoDS::Wire(exp.Current());
    }
    const double height = l->Depth() * getValue(GV_LENGTH_UNIT);
    gp_Trsf trsf;
    IfcGeom::Kernel::convert(l->Position(),trsf);

    gp_Dir dir;
    convert(l->ExtrudedDirection(),dir);

    shape = BRepPrimAPI_MakePrism(wire, height*dir);
    shape.Move(trsf);
    return !shape.IsNull();
}
예제 #7
0
bool IfcGeom::Kernel::convert(const IfcSchema::IfcExtrudedAreaSolid* l, TopoDS_Shape& shape) {
    TopoDS_Shape face;
    if ( !convert_face(l->SweptArea(),face) ) return false;

    const double height = l->Depth() * getValue(GV_LENGTH_UNIT);
    gp_Trsf trsf;
    IfcGeom::Kernel::convert(l->Position(),trsf);

    gp_Dir dir;
    convert(l->ExtrudedDirection(),dir);

    shape.Nullify();

    if (face.ShapeType() == TopAbs_COMPOUND) {

        // For compounds (most likely the result of a IfcCompositeProfileDef)
        // create a compound solid shape.

        TopExp_Explorer exp(face, TopAbs_FACE);

        TopoDS_CompSolid compound;
        BRep_Builder builder;
        builder.MakeCompSolid(compound);

        int num_faces_extruded = 0;
        for (; exp.More(); exp.Next(), ++num_faces_extruded) {
            builder.Add(compound, BRepPrimAPI_MakePrism(exp.Current(), height*dir));
        }

        if (num_faces_extruded) {
            shape = compound;
        }

    }

    if (shape.IsNull()) {
        shape = BRepPrimAPI_MakePrism(face, height*dir);
    }

    shape.Move(trsf);
    return ! shape.IsNull();
}
예제 #8
0
bool IfcGeom::Kernel::convert(const IfcSchema::IfcSurfaceOfRevolution* l, TopoDS_Shape& shape) {
    TopoDS_Wire wire;
    if ( !convert_wire(l->SweptCurve(), wire) ) {
        TopoDS_Face face;
        if ( !convert_face(l->SweptCurve(),face) ) return false;
        TopExp_Explorer exp(face, TopAbs_WIRE);
        wire = TopoDS::Wire(exp.Current());
    }

    gp_Ax1 ax1;
    IfcGeom::Kernel::convert(l->AxisPosition(), ax1);

    gp_Trsf trsf;
    IfcGeom::Kernel::convert(l->Position(),trsf);

    shape = BRepPrimAPI_MakeRevol(wire, ax1);

    shape.Move(trsf);
    return !shape.IsNull();
}
예제 #9
0
bool IfcGeom::Kernel::convert(const IfcSchema::IfcRevolvedAreaSolid* l, TopoDS_Shape& shape) {
    const double ang = l->Angle() * getValue(GV_PLANEANGLE_UNIT);

    TopoDS_Face face;
    if ( ! convert_face(l->SweptArea(),face) ) return false;

    gp_Ax1 ax1;
    IfcGeom::Kernel::convert(l->Axis(), ax1);

    gp_Trsf trsf;
    IfcGeom::Kernel::convert(l->Position(),trsf);

    if (ang >= M_PI * 2. - ALMOST_ZERO) {
        shape = BRepPrimAPI_MakeRevol(face, ax1);
    } else {
        shape = BRepPrimAPI_MakeRevol(face, ax1, ang);
    }

    shape.Move(trsf);
    return !shape.IsNull();
}
예제 #10
0
bool IfcGeom::Kernel::convert(const IfcSchema::IfcSurfaceCurveSweptAreaSolid* l, TopoDS_Shape& shape) {
    gp_Trsf directrix, position;
    TopoDS_Shape face;
    TopoDS_Wire wire, section;

    if (!l->ReferenceSurface()->is(IfcSchema::Type::IfcPlane)) {
        Logger::Message(Logger::LOG_WARNING, "Reference surface not supported", l->ReferenceSurface()->entity);
        return false;
    }

    if (!IfcGeom::Kernel::convert(l->Position(), position)   ||
            !convert_face(l->SweptArea(), face) ||
            !convert_wire(l->Directrix(), wire)    ) {
        return false;
    }

    gp_Pln pln;
    gp_Pnt directrix_origin;
    gp_Vec directrix_tangent;
    bool directrix_on_plane = true;
    IfcGeom::Kernel::convert((IfcSchema::IfcPlane*) l->ReferenceSurface(), pln);

    // As per Informal propositions 2: The Directrix shall lie on the ReferenceSurface.
    // This is not always the case with the test files in the repository. I am not sure
    // how to deal with this and whether my interpretation of the propositions is
    // correct. However, if it has been asserted that the vertices of the directrix do
    // not conform to the ReferenceSurface, the ReferenceSurface is ignored.
    {
        for (TopExp_Explorer exp(wire, TopAbs_VERTEX); exp.More(); exp.Next()) {
            if (pln.Distance(BRep_Tool::Pnt(TopoDS::Vertex(exp.Current()))) > ALMOST_ZERO) {
                directrix_on_plane = false;
                Logger::Message(Logger::LOG_WARNING, "The Directrix does not lie on the ReferenceSurface", l->entity);
                break;
            }
        }
    }

    {
        TopExp_Explorer exp(wire, TopAbs_EDGE);
        TopoDS_Edge edge = TopoDS::Edge(exp.Current());
        double u0, u1;
        Handle(Geom_Curve) crv = BRep_Tool::Curve(edge, u0, u1);
        crv->D1(u0, directrix_origin, directrix_tangent);
    }

    if (pln.Axis().Direction().IsNormal(directrix_tangent, Precision::Approximation()) && directrix_on_plane) {
        directrix.SetTransformation(gp_Ax3(directrix_origin, directrix_tangent, pln.Axis().Direction()), gp::XOY());
    } else {
        directrix.SetTransformation(gp_Ax3(directrix_origin, directrix_tangent), gp::XOY());
    }
    face = BRepBuilderAPI_Transform(face, directrix);

    // NB: Note that StartParam and EndParam param are ignored and the assumption is
    // made that the parametric range over which to be swept matches the IfcCurve in
    // its entirety.
    BRepOffsetAPI_MakePipeShell builder(wire);

    {   TopExp_Explorer exp(face, TopAbs_WIRE);
        section = TopoDS::Wire(exp.Current());
    }

    builder.Add(section);
    builder.SetTransitionMode(BRepBuilderAPI_RightCorner);
    if (directrix_on_plane) {
        builder.SetMode(pln.Axis().Direction());
    }
    builder.Build();
    builder.MakeSolid();
    shape = builder.Shape();
    shape.Move(position);

    return true;
}
예제 #11
0
bool IfcGeom::Kernel::convert(const IfcSchema::IfcConnectedFaceSet* l, TopoDS_Shape& shape) {
    IfcSchema::IfcFace::list::ptr faces = l->CfsFaces();
    bool facesAdded = false;
    const unsigned int num_faces = faces->size();
    bool valid_shell = false;
    if ( num_faces < getValue(GV_MAX_FACES_TO_SEW) ) {
        BRepOffsetAPI_Sewing builder;
        builder.SetTolerance(getValue(GV_POINT_EQUALITY_TOLERANCE));
        builder.SetMaxTolerance(getValue(GV_POINT_EQUALITY_TOLERANCE));
        builder.SetMinTolerance(getValue(GV_POINT_EQUALITY_TOLERANCE));
        for( IfcSchema::IfcFace::list::it it = faces->begin(); it != faces->end(); ++ it ) {
            TopoDS_Face face;
            bool converted_face = false;
            try {
                converted_face = convert_face(*it,face);
            } catch (...) {}
            if ( converted_face && face_area(face) > getValue(GV_MINIMAL_FACE_AREA) ) {
                builder.Add(face);
                facesAdded = true;
            } else {
                Logger::Message(Logger::LOG_WARNING,"Invalid face:",(*it)->entity);
            }
        }
        if ( ! facesAdded ) return false;
        try {
            builder.Perform();
            shape = builder.SewedShape();
            valid_shell = BRepCheck_Analyzer(shape).IsValid();
        } catch(...) {}
        if (valid_shell) {
            try {
                ShapeFix_Solid solid;
                solid.LimitTolerance(getValue(GV_POINT_EQUALITY_TOLERANCE));
                TopoDS_Solid solid_shape = solid.SolidFromShell(TopoDS::Shell(shape));
                if (!solid_shape.IsNull()) {
                    try {
                        BRepClass3d_SolidClassifier classifier(solid_shape);
                        shape = solid_shape;
                    } catch (...) {}
                }
            } catch(...) {}
        } else {
            Logger::Message(Logger::LOG_WARNING,"Failed to sew faceset:",l->entity);
        }
    }
    if (!valid_shell) {
        TopoDS_Compound compound;
        BRep_Builder builder;
        builder.MakeCompound(compound);
        for( IfcSchema::IfcFace::list::it it = faces->begin(); it != faces->end(); ++ it ) {
            TopoDS_Face face;
            bool converted_face = false;
            try {
                converted_face = convert_face(*it,face);
            } catch (...) {}
            if ( converted_face && face_area(face) > getValue(GV_MINIMAL_FACE_AREA) ) {
                builder.Add(compound,face);
                facesAdded = true;
            } else {
                Logger::Message(Logger::LOG_WARNING,"Invalid face:",(*it)->entity);
            }
        }
        if ( ! facesAdded ) return false;
        shape = compound;
    }
    return true;
}
예제 #12
0
int cycle_tent (struct face *given_face, struct cycle *given_cyc, struct vertex *vtx0, int use_given)
{
	int orn, orn0, orn1;
	long n_e, i, j;
	char message[MAXLINE];
	struct vertex *vtx1, *vtx2;
	struct arc *arc0, *arc1;
	struct edge *edge0, *edge1, *edge2;
	struct face *triangle_face;
	struct face **face_list;
	struct vertex **vertex_list;
	struct edge **edge_list0, **edge_list1, **edge_list2;
	struct surface *this_srf;

	this_srf = given_face -> srf;
	if (this_srf == NULL) return (0);

	if (given_cyc == NULL)  {
		set_error1 ("(cycle_tent): face has no boundary");
		return (0);
	}
	n_e = edges_in_cycle (given_cyc);
	if (error()) return (0);
	if (n_e < 3) {
		sprintf (message, "(cycle_tent): face with %d sides", n_e);
		set_error1 (message);
		return (0);
	}

	/* allocate local arrays */
	edge_list0 = (struct edge **)
		allocate_pointers (EDGE, n_e);
	if (edge_list0 == NULL) {
		set_error1 ("(cycle_tent): mem allocation failure");
		return (0);
	}
	edge_list1 = (struct edge **)
		allocate_pointers (EDGE, n_e);
	if (edge_list1 == NULL) {
		set_error1 ("(cycle_tent): mem allocation failure");
		return (0);
	}
	edge_list2 = (struct edge **)
		allocate_pointers (EDGE, n_e);
	if (edge_list2 == NULL) {
		set_error1 ("(cycle_tent): mem allocation failure");
		return (0);
	}
	face_list = (struct face **)
		allocate_pointers (FACE, n_e);
	if (face_list == NULL) {
		set_error1 ("(cycle_tent): mem allocation failure");
		return (0);
	}
	vertex_list = (struct vertex **)
		allocate_pointers (VERTEX, n_e);
	if (vertex_list == NULL) {
		set_error1 ("(cycle_tent): mem allocation failure");
		return (0);
	}

	for (i = 0, edge0 = given_cyc -> first_edge; edge0 != NULL; i++, edge0 = edge0 -> next) {
		*(edge_list0+i) = edge0;
		if (edge0 == NULL) continue;
		arc0 = edge0 -> arcptr;
		if (arc0 == NULL) {
			set_error1 ("(cycle_tent): null arcptr");
			return (0);
		}
		orn0 = edge0 -> orn;
	}

	/* create vertex array */
	for (i = 0; i < n_e; i++) {
		edge0 = *(edge_list0+i);
		arc0 = edge0 -> arcptr;
		orn = edge0 -> orn;
		vtx1 = arc0 -> vtx[orn];
		*(vertex_list+i) = vtx1;
	}
	for (i = 0; i < n_e-1; i++) {
		for (j = i + 1; j < n_e; j++) {
			vtx1 = *(vertex_list+i);
			vtx2 = *(vertex_list+j);
			if (vtx1 == vtx2 && ! this_srf -> van_der_Waals &&
				(j == i + 1 || i == 0 && j == n_e-1)) {
				sprintf (message, "cycle_tent: repeated vertex: %8ld", vtx1 -> number);
				set_error1(message);
				sprintf (message, "cycle_tent: i = %d, j = %d",
					i, j);
				set_error2(message);
				return (0);
			}
		}
	}

	/* create spoke edges */
	for (i = 0; i < n_e; i++) {
		vtx1 = *(vertex_list+i);
		edge1 = make_straight_edge (this_srf, vtx0, vtx1);
		if (error()) return (0);
		arc1 = edge1 -> arcptr;
		orn1 = edge1 -> orn;
		*(edge_list1+i) = edge1;
		*(edge_list2+i) = new_edge (edge1 -> arcptr, 1, (struct face *) NULL, NULL);
	}

	for (i = 0; i < n_e; i++) {
		edge0 = *(edge_list0+i);
		j = ((i < n_e - 1) ? i + 1 : 0);
		edge1 = *(edge_list1+i);
		edge2 = *(edge_list2+j);
		/* use given or duplicate face */
		if (use_given && i == 0) {
			triangle_face = given_face;
			given_cyc -> first_edge = edge1;
			triangle_face -> first_cycle = given_cyc;
		}
		else {
			triangle_face = duplicate_face (given_face);
			if (error()) return (0);
			triangle_face -> first_cycle = new_cycle (NULL, edge1);
			if (error()) return (0);
			ink_cycle (this_srf);
		}
		/* later: triangle_face -> shape = STRAIGHT; */
		*(face_list + i) = triangle_face;
		edge1 -> next = edge0;
		edge0 -> next = edge2;
		edge2 -> next = NULL;
	}

	/* edge -> face pointers */
	for (i = 0; i < n_e; i++) {
		edge0 = *(edge_list0+i);
		j = ((i < n_e - 1) ? i + 1 : 0);
		edge1 = *(edge_list1+i);
		edge2 = *(edge_list2+j);
		triangle_face = *(face_list+i);
		/* pointer from old edge to face */
		edge0 -> fac = triangle_face;
		/* pointers from new edges to faces */
		edge1 -> fac = triangle_face;
		edge2 -> fac = triangle_face;
	}
	
	for (i = 0; i < n_e; i++) {
		triangle_face = *(face_list+i);
		if (!convert_face (this_srf, triangle_face)) {
			inform("cycle_tent: failure to convert face to triangle");
			return(0);
		}
		if (error()) return (0);
	}

	free_pointers (EDGE, edge_list0);
	free_pointers (EDGE, edge_list1);
	free_pointers (EDGE, edge_list2);
	free_pointers (FACE, face_list);
	free_pointers (VERTEX, vertex_list);
	return (1);
}