001/* 002 * (C) Copyright 2006-2016 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Tiago Cardoso <[email protected]> 018 */ 019package org.nuxeo.ecm.platform.threed.service; 020 021import org.nuxeo.common.xmap.annotation.XNode; 022import org.nuxeo.common.xmap.annotation.XObject; 023 024/** 025 * Object representing a registered automatic level of detail conversion on the {@link ThreeDService}. An 026 * {@code AutomaticLOD} references the percentage of mesh polygons through its percentage. 027 * 028 * @since 8.4 029 */ 030@XObject("automaticLOD") 031public class AutomaticLOD implements Comparable<AutomaticLOD> { 032 033 @XNode("@order") 034 protected Integer order; 035 036 @XNode("@name") 037 protected String name; 038 039 @XNode("@percPoly") 040 protected Integer percPoly; 041 042 @XNode("@maxPoly") 043 protected Long maxPoly; 044 045 @XNode("@percTex") 046 protected Integer percTex; 047 048 @XNode("@maxTex") 049 protected String maxTex; 050 051 @XNode("@enabled") 052 protected Boolean enabled; 053 054 @XNode("@rendition") 055 protected Boolean rendition; 056 057 @XNode("@renditionVisible") 058 protected Boolean renditionVisible; 059 060 public AutomaticLOD(AutomaticLOD other) { 061 order = other.order; 062 name = other.name; 063 percPoly = other.percPoly; 064 maxPoly = other.maxPoly; 065 percTex = other.percTex; 066 maxTex = other.maxTex; 067 enabled = other.enabled; 068 rendition = other.rendition; 069 renditionVisible = other.renditionVisible; 070 } 071 072 public AutomaticLOD() { 073 super(); 074 } 075 076 public Integer getOrder() { 077 return order; 078 } 079 080 public void setOrder(Integer order) { 081 this.order = order; 082 } 083 084 public String getName() { 085 return name; 086 } 087 088 public void setName(String name) { 089 this.name = name; 090 } 091 092 public boolean isEnabled() { 093 return (enabled == null) || enabled; 094 } 095 096 public void setEnabled(boolean enabled) { 097 this.enabled = enabled; 098 } 099 100 public Integer getPercPoly() { 101 return percPoly; 102 } 103 104 public void setPercPoly(Integer percPoly) { 105 this.percPoly = percPoly; 106 } 107 108 public Long getMaxPoly() { 109 return maxPoly; 110 } 111 112 public void setMaxPoly(Long maxPoly) { 113 this.maxPoly = maxPoly; 114 } 115 116 public Integer getPercTex() { 117 return percTex; 118 } 119 120 public void setPercTex(Integer percTex) { 121 this.percTex = percTex; 122 } 123 124 public String getMaxTex() { 125 return maxTex; 126 } 127 128 public void setMaxTex(String maxTex) { 129 this.maxTex = maxTex; 130 } 131 132 public boolean isRendition() { 133 return (rendition == null) || rendition; 134 } 135 136 public void setRendition(boolean rendition) { 137 this.rendition = rendition; 138 } 139 140 public boolean isRenditionVisible() { 141 return (renditionVisible == null) || renditionVisible; 142 } 143 144 public void setRenditionVisible(boolean renditionVisible) { 145 this.renditionVisible = renditionVisible; 146 } 147 148 public String getId() { 149 return String.valueOf(name.hashCode() & 0x7fffffff); 150 } 151 152 @Override 153 public int compareTo(AutomaticLOD o) { 154 return o.percPoly.compareTo(percPoly); 155 } 156 157 public void merge(AutomaticLOD src) { 158 if (src.order != null) { 159 order = src.order; 160 } 161 if (src.name != null) { 162 name = src.name; 163 } 164 if (src.percPoly != null) { 165 percPoly = src.percPoly; 166 } 167 if (src.maxPoly != null) { 168 maxPoly = src.maxPoly; 169 } 170 if (src.maxTex != null) { 171 maxTex = src.maxTex; 172 } 173 if (src.percTex != null) { 174 percTex = src.percTex; 175 } 176 if (src.enabled != null) { 177 enabled = src.enabled; 178 } 179 if (src.rendition != null) { 180 rendition = src.rendition; 181 } 182 if (src.renditionVisible != null) { 183 renditionVisible = src.renditionVisible; 184 } 185 } 186}