void RenderObject::draw() const { glTranslatef(0.0f, 0.0f, -5.0f); glTranslatef(position().x(), position().y(), position().z()); glRotatef(rotation().x(), 1, 0, 0); glRotatef(rotation().y(), 0, 1, 0); glRotatef(rotation().z(), 0, 0, 1); glBegin(shape_type()); /*for(int j = 0; j < points(); j++){ const Point& pt = getPoint(j); glColor3f( ((float)(rand()%100))/100 ,((float)(rand()%100))/100 ,((float)(rand()%100))/100 ); //glVertex3f(pt.x(), pt.y(), pt.z()); }*/ glColor3f( ((float)(rand()%100))/100 ,((float)(rand()%100))/100 ,((float)(rand()%100))/100 ); glVertexPointer(3, GL_FLOAT, 0, m_vertices); glEnd(); glDrawArrays(shape_type(), 0, m_vertices->numPoints()); //Change to draw elements, use index mapping in vertex array class }
bool IfcGeom::Kernel::convert(const IfcSchema::IfcRepresentation* l, IfcRepresentationShapeItems& shapes) { IfcSchema::IfcRepresentationItem::list::ptr items = l->Items(); bool part_succes = false; if ( items->size() ) { for ( IfcSchema::IfcRepresentationItem::list::it it = items->begin(); it != items->end(); ++ it ) { IfcSchema::IfcRepresentationItem* representation_item = *it; if ( shape_type(representation_item) == ST_SHAPELIST ) { part_succes |= convert_shapes(*it, shapes); } else { TopoDS_Shape s; if (convert_shape(representation_item,s)) { shapes.push_back(IfcRepresentationShapeItem(s, get_style(representation_item))); part_succes |= true; } } } } return part_succes; }
bool IfcGeom::Kernel::convert(const IfcSchema::IfcBooleanResult* l, TopoDS_Shape& shape) { TopoDS_Shape s1, s2; IfcRepresentationShapeItems items1, items2; TopoDS_Wire boundary_wire; IfcSchema::IfcBooleanOperand* operand1 = l->FirstOperand(); IfcSchema::IfcBooleanOperand* operand2 = l->SecondOperand(); bool is_halfspace = operand2->is(IfcSchema::Type::IfcHalfSpaceSolid); if ( shape_type(operand1) == ST_SHAPELIST ) { if (!(convert_shapes(operand1, items1) && flatten_shape_list(items1, s1, true))) { return false; } } else if ( shape_type(operand1) == ST_SHAPE ) { if ( ! convert_shape(operand1, s1) ) { return false; } { TopoDS_Solid temp_solid; s1 = ensure_fit_for_subtraction(s1, temp_solid); } } else { Logger::Message(Logger::LOG_ERROR, "Invalid representation item for boolean operation", operand1->entity); return false; } const double first_operand_volume = shape_volume(s1); if ( first_operand_volume <= ALMOST_ZERO ) Logger::Message(Logger::LOG_WARNING,"Empty solid for:",l->FirstOperand()->entity); bool shape2_processed = false; if ( shape_type(operand2) == ST_SHAPELIST ) { shape2_processed = convert_shapes(operand2, items2) && flatten_shape_list(items2, s2, true); } else if ( shape_type(operand2) == ST_SHAPE ) { shape2_processed = convert_shape(operand2,s2); if (shape2_processed && !is_halfspace) { TopoDS_Solid temp_solid; s2 = ensure_fit_for_subtraction(s2, temp_solid); } } else { Logger::Message(Logger::LOG_ERROR, "Invalid representation item for boolean operation", operand2->entity); } if (!shape2_processed) { shape = s1; Logger::Message(Logger::LOG_ERROR,"Failed to convert SecondOperand of:",l->entity); return true; } if (!is_halfspace) { const double second_operand_volume = shape_volume(s2); if ( second_operand_volume <= ALMOST_ZERO ) Logger::Message(Logger::LOG_WARNING,"Empty solid for:",operand2->entity); } const IfcSchema::IfcBooleanOperator::IfcBooleanOperator op = l->Operator(); if (op == IfcSchema::IfcBooleanOperator::IfcBooleanOperator_DIFFERENCE) { bool valid_cut = false; BRepAlgoAPI_Cut brep_cut(s1,s2); if ( brep_cut.IsDone() ) { TopoDS_Shape result = brep_cut; ShapeFix_Shape fix(result); try { fix.Perform(); result = fix.Shape(); } catch (...) { Logger::Message(Logger::LOG_WARNING, "Shape healing failed on boolean result", l->entity); } bool is_valid = BRepCheck_Analyzer(result).IsValid() != 0; if ( is_valid ) { shape = result; valid_cut = true; } } if ( valid_cut ) { const double volume_after_subtraction = shape_volume(shape); if ( ALMOST_THE_SAME(first_operand_volume,volume_after_subtraction) ) Logger::Message(Logger::LOG_WARNING,"Subtraction yields unchanged volume:",l->entity); } else { Logger::Message(Logger::LOG_ERROR,"Failed to process subtraction:",l->entity); shape = s1; } return true; } else if (op == IfcSchema::IfcBooleanOperator::IfcBooleanOperator_UNION) { BRepAlgoAPI_Fuse brep_fuse(s1,s2); if ( brep_fuse.IsDone() ) { TopoDS_Shape result = brep_fuse; ShapeFix_Shape fix(result); fix.Perform(); result = fix.Shape(); bool is_valid = BRepCheck_Analyzer(result).IsValid() != 0; if ( is_valid ) { shape = result; return true; } } } else if (op == IfcSchema::IfcBooleanOperator::IfcBooleanOperator_INTERSECTION) { BRepAlgoAPI_Common brep_common(s1,s2); if ( brep_common.IsDone() ) { TopoDS_Shape result = brep_common; ShapeFix_Shape fix(result); fix.Perform(); result = fix.Shape(); bool is_valid = BRepCheck_Analyzer(result).IsValid() != 0; if ( is_valid ) { shape = result; return true; } } } return false; }
shape_type shape() const { return shape_type(_data.shape()[1], _data.shape()[2]); }
int do_switches (int argc, const char **argv) { int i; const char *cp, *color, *type; SHAPE_TYPE t; #ifdef DDS_SECURITY const char *arg_input; #endif progname = argv [0]; for (i = 1; i < argc; i++) { cp = argv [i]; if (*cp++ != '-') break; while (*cp) { switch (*cp++) { case 'p': INC_ARG (); if (!get_str (&cp, &type)) { printf ("shape type expected!\r\n"); usage (); } t = shape_type (type); INC_ARG(); if (!get_str (&cp, &color)) { printf ("color expected!\r\n"); usage (); } shape_add (t, color); break; case 's': INC_ARG (); if (!get_str (&cp, &type)) { printf ("shape type expected!\r\n"); usage (); } t = shape_type (type); subscriptions |= 1 << t; break; #ifdef DDS_DEBUG case 'd': debug = 1; break; #endif case 'i': INC_ARG (); get_num (&cp, &domain_id, 0, 255); break; #ifdef DDS_SECURITY case 'e': INC_ARG () if (!get_str (&cp, &arg_input)) usage(); engine_id = malloc (strlen (arg_input) + 1); strcpy (engine_id, arg_input); break; case 'c': INC_ARG () if (!get_str (&cp, &arg_input)) usage (); cert_path = malloc (strlen (arg_input) + 1); strcpy (cert_path, arg_input); break; case 'k': INC_ARG () if (!get_str (&cp, &arg_input)) usage (); key_path = malloc (strlen (arg_input) + 1); strcpy (key_path, arg_input); break; case 'z': INC_ARG () if (!get_str (&cp, &arg_input)) usage (); realm_name = malloc (strlen (arg_input) + 1); strcpy (realm_name, arg_input); break; case 'j': INC_ARG () if (!get_str (&cp, &arg_input)) usage (); sname = malloc (strlen (arg_input) + 1); strcpy (sname, arg_input); sfile = 1; break; #endif case 't': trace = 1; break; case 'v': verbose = 1; if (*cp == 'v') { verbose = 2; cp++; } break; case 'x': INC_ARG (); exclusive = 1; get_num (&cp, &strength, 0, 0x7fffffff); break; case 'b': white_bg = 1; break; #ifdef XTYPES_USED case 'y': dyn_type = dyn_data = 1; break; #endif default: usage (); break; } } } return (i); }
int do_switches (int argc, const char **argv) { int i; const char *cp, *type; #if 0 const char *color; #endif SHAPE_TYPE t; progname = argv [0]; for (i = 1; i < argc; i++) { cp = argv [i]; if (*cp++ != '-') break; while (*cp) { switch (*cp++) { # if 0 case 'p': INC_ARG(); if (!get_str (&cp, &type)) { printf ("shape type expected!\r\n"); usage (); } t = shape_type (type); INC_ARG(); if (!get_str (&cp, &color)) { printf ("color expected!\r\n"); usage (); } shape_add (t, color); break; # endif case 's': INC_ARG(); if (!get_str (&cp, &type)) { printf ("shape type expected!\r\n"); usage (); } t = shape_type (type); subscriptions |= 1 << t; break; #ifdef DDS_DEBUG case 'd': debug = 1; break; #endif case 't': trace = 1; break; case 'v': verbose = 1; if (*cp == 'v') { verbose = 2; cp++; } break; default: usage (); break; } } } return (i); }