Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages

CUDADispCmds.cu

Go to the documentation of this file.
00001 /***************************************************************************
00002 *cr 
00003 *cr (C) Copyright 1995-2019 The Board of Trustees of the 
00004 *cr University of Illinois 
00005 *cr All Rights Reserved 
00006 *cr 
00007 ***************************************************************************/
00008 /***************************************************************************
00009 * RCS INFORMATION:
00010 *
00011 * $RCSfile: CUDADispCmds.cu,v $
00012 * $Author: johns $ $Locker: $ $State: Exp $
00013 * $Revision: 1.11 $ $Date: 2020年02月26日 04:22:39 $
00014 *
00015 ***************************************************************************/
00021 #include <string.h>
00022 #include <stdlib.h>
00023 #include <stdio.h>
00024 #include <math.h>
00025 #include "Scene.h"
00026 #include "DispCmds.h"
00027 #include "utilities.h"
00028 #include "Matrix4.h"
00029 #include "VMDDisplayList.h"
00030 
00031 //*************************************************************
00032 // draw a mesh consisting of vertices, facets, colors, normals etc.
00033 void DispCmdTriMesh::cuda_putdata(const float * vertices_d,
00034 const float * normals_d,
00035 const float * colors_d,
00036 int num_facets,
00037 VMDDisplayList * dobj) {
00038 // make a triangle mesh (no strips)
00039 DispCmdTriMesh *ptr;
00040 if (colors_d == NULL) {
00041 ptr = (DispCmdTriMesh *)
00042 (dobj->append(DTRIMESH_C3F_N3F_V3F, sizeof(DispCmdTriMesh) +
00043 sizeof(float) * num_facets * 3 * 6));
00044 } else {
00045 ptr = (DispCmdTriMesh *)
00046 (dobj->append(DTRIMESH_C3F_N3F_V3F, sizeof(DispCmdTriMesh) +
00047 sizeof(float) * num_facets * 3 * 9));
00048 }
00049 
00050 if (ptr == NULL)
00051 return;
00052 
00053 ptr->numverts=num_facets * 3;
00054 ptr->numfacets=num_facets;
00055 
00056 float *c=NULL, *n=NULL, *v=NULL;
00057 if (colors_d == NULL) {
00058 ptr->pervertexcolors=0;
00059 ptr->getpointers(n, v);
00060 } else {
00061 ptr->pervertexcolors=1;
00062 ptr->getpointers(c, n, v);
00063 cudaMemcpy(c, colors_d, ptr->numverts * 3 * sizeof(float), cudaMemcpyDeviceToHost);
00064 }
00065 
00066 cudaMemcpy(n, normals_d, ptr->numverts * 3 * sizeof(float), cudaMemcpyDeviceToHost);
00067 cudaMemcpy(v, vertices_d, ptr->numverts * 3 * sizeof(float), cudaMemcpyDeviceToHost);
00068 }
00069 
00070 
00071 //*************************************************************
00072 // draw a mesh consisting of vertices, facets, colors, normals etc.
00073 void DispCmdTriMesh::cuda_putdata(const float * vertices_d,
00074 const float * normals_d,
00075 const unsigned char * colors_d,
00076 int num_facets,
00077 VMDDisplayList * dobj) {
00078 // make a triangle mesh (no strips)
00079 DispCmdTriMesh *ptr;
00080 if (colors_d == NULL) {
00081 ptr = (DispCmdTriMesh *)
00082 (dobj->append(DTRIMESH_C3F_N3F_V3F, sizeof(DispCmdTriMesh) +
00083 sizeof(float) * num_facets * 3 * 6));
00084 } else {
00085 ptr = (DispCmdTriMesh *)
00086 (dobj->append(DTRIMESH_C4U_N3F_V3F, sizeof(DispCmdTriMesh) +
00087 4 * sizeof(unsigned char) * num_facets * 3 +
00088 sizeof(float) * num_facets * 3 * 6));
00089 }
00090 
00091 if (ptr == NULL)
00092 return;
00093 
00094 ptr->numverts=num_facets * 3;
00095 ptr->numfacets=num_facets;
00096 
00097 unsigned char *c=NULL;
00098 float *n=NULL, *v=NULL;
00099 if (colors_d == NULL) {
00100 ptr->pervertexcolors=0;
00101 ptr->getpointers(n, v);
00102 } else {
00103 ptr->pervertexcolors=1;
00104 ptr->getpointers(c, n, v);
00105 cudaMemcpy(c, colors_d, ptr->numverts * 4 * sizeof(unsigned char), cudaMemcpyDeviceToHost);
00106 }
00107 
00108 cudaMemcpy(n, normals_d, ptr->numverts * 3 * sizeof(float), cudaMemcpyDeviceToHost);
00109 cudaMemcpy(v, vertices_d, ptr->numverts * 3 * sizeof(float), cudaMemcpyDeviceToHost);
00110 }
00111 
00112 
00113 //*************************************************************
00114 // draw a mesh consisting of vertices, facets, colors, normals etc.
00115 void DispCmdTriMesh::cuda_putdata(const float * vertices_d,
00116 const char * normals_d,
00117 const unsigned char * colors_d,
00118 int num_facets,
00119 VMDDisplayList * dobj) {
00120 // make a triangle mesh (no strips)
00121 DispCmdTriMesh *ptr;
00122 if (colors_d == NULL) {
00123 ptr = (DispCmdTriMesh *)
00124 (dobj->append(DTRIMESH_C4U_N3B_V3F, sizeof(DispCmdTriMesh) +
00125 sizeof(char) * num_facets * 3 * 3 +
00126 sizeof(float) * num_facets * 3 * 3));
00127 
00128 } else {
00129 ptr = (DispCmdTriMesh *)
00130 (dobj->append(DTRIMESH_C4U_N3B_V3F, sizeof(DispCmdTriMesh) +
00131 4 * sizeof(unsigned char) * num_facets * 3 +
00132 sizeof(char) * num_facets * 3 * 3 +
00133 sizeof(float) * num_facets * 3 * 3));
00134 }
00135 
00136 if (ptr == NULL)
00137 return;
00138 
00139 ptr->numverts=num_facets * 3;
00140 ptr->numfacets=num_facets;
00141 
00142 unsigned char *c=NULL;
00143 signed char *n=NULL;
00144 float *v=NULL;
00145 if (colors_d == NULL) {
00146 ptr->pervertexcolors=0;
00147 ptr->getpointers(n, v);
00148 } else {
00149 ptr->pervertexcolors=1;
00150 ptr->getpointers(c, n, v);
00151 cudaMemcpy(c, colors_d, ptr->numverts * 4 * sizeof(unsigned char), cudaMemcpyDeviceToHost);
00152 }
00153 
00154 cudaMemcpy(n, normals_d, ptr->numverts * 3 * sizeof(char), cudaMemcpyDeviceToHost);
00155 cudaMemcpy(v, vertices_d, ptr->numverts * 3 * sizeof(float), cudaMemcpyDeviceToHost);
00156 }
00157 
00158 
00159 

Generated on Mon Nov 17 02:45:59 2025 for VMD (current) by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002

AltStyle によって変換されたページ (->オリジナル) /