Changeset 3492 for trunk/packages/vizservers/nanovis/FlowCmd.cpp
- Timestamp:
- Mar 13, 2013, 9:57:03 AM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/nanovis/FlowCmd.cpp
r3476 r3492 14 14 #include <RpFieldPrism3D.h> 15 15 #include <RpOutcome.h> 16 17 #include <vrmath/Vector3f.h> 18 #include <vrmath/Vector4f.h> 19 #include <vrmath/Matrix4x4d.h> 16 20 17 21 #include "nvconf.h" … … 38 42 #define RELPOS 0 39 43 #define ABSPOS 1 44 45 using namespace vrmath; 40 46 41 47 static Rappture::SwitchParseProc AxisSwitchProc; … … 170 176 { 171 177 _rendererPtr->setPos(FlowCmd::GetRelativePosition(&_sv.position)); 172 _rendererPtr->setColor(Vector4 (_sv.color.r, _sv.color.g, _sv.color.b,173 _sv.color.a));178 _rendererPtr->setColor(Vector4f(_sv.color.r, _sv.color.g, _sv.color.b, 179 _sv.color.a)); 174 180 _rendererPtr->particleSize(_sv.particleSize); 175 181 _rendererPtr->setAxis(_sv.position.axis); … … 192 198 } 193 199 200 void 201 FlowBox::getWorldSpaceBounds(Vector3f& bboxMin, 202 Vector3f& bboxMax, 203 const Volume *vol) const 204 { 205 bboxMin.set(FLT_MAX, FLT_MAX, FLT_MAX); 206 bboxMax.set(-FLT_MAX, -FLT_MAX, -FLT_MAX); 207 208 Vector3f origin = vol->location(); 209 Vector3f scale = vol->getPhysicalScaling(); 210 211 Matrix4x4d mat; 212 mat.makeTranslation(origin); 213 Matrix4x4d mat2; 214 mat2.makeScale(scale); 215 216 mat.multiply(mat2); 217 218 Vector3f min, max; 219 min.x = vol->xAxis.min(); 220 min.y = vol->yAxis.min(); 221 min.z = vol->zAxis.min(); 222 max.x = vol->xAxis.max(); 223 max.y = vol->yAxis.max(); 224 max.z = vol->zAxis.max(); 225 226 float x0, y0, z0, x1, y1, z1; 227 x0 = y0 = z0 = 0.0f; 228 x1 = y1 = z1 = 0.0f; 229 if (max.x > min.x) { 230 x0 = (_sv.corner1.x - min.x) / (max.x - min.x); 231 x1 = (_sv.corner2.x - min.x) / (max.x - min.x); 232 } 233 if (max.y > min.y) { 234 y0 = (_sv.corner1.y - min.y) / (max.y - min.y); 235 y1 = (_sv.corner2.y - min.y) / (max.y - min.y); 236 } 237 if (max.z > min.z) { 238 z0 = (_sv.corner1.z - min.z) / (max.z - min.z); 239 z1 = (_sv.corner2.z - min.z) / (max.z - min.z); 240 } 241 242 TRACE("Box model bounds: (%g,%g,%g) - (%g,%g,%g)", x0, y0, z0, x1, y1, z1); 243 244 Vector3f modelMin(x0, y0, z0); 245 Vector3f modelMax(x1, y1, z1); 246 247 Vector4f bvert[8]; 248 bvert[0] = Vector4f(modelMin.x, modelMin.y, modelMin.z, 1); 249 bvert[1] = Vector4f(modelMax.x, modelMin.y, modelMin.z, 1); 250 bvert[2] = Vector4f(modelMin.x, modelMax.y, modelMin.z, 1); 251 bvert[3] = Vector4f(modelMin.x, modelMin.y, modelMax.z, 1); 252 bvert[4] = Vector4f(modelMax.x, modelMax.y, modelMin.z, 1); 253 bvert[5] = Vector4f(modelMax.x, modelMin.y, modelMax.z, 1); 254 bvert[6] = Vector4f(modelMin.x, modelMax.y, modelMax.z, 1); 255 bvert[7] = Vector4f(modelMax.x, modelMax.y, modelMax.z, 1); 256 257 for (int i = 0; i < 8; i++) { 258 Vector4f worldVert = mat.transform(bvert[i]); 259 if (worldVert.x < bboxMin.x) bboxMin.x = worldVert.x; 260 if (worldVert.x > bboxMax.x) bboxMax.x = worldVert.x; 261 if (worldVert.y < bboxMin.y) bboxMin.y = worldVert.y; 262 if (worldVert.y > bboxMax.y) bboxMax.y = worldVert.y; 263 if (worldVert.z < bboxMin.z) bboxMin.z = worldVert.z; 264 if (worldVert.z > bboxMax.z) bboxMax.z = worldVert.z; 265 } 266 267 TRACE("Box world bounds: (%g,%g,%g) - (%g,%g,%g)", 268 bboxMin.x, bboxMin.y, bboxMin.z, 269 bboxMax.x, bboxMax.y, bboxMax.z); 270 } 271 194 272 void 195 FlowBox::Render(Volume *vol Ptr)273 FlowBox::Render(Volume *vol) 196 274 { 197 275 TRACE("Rendering box %s", _name); … … 206 284 glPushMatrix(); 207 285 208 Vector3 origin = volPtr->location();286 Vector3f origin = vol->location(); 209 287 glTranslatef(origin.x, origin.y, origin.z); 210 288 211 Vector3 scale = volPtr->getPhysicalScaling();212 glScale d(scale.x, scale.y, scale.z);213 214 Vector3 min, max;215 min.x = vol Ptr->xAxis.min();216 min.y = vol Ptr->yAxis.min();217 min.z = vol Ptr->zAxis.min();218 max.x = vol Ptr->xAxis.max();219 max.y = vol Ptr->yAxis.max();220 max.z = vol Ptr->zAxis.max();289 Vector3f scale = vol->getPhysicalScaling(); 290 glScalef(scale.x, scale.y, scale.z); 291 292 Vector3f min, max; 293 min.x = vol->xAxis.min(); 294 min.y = vol->yAxis.min(); 295 min.z = vol->zAxis.min(); 296 max.x = vol->xAxis.max(); 297 max.y = vol->yAxis.max(); 298 max.z = vol->zAxis.max(); 221 299 222 300 TRACE("box is %g,%g %g,%g %g,%g", … … 557 635 } 558 636 559 Vector3 scale = volPtr->getPhysicalScaling();560 Vector3 location = _volPtr->location();637 Vector3f scale = volPtr->getPhysicalScaling(); 638 Vector3f location = _volPtr->location(); 561 639 562 640 _fieldPtr->setVectorField(_volPtr, … … 688 766 volPtr->visible(_sv.showVolume); 689 767 690 Vector3 volScaling = volPtr->getPhysicalScaling(); 691 float dx0 = -0.5 * volScaling.x; 692 float dy0 = -0.5 * volScaling.y; 693 float dz0 = -0.5 * volScaling.z; 694 volPtr->location(Vector3(dx0, dy0, dz0)); 768 Vector3f volScaling = volPtr->getPhysicalScaling(); 769 Vector3f loc(volScaling); 770 loc *= -0.5; 771 volPtr->location(loc); 695 772 696 773 Volume::updatePending = true; … … 1013 1090 { 1014 1091 flags &= ~MAP_FLOWS; 1015 TRACE(" MapFlows");1092 TRACE("Enter"); 1016 1093 1017 1094 /* … … 1057 1134 } 1058 1135 } 1136 1059 1137 TRACE("MapFlows magMin=%g magMax=%g", NanoVis::magMin, NanoVis::magMax); 1060 1138 … … 1079 1157 AdvectFlows(); 1080 1158 return true; 1159 } 1160 1161 void 1162 NanoVis::GetFlowBounds(Vector3f& min, 1163 Vector3f& max, 1164 bool onlyVisible) 1165 { 1166 TRACE("Enter"); 1167 1168 min.set(FLT_MAX, FLT_MAX, FLT_MAX); 1169 max.set(-FLT_MAX, -FLT_MAX, -FLT_MAX); 1170 1171 FlowCmd *flow; 1172 FlowIterator iter; 1173 for (flow = FirstFlow(&iter); flow != NULL; 1174 flow = NextFlow(&iter)) { 1175 if (onlyVisible && !flow->visible()) 1176 continue; 1177 #if 0 // Using volume bounds instead of these 1178 if (flow->isDataLoaded()) { 1179 Vector3f umin, umax; 1180 Rappture::Unirect3d *unirect = flow->data(); 1181 unirect->getWorldSpaceBounds(umin, umax); 1182 if (min.x > umin.x) { 1183 min.x = umin.x; 1184 } 1185 if (max.x < umax.x) { 1186 max.x = umax.x; 1187 } 1188 if (min.y > umin.y) { 1189 min.y = umin.y; 1190 } 1191 if (max.y < umax.y) { 1192 max.y = umax.y; 1193 } 1194 if (min.z > umin.z) { 1195 min.z = umin.z; 1196 } 1197 if (max.z < umax.z) { 1198 max.z = umax.z; 1199 } 1200 } 1201 #endif 1202 FlowBox *box; 1203 FlowBoxIterator iter; 1204 for (box = flow->FirstBox(&iter); box != NULL; 1205 box = flow->NextBox(&iter)) { 1206 TRACE("found box %s", box->name()); 1207 if (!onlyVisible || box->visible()) { 1208 Vector3f fbmin, fbmax; 1209 box->getWorldSpaceBounds(fbmin, fbmax, 1210 flow->getVolume()); 1211 if (min.x > fbmin.x) { 1212 min.x = fbmin.x; 1213 } 1214 if (max.x < fbmax.x) { 1215 max.x = fbmax.x; 1216 } 1217 if (min.y > fbmin.y) { 1218 min.y = fbmin.y; 1219 } 1220 if (max.y < fbmax.y) { 1221 max.y = fbmax.y; 1222 } 1223 if (min.z > fbmin.z) { 1224 min.z = fbmin.z; 1225 } 1226 if (max.z < fbmax.z) { 1227 max.z = fbmax.z; 1228 } 1229 } 1230 } 1231 } 1081 1232 } 1082 1233
Note: See TracChangeset
for help on using the changeset viewer.