43 #include "TypeTetrahedralMesh.hh" 48 TypeTetrahedralMeshPlugin::TypeTetrahedralMeshPlugin() :
50 translucency_factor_action_(0)
54 bool TypeTetrahedralMeshPlugin::registerType() {
56 addDataType(
"TetrahedralMesh", tr(
"Tetrahedral Volume Mesh"));
57 setTypeIcon(
"TetrahedralMesh",
"PolyVolMeshType.png");
63 void TypeTetrahedralMeshPlugin::pluginsInitialized() {
65 if(OpenFlipper::Options::nogui())
return;
67 emit registerKey(Qt::Key_F8, Qt::ShiftModifier,
"Set scaling of Tet shrinkage");
69 QMenu* menu =
new QMenu(
"Tetrahedral Mesh Options");
72 QAction* act_scale_cells =
new QAction(tr(
"Scale cells (Shift-F8)"),
this);
73 act_scale_cells->setStatusTip(tr(
"Scale cells (Shift-F8)"));
74 connect(act_scale_cells, SIGNAL( triggered() ),
this, SLOT( slot_change_shrinkage() ));
75 menu->addAction(act_scale_cells);
78 render_switch_ =
new QAction(tr(
"Render Boundary Only"),
this);
79 render_switch_->setStatusTip(tr(
"Render Boundary Only"));
80 render_switch_->setCheckable(
true);
81 render_switch_->setChecked(
false);
82 connect(render_switch_, SIGNAL( triggered() ),
this, SLOT( switchRendering() ));
83 menu->addAction(render_switch_);
85 translucency_factor_action_ =
new QAction(tr(
"Set Translucency Factor"),
this);
86 translucency_factor_action_->setStatusTip(tr(
"Set Translucency Factor"));
87 translucency_factor_action_->setCheckable(
false);
88 connect(translucency_factor_action_, SIGNAL( triggered() ),
this, SLOT( setTranslucencyFactor() ));
89 menu->addAction(translucency_factor_action_);
91 emit addContextMenuItem(menu->menuAction(), DATA_TETRAHEDRAL_MESH,
CONTEXTOBJECTMENU);
96 int TypeTetrahedralMeshPlugin::addEmpty() {
99 TetrahedralMeshObject*
object =
new TetrahedralMeshObject(DATA_TETRAHEDRAL_MESH);
102 object->target(
true);
105 object->target(
true);
107 QString
name = QString(tr(
"New Tetrahedral Mesh %1.ovm").arg( object->id() ));
111 object->setName(f.fileName());
118 const QColor color = OpenFlipper::Options::defaultColor();
119 const ACG::Vec4f default_color(color.redF(), color.greenF(), color.blueF(), color.alphaF());
120 object->materialNode()->set_color(default_color);
123 if(OpenFlipper::Options::gui()) {
124 object->meshNode()->set_scaling(0.8);
131 emit log(
LOGINFO, object->getObjectinfo());
133 emit emptyObjectAdded(object->id());
140 void TypeTetrahedralMeshPlugin::slotKeyEvent(QKeyEvent* _event) {
142 switch (_event->key()) {
144 if (_event->modifiers() & Qt::ShiftModifier)
145 slot_change_shrinkage();
154 void TypeTetrahedralMeshPlugin::slotObjectUpdated(
int _identifier,
const UpdateType& _type) {
161 slot_update_planes_in_scenegraph_node();
166 void TypeTetrahedralMeshPlugin::objectDeleted(
int _identifier) {
170 slot_update_planes_in_scenegraph_node(_identifier);
176 void TypeTetrahedralMeshPlugin::slotUpdateContextMenu(
int _objectId) {
178 TetrahedralMeshObject* hmobj;
180 render_switch_->setChecked(hmobj->meshNode()->boundary_only());
186 void TypeTetrahedralMeshPlugin::slot_update_planes_in_scenegraph_node(
int _deletedObject) {
189 std::vector<Plane> planes;
195 if(o_it->id() == _deletedObject)
continue;
204 planes.push_back(Plane(p, n, x, y));
211 PluginFunctions::tetrahedralMeshObject(*o_it)->meshNode()->clear_cut_planes();
212 for (
unsigned int i = 0; i < planes.size(); ++i) {
213 PluginFunctions::tetrahedralMeshObject(*o_it)->meshNode()->add_cut_plane(planes[i]);
215 PluginFunctions::tetrahedralMeshObject(*o_it)->meshNode()->set_geometry_changed(
true);
223 void TypeTetrahedralMeshPlugin::switchRendering() {
225 QVariant contextObject = render_switch_->data();
226 int objectId = contextObject.toInt();
235 TetrahedralMeshObject* tetMeshObject =
dynamic_cast<TetrahedralMeshObject*
>(bod);
238 tetMeshObject->meshNode()->set_boundary_only(render_switch_->isChecked());
239 tetMeshObject->meshNode()->set_geometry_changed(
true);
245 void TypeTetrahedralMeshPlugin::setTranslucencyFactor() {
247 QVariant contextObject = translucency_factor_action_->data();
248 int objectId = contextObject.toInt();
257 TetrahedralMeshObject* tetMeshObject =
dynamic_cast<TetrahedralMeshObject*
>(bod);
262 float val = tetMeshObject->meshNode()->translucency_factor();
263 double factor = QInputDialog::getDouble(0, tr(
"Set translucency factor"), tr(
"Factor [0, 1]:"), val,
266 tetMeshObject->meshNode()->set_translucency_factor((
float)factor);
272 void TypeTetrahedralMeshPlugin::slot_change_shrinkage() {
278 double val = PluginFunctions::tetrahedralMeshObject(*o_it)->meshNode()->scaling();
279 double scale = QInputDialog::getDouble(0, tr(
"Set singularity scaling for tet shrinkage"), tr(
"Size * :"), val,
282 PluginFunctions::tetrahedralMeshObject(*o_it)->meshNode()->set_boundary_only(
false);
283 PluginFunctions::tetrahedralMeshObject(*o_it)->meshNode()->set_scaling(scale);
288 #if QT_VERSION < 0x050000 QString name()
Return a name for the plugin.
ACG::Vec3d xDirection()
local x direction (multiplied with width)
bool getObject(int _identifier, BSplineCurveObject *&_object)
The Menu will be shown when an object was picked.
const QStringList ALL_OBJECTS
Iterable object range.
DLLEXPORT DataType addDataType(QString _name, QString _readableName)
Adds a datatype and returns the id for the new type.
bool contains(const UpdateType &_type) const
Check if this update contains the given UpdateType.
int objectCount()
Get the number of available objects.
PlaneNode * planeNode(BaseObjectData *_object)
Get a PlaneNode from an object.
const UpdateType UPDATE_GEOMETRY(UpdateTypeSet(1)<< 2)
Geometry updated.
ACG::Vec3d position()
get center position of the plane
ACG::Vec3d normal()
get current normal
DLLEXPORT void setTypeIcon(DataType _id, QString _icon)
Set an Icon for a given DataType.
virtual void updateView()
Update current view in Main Application.
int targetCount()
Get the number of target objects.
decltype(std::declval< S >()*std::declval< S >()) sqrnorm() const
compute squared euclidean norm
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
VectorT< double, 3 > Vec3d
ACG::Vec3d yDirection()
local y direction (multiplied with height)
DLLEXPORT ObjectIterator objectsEnd()
Return Iterator to Object End.