def _applyFPS(self, event):
        item = self.app_state.current_item
        if (item is None or item.data is None):
            return

        if (item.type != item.TypePointCloud):
            self.app_state.showError(
                'This operation can only be applyed to a Point Clouds.')
            return

        if (len(self.tf_centroid_count.text()) <= 0):
            return

        count = int(self.tf_centroid_count.text())
        rateo = count / item.data.pos.size(0)
        if (rateo >= 1):
            self.app_state.showError(
                'The number of point to select with FPS({}) have to be less than the total number of points({}).'
                .format(count, item.data.pos.size(0)))
            return

        item.data.pos = item.data.pos.double()
        idx = FPS(item.data.pos,
                  torch.zeros(item.data.pos.size(0)).long(), rateo)

        new_item = Item(name='{}-FPS'.format(item.name),
                        data=Data(pos=item.data.pos[idx]),
                        type=Item.TypePointCloud)
        self.app_state.setNewItem(new_item)
Exemple #2
0
    def _loadTorch(path):
        tensor = torch.load(path)
        data = Data(pos=tensor.pos.float)

        return Item(data=data,
                    type=Item.TypePointCloud,
                    name=os.path.basename(path))
    def _applySaveEdit(self, event):
        sourceItem = self.app_state.current_item

        item = Item(data=sourceItem.data,
                    name=sourceItem.name,
                    type=sourceItem.type)

        self.app_state.addItem(item)
    def _applyFaceImportanceSampling(self, event):
        item = self.app_state.current_item
        if (item is None or item.data is None):
            return

        if (item.type != item.TypeMesh):
            self.app_state.showError(
                'This operation can only be applyed to be a Mesh object.')
            return

        if (len(self.tf_importance_point_count.text()) <= 0):
            return

        count = int(self.tf_importance_point_count.text())

        item.data.pos = item.data.pos.float()
        new_data = SamplePoints(count)(item.data)
        new_item = Item(name='{}-ImportanceSamped'.format(item.name),
                        data=new_data,
                        type=Item.TypePointCloud)
        self.app_state.setNewItem(new_item)
    def _applyPoissonDiskSampling(self, event):
        item = self.app_state.current_item
        if (item is None or item.data is None):
            return

        if (item.type != item.TypeMesh):
            self.app_state.showError(
                'This operation can only be applyed to be a Mesh object.')
            return

        if (len(self.tf_poisson_point_count.text()) <= 0
                or len(self.tf_poisson_radius.text()) <= 0):
            return

        count = int(self.tf_poisson_point_count.text())
        radio = float(self.tf_poisson_radius.text())

        item.data.pos = item.data.pos.float()
        new_data = PoissonDiskSampling(count, radio)(item.data)
        new_item = Item(name='{}-Poisson'.format(item.name),
                        data=new_data,
                        type=Item.TypePointCloud)
        self.app_state.setNewItem(new_item)
Exemple #6
0
    def _loadOff(path):
        off_obj = Off.OffParser(path)
        data = Data(pos=torch.Tensor(off_obj.points).double(),
                    face=torch.Tensor(off_obj.faces).transpose(0, 1).long())

        return Item(data=data, type=Item.TypeMesh, name=os.path.basename(path))