Beispiel #1
0
void PLodNode::update_cache() {
  if (geometry_changed_) {
    if (geometry_description_ != "") {
      if (!GeometryDatabase::instance()->contains(geometry_description_)) {
        GeometryDescription desc(geometry_description_);
        try {
          gua::LodLoader loader;
          loader.load_lod_pointcloud(desc.filepath(), desc.flags());
        } catch (std::exception& e) {
          Logger::LOG_WARNING
              << "PLodNode::update_cache(): Loading failed from "
              << desc.filepath() << " : " << e.what() << std::endl;
        }
      }
      geometry_ = std::dynamic_pointer_cast<LodResource>(
          GeometryDatabase::instance()->lookup(geometry_description_));

      if (!geometry_) {
        Logger::LOG_WARNING
            << "Failed to get LodResource for " << geometry_description_
            << ": The data base entry is of wrong type!" << std::endl;
      }
    }

    geometry_changed_ = false;
  }

  // modified version of Node::update_cache -> add local transformation
  if (self_dirty_) {
    math::mat4 old_world_trans(world_transform_);

    if (is_root()) {
      world_transform_ = transform_ * geometry_->local_transform();
    } else {
      world_transform_ = get_parent()->get_world_transform() * transform_ *
                         geometry_->local_transform();
    }

    update_bounding_box();

    if (world_transform_ != old_world_trans) {
      on_world_transform_changed.emit(world_transform_);
    }

    self_dirty_ = false; 
  }

  if (child_dirty_) {
    for (auto const& child : get_children()) {
      child->update_cache();
    }

    update_bounding_box();

    child_dirty_ = false;
  }
}
Beispiel #2
0
static void
process_monitors_change (GdkScreen *screen)
{
  GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
  gint		 n_monitors;
  gint		 primary_monitor;
  GdkX11Monitor	*monitors;
  gboolean changed;

  primary_monitor = x11_screen->primary_monitor;
  n_monitors = x11_screen->n_monitors;
  monitors = x11_screen->monitors;

  x11_screen->n_monitors = 0;
  x11_screen->monitors = NULL;

  init_multihead (screen);

  changed =
    !compare_monitors (monitors, n_monitors,
		       x11_screen->monitors, x11_screen->n_monitors) ||
    x11_screen->primary_monitor != primary_monitor;

  free_monitors (monitors, n_monitors);

  if (changed)
    {
      update_bounding_box (screen);
      g_signal_emit_by_name (screen, "monitors-changed");
    }
}
Beispiel #3
0
void AbstractForm::add_point_to_form(float x, float y)
{
    Point new_point(x,y);
    points.push_back(new_point);
    update_bounding_box(x,y);
    update_values();
}
Beispiel #4
0
void AbstractForm::set_xy_of_point(int point, float x, float y)
{
    points[point].set_x(x);
    points[point].set_y(y);
    update_bounding_box(x,y);
    update_values();
}
Beispiel #5
0
void
ball_update(void *object)
{
    int signal;

    struct ball *b = (struct ball *) object;

    b->x += b->direction[COORD_X];
    b->y += b->direction[COORD_Y];

    signal = (b->x) < 0.0 ? -1 : 1;

    if (fabs(b->x) > WORLD_BOUNDARY_X) {
        ball_set_direction(b, 180 - b->angle);
        b->x = signal * WORLD_BOUNDARY_X;
    }

    if (b->y > WORLD_BOUNDARY_Y) {
        ball_set_direction(b, -b->angle);
        b->y = WORLD_BOUNDARY_Y;
    }

    recalculate_matrices(b);
    update_bounding_box(b);
}
Beispiel #6
0
	Light::Light(const LightData &light_data): m_light_data(light_data),
		m_inv_sqr_radius(0.0f)
	{
		set_inv_sqr_radius(get_radius());
		update_bounding_box();
		update_rgb9_e5_color();
	}
Beispiel #7
0
static void
process_monitors_change (GdkScreen *screen)
{
  if (init_multihead (screen))
    {
      update_bounding_box (screen);
      g_signal_emit_by_name (screen, "monitors-changed");
    }
}
Beispiel #8
0
	Object::Object(const ObjectData &object_data,
		const AbstractMeshSharedPtr &mesh,
		const MaterialSharedPtrVector &materials):
		m_object_data(object_data), m_mesh(mesh), m_materials(materials)
	{
		assert(materials.size() > 0);

		update_bounding_box();
	}
Beispiel #9
0
//----------------------------------------------------------------
// Function: private function to update the core compound and      
//           for any movement of the body.
// Note:     input shape must have the same number of Compound
//           as the body's lumps number.
// Author: Jane Hu
//----------------------------------------------------------------
CubitStatus OCCBody::update_OCC_entity( BRepBuilderAPI_ModifyShape *aBRepTrsf,
                                       BRepAlgoAPI_BooleanOperation *op) 
{
  assert(aBRepTrsf != NULL || op != NULL);

  TopoDS_Compound compsolid;
  TopoDS_Shape shape;
  shape = aBRepTrsf->Shape();
  if(aBRepTrsf && myTopoDSShape)
  {
    compsolid = TopoDS::Compound(shape);
  
    if(OCCQueryEngine::instance()->OCCMap->IsBound(*myTopoDSShape) )
       OCCQueryEngine::instance()->update_OCC_map(*myTopoDSShape, shape);
    else if (!shape.IsEqual(*myTopoDSShape))
       set_TopoDS_Shape(compsolid);
  }

  //Boolean operation works only on one lump body
  //set the lumps
  DLIList<Lump *> lumps;
  lumps = this->lumps();
  for (int i = 1; i <= lumps.size(); i++)
  {
     OCCLump *lump = CAST_TO(lumps.get_and_step(), OCCLump);
     lump->update_OCC_entity(aBRepTrsf, op);
  }

  for(int i = 0; i < mySheetSurfaces.size(); i++)
  {
    OCCSurface* surface = mySheetSurfaces.get_and_step();
    surface->update_OCC_entity(aBRepTrsf, op);
  }
  for(int i = 0; i <myShells.size() ; i++)
  {
    OCCShell* occ_shell = myShells.get_and_step();
    occ_shell->update_OCC_entity(aBRepTrsf,op);
  }

  if (aBRepTrsf && !compsolid.IsNull())
    set_TopoDS_Shape(compsolid);

  update_bounding_box(); 

  //unset marks.
  DLIList<OCCCurve*> curves;
  DLIList<OCCPoint*> points;
  get_all_curves(curves);
  get_all_points(points);

  for(int i = 0; i < curves.size(); i++)
    curves.get_and_step()->set_myMarked(CUBIT_FALSE);

  for(int i = 0; i < points.size(); i++)
    points.get_and_step()->set_myMarked(CUBIT_FALSE);
  return CUBIT_SUCCESS;
}
Beispiel #10
0
//----------------------------------------------------------------
// Function: transform
// Description: transform the body and its child entities
//              use a transform matrix
//
// Author: Jane Hu
//----------------------------------------------------------------
CubitStatus OCCBody::transform(BRepBuilderAPI_Transform& aBRepTrsf)
{
  TopoDS_Shape * shape;
  get_TopoDS_Shape(shape);
  aBRepTrsf.Perform(*shape);

  update_OCC_entity(&aBRepTrsf);
  // calculate for bounding box
  update_bounding_box();
  
  return CUBIT_SUCCESS;
}
Beispiel #11
0
	Object::Object(const InstanceData &instance_data,
		const AbstractMeshSharedPtr &mesh,
		const MaterialSharedPtrVector &materials,
		const SubObjectVector &sub_objects):
		m_object_data(instance_data), m_mesh(mesh),
		m_materials(materials), m_sub_objects(sub_objects)
	{
		assert(get_sub_objects().size() > 0);
		assert(materials.size() > 0);

		update_bounding_box();
	}
Beispiel #12
0
OCCBody::OCCBody(DLIList<Lump*>& my_lumps, 
                 DLIList<OCCShell*>& shells,
                 DLIList<OCCSurface*>& surfaces)
{
  myLumps = my_lumps;
  mySheetSurfaces = surfaces;
  myShells = shells;
  TopoDS_Compound* new_top = make_Compound(my_lumps, shells, surfaces);
  myTopoDSShape = new_top;
  assert (myTopoDSShape->ShapeType() == TopAbs_COMPOUND);
  update_bounding_box();
}
Beispiel #13
0
//-------------------------------------------------------------------------
// Purpose       : A constructor with a list of lumps that are attached.
//
// Special Notes :
//
//-------------------------------------------------------------------------
OCCBody::OCCBody(TopoDS_Compound *theShape, 
                 OCCSurface* surface, OCCShell* shell, Lump* lump)
{
  myTopoDSShape = theShape;
  if (surface != NULL)
    mySheetSurfaces.append(surface);
  if( shell != NULL)
    myShells.append(shell);
  if (lump != NULL)
    myLumps.append(lump);
  update_bounding_box();
  if (myTopoDSShape && !myTopoDSShape->IsNull())
    assert(myTopoDSShape->ShapeType() == TopAbs_COMPOUND);
}
Beispiel #14
0
GdkScreen *
_gdk_x11_screen_new (GdkDisplay *display,
		     gint	 screen_number) 
{
  GdkScreen *screen;
  GdkX11Screen *x11_screen;
  GdkX11Display *display_x11 = GDK_X11_DISPLAY (display);
  const char *scale_str;

  screen = g_object_new (GDK_TYPE_X11_SCREEN, NULL);

  x11_screen = GDK_X11_SCREEN (screen);
  x11_screen->display = display;
  x11_screen->xdisplay = display_x11->xdisplay;
  x11_screen->xscreen = ScreenOfDisplay (display_x11->xdisplay, screen_number);
  x11_screen->screen_num = screen_number;
  x11_screen->xroot_window = RootWindow (display_x11->xdisplay,screen_number);
  x11_screen->wmspec_check_window = None;
  /* we want this to be always non-null */
  x11_screen->window_manager_name = g_strdup ("unknown");

#ifdef HAVE_CAIRO_SURFACE_SET_DEVICE_SCALE
  scale_str = g_getenv ("GDK_SCALE");
#else
  scale_str = "1";
#endif
  if (scale_str)
    {
      x11_screen->fixed_window_scale = TRUE;
      x11_screen->window_scale = atol (scale_str);
      if (x11_screen->window_scale == 0)
        x11_screen->window_scale = 1;
    }
  else
    x11_screen->window_scale = 1;

  init_multihead (screen);
  init_randr_support (screen);
  
  _gdk_x11_screen_init_visuals (screen);
  _gdk_x11_screen_init_root_window (screen);
  update_bounding_box (screen);

  return screen;
}
Beispiel #15
0
//----------------------------------------------------------------
// Function: scale
// Description: deforming transformation of the body and its child entities
// Author: Jane Hu 
//----------------------------------------------------------------
CubitStatus OCCBody::scale(double scale_factor_x,
                           double scale_factor_y,
                           double scale_factor_z )
{
  gp_GTrsf gTrsf; 
  gTrsf.SetValue(1,1, scale_factor_x);
  gTrsf.SetValue(2,2, scale_factor_y);
  gTrsf.SetValue(3,3, scale_factor_z);

  BRepBuilderAPI_GTransform gBRepTrsf(gTrsf);

  TopoDS_Shape * shape;
  get_TopoDS_Shape(shape);
  gBRepTrsf.Perform(*shape);

  update_OCC_entity(&gBRepTrsf);
  // calculate for bounding box
  update_bounding_box();

  return CUBIT_SUCCESS;
}
Beispiel #16
0
void GL_widget_3::draw () {
	default_bounding_box = true;

	bool is_valid;
	std::vector<Visualization_layer *>::iterator it, end=layers.end();
	for (it=layers.begin(); it!=end; it++) {
		GL_draw_layer_3 *l = (GL_draw_layer_3*)*it;
		if (l->is_active()) {
			l->draw();
			Box3D bbox = l->get_3d_bounding_box(&is_valid);
			if (is_valid) 
				update_bounding_box(bbox);
		}
	}
	setSceneBoundingBox(qglviewer::Vec((float)bounding_xmin, (float)bounding_ymin, (float)bounding_zmin),
						qglviewer::Vec((float)bounding_xmax, (float)bounding_ymax, (float)bounding_zmax));
//	std::cout << "BBox: [" << bounding_xmin << ", " << bounding_ymin << ", " << bounding_zmin << "] - [" << bounding_xmax << ", " << bounding_ymax << ", " << bounding_zmax << "]" << std::endl;

	glDisable(GL_CLIP_PLANE0);
	glDisable(GL_CLIP_PLANE1);

}
Beispiel #17
0
void GL_widget_2::paintGL () {
	bool is_valid;
	std::vector<Visualization_layer *>::iterator it, end;
	//int infologLength = 0;
	//int charsWritten  = 0;
	QSettings settings;
	
	switch (rendering_effect) {
		case RENDERING_PENCIL:
			// render into pbuffer
			pbuffer->makeCurrent();
			//glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
			default_bounding_box = true;
			end=layers.end();
			for (it=layers.begin(); it!=end; it++) {
				Visualization_layer *l = *it;
				if (l->is_active()) {
					l->draw();
					QRectF bbox = l->get_bounding_box(&is_valid);
					if (is_valid) 
						update_bounding_box(bbox);
				}
			}
			glFlush();

			//pbuffer->toImage().save("D:/pbuffer.png");
			// on the screen now
			makeCurrent();
			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

			//draw a quad with the texture on it
				//glGenTextures(1, &noise_texture);
				//GLubyte *noise_data = make_2d_noise_texture(128,4,4);
				//glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, noise_data);
				//glUniform1i(noise_uniform,6);



			//
			//glActiveTexture(GL_TEXTURE0+6);
			//std::cout << "noise texture: " << noise_texture << std::endl;
			//glBindTexture(GL_TEXTURE_2D, noise_texture);

			//

			//glGetProgramiv(npr_shader_program, GL_INFO_LOG_LENGTH,&infologLength);

			//if (infologLength > 0)
			//{
			//	infoLog = (char *)malloc(infologLength);
			//	glGetProgramInfoLog(npr_shader_program, infologLength, &charsWritten, infoLog);
			//	std::cout << infoLog << std::endl;
			//	free(infoLog);
			//}

			if (settings.value("npr-render-paper").toBool()) {
				glActiveTexture(GL_TEXTURE0);
				glBindTexture(GL_TEXTURE_2D,paper_texture);
				glBegin(GL_QUADS);
				glTexCoord2d(0,0);
				glVertex2d(0, 0);
				glTexCoord2d(10,0);
				glVertex2d(2048, 0);
				glTexCoord2d(10,10);
				glVertex2d(2048, 2048);
				glTexCoord2d(0,10);
				glVertex2d(0, 2048);
				glEnd();
			}
			glActiveTexture(GL_TEXTURE0+6);
			glBindTexture(GL_TEXTURE_2D, noise_texture);
//			glActiveTexture(GL_TEXTURE0);
//			glBindTexture(GL_TEXTURE_2D, paper_texture);
			glActiveTexture(GL_TEXTURE0);
			glBindTexture(GL_TEXTURE_2D, dynamic_texture);

			// activate shader program
			glUseProgram(npr_shader_program);

			glBegin(GL_QUADS);
				glTexCoord2d(0,0);
				glVertex2d(0, 0);
				glTexCoord2d(1,0);
				glVertex2d(2048, 0);
				glTexCoord2d(1,1);
				glVertex2d(2048, 2048);
				glTexCoord2d(0,1);
				glVertex2d(0, 2048);
			glEnd();
			glUseProgram(0);
			glActiveTexture(GL_TEXTURE0);

			glFlush();
			break;
		default:
			// render directly into the widget
			makeCurrent();
			glBindTexture(GL_TEXTURE_2D, 0);
			glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
			default_bounding_box = true;
			end=layers.end();


			//do computation for layers
			//if (! computation_thread->isRunning()) {
			//	computation_thread->start();
			//} else {
			//	std::cout << LOG_GREEN << "thread is running" << std::endl;

			//	//			std::cout << LOG_RED << "DONE Preparing layers" << std::endl;


			//	//			std::cout << LOG_BLUE << "START Drawing layers" << std::endl;

			//}

			//render them
			makeCurrent();
			for (it=layers.begin(); it!=end; it++) {
				Visualization_layer *l = *it;
				if (l->is_active()) {
					l->draw();
					QRectF bbox = l->get_bounding_box(&is_valid);
					if (is_valid) 
						update_bounding_box(bbox);
				}
			}
			glFlush();

//			std::cout << LOG_BLUE << "DONE Drawing layers" << std::endl;
			break;
	}


}