Developer Documentation
Loading...
Searching...
No Matches
PropertyModelFactory.cc
1/*===========================================================================*\
2* *
3* OpenFlipper *
4 * Copyright (c) 2001-2015, RWTH-Aachen University *
5 * Department of Computer Graphics and Multimedia *
6 * All rights reserved. *
7 * www.openflipper.org *
8 * *
9 *---------------------------------------------------------------------------*
10 * This file is part of OpenFlipper. *
11 *---------------------------------------------------------------------------*
12 * *
13 * Redistribution and use in source and binary forms, with or without *
14 * modification, are permitted provided that the following conditions *
15 * are met: *
16 * *
17 * 1. Redistributions of source code must retain the above copyright notice, *
18 * this list of conditions and the following disclaimer. *
19 * *
20 * 2. Redistributions in binary form must reproduce the above copyright *
21 * notice, this list of conditions and the following disclaimer in the *
22 * documentation and/or other materials provided with the distribution. *
23 * *
24 * 3. Neither the name of the copyright holder nor the names of its *
25 * contributors may be used to endorse or promote products derived from *
26 * this software without specific prior written permission. *
27 * *
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39* *
40\*===========================================================================*/
41
42
43
44#include "PropertyModelFactory.hh"
45
46#include "MultiObjectPropertyModel.hh"
47#include "OpenMesh/OMPropertyModel.hh"
48
49#if defined(ENABLE_HEXAHEDRALMESH_SUPPORT) || defined(ENABLE_POLYHEDRALMESH_SUPPORT) || defined(ENABLE_TETRAHEDRALMESH_SUPPORT)
50 #include "OpenVolumeMesh/OVMPropertyModelT.hh"
51#endif /* ENABLE_OPENVOLUMEMESH_SUPPORT */
52
53#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
54#endif /* ENABLE_POLYHEDRALMESH_SUPPORT */
55
56#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
57#endif /* ENABLE_HEXAHEDRALMESH_SUPPORT */
58
59#ifdef ENABLE_TETRAHEDRALMESH_SUPPORT
61#endif
62
63
80{
81 using namespace PluginFunctions;
82
83 if (objectID == -13 || objectID == -14 || objectID == -15)
84 {
85 if (propertyModelMap.find(objectID) == propertyModelMap.end())
86 {
87 propertyModelMap[objectID] = 0;
88 }
89
90 if (propertyModelMap[objectID])
91 {
92 delete propertyModelMap[objectID];
93 propertyModelMap[objectID] = 0;
94 }
95
96 switch (objectID) {
97 case -13:
98 propertyModelMap[objectID] = new MultiObjectPropertyModel(ALL_OBJECTS);
99 break;
100 case -14:
101 propertyModelMap[objectID] = new MultiObjectPropertyModel(TARGET_OBJECTS);
102 break;
103 case -15:
104 propertyModelMap[objectID] = new MultiObjectPropertyModel(SOURCE_OBJECTS);
105 break;
106 }
107
108 return propertyModelMap[objectID];
109 }
110
111 PropertyModelMap::iterator it = propertyModelMap.find(objectID);
112 if (it != propertyModelMap.end())
113 return it->second;
114
115 BaseObjectData* object = 0;
116
117 PluginFunctions::getObject( objectID, object );
118
119 PropertyModel* propertyModel;
120
121 if (object == 0) {
122 return 0;
123 }
124
125 if ( object->dataType(DATA_TRIANGLE_MESH) )
126 {
127 TriMesh* mesh = PluginFunctions::triMesh(object);
128 propertyModel = new OMPropertyModel<TriMesh>(mesh, objectID);
129 }
130 else if ( object->dataType(DATA_POLY_MESH) )
131 {
132 PolyMesh* mesh = PluginFunctions::polyMesh(object);
133 propertyModel = new OMPropertyModel<PolyMesh>(mesh, objectID);
134 }
135#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
136 else if ( object->dataType(DATA_POLYHEDRAL_MESH) )
137 {
139 propertyModel = new OVMPropertyModel<PolyhedralMesh>(mesh, objectID);
140 }
141#endif /* ENABLE_POLYHEDRALMESH_SUPPORT */
142#ifdef ENABLE_HEXAHEDRALMESH_SUPPORT
143 else if ( object->dataType(DATA_HEXAHEDRAL_MESH) )
144 {
146 propertyModel = new OVMPropertyModel<HexahedralMesh>(mesh, objectID);
147 }
148#endif /* ENABLE_HEXAHEDRALMESH_SUPPORT */
149#ifdef ENABLE_TETRAHEDRALMESH_SUPPORT
150 else if ( object->dataType(DATA_TETRAHEDRAL_MESH) )
151 {
153 propertyModel = new OVMPropertyModel<TetrahedralMesh>(mesh, objectID);
154 }
155#endif
156 else
157 {
158 return 0;
159 }
160
161 propertyModelMap.insert(std::pair<int, PropertyModel*>(objectID, propertyModel));
162 return propertyModel;
163}
164
166{
167 if (propertyModelMap.find(objectID) != propertyModelMap.end())
168 {
169 delete getModel(objectID);
170 propertyModelMap.erase(objectID);
171 }
172}
#define DATA_HEXAHEDRAL_MESH
#define DATA_POLYHEDRAL_MESH
#define DATA_TETRAHEDRAL_MESH
#define DATA_POLY_MESH
Definition PolyMesh.hh:59
#define DATA_TRIANGLE_MESH
bool dataType(DataType _type) const
PropertyModel * getModel(int objectID)
Returns the PropertyModel.
void deleteModel(int objectID)
Deletes the PropertyModel.
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
TriMesh * triMesh(BaseObjectData *_object)
Get a triangle mesh from an object.
PolyhedralMesh * polyhedralMesh(BaseObjectData *_object)
Get an PolyhedralMesh from an object.
PolyMesh * polyMesh(BaseObjectData *_object)
Get a poly mesh from an object.
HexahedralMesh * hexahedralMesh(BaseObjectData *_object)
Get an HexahedralMesh from an object.
TetrahedralMesh * tetrahedralMesh(BaseObjectData *_object)
Get an TetrahedralMesh from an object.