WPF 3D graphics redraw when data changes











up vote
0
down vote

favorite












I am rendering a 3D contour surface from data. I get new data every few seconds from real time monitoring and need to redraw using the new data. All of the examples I can find only show how render the 3D contour surface from fixed data.



I can't find an example of explanation of how to (clear, delete, erase) the mesh or model and redraw with new data.



Can anyone point me to an example or explain how to redraw the 3D contour surface with the new data.










share|improve this question









New contributor




TomC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • If you know how to calculate your mesh, just use MVVM and bind your data to the MeshGeometry3D. Take a look.
    – jsanalytics
    Nov 11 at 15:45















up vote
0
down vote

favorite












I am rendering a 3D contour surface from data. I get new data every few seconds from real time monitoring and need to redraw using the new data. All of the examples I can find only show how render the 3D contour surface from fixed data.



I can't find an example of explanation of how to (clear, delete, erase) the mesh or model and redraw with new data.



Can anyone point me to an example or explain how to redraw the 3D contour surface with the new data.










share|improve this question









New contributor




TomC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















  • If you know how to calculate your mesh, just use MVVM and bind your data to the MeshGeometry3D. Take a look.
    – jsanalytics
    Nov 11 at 15:45













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I am rendering a 3D contour surface from data. I get new data every few seconds from real time monitoring and need to redraw using the new data. All of the examples I can find only show how render the 3D contour surface from fixed data.



I can't find an example of explanation of how to (clear, delete, erase) the mesh or model and redraw with new data.



Can anyone point me to an example or explain how to redraw the 3D contour surface with the new data.










share|improve this question









New contributor




TomC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I am rendering a 3D contour surface from data. I get new data every few seconds from real time monitoring and need to redraw using the new data. All of the examples I can find only show how render the 3D contour surface from fixed data.



I can't find an example of explanation of how to (clear, delete, erase) the mesh or model and redraw with new data.



Can anyone point me to an example or explain how to redraw the 3D contour surface with the new data.







wpf






share|improve this question









New contributor




TomC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




TomC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited Nov 10 at 17:32









amonk

1,49111323




1,49111323






New contributor




TomC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked Nov 10 at 15:31









TomC

1




1




New contributor




TomC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





TomC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






TomC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • If you know how to calculate your mesh, just use MVVM and bind your data to the MeshGeometry3D. Take a look.
    – jsanalytics
    Nov 11 at 15:45


















  • If you know how to calculate your mesh, just use MVVM and bind your data to the MeshGeometry3D. Take a look.
    – jsanalytics
    Nov 11 at 15:45
















If you know how to calculate your mesh, just use MVVM and bind your data to the MeshGeometry3D. Take a look.
– jsanalytics
Nov 11 at 15:45




If you know how to calculate your mesh, just use MVVM and bind your data to the MeshGeometry3D. Take a look.
– jsanalytics
Nov 11 at 15:45












1 Answer
1






active

oldest

votes

















up vote
0
down vote













I have solved this issue with the help of several answered questions.





  1. Removed all children of the Model3DGroup 'main_model_3D_group'.



    for (int i = main_model_3D_group.Children.Count-1; i >= 0; i--)
    {
    if (main_model_3D_group.Children[i] is GeometryModel3D)
    main_model_3D_group.Children.RemoveAt(i);
    }



  2. rebuild the GeometryModel3D objects


  3. add the GeometryModel3D objects back to the children of the main_model_3D_group.


Second Issue encountered:
I used an ImageBrush to get a gradient colored surface material.
The ImageBrush.ImageSource locks the file so you can't save the same filename with new color data.
Solved this with the following function;



public ImageSource BitmapFromUri(Uri source)
{
bitmap.BeginInit();
bitmap.UriSource = source;
bitmap.CacheOption = BitmapCacheOption.OnLoad;
bitmap.EndInit();
return bitmap;


}



This function leaves Uri source (xxx.PNG file) unlocked, but the 2nd call doesn't reload the file (assume because it is cached). Solved this by using 2 filename (odd/even). So every other call used a different filename.






share|improve this answer








New contributor




TomC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • Can you please post a MCVE ?
    – jsanalytics
    Nov 13 at 0:24













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});






TomC is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240451%2fwpf-3d-graphics-redraw-when-data-changes%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













I have solved this issue with the help of several answered questions.





  1. Removed all children of the Model3DGroup 'main_model_3D_group'.



    for (int i = main_model_3D_group.Children.Count-1; i >= 0; i--)
    {
    if (main_model_3D_group.Children[i] is GeometryModel3D)
    main_model_3D_group.Children.RemoveAt(i);
    }



  2. rebuild the GeometryModel3D objects


  3. add the GeometryModel3D objects back to the children of the main_model_3D_group.


Second Issue encountered:
I used an ImageBrush to get a gradient colored surface material.
The ImageBrush.ImageSource locks the file so you can't save the same filename with new color data.
Solved this with the following function;



public ImageSource BitmapFromUri(Uri source)
{
bitmap.BeginInit();
bitmap.UriSource = source;
bitmap.CacheOption = BitmapCacheOption.OnLoad;
bitmap.EndInit();
return bitmap;


}



This function leaves Uri source (xxx.PNG file) unlocked, but the 2nd call doesn't reload the file (assume because it is cached). Solved this by using 2 filename (odd/even). So every other call used a different filename.






share|improve this answer








New contributor




TomC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • Can you please post a MCVE ?
    – jsanalytics
    Nov 13 at 0:24

















up vote
0
down vote













I have solved this issue with the help of several answered questions.





  1. Removed all children of the Model3DGroup 'main_model_3D_group'.



    for (int i = main_model_3D_group.Children.Count-1; i >= 0; i--)
    {
    if (main_model_3D_group.Children[i] is GeometryModel3D)
    main_model_3D_group.Children.RemoveAt(i);
    }



  2. rebuild the GeometryModel3D objects


  3. add the GeometryModel3D objects back to the children of the main_model_3D_group.


Second Issue encountered:
I used an ImageBrush to get a gradient colored surface material.
The ImageBrush.ImageSource locks the file so you can't save the same filename with new color data.
Solved this with the following function;



public ImageSource BitmapFromUri(Uri source)
{
bitmap.BeginInit();
bitmap.UriSource = source;
bitmap.CacheOption = BitmapCacheOption.OnLoad;
bitmap.EndInit();
return bitmap;


}



This function leaves Uri source (xxx.PNG file) unlocked, but the 2nd call doesn't reload the file (assume because it is cached). Solved this by using 2 filename (odd/even). So every other call used a different filename.






share|improve this answer








New contributor




TomC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • Can you please post a MCVE ?
    – jsanalytics
    Nov 13 at 0:24















up vote
0
down vote










up vote
0
down vote









I have solved this issue with the help of several answered questions.





  1. Removed all children of the Model3DGroup 'main_model_3D_group'.



    for (int i = main_model_3D_group.Children.Count-1; i >= 0; i--)
    {
    if (main_model_3D_group.Children[i] is GeometryModel3D)
    main_model_3D_group.Children.RemoveAt(i);
    }



  2. rebuild the GeometryModel3D objects


  3. add the GeometryModel3D objects back to the children of the main_model_3D_group.


Second Issue encountered:
I used an ImageBrush to get a gradient colored surface material.
The ImageBrush.ImageSource locks the file so you can't save the same filename with new color data.
Solved this with the following function;



public ImageSource BitmapFromUri(Uri source)
{
bitmap.BeginInit();
bitmap.UriSource = source;
bitmap.CacheOption = BitmapCacheOption.OnLoad;
bitmap.EndInit();
return bitmap;


}



This function leaves Uri source (xxx.PNG file) unlocked, but the 2nd call doesn't reload the file (assume because it is cached). Solved this by using 2 filename (odd/even). So every other call used a different filename.






share|improve this answer








New contributor




TomC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









I have solved this issue with the help of several answered questions.





  1. Removed all children of the Model3DGroup 'main_model_3D_group'.



    for (int i = main_model_3D_group.Children.Count-1; i >= 0; i--)
    {
    if (main_model_3D_group.Children[i] is GeometryModel3D)
    main_model_3D_group.Children.RemoveAt(i);
    }



  2. rebuild the GeometryModel3D objects


  3. add the GeometryModel3D objects back to the children of the main_model_3D_group.


Second Issue encountered:
I used an ImageBrush to get a gradient colored surface material.
The ImageBrush.ImageSource locks the file so you can't save the same filename with new color data.
Solved this with the following function;



public ImageSource BitmapFromUri(Uri source)
{
bitmap.BeginInit();
bitmap.UriSource = source;
bitmap.CacheOption = BitmapCacheOption.OnLoad;
bitmap.EndInit();
return bitmap;


}



This function leaves Uri source (xxx.PNG file) unlocked, but the 2nd call doesn't reload the file (assume because it is cached). Solved this by using 2 filename (odd/even). So every other call used a different filename.







share|improve this answer








New contributor




TomC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this answer



share|improve this answer






New contributor




TomC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









answered Nov 12 at 18:26









TomC

1




1




New contributor




TomC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





TomC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






TomC is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












  • Can you please post a MCVE ?
    – jsanalytics
    Nov 13 at 0:24




















  • Can you please post a MCVE ?
    – jsanalytics
    Nov 13 at 0:24


















Can you please post a MCVE ?
– jsanalytics
Nov 13 at 0:24






Can you please post a MCVE ?
– jsanalytics
Nov 13 at 0:24












TomC is a new contributor. Be nice, and check out our Code of Conduct.










 

draft saved


draft discarded


















TomC is a new contributor. Be nice, and check out our Code of Conduct.













TomC is a new contributor. Be nice, and check out our Code of Conduct.












TomC is a new contributor. Be nice, and check out our Code of Conduct.















 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240451%2fwpf-3d-graphics-redraw-when-data-changes%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Full-time equivalent

Bicuculline

さくらももこ