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 <tcardoso@nuxeo.com> 018 */ 019package org.nuxeo.ecm.platform.threed.service; 020 021import org.nuxeo.common.xmap.annotation.XNode; 022import org.nuxeo.common.xmap.annotation.XObject; 023 024import static java.lang.Math.abs; 025 026/** 027 * Object representing a registered automatic level of detail conversion on the {@link ThreeDService}. An 028 * {@code AutomaticLOD} references the percentage of mesh polygons through its percentage. 029 * 030 * @since 8.4 031 */ 032@XObject("automaticLOD") 033public class AutomaticLOD implements Comparable<AutomaticLOD> { 034 035 @XNode("@order") 036 protected Integer order; 037 038 @XNode("@name") 039 protected String name; 040 041 @XNode("@percPoly") 042 protected Integer percPoly; 043 044 @XNode("@maxPoly") 045 protected Long maxPoly; 046 047 @XNode("@percTex") 048 protected Integer percTex; 049 050 @XNode("@maxTex") 051 protected String maxTex; 052 053 @XNode("@enabled") 054 protected Boolean enabled; 055 056 @XNode("@rendition") 057 protected Boolean rendition; 058 059 @XNode("@renditionVisible") 060 protected Boolean renditionVisible; 061 062 public AutomaticLOD(AutomaticLOD other) { 063 order = other.order; 064 name = other.name; 065 percPoly = other.percPoly; 066 maxPoly = other.maxPoly; 067 percTex = other.percTex; 068 maxTex = other.maxTex; 069 enabled = other.enabled; 070 rendition = other.rendition; 071 renditionVisible = other.renditionVisible; 072 } 073 074 public AutomaticLOD() { 075 super(); 076 } 077 078 public Integer getOrder() { 079 return order; 080 } 081 082 public void setOrder(Integer order) { 083 this.order = order; 084 } 085 086 public String getName() { 087 return name; 088 } 089 090 public void setName(String name) { 091 this.name = name; 092 } 093 094 public boolean isEnabled() { 095 return (enabled == null) || enabled; 096 } 097 098 public void setEnabled(boolean enabled) { 099 this.enabled = enabled; 100 } 101 102 public Integer getPercPoly() { 103 return percPoly; 104 } 105 106 public void setPercPoly(Integer percPoly) { 107 this.percPoly = percPoly; 108 } 109 110 public Long getMaxPoly() { 111 return maxPoly; 112 } 113 114 public void setMaxPoly(Long maxPoly) { 115 this.maxPoly = maxPoly; 116 } 117 118 public Integer getPercTex() { 119 return percTex; 120 } 121 122 public void setPercTex(Integer percTex) { 123 this.percTex = percTex; 124 } 125 126 public String getMaxTex() { 127 return maxTex; 128 } 129 130 public void setMaxTex(String maxTex) { 131 this.maxTex = maxTex; 132 } 133 134 public boolean isRendition() { 135 return (rendition == null) || rendition; 136 } 137 138 public void setRendition(boolean rendition) { 139 this.rendition = rendition; 140 } 141 142 public boolean isRenditionVisible() { 143 return (renditionVisible == null) || renditionVisible; 144 } 145 146 public void setRenditionVisible(boolean renditionVisible) { 147 this.renditionVisible = renditionVisible; 148 } 149 150 public String getId() { 151 return String.valueOf(abs(name.hashCode())); 152 } 153 154 @Override 155 public int compareTo(AutomaticLOD o) { 156 return o.percPoly.compareTo(percPoly); 157 } 158 159 public void merge(AutomaticLOD src) { 160 if (src.order != null) { 161 order = src.order; 162 } 163 if (src.name != null) { 164 name = src.name; 165 } 166 if (src.percPoly != null) { 167 percPoly = src.percPoly; 168 } 169 if (src.maxPoly != null) { 170 maxPoly = src.maxPoly; 171 } 172 if (src.maxTex != null) { 173 maxTex = src.maxTex; 174 } 175 if (src.percTex != null) { 176 percTex = src.percTex; 177 } 178 if (src.enabled != null) { 179 enabled = src.enabled; 180 } 181 if (src.rendition != null) { 182 rendition = src.rendition; 183 } 184 if (src.renditionVisible != null) { 185 renditionVisible = src.renditionVisible; 186 } 187 } 188}